X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fservices%2Fconfig.service.ts;h=bbe2fb83a2a96c1a2bafab62a707c4eed68d3f40;hb=4695555e178bcabe54c5bf82117c9c4cef5440b5;hp=090df7beabb39e1214e09e0399fe3ab0a3431cff;hpb=97ca1f277dc8b6973d6fa67add5593a9c395ce60;p=src%2Fxds%2Fxds-agent.git diff --git a/webapp/src/app/services/config.service.ts b/webapp/src/app/services/config.service.ts index 090df7b..bbe2fb8 100644 --- a/webapp/src/app/services/config.service.ts +++ b/webapp/src/app/services/config.service.ts @@ -1,25 +1,13 @@ -import { Injectable, OnInit } from '@angular/core'; -import { Http, Headers, RequestOptionsArgs, Response } from '@angular/http'; -import { Location } from '@angular/common'; +import { Injectable } from '@angular/core'; import { CookieService } from 'ngx-cookie'; import { Observable } from 'rxjs/Observable'; -import { Subscriber } from 'rxjs/Subscriber'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; -// Import RxJs required methods -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/observable/throw'; -import 'rxjs/add/operator/mergeMap'; - - -import { XDSAgentService, IXDSProjectConfig } from "../services/xdsagent.service"; import { AlertService, IAlert } from "../services/alert.service"; import { UtilsService } from "../services/utils.service"; export interface IConfig { projectsRootDir: string; - //SEB projects: IProject[]; } @Injectable() @@ -29,21 +17,15 @@ export class ConfigService { private confSubject: BehaviorSubject; private confStore: IConfig; - // SEB cleanup private AgentConnectObs = null; - // SEB cleanup private stConnectObs = null; constructor(private _window: Window, private cookie: CookieService, - private xdsAgentSvr: XDSAgentService, private alert: AlertService, private utils: UtilsService, ) { this.load(); this.confSubject = >new BehaviorSubject(this.confStore); this.Conf$ = this.confSubject.asObservable(); - - // force to load projects - this.loadProjects(); } // Load config @@ -71,107 +53,7 @@ export class ConfigService { this.cookie.putObject("xds-config", cfg); } - loadProjects() { - /* SEB - // Setup connection with local XDS agent - if (this.AgentConnectObs) { - try { - this.AgentConnectObs.unsubscribe(); - } catch (err) { } - this.AgentConnectObs = null; - } - - let cfg = this.confStore.xdsAgent; - this.AgentConnectObs = this.xdsAgentSvr.connect(cfg.retry, cfg.URL) - .subscribe((sts) => { - //console.log("Agent sts", sts); - // FIXME: load projects from local XDS Agent and - // not directly from local syncthing - this._loadProjectFromLocalST(); - - }, error => { - if (error.indexOf("XDS local Agent not responding") !== -1) { - let url_OS_Linux = "https://en.opensuse.org/LinuxAutomotive#Installation_AGL_XDS"; - let url_OS_Other = "https://github.com/iotbzh/xds-agent#how-to-install-on-other-platform"; - let msg = `` + error + `
- You may need to install and execute XDS-Agent:
- On Linux machine -
- On Windows machine -
- On MacOS machine - `; - this.alert.error(msg); - } else { - this.alert.error(error); - } - }); - */ - } - - /* SEB - private _loadProjectFromLocalST() { - // Remove previous subscriber if existing - if (this.stConnectObs) { - try { - this.stConnectObs.unsubscribe(); - } catch (err) { } - this.stConnectObs = null; - } - - // FIXME: move this code and all logic about syncthing inside XDS Agent - // Setup connection with local SyncThing - let retry = this.confStore.localSThg.retry; - let url = this.confStore.localSThg.URL; - this.stConnectObs = this.stSvr.connect(retry, url).subscribe((sts) => { - this.confStore.localSThg.ID = sts.ID; - this.confStore.localSThg.tilde = sts.tilde; - if (this.confStore.projectsRootDir === "") { - this.confStore.projectsRootDir = sts.tilde; - } - - // Rebuild projects definition from local and remote syncthing - this.confStore.projects = []; - - this.xdsServerSvr.getProjects().subscribe(remotePrj => { - this.stSvr.getProjects().subscribe(localPrj => { - remotePrj.forEach(rPrj => { - let lPrj = localPrj.filter(item => item.id === rPrj.id); - if (lPrj.length > 0 || rPrj.type === ProjectType.NATIVE_PATHMAP) { - this._addProject(rPrj, true); - } - }); - this.confSubject.next(Object.assign({}, this.confStore)); - }), error => this.alert.error('Could not load initial state of local projects.'); - }), error => this.alert.error('Could not load initial state of remote projects.'); - - }, error => { - if (error.indexOf("Syncthing local daemon not responding") !== -1) { - let msg = "" + error + "
"; - msg += "Please check that local XDS-Agent is running.
"; - msg += "
"; - this.alert.error(msg); - } else { - this.alert.error(error); - } - }); - } - - set syncToolURL(url: string) { - this.confStore.localSThg.URL = url; - this.save(); - } - */ - set projectsRootDir(p: string) { - /* SEB - if (p.charAt(0) === '~') { - p = this.confStore.localSThg.tilde + p.substring(1); - } - */ this.confStore.projectsRootDir = p; this.save(); }