X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fpages%2Fbuild%2Fbuild.component.ts;h=681efe2028366046100a0ed5c0717093758ba021;hb=cd8d64e86de540aea78a253c5fcc7826e8f15456;hp=99b7e54a06fd4b0054c6f1de12bbc86f5165bdeb;hpb=b5f2398c5cfb44bc18b6d1ab7c59be0ef090d8cf;p=src%2Fxds%2Fxds-agent.git diff --git a/webapp/src/app/pages/build/build.component.ts b/webapp/src/app/pages/build/build.component.ts index 99b7e54..681efe2 100644 --- a/webapp/src/app/pages/build/build.component.ts +++ b/webapp/src/app/pages/build/build.component.ts @@ -31,6 +31,7 @@ export class BuildComponent implements OnInit, AfterViewChecked { public buildIsCollapsed = false; public cmdOutput: string; public cmdInfo: string; + public curPrj: IProject; private startTime: Map = new Map(); @@ -42,11 +43,13 @@ export class BuildComponent implements OnInit, AfterViewChecked { private modalService: NgbModal, ) { this.cmdOutput = ''; - this.cmdInfo = ''; // TODO: to be remove (only for debug) - + this.cmdInfo = ''; // TODO: to be remove (only for debug) } ngOnInit() { + // Retreive current project + this.prjSvr.curProject$.subscribe(p => this.curPrj = p); + // Command output data tunneling this.xdsSvr.CmdOutput$.subscribe(data => { this.cmdOutput += data.stdout; @@ -76,66 +79,82 @@ export class BuildComponent implements OnInit, AfterViewChecked { this.cmdOutput = ''; } + isSetupValid(): boolean { + return (typeof this.curPrj !== 'undefined'); + } + settingsShow() { + if (!this.isSetupValid()) { + return this.alertSvr.warning('Please select first a valid project.', true); + } + const activeModal = this.modalService.open(BuildSettingsModalComponent, { size: 'lg', container: 'nb-layout' }); activeModal.componentInstance.modalHeader = 'Large Modal'; } clean() { - const curPrj = this.prjSvr.getCurrent(); + if (!this.isSetupValid()) { + return this.alertSvr.warning('Please select first a valid project.', true); + } this._exec( - curPrj.uiSettings.cmdClean, - curPrj.uiSettings.subpath, + this.curPrj.uiSettings.cmdClean, + this.curPrj.uiSettings.subpath, [], - curPrj.uiSettings.envVars.join(' ')); + this.curPrj.uiSettings.envVars.join(' ')); } preBuild() { - const curPrj = this.prjSvr.getCurrent(); + if (!this.isSetupValid()) { + return this.alertSvr.warning('Please select first a valid project.', true); + } this._exec( - curPrj.uiSettings.cmdPrebuild, - curPrj.uiSettings.subpath, + this.curPrj.uiSettings.cmdPrebuild, + this.curPrj.uiSettings.subpath, [], - curPrj.uiSettings.envVars.join(' ')); + this.curPrj.uiSettings.envVars.join(' ')); } build() { - const curPrj = this.prjSvr.getCurrent(); + if (!this.isSetupValid()) { + return this.alertSvr.warning('Please select first a valid project.', true); + } this._exec( - curPrj.uiSettings.cmdBuild, - curPrj.uiSettings.subpath, + this.curPrj.uiSettings.cmdBuild, + this.curPrj.uiSettings.subpath, [], - curPrj.uiSettings.envVars.join(' '), + this.curPrj.uiSettings.envVars.join(' '), ); } populate() { - const curPrj = this.prjSvr.getCurrent(); + if (!this.isSetupValid()) { + return this.alertSvr.warning('Please select first a valid project.', true); + } this._exec( - curPrj.uiSettings.cmdPopulate, - curPrj.uiSettings.subpath, + this.curPrj.uiSettings.cmdPopulate, + this.curPrj.uiSettings.subpath, [], // args - curPrj.uiSettings.envVars.join(' '), + this.curPrj.uiSettings.envVars.join(' '), ); } execCmd() { - const curPrj = this.prjSvr.getCurrent(); + if (!this.isSetupValid()) { + return this.alertSvr.warning('Please select first a valid project.', true); + } this._exec( - curPrj.uiSettings.cmdArgs.join(' '), - curPrj.uiSettings.subpath, + this.curPrj.uiSettings.cmdArgs.join(' '), + this.curPrj.uiSettings.subpath, [], - curPrj.uiSettings.envVars.join(' '), + this.curPrj.uiSettings.envVars.join(' '), ); } private _exec(cmd: string, dir: string, args: string[], env: string) { - this.curProject = this.prjSvr.getCurrent(); - const prjID = this.curProject.id; - - if (!this.curProject) { + if (!this.isSetupValid()) { return this.alertSvr.warning('No active project', true); } + const prjID = this.curPrj.id; this.cmdOutput += this._outputHeader();