aboutsummaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-30 11:00:14 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-30 11:00:14 +0100
commit1f0c46a7f3b6c00ac236311444ef6583855b8f9a (patch)
tree78a7e9a3b1d5ce1c549fff16f1d3340436fdf65a /webapp
parentff47ccb072076c16eadaee08419d6afac3e53790 (diff)
Fixed env var settings - dashboard.
Diffstat (limited to 'webapp')
-rw-r--r--webapp/src/app/pages/build/build.component.html8
-rw-r--r--webapp/src/app/pages/build/build.component.ts90
2 files changed, 39 insertions, 59 deletions
diff --git a/webapp/src/app/pages/build/build.component.html b/webapp/src/app/pages/build/build.component.html
index 6c8df72..3fd2574 100644
--- a/webapp/src/app/pages/build/build.component.html
+++ b/webapp/src/app/pages/build/build.component.html
@@ -35,19 +35,19 @@
<nb-action>
</nb-action>
- <nb-action (click)="clean()" [disabled]="!isSetupValid()">
+ <nb-action (click)="execCmd('clean')" [disabled]="!isSetupValid()">
<i class="fa fa-eraser"></i>
<span>Clean</span>
</nb-action>
- <nb-action (click)="preBuild()" [disabled]="!isSetupValid()">
+ <nb-action (click)="execCmd('prebuild')" [disabled]="!isSetupValid()">
<i class="nb-list"></i>
<span>Pre-Build</span>
</nb-action>
- <nb-action (click)="build()" [disabled]="!isSetupValid()">
+ <nb-action (click)="execCmd('build')" [disabled]="!isSetupValid()">
<i class="fa fa-wrench"></i>
<span>Build</span>
</nb-action>
- <nb-action (click)="populate()" [disabled]="!isSetupValid()">
+ <nb-action (click)="execCmd('populate')" [disabled]="!isSetupValid()">
<i class="fa fa-send"></i>
<span>Populate</span>
</nb-action>
diff --git a/webapp/src/app/pages/build/build.component.ts b/webapp/src/app/pages/build/build.component.ts
index 681efe2..3ebdfe5 100644
--- a/webapp/src/app/pages/build/build.component.ts
+++ b/webapp/src/app/pages/build/build.component.ts
@@ -92,74 +92,54 @@ export class BuildComponent implements OnInit, AfterViewChecked {
activeModal.componentInstance.modalHeader = 'Large Modal';
}
- clean() {
+ execCmd(cmdName: string) {
if (!this.isSetupValid()) {
return this.alertSvr.warning('Please select first a valid project.', true);
}
- this._exec(
- this.curPrj.uiSettings.cmdClean,
- this.curPrj.uiSettings.subpath,
- [],
- this.curPrj.uiSettings.envVars.join(' '));
- }
-
- preBuild() {
- if (!this.isSetupValid()) {
- return this.alertSvr.warning('Please select first a valid project.', true);
- }
- this._exec(
- this.curPrj.uiSettings.cmdPrebuild,
- this.curPrj.uiSettings.subpath,
- [],
- this.curPrj.uiSettings.envVars.join(' '));
- }
- build() {
- if (!this.isSetupValid()) {
- return this.alertSvr.warning('Please select first a valid project.', true);
+ if (!this.curPrj.uiSettings) {
+ return this.alertSvr.warning('Invalid setting structure', true);
}
- this._exec(
- this.curPrj.uiSettings.cmdBuild,
- this.curPrj.uiSettings.subpath,
- [],
- this.curPrj.uiSettings.envVars.join(' '),
- );
- }
- populate() {
- if (!this.isSetupValid()) {
- return this.alertSvr.warning('Please select first a valid project.', true);
+ let cmd = '';
+ switch (cmdName) {
+ case 'clean':
+ cmd = this.curPrj.uiSettings.cmdClean;
+ break;
+ case 'prebuild':
+ cmd = this.curPrj.uiSettings.cmdPrebuild;
+ break;
+ case 'build':
+ cmd = this.curPrj.uiSettings.cmdBuild;
+ break;
+ case 'populate':
+ cmd = this.curPrj.uiSettings.cmdPopulate;
+ break;
+ case 'exec':
+ if (this.curPrj.uiSettings.cmdArgs instanceof Array)  {
+ cmd = this.curPrj.uiSettings.cmdArgs.join(' ');
+ } else {
+ cmd = this.curPrj.uiSettings.cmdArgs;
+ }
+ break;
+ default:
+ return this.alertSvr.warning('Unknown command name ' + cmdName);
}
- this._exec(
- this.curPrj.uiSettings.cmdPopulate,
- this.curPrj.uiSettings.subpath,
- [], // args
- this.curPrj.uiSettings.envVars.join(' '),
- );
- }
- execCmd() {
- if (!this.isSetupValid()) {
- return this.alertSvr.warning('Please select first a valid project.', true);
- }
- this._exec(
- this.curPrj.uiSettings.cmdArgs.join(' '),
- this.curPrj.uiSettings.subpath,
- [],
- this.curPrj.uiSettings.envVars.join(' '),
- );
- }
+ const prjID = this.curPrj.id;
+ const dir = this.curPrj.uiSettings.subpath;
+ const args: string[] = [];
+ const sdkid = this.sdkSvr.getCurrentId();
- private _exec(cmd: string, dir: string, args: string[], env: string) {
- if (!this.isSetupValid()) {
- return this.alertSvr.warning('No active project', true);
+ let env = '';
+ if (this.curPrj.uiSettings.envVars instanceof Array) {
+ env = this.curPrj.uiSettings.envVars.join(' ');
+ } else {
+ env = this.curPrj.uiSettings.envVars;
}
- const prjID = this.curPrj.id;
this.cmdOutput += this._outputHeader();
- const sdkid = this.sdkSvr.getCurrentId();
-
// Detect key=value in env string to build array of string
const envArr = [];
env.split(';').forEach(v => envArr.push(v.trim()));