- this.xdsServerSvr.addProject(sdkPrj)
- .subscribe(resStRemotePrj => {
- newPrj.remotePrjDef = resStRemotePrj;
-
- // FIXME REWORK local ST config
- // move logic to server side tunneling-back by WS
-
- // Now setup local config
- let stLocPrj: ISyncThingProject = {
- id: sdkPrj.id,
- label: sdkPrj.label,
- path: sdkPrj.path,
- remoteSyncThingID: resStRemotePrj.builderSThgID
- };
-
- // Set local Syncthing config
- this.stSvr.addProject(stLocPrj)
- .subscribe(resStLocalPrj => {
- newPrj.localPrjDef = resStLocalPrj;
-
- // FIXME: maybe reduce subject to only .project
- //this.confSubject.next(Object.assign({}, this.confStore).project);
- this.confStore.projects.push(Object.assign({}, newPrj));
- this.confSubject.next(Object.assign({}, this.confStore));
- },
- err => {
- this.alert.error("Configuration local ERROR: " + err);
- });
- },
- err => {
- this.alert.error("Configuration remote ERROR: " + err);
+ return this.xdsServerSvr.addProject(xdsPrj)
+ .flatMap(resStRemotePrj => {
+ xdsPrj = resStRemotePrj;
+ if (xdsPrj.type === ProjectType.SYNCTHING) {
+ // FIXME REWORK local ST config
+ // move logic to server side tunneling-back by WS
+ let stData = xdsPrj.dataCloudSync;
+
+ // Now setup local config
+ let stLocPrj: ISyncThingProject = {
+ id: xdsPrj.id,
+ label: xdsPrj.label,
+ path: xdsPrj.path,
+ serverSyncThingID: stData.builderSThgID
+ };
+
+ // Set local Syncthing config
+ return this.stSvr.addProject(stLocPrj);
+
+ } else {
+ return Observable.of(null);
+ }
+ })
+ .map(resStLocalPrj => {
+ this._addProject(xdsPrj);
+ return newPrj;