From cd8d64e86de540aea78a253c5fcc7826e8f15456 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Thu, 30 Nov 2017 00:11:34 +0100 Subject: [PATCH] Fixed build page when no project exists Signed-off-by: Sebastien Douheret --- webapp/src/app/pages/build/build.component.html | 14 ++--- webapp/src/app/pages/build/build.component.ts | 71 ++++++++++++++-------- .../settings/project-select-dropdown.component.ts | 4 +- .../config/config-xds/config-xds.component.ts | 2 +- .../app/pages/dashboard/dashboard.component.html | 5 +- 5 files changed, 58 insertions(+), 38 deletions(-) diff --git a/webapp/src/app/pages/build/build.component.html b/webapp/src/app/pages/build/build.component.html index 1ce9484..6c8df72 100644 --- a/webapp/src/app/pages/build/build.component.html +++ b/webapp/src/app/pages/build/build.component.html @@ -27,7 +27,7 @@ - + Settings @@ -35,19 +35,19 @@ - + Clean - + Pre-Build - + Build - + Populate @@ -57,10 +57,10 @@ - Content deploy... +
   Under construction...
- Content debug... +
   Under construction...
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(); diff --git a/webapp/src/app/pages/build/settings/project-select-dropdown.component.ts b/webapp/src/app/pages/build/settings/project-select-dropdown.component.ts index a83ec0a..a99dc6b 100644 --- a/webapp/src/app/pages/build/settings/project-select-dropdown.component.ts +++ b/webapp/src/app/pages/build/settings/project-select-dropdown.component.ts @@ -28,7 +28,9 @@ export class ProjectSelectDropdownComponent implements OnInit { } select() { - this.projectSvr.setCurrentById(this.curPrj.id); + if (this.curPrj) { + this.projectSvr.setCurrentById(this.curPrj.id); + } } } diff --git a/webapp/src/app/pages/config/config-xds/config-xds.component.ts b/webapp/src/app/pages/config/config-xds/config-xds.component.ts index e62cd37..bd46145 100644 --- a/webapp/src/app/pages/config/config-xds/config-xds.component.ts +++ b/webapp/src/app/pages/config/config-xds/config-xds.component.ts @@ -20,7 +20,7 @@ export class ConfigXdsComponent { // TODO: cleanup agentStatus$: Observable; applying = false; xdsServerUrl = ''; - server: IXDServerCfg = { id: '', url: '', connRetry: 10, connected: false }; + server: IXDServerCfg = { id: '', url: 'http://localhost:8000', connRetry: 10, connected: false }; configFormChanged = false; diff --git a/webapp/src/app/pages/dashboard/dashboard.component.html b/webapp/src/app/pages/dashboard/dashboard.component.html index 9160019..ed6cfdb 100644 --- a/webapp/src/app/pages/dashboard/dashboard.component.html +++ b/webapp/src/app/pages/dashboard/dashboard.component.html @@ -1,10 +1,9 @@
- Dashboard page... -
---> -- 2.16.6