X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fconfig%2Fconfig.component.ts;h=0df707b9c7de9beadd207425f182adbe90ba6160;hb=dd6f08b10b1597f44e3dc25509ac9a45336b0914;hp=1e1e9c23d8f1f38bd2b5a9c5d806c4b45e5f2ee7;hpb=61ca475685c6b7b33654edaad637c7d53bdf8d34;p=src%2Fxds%2Fxds-server.git diff --git a/webapp/src/app/config/config.component.ts b/webapp/src/app/config/config.component.ts index 1e1e9c2..0df707b 100644 --- a/webapp/src/app/config/config.component.ts +++ b/webapp/src/app/config/config.component.ts @@ -7,12 +7,13 @@ import 'rxjs/add/operator/map'; import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/debounceTime'; -import { ConfigService, IConfig, IProject, ProjectType } from "../common/config.service"; -import { XDSServerService, IServerStatus, IXDSAgentInfo } from "../common/xdsserver.service"; -import { XDSAgentService, IAgentStatus } from "../common/xdsagent.service"; -import { SyncthingService, ISyncThingStatus } from "../common/syncthing.service"; -import { AlertService } from "../common/alert.service"; -import { ISdk, SdkService } from "../common/sdk.service"; +import { ConfigService, IConfig, IProject, ProjectType, ProjectTypes, + IxdsAgentPackage } from "../services/config.service"; +import { XDSServerService, IServerStatus, IXDSAgentInfo } from "../services/xdsserver.service"; +import { XDSAgentService, IAgentStatus } from "../services/xdsagent.service"; +import { SyncthingService, ISyncThingStatus } from "../services/syncthing.service"; +import { AlertService } from "../services/alert.service"; +import { ISdk, SdkService } from "../services/sdk.service"; @Component({ templateUrl: './app/config/config.component.html', @@ -32,7 +33,8 @@ export class ConfigComponent implements OnInit { curProj: number; userEditedLabel: boolean = false; - xdsAgentZipUrl: string = ""; + xdsAgentPackages: IxdsAgentPackage[] = []; + projectTypes = ProjectTypes; // TODO replace by reactive FormControl + add validation syncToolUrl: string; @@ -45,8 +47,8 @@ export class ConfigComponent implements OnInit { }; addProjectForm: FormGroup; - pathCtrl = new FormControl("", Validators.required); - + pathCliCtrl = new FormControl("", Validators.required); + pathSvrCtrl = new FormControl("", Validators.required); constructor( private configSvr: ConfigService, @@ -57,11 +59,16 @@ export class ConfigComponent implements OnInit { private alert: AlertService, private fb: FormBuilder ) { - // FIXME implement multi project support + // Define types (first one is special/placeholder) + this.projectTypes.unshift({value: -1, display: "--Select a type--"}); + let selectedType = this.projectTypes[0].value; + this.curProj = 0; this.addProjectForm = fb.group({ - path: this.pathCtrl, + pathCli: this.pathCliCtrl, + pathSvr: this.pathSvrCtrl, label: ["", Validators.nullValidator], + type: [selectedType, Validators.pattern("[0-9]+")], }); } @@ -78,11 +85,11 @@ export class ConfigComponent implements OnInit { this.xdsAgentUrl = cfg.xdsAgent.URL; this.xdsAgentRetry = String(cfg.xdsAgent.retry); this.projectsRootDir = cfg.projectsRootDir; - this.xdsAgentZipUrl = cfg.xdsAgentZipUrl; + this.xdsAgentPackages = cfg.xdsAgentPackages; }); // Auto create label name - this.pathCtrl.valueChanges + this.pathCliCtrl.valueChanges .debounceTime(100) .filter(n => n) .map(n => "Project_" + n.split('/')[0]) @@ -91,6 +98,9 @@ export class ConfigComponent implements OnInit { this.addProjectForm.patchValue({ label: value }); } }); + + // Select 1 first type by default + // SEB this.typeCtrl.setValue({type: ProjectTypes[0].value}); } onKeyLabel(event: any) { @@ -118,21 +128,24 @@ export class ConfigComponent implements OnInit { } xdsAgentRestartConn() { - let aurl = this.xdsAgentUrl; + let aUrl = this.xdsAgentUrl; this.configSvr.syncToolURL = this.syncToolUrl; - this.configSvr.xdsAgentUrl = aurl; + this.configSvr.xdsAgentUrl = aUrl; this.configSvr.loadProjects(); } onSubmit() { let formVal = this.addProjectForm.value; + let type = formVal['type'].value; + let numType = Number(formVal['type']); this.configSvr.addProject({ label: formVal['label'], - path: formVal['path'], - type: ProjectType.SYNCTHING, + pathClient: formVal['pathCli'], + pathServer: formVal['pathSvr'], + type: numType, // FIXME: allow to set defaultSdkID from New Project config panel }); } -} \ No newline at end of file +}