X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fpages%2Fbuild%2Fbuild.component.ts;h=42975c114ce0834a5b0c67e261a883de73dd5c87;hb=a2cc38902ff7528870822110c4f04329a3918564;hp=681efe2028366046100a0ed5c0717093758ba021;hpb=cd8d64e86de540aea78a253c5fcc7826e8f15456;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 681efe2..42975c1 100644 --- a/webapp/src/app/pages/build/build.component.ts +++ b/webapp/src/app/pages/build/build.component.ts @@ -1,3 +1,21 @@ +/** +* @license +* Copyright (C) 2017-2018 "IoT.bzh" +* Author Sebastien Douheret +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + import { Component, ViewEncapsulation, AfterViewChecked, ElementRef, ViewChild, OnInit, Input } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { FormControl, FormGroup, Validators, FormBuilder } from '@angular/forms'; @@ -87,79 +105,60 @@ export class BuildComponent implements OnInit, AfterViewChecked { 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'; + const modal = this.modalService.open( + BuildSettingsModalComponent, + { size: 'lg', container: 'nb-layout' }, + ); } - 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); + if (!this.curPrj.uiSettings) { + return this.alertSvr.warning('Invalid setting structure', 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); + 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.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); - } - 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()));