X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fconfig%2Fconfig.component.ts;h=b107e811fd732502417d58ef3c7d062b414867d6;hb=52c9bdcb2f9fc6b33fd984a794f43c1f9324e5c2;hp=681c296364fd8296370ed14505141c27f82cce41;hpb=ec7051e1da665206f594c7616ad381bfeaea333a;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 681c296..b107e81 100644 --- a/webapp/src/app/config/config.component.ts +++ b/webapp/src/app/config/config.component.ts @@ -1,16 +1,16 @@ -import { Component, OnInit } from "@angular/core"; +import { Component, ViewChild, OnInit } from "@angular/core"; import { Observable } from 'rxjs/Observable'; import { FormControl, FormGroup, Validators, FormBuilder } from '@angular/forms'; +import { CollapseModule } from 'ngx-bootstrap/collapse'; -// Import RxJs required methods -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 } from "../common/xdsserver.service"; -import { SyncthingService, ISyncThingStatus } from "../common/syncthing.service"; -import { AlertService } from "../common/alert.service"; +import { ConfigService, IConfig, 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"; +import { ProjectAddModalComponent } from "../projects/projectAddModal.component"; +import { SdkAddModalComponent } from "../sdks/sdkAddModal.component"; @Component({ templateUrl: './app/config/config.component.html', @@ -21,77 +21,68 @@ import { AlertService } from "../common/alert.service"; // and from http://plnkr.co/edit/vCdjZM?p=preview export class ConfigComponent implements OnInit { + @ViewChild('childProjectModal') childProjectModal: ProjectAddModalComponent; + @ViewChild('childSdkModal') childSdkModal: SdkAddModalComponent; config$: Observable; - severStatus$: Observable; + sdks$: Observable; + serverStatus$: Observable; + agentStatus$: Observable; localSTStatus$: Observable; curProj: number; userEditedLabel: boolean = false; + xdsAgentPackages: IxdsAgentPackage[] = []; + + gConfigIsCollapsed: boolean = true; + sdksIsCollapsed: boolean = true; + projectsIsCollapsed: boolean = false; // TODO replace by reactive FormControl + add validation syncToolUrl: string; - syncToolRetry: string; - projectsRootDir: string; + xdsAgentUrl: string; + xdsAgentRetry: string; + projectsRootDir: string; // FIXME: should be remove when projectAddModal will always return full path showApplyBtn = { // Used to show/hide Apply buttons "retry": false, "rootDir": false, }; - addProjectForm: FormGroup; - pathCtrl = new FormControl("", Validators.required); - - constructor( private configSvr: ConfigService, - private sdkSvr: XDSServerService, + private xdsServerSvr: XDSServerService, + private xdsAgentSvr: XDSAgentService, private stSvr: SyncthingService, + private sdkSvr: SdkService, private alert: AlertService, - private fb: FormBuilder ) { - // FIXME implement multi project support - this.curProj = 0; - this.addProjectForm = fb.group({ - path: this.pathCtrl, - label: ["", Validators.nullValidator], - }); } ngOnInit() { this.config$ = this.configSvr.conf; - this.severStatus$ = this.sdkSvr.Status$; + this.sdks$ = this.sdkSvr.Sdks$; + this.serverStatus$ = this.xdsServerSvr.Status$; + this.agentStatus$ = this.xdsAgentSvr.Status$; this.localSTStatus$ = this.stSvr.Status$; - // Bind syncToolUrl to baseURL + // Bind xdsAgentUrl to baseURL this.config$.subscribe(cfg => { this.syncToolUrl = cfg.localSThg.URL; - this.syncToolRetry = String(cfg.localSThg.retry); + this.xdsAgentUrl = cfg.xdsAgent.URL; + this.xdsAgentRetry = String(cfg.xdsAgent.retry); this.projectsRootDir = cfg.projectsRootDir; + this.xdsAgentPackages = cfg.xdsAgentPackages; }); - // Auto create label name - this.pathCtrl.valueChanges - .debounceTime(100) - .filter(n => n) - .map(n => "Project_" + n.split('/')[0]) - .subscribe(value => { - if (value && !this.userEditedLabel) { - this.addProjectForm.patchValue({ label: value }); - } - }); - } - - onKeyLabel(event: any) { - this.userEditedLabel = (this.addProjectForm.value.label !== ""); } submitGlobConf(field: string) { switch (field) { case "retry": let re = new RegExp('^[0-9]+$'); - let rr = parseInt(this.syncToolRetry, 10); - if (re.test(this.syncToolRetry) && rr >= 0) { - this.configSvr.syncToolRetry = rr; + let rr = parseInt(this.xdsAgentRetry, 10); + if (re.test(this.xdsAgentRetry) && rr >= 0) { + this.configSvr.xdsAgentRetry = rr; } else { this.alert.warning("Not a valid number", true); } @@ -105,19 +96,11 @@ export class ConfigComponent implements OnInit { this.showApplyBtn[field] = false; } - syncToolRestartConn() { + xdsAgentRestartConn() { + let aUrl = this.xdsAgentUrl; this.configSvr.syncToolURL = this.syncToolUrl; + this.configSvr.xdsAgentUrl = aUrl; this.configSvr.loadProjects(); } - onSubmit() { - let formVal = this.addProjectForm.value; - - this.configSvr.addProject({ - label: formVal['label'], - path: formVal['path'], - type: ProjectType.SYNCTHING, - }); - } - -} \ No newline at end of file +}