Used non default syncthing port to avoid confict.
[src/xds/xds-server.git] / webapp / src / app / services / config.service.ts
index f5e353c..3f07a6a 100644 (file)
@@ -29,6 +29,14 @@ export var ProjectTypes = [
     { value: ProjectType.SYNCTHING, display: "Cloud Sync" }
 ];
 
+export var ProjectStatus = {
+    ErrorConfig: "ErrorConfig",
+    Disable: "Disable",
+    Enable: "Enable",
+    Pause: "Pause",
+    Syncing: "Syncing"
+};
+
 export interface IProject {
     id?: string;
     label: string;
@@ -37,6 +45,7 @@ export interface IProject {
     type: ProjectType;
     status?: string;
     isInSync?: boolean;
+    isUsable?: boolean;
     serverPrjDef?: IXDSFolderConfig;
     isExpanded?: boolean;
     visible?: boolean;
@@ -108,7 +117,7 @@ export class ConfigService {
             this.confStore = {
                 xdsServerURL: this._window.location.origin + '/api/v1',
                 xdsAgent: {
-                    URL: 'http://localhost:8000',
+                    URL: 'http://localhost:8010',
                     retry: 10,
                 },
                 xdsAgentPackages: [],
@@ -116,7 +125,7 @@ export class ConfigService {
                 projects: [],
                 localSThg: {
                     ID: null,
-                    URL: "http://localhost:8384",
+                    URL: "http://localhost:8385",
                     retry: 10,    // 10 seconds
                     tilde: "",
                 }
@@ -144,6 +153,7 @@ export class ConfigService {
                 // XXX for now, only isInSync and status may change
                 this.confStore.projects[i].isInSync = prj.isInSync;
                 this.confStore.projects[i].status = prj.status;
+                this.confStore.projects[i].isUsable = this._isUsableProject(prj);
                 this.confSubject.next(Object.assign({}, this.confStore));
             }
         });
@@ -179,16 +189,19 @@ export class ConfigService {
 
             }, error => {
                 if (error.indexOf("XDS local Agent not responding") !== -1) {
-                    let msg = "<span><strong>" + error + "<br></strong>";
-                    msg += "You may need to download and execute XDS-Agent.<br>";
-
-                    let os = this.utils.getOSName(true);
-                    let zurl = this.confStore.xdsAgentPackages && this.confStore.xdsAgentPackages.filter(elem => elem.os === os);
-                    if (zurl && zurl.length) {
-                        msg += " Download XDS-Agent tarball for " + zurl[0].os + " host OS ";
-                        msg += "<a class=\"fa fa-download\" href=\"" + zurl[0].url + "\" target=\"_blank\"></a>";
-                    }
-                    msg += "</span>";
+                    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 = `<span><strong>` + error + `<br></strong>
+                    You may need to install and execute XDS-Agent: <br>
+                        On Linux machine <a href="` + url_OS_Linux + `" target="_blank"><span
+                            class="fa fa-external-link"></span></a>
+                        <br>
+                        On Windows machine <a href="` + url_OS_Other + `" target="_blank"><span
+                            class="fa fa-external-link"></span></a>
+                        <br>
+                        On MacOS machine <a href="` + url_OS_Other + `" target="_blank"><span
+                            class="fa fa-external-link"></span></a>
+                    `;
                     this.alert.error(msg);
                 } else {
                     this.alert.error(error);
@@ -359,6 +372,12 @@ export class ConfigService {
         return this.xdsServerSvr.syncProject(prj.id);
     }
 
+    private _isUsableProject(p) {
+        return p && p.isInSync &&
+            (p.status === ProjectStatus.Enable) &&
+            (p.status !== ProjectStatus.Syncing);
+    }
+
     private _getProjectIdx(id: string): number {
         return this.confStore.projects.findIndex((item) => item.id === id);
     }
@@ -374,6 +393,7 @@ export class ConfigService {
             type: rPrj.type,
             status: rPrj.status,
             isInSync: rPrj.isInSync,
+            isUsable: this._isUsableProject(rPrj),
             defaultSdkID: rPrj.defaultSdkID,
             serverPrjDef: Object.assign({}, rPrj),  // do a copy
         };