summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-ui/src/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/services')
-rw-r--r--sdc-workflow-designer-ui/src/app/services/broadcast.service.ts30
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data-access/catalog.service.ts32
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data-access/data-access.service.ts27
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data-access/sdc.service.ts49
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/backend.service.ts100
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/data.service.ts79
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/in-memory-data.service.ts (renamed from sdc-workflow-designer-ui/src/app/services/data-access/in-memory-data.service.ts)66
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/mockdata.ts (renamed from sdc-workflow-designer-ui/src/app/services/data-access/mockdata.ts)0
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/sdc.service.ts86
-rw-r--r--sdc-workflow-designer-ui/src/app/services/data/swagger.ts (renamed from sdc-workflow-designer-ui/src/app/services/data-access/swagger.ts)0
-rw-r--r--sdc-workflow-designer-ui/src/app/services/rest.service.ts28
-rw-r--r--sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts15
-rw-r--r--sdc-workflow-designer-ui/src/app/services/setting.service.ts21
-rw-r--r--sdc-workflow-designer-ui/src/app/services/workflow.service.ts44
14 files changed, 397 insertions, 180 deletions
diff --git a/sdc-workflow-designer-ui/src/app/services/broadcast.service.ts b/sdc-workflow-designer-ui/src/app/services/broadcast.service.ts
index 4322c32e..af567b9a 100644
--- a/sdc-workflow-designer-ui/src/app/services/broadcast.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/broadcast.service.ts
@@ -12,11 +12,12 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
+import { PlanModel } from '../model/plan-model';
+import { RestConfig } from '../model/rest-config';
+import { Swagger } from '../model/swagger';
+import { SequenceFlow } from '../model/workflow/sequence-flow';
import { WorkflowNode } from '../model/workflow/workflow-node';
-import { SequenceFlow } from "../model/workflow/sequence-flow";
-import { PlanModel } from "../model/plan-model";
import { WorkflowElement } from '../model/workflow/workflow-element';
-import { RestConfig } from '../model/rest-config';
/**
* BroadcastService
@@ -26,30 +27,37 @@ import { RestConfig } from '../model/rest-config';
@Injectable()
export class BroadcastService {
- public jsPlumbInstance = new Subject<any>();
- public jsPlumbInstance$ = this.jsPlumbInstance.asObservable();
+ public showProperty = new Subject<WorkflowElement>();
+ public showProperty$ = this.showProperty.asObservable();
- public workflows = new Subject<Map<number, any>>();
+ public workflows = new Subject<Map<string, any>>();
public workflows$ = this.workflows.asObservable();
- public planId = new Subject<number>();
+ public planId = new Subject<string>();
public planId$ = this.planId.asObservable();
public planModel = new Subject<PlanModel>();
public planModel$ = this.planModel.asObservable();
- public showProperty = new Subject<WorkflowElement>();
- public showProperty$ = this.showProperty.asObservable();
-
public updateModelRestConfig = new Subject<RestConfig[]>();
public updateModelRestConfig$ = this.updateModelRestConfig.asObservable();
- public saveEvent = new Subject<string>();
+ public saveEvent = new Subject<any>();
public saveEvent$ = this.saveEvent.asObservable();
public selectedElement = new Subject<WorkflowElement[]>();
public selectedElement$ = this.selectedElement.asObservable();
+ // public elementClick = new Subject<WorkflowElement>();
+ // public elementClick$ = this.elementClick.asObservable();
+ /**
+ * this should be used while the source of rest interfaces changed.
+ * @type {Subject<>}
+ */
+ public backendServiceReady = new Subject<any>();
+ public backendServiceReady$ = this.backendServiceReady.asObservable();
+
+
public nodeProperty = new Subject<WorkflowNode>();
public nodeProperty$ = this.nodeProperty.asObservable();
diff --git a/sdc-workflow-designer-ui/src/app/services/data-access/catalog.service.ts b/sdc-workflow-designer-ui/src/app/services/data-access/catalog.service.ts
deleted file mode 100644
index 987f049d..00000000
--- a/sdc-workflow-designer-ui/src/app/services/data-access/catalog.service.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-
-import { Injectable } from '@angular/core';
-import { WorkflowNode } from "../../model/workflow/workflow-node";
-import { Observable } from "rxjs/Observable";
-import { HttpService } from "../../util/http.service";
-import { PlanModel } from "../../model/plan-model";
-
-/**
- * CatalogService
- * provides data access from backend
- */
-@Injectable()
-export abstract class CatalogService {
-
- constructor(protected httpService: HttpService) {}
-
- public abstract loadWorkflow(workflowId: string): Observable<PlanModel>;
- public abstract loadWorkflows(): Observable<Map<string, PlanModel>>;
-
- public abstract saveWorkflow(name: string, workflow: PlanModel): Observable<boolean>;
-}
diff --git a/sdc-workflow-designer-ui/src/app/services/data-access/data-access.service.ts b/sdc-workflow-designer-ui/src/app/services/data-access/data-access.service.ts
deleted file mode 100644
index 451d7a2b..00000000
--- a/sdc-workflow-designer-ui/src/app/services/data-access/data-access.service.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-
-import { Injectable } from '@angular/core';
-import { CatalogService } from "./catalog.service";
-import { SdcService } from "./sdc.service";
-import { HttpService } from "../../util/http.service";
-
-/**
- * DataAccessService
- * provides data access from backend
- */
-@Injectable()
-export class DataAccessService {
- constructor(private httpService: HttpService) {}
-
- public catalogService: CatalogService = new SdcService(this.httpService);
-}
diff --git a/sdc-workflow-designer-ui/src/app/services/data-access/sdc.service.ts b/sdc-workflow-designer-ui/src/app/services/data-access/sdc.service.ts
deleted file mode 100644
index 12da953b..00000000
--- a/sdc-workflow-designer-ui/src/app/services/data-access/sdc.service.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) 2017 ZTE Corporation.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and the Apache License 2.0 which both accompany this distribution,
- * and are available at http://www.eclipse.org/legal/epl-v10.html
- * and http://www.apache.org/licenses/LICENSE-2.0
- *
- * Contributors:
- * ZTE - initial API and implementation and/or initial documentation
- */
-
-import { Injectable } from '@angular/core';
-import { CatalogService } from "./catalog.service";
-import { Observable } from "rxjs/Observable";
-import { WorkflowNode } from "../../model/workflow/workflow-node";
-import { HttpService } from "../../util/http.service";
-import { PlanModel } from "../../model/plan-model";
-
-/**
- * SdcService
- * provides data access from sdc
- */
-@Injectable()
-export class SdcService extends CatalogService {
-
- constructor(protected httpService: HttpService) {
- super(httpService);
- }
-
- public loadWorkflows(): Observable<Map<string, PlanModel>> {
- // TODO load data from sdc
- const url = 'api/workflows';
- return this.httpService.get(url).map(response => response.data);
- }
-
- public loadWorkflow(workflowId: string): Observable<PlanModel> {
- // TODO load data from sdc
- const url = `api/workflows/${workflowId}`;
- return this.httpService.get(url).map(response => response.data as PlanModel);
- }
-
- public saveWorkflow(name: string, workflow: PlanModel): Observable<boolean> {
- // TODO save workflow design to sdc
- const url = `api/workflows/${name}`;
- return this.httpService.put(url, JSON.stringify(workflow)).map(() => true);
- }
-
-}
diff --git a/sdc-workflow-designer-ui/src/app/services/data/backend.service.ts b/sdc-workflow-designer-ui/src/app/services/data/backend.service.ts
new file mode 100644
index 00000000..41f6fccd
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/data/backend.service.ts
@@ -0,0 +1,100 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs/Observable';
+import { TranslateService } from '@ngx-translate/core';
+
+import { PlanModel } from '../../model/plan-model';
+import { NodeTemplate } from '../../model/topology/node-template';
+import { HttpService } from '../../util/http.service';
+import { BroadcastService } from '../broadcast.service';
+import { NoticeService } from '../notice.service';
+
+/**
+ * BackendService
+ * provides backend data accessor to load and save data.
+ */
+@Injectable()
+export abstract class BackendService {
+ private topologyProperties: { name: string, value: string }[] = [];
+
+ constructor(protected broadcastService: BroadcastService, protected noticeService: NoticeService,
+ protected httpService: HttpService, private translate: TranslateService) {
+ this.broadcastService.saveEvent$.subscribe(data => {
+ this.save(data).subscribe(response => {
+ this.translate.get('WORKFLOW.MSG.SAVE_SUCCESS').subscribe((res: string) => {
+ this.noticeService.success(res);
+ });
+ }, error => {
+ this.noticeService.error(error);
+ });
+ });
+ }
+
+ public abstract loadPlans(): Observable<Map<number, any>>;
+
+ public abstract getBackendType(): string;
+
+ public abstract setParameters(params: any);
+
+ public abstract loadNodeTemplates(): Observable<NodeTemplate[]>;
+
+ public abstract loadTopologyProperties(nodeTemplate: NodeTemplate): Observable<string[]>;
+
+ public abstract loadNodeTemplateInterfaces(nodeTemplate: NodeTemplate): Observable<string[]>;
+
+ public abstract loadNodeTemplateOperations(nodeTemplate: NodeTemplate,
+ interfaceName: string): Observable<string[]>;
+
+ public abstract loadNodeTemplateOperationParameter(nodeTemplate: NodeTemplate,
+ interfaceName: string,
+ operation: string): Observable<any>;
+
+ public abstract save(data: any): Observable<any>;
+
+ public abstract loadPlan(): Observable<PlanModel>;
+
+ public getTopologyProperties(): { name: string, value: string }[] {
+ return this.topologyProperties;
+ }
+
+ public canEdit(): boolean {
+ return true;
+ }
+
+ protected refreshTopologyProperties(): void {
+ this.loadNodeTemplates().subscribe(nodes => {
+ if (0 === nodes.length) {
+ return;
+ }
+
+ const subscribes = nodes.map(node => this.loadTopologyProperties(node));
+ Observable.forkJoin(subscribes).map(nodesProperties => {
+ const allProperties: { name: string, value: string }[] = [];
+ nodesProperties.forEach((properties, index) => {
+ properties.forEach(property => {
+ // allProperties.push(nodes[index].name + '.' + property);
+ const propertyOption = {
+ name: `${nodes[index].name}.${property}`,
+ value: `[${nodes[index].name}].[${property}]`
+ };
+ allProperties.push(propertyOption);
+ });
+ });
+ return allProperties;
+ }).subscribe(allProperties => {
+ this.topologyProperties = allProperties;
+ });
+ });
+ }
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/data/data.service.ts b/sdc-workflow-designer-ui/src/app/services/data/data.service.ts
new file mode 100644
index 00000000..73be01b7
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/data/data.service.ts
@@ -0,0 +1,79 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+
+import { Injectable } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
+import { Observable } from 'rxjs/Observable';
+import { TranslateService } from '@ngx-translate/core';
+
+import { PlanModel } from '../../model/plan-model';
+import { NodeTemplate } from '../../model/topology/node-template';
+import { HttpService } from '../../util/http.service';
+import { BroadcastService } from '../broadcast.service';
+import { SettingService } from "../setting.service";
+import { NoticeService } from '../notice.service';
+import { BackendService } from './backend.service';
+import { SdcService } from './sdc.service';
+
+/**
+ * DataService
+ * BackendService factory, provide backend service by running environment.
+ */
+@Injectable()
+export class DataService {
+ private service: BackendService;
+
+ constructor(private broadcastService: BroadcastService, private noticeService: NoticeService,
+ protected httpService: HttpService, private translate: TranslateService,
+ private settingService: SettingService, private activatedRoute: ActivatedRoute) {
+ this.createBackendService();
+ }
+
+ public initData(): void {
+ this.activatedRoute.queryParams.subscribe(queryParams => {
+ this.service.setParameters(queryParams);
+ });
+ }
+
+ public getTopologyProperties(): { name: string, value: string }[] {
+ return this.service.getTopologyProperties();
+ }
+
+ public loadNodeTemplates(): Observable<NodeTemplate[]> {
+ return this.service.loadNodeTemplates();
+ }
+
+ public loadNodeTemplateInterfaces(nodeTemplate: NodeTemplate): Observable<string[]> {
+ return this.service.loadNodeTemplateInterfaces(nodeTemplate);
+ }
+
+ public loadNodeTemplateOperations(nodeTemplate: NodeTemplate, interfaceName: string): Observable<string[]> {
+ return this.service.loadNodeTemplateOperations(nodeTemplate, interfaceName);
+ }
+
+ public loadNodeTemplateOperationParameter(nodeTemplate: NodeTemplate, interfaceName: string,
+ operation: string): Observable<any> {
+ return this.service.loadNodeTemplateOperationParameter(nodeTemplate, interfaceName, operation);
+ }
+
+ public getBackendType(): string {
+ return this.service.getBackendType();
+ }
+
+ private createBackendService() {
+ this.settingService.getSetting().subscribe(response => {
+ let serviceType = response.BackendType;
+ this.service = new SdcService(this.broadcastService, this.noticeService, this.httpService, this.translate);
+ this.broadcastService.broadcast(this.broadcastService.backendServiceReady, null);
+ })
+ }
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/data-access/in-memory-data.service.ts b/sdc-workflow-designer-ui/src/app/services/data/in-memory-data.service.ts
index 9055086c..e1ead992 100644
--- a/sdc-workflow-designer-ui/src/app/services/data-access/in-memory-data.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/data/in-memory-data.service.ts
@@ -13,6 +13,7 @@
import { Injectable } from '@angular/core';
import { InMemoryDbService } from 'angular-in-memory-web-api';
import { workflowFJH } from "./mockdata";
+import { PlanModel } from '../../model/plan-model';
/**
* InMemeoryDataService
* Mock backend data
@@ -22,28 +23,47 @@ export class InMemoryDataService implements InMemoryDbService {
const swagger = {"swagger":"2.0","info":{"version":"1.0.0","title":"MicroService Bus rest API"},"basePath":"/api/microservices/v1","tags":[{"name":"metrics"},{"name":"iuiRoute"},{"name":"ServiceAccess"},{"name":"ApiRoute"},{"name":"MSB-Service Resource"},{"name":"CustomRoute"}],"paths":{"/apiRoute":{"get":{"tags":["ApiRoute"],"summary":"get all ApiRoute ","description":"","operationId":"getApiRoutes","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/ApiRouteInfo"}}},"500":{"description":"get ApiRouteInfo List fail","schema":{"type":"string"}}}},"post":{"tags":["ApiRoute"],"summary":"add one ApiRoute ","description":"","operationId":"addApiRoute","produces":["application/json"],"parameters":[{"in":"body","name":"body","description":"ApiRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/ApiRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiRouteInfo"}},"400":{"description":"Unprocessable ApiRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"add ApiRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable ApiRouteInfo Entity ","schema":{"type":"string"}}}}},"/apiRoute/apiDocs":{"get":{"tags":["ApiRoute"],"summary":"get all Local apiDoc ","description":"","operationId":"getApiDocs","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"type":"string"}}},"500":{"description":"get apiDoc List fail","schema":{"type":"string"}}}}},"/apiRoute/apiGatewayPort":{"get":{"tags":["ApiRoute"],"summary":"get apiGateway Port ","description":"","operationId":"getApiGatewayPort","produces":["text/plain"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"string"}},"500":{"description":"get apiGateway Port fail","schema":{"type":"string"}}}}},"/apiRoute/discoverInfo":{"get":{"tags":["ApiRoute"],"summary":"get discover Info ","description":"","operationId":"getServiceDiscoverInfo","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/DiscoverInfo"}},"500":{"description":"get discover Info fail","schema":{"type":"string"}}}}},"/apiRoute/export":{"get":{"tags":["ApiRoute"],"summary":"export all route service Info by json-file","description":"","operationId":"exportService","produces":["text/plain"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"string"}},"500":{"description":"export fail","schema":{"type":"string"}},"406":{"description":" not Acceptable client-side","schema":{"type":"string"}}}}},"/apiRoute/{serviceName}/version/{version}":{"get":{"tags":["ApiRoute"],"summary":"get one ApiRoute ","description":"","operationId":"getApiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"ApiRoute serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"ApiRoute version,if the version is empty, please enter \"null\"","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiRouteInfo"}},"500":{"description":"get ApiRouteInfo fail","schema":{"type":"string"}},"404":{"description":"ApiRouteInfo not found","schema":{"type":"string"}},"415":{"description":"Unprocessable ApiRouteInfo Entity ","schema":{"type":"string"}}}},"put":{"tags":["ApiRoute"],"summary":"update one ApiRoute by serviceName and version","description":"","operationId":"updateApiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"ApiRoute serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"ApiRoute version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"in":"body","name":"body","description":"ApiRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/ApiRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiRouteInfo"}},"400":{"description":"Unprocessable ApiRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"update ApiRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable ApiRouteInfo Entity ","schema":{"type":"string"}}}},"delete":{"tags":["ApiRoute"],"summary":"delete one ApiRoute by serviceName and version","description":"","operationId":"deleteApiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"ApiRoute serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"ApiRoute version,if the version is empty, please enter \"null\"","required":true,"type":"string"}],"responses":{"500":{"description":"delete ApiRouteInfo fail","schema":{"type":"string"}},"204":{"description":"delete ApiRouteInfo succeed "},"404":{"description":"ApiRouteInfo not found","schema":{"type":"string"}}}}},"/apiRoute/{serviceName}/version/{version}/status/{status}":{"put":{"tags":["ApiRoute"],"summary":"update one ApiRoute status by serviceName and version","description":"","operationId":"updateApiRouteStatus","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"ApiRoute serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"ApiRoute version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"status","in":"path","description":"ApiRoute status,1:abled 0:disabled","required":true,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/ApiRouteInfo"}},"500":{"description":"update status fail","schema":{"type":"string"}},"415":{"description":"Unprocessable ApiRouteInfo Entity ","schema":{"type":"string"}},"404":{"description":"ApiRouteInfo not found","schema":{"type":"string"}}}}},"/customRoute/all":{"get":{"tags":["CustomRoute"],"summary":"get all CustomRoute ","description":"","operationId":"getCustomRoutes","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/CustomRouteInfo"}}},"500":{"description":"get CustomRouteInfo List fail","schema":{"type":"string"}}}}},"/customRoute/instance":{"get":{"tags":["CustomRoute"],"summary":"get one CustomRoute ","description":"","operationId":"getCustomRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"query","description":"CustomRoute serviceName","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/CustomRouteInfo"}},"500":{"description":"get CustomRoute fail","schema":{"type":"string"}},"404":{"description":"CustomRoute not found","schema":{"type":"string"}},"415":{"description":"Unprocessable CustomRoute Entity ","schema":{"type":"string"}}}},"post":{"tags":["CustomRoute"],"summary":"add one CustomRoute ","description":"","operationId":"addCustomRoute","produces":["application/json"],"parameters":[{"in":"body","name":"body","description":"CustomRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/CustomRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/CustomRouteInfo"}},"400":{"description":"Unprocessable CustomRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"add CustomRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable CustomRouteInfo Entity ","schema":{"type":"string"}}}},"put":{"tags":["CustomRoute"],"summary":"update one CustomRoute by serviceName","description":"","operationId":"updateCustomRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"query","description":"CustomRoute serviceName","required":true,"type":"string"},{"in":"body","name":"body","description":"CustomRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/CustomRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/CustomRouteInfo"}},"400":{"description":"Unprocessable CustomRoute JSON REQUEST","schema":{"type":"string"}},"500":{"description":"update CustomRoute fail","schema":{"type":"string"}},"415":{"description":"Unprocessable CustomRoute Entity ","schema":{"type":"string"}}}},"delete":{"tags":["CustomRoute"],"summary":"delete one CustomRoute by serviceName","description":"","operationId":"deleteCustomRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"query","description":"CustomRoute serviceName","required":true,"type":"string"}],"responses":{"500":{"description":"delete customRoute fail","schema":{"type":"string"}},"204":{"description":"delete customRoute succeed "},"404":{"description":"customRoute not found","schema":{"type":"string"}}}}},"/customRoute/status":{"put":{"tags":["CustomRoute"],"summary":"update one CustomRoute status by serviceName ","description":"","operationId":"updateCustomRouteStatus","produces":["application/json"],"parameters":[{"name":"serviceName","in":"query","description":"CustomRoute serviceName","required":true,"type":"string"},{"name":"status","in":"query","description":"CustomRoute status,1:abled 0:disabled","required":true,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/CustomRouteInfo"}},"500":{"description":"update status fail","schema":{"type":"string"}},"415":{"description":"Unprocessable customRoute Entity ","schema":{"type":"string"}},"404":{"description":"customRoute not found","schema":{"type":"string"}}}}},"/iuiRoute":{"get":{"tags":["iuiRoute"],"summary":"get all iuiRoute ","description":"","operationId":"getIuiRoutes","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/IuiRouteInfo"}}},"500":{"description":"get iuiRouteInfo List fail","schema":{"type":"string"}}}},"post":{"tags":["iuiRoute"],"summary":"add one iuiRoute ","description":"","operationId":"addIuiRoute","produces":["application/json"],"parameters":[{"in":"body","name":"body","description":"iuiRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/IuiRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/IuiRouteInfo"}},"400":{"description":"Unprocessable iuiRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"add iuiRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable iuiRouteInfo Entity ","schema":{"type":"string"}}}}},"/iuiRoute/{serviceName}":{"get":{"tags":["iuiRoute"],"summary":"get one iuiRoute ","description":"","operationId":"getIuiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"iuiRoute serviceName","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/IuiRouteInfo"}},"500":{"description":"get IuiRouteInfo fail","schema":{"type":"string"}},"404":{"description":"IuiRouteInfo not found","schema":{"type":"string"}},"415":{"description":"Unprocessable IuiRouteInfo Entity ","schema":{"type":"string"}}}},"put":{"tags":["iuiRoute"],"summary":"update one iuiRoute by serviceName","description":"","operationId":"updateIuiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"iuiRoute serviceName","required":true,"type":"string"},{"in":"body","name":"body","description":"iuiRoute Instance Info","required":true,"schema":{"$ref":"#/definitions/IuiRouteInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/IuiRouteInfo"}},"400":{"description":"Unprocessable IuiRouteInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"update IuiRouteInfo fail","schema":{"type":"string"}},"415":{"description":"Unprocessable IuiRouteInfo Entity ","schema":{"type":"string"}}}},"delete":{"tags":["iuiRoute"],"summary":"delete one iuiRoute by serviceName","description":"","operationId":"deleteIuiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"iuiRoute serviceName","required":true,"type":"string"}],"responses":{"500":{"description":"delete IuiRouteInfo fail","schema":{"type":"string"}},"204":{"description":"delete IuiRouteInfo succeed "},"404":{"description":"IuiRouteInfo not found","schema":{"type":"string"}}}}},"/iuiRoute/{serviceName}/status/{status}":{"put":{"tags":["iuiRoute"],"summary":"update one iuiRoute status by serviceName ","description":"","operationId":"updateIuiRouteStatus","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"iuiRoute serviceName","required":true,"type":"string"},{"name":"status","in":"path","description":"iuiRoute status,1:abled 0:disabled","required":true,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/IuiRouteInfo"}},"500":{"description":"update IuiRouteInfo status fail","schema":{"type":"string"}},"415":{"description":"Unprocessable IuiRouteInfo Entity ","schema":{"type":"string"}},"404":{"description":"IuiRouteInfo not found","schema":{"type":"string"}}}}},"/metrics":{"get":{"tags":["metrics"],"summary":"get Metrics Info ","description":"","operationId":"getMetricsInfo","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/MetricsInfo"}}}}},"/serviceaccess/{serviceName}":{"get":{"tags":["ServiceAccess"],"summary":"get the msb access address of the service ","description":"","operationId":"getApiRoute","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"serviceName","required":true,"type":"string"},{"name":"type","in":"query","description":"service type","required":false,"type":"string","enum":["api","iui","custom","p2p"]},{"name":"version","in":"query","description":"version","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/ServiceAccessInfo"}},"500":{"description":"get access address error "}}}},"/services":{"get":{"tags":["MSB-Service Resource"],"summary":"get all microservices ","description":"","operationId":"getMicroService","produces":["application/json"],"parameters":[],"responses":{"200":{"description":"successful operation","schema":{"type":"array","items":{"$ref":"#/definitions/MicroServiceFullInfo"}}},"500":{"description":"get microservice List fail","schema":{"type":"string"}}}},"post":{"tags":["MSB-Service Resource"],"summary":"add one microservice ","description":"","operationId":"addMicroService","produces":["application/json"],"parameters":[{"in":"body","name":"body","description":"MicroServiceInfo Instance Info","required":true,"schema":{"$ref":"#/definitions/MicroServiceInfo"}},{"name":"createOrUpdate","in":"query","description":"createOrUpdate","required":false,"type":"boolean","default":"true"},{"name":"port","in":"query","description":"port","required":false,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"400":{"description":"Unprocessable MicroServiceInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"add microservice fail","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}}},"/services/{serviceName}/version/{version}":{"get":{"tags":["MSB-Service Resource"],"summary":"get one microservice ","description":"","operationId":"getMicroService","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"port","in":"query","description":"port","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"500":{"description":"get microservice fail","schema":{"type":"string"}},"404":{"description":"microservice not found","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}},"put":{"tags":["MSB-Service Resource"],"summary":"update one microservice by serviceName and version","description":"","operationId":"updateMicroService","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"in":"body","name":"body","description":"microservice Instance Info","required":true,"schema":{"$ref":"#/definitions/MicroServiceInfo"}}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"400":{"description":"Unprocessable MicroServiceInfo JSON REQUEST","schema":{"type":"string"}},"500":{"description":"update microservice fail","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}},"delete":{"tags":["MSB-Service Resource"],"summary":"delete one full microservice by serviceName and version","description":"","operationId":"deleteMicroService","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"port","in":"query","description":"port","required":false,"type":"string"}],"responses":{"500":{"description":"delete microservice fail","schema":{"type":"string"}},"204":{"description":"delete microservice succeed "},"404":{"description":"microservice not found","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}}},"/services/{serviceName}/version/{version}/nodes/{ip}/{port}":{"put":{"tags":["MSB-Service Resource"],"summary":"update single node by serviceName and version and node","description":"","operationId":"updateNode","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"ip","in":"path","description":"ip","required":true,"type":"string"},{"name":"port","in":"path","description":"port","required":true,"type":"string"},{"name":"ttl","in":"query","description":"ttl","required":false,"type":"integer","format":"int32"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"500":{"description":"update node fail","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}},"404":{"description":"microservice not found","schema":{"type":"string"}}}},"delete":{"tags":["MSB-Service Resource"],"summary":"delete single node by serviceName and version and node","description":"","operationId":"deleteNode","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"ip","in":"path","description":"ip","required":true,"type":"string"},{"name":"port","in":"path","description":"port","required":true,"type":"string"}],"responses":{"500":{"description":"delete node fail","schema":{"type":"string"}},"204":{"description":"delete node succeed "},"404":{"description":"node not found","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}}}}},"/services/{serviceName}/version/{version}/status/{status}":{"put":{"tags":["MSB-Service Resource"],"summary":"update microservice status by serviceName and version","description":"","operationId":"updateServiceStatus","produces":["application/json"],"parameters":[{"name":"serviceName","in":"path","description":"microservice serviceName","required":true,"type":"string"},{"name":"version","in":"path","description":"microservice version,if the version is empty, please enter \"null\"","required":true,"type":"string"},{"name":"status","in":"path","description":"status,1:abled 0:disabled","required":true,"type":"string"}],"responses":{"201":{"description":"successful operation","schema":{"$ref":"#/definitions/MicroServiceFullInfo"}},"500":{"description":"update status fail","schema":{"type":"string"}},"415":{"description":"Unprocessable MicroServiceInfo Entity ","schema":{"type":"string"}},"404":{"description":"microservice not found","schema":{"type":"string"}}}}}},"definitions":{"JVMMetrics":{"type":"object","properties":{"value":{"type":"number","format":"double"}}},"DiscoverInfo":{"type":"object","properties":{"ip":{"type":"string"},"port":{"type":"integer","format":"int32"},"enabled":{"type":"boolean","default":false}}},"IuiRouteInfo":{"type":"object","required":["servers","serviceName","url"],"properties":{"serviceName":{"type":"string"},"url":{"type":"string","example":"/test","description":"Target Service URL,start with /"},"control":{"type":"string","example":"0","description":"[control Range] 0:default 1:readonly 2:hidden ","enum":["0","1","2"]},"status":{"type":"string","example":"1","description":"[status] 1:abled 0:disabled ","enum":["0","1"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"useOwnUpstream":{"type":"string","example":"0","description":"[LB Policy]non_ip_hash:0,ip_hash:1","enum":["0","1"]},"servers":{"type":"array","items":{"$ref":"#/definitions/RouteServer"}}}},"Node":{"type":"object","required":["ip","port"],"properties":{"ip":{"type":"string"},"port":{"type":"string"},"ttl":{"type":"integer","format":"int32"}}},"RouteServer":{"type":"object","required":["ip","port"],"properties":{"ip":{"type":"string"},"port":{"type":"string"},"weight":{"type":"integer","format":"int32"}}},"MicroServiceInfo":{"type":"object","required":["protocol","serviceName","url"],"properties":{"serviceName":{"type":"string"},"version":{"type":"string","example":"v1"},"url":{"type":"string","example":"/api/serviceName/v1","description":"Target Service URL,start with /"},"protocol":{"type":"string","example":"REST","description":"Service Protocol","enum":["REST","UI","MQ","FTP","SNMP","TCP","UDP"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"lb_policy":{"type":"string","example":"hash","description":"lb policy","enum":["round-robin","hash","least_conn"]},"namespace":{"type":"string"},"nodes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/definitions/Node"}}}},"HttpMetrics":{"type":"object","properties":{"count":{"type":"integer","format":"int32"},"max":{"type":"number","format":"double"},"mean":{"type":"number","format":"double"},"min":{"type":"number","format":"double"},"p50":{"type":"number","format":"double"},"p75":{"type":"number","format":"double"},"p95":{"type":"number","format":"double"},"p98":{"type":"number","format":"double"},"p99":{"type":"number","format":"double"},"p999":{"type":"number","format":"double"},"stddev":{"type":"number","format":"double"},"m15_rate":{"type":"number","format":"double"},"m1_rate":{"type":"number","format":"double"},"m5_rate":{"type":"number","format":"double"},"mean_rate":{"type":"number","format":"double"},"duration_units":{"type":"string"},"rate_units":{"type":"string"}}},"ApiRouteInfo":{"type":"object","required":["servers","serviceName","url","version"],"properties":{"serviceName":{"type":"string"},"version":{"type":"string","example":"v1"},"url":{"type":"string","example":"/test","description":"Target Service URL,start with /"},"apiJson":{"type":"string"},"apiJsonType":{"type":"string","example":"1","description":"[apiJson Type] 0:local file 1: remote file","enum":["0","1"]},"metricsUrl":{"type":"string"},"control":{"type":"string","example":"0","description":"[control Range] 0:default 1:readonly 2:hidden ","enum":["0","1","2"]},"status":{"type":"string","example":"1","description":"[status] 1:abled 0:disabled ","enum":["0","1"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"useOwnUpstream":{"type":"string","example":"0","description":"[LB Policy]non_ip_hash:0,ip_hash:1","enum":["0","1"]},"servers":{"type":"array","items":{"$ref":"#/definitions/RouteServer"}}}},"Gauges":{"type":"object","properties":{"jvm.attribute.uptime":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Eden-Space.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.PS-Eden-Space.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Perm-Gen.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.PS-Perm-Gen.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Survivor-Space.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.PS-Survivor-Space.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Tenured-Gen.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.PS-Old-Gen.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.pools.Code-Cache.usage":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.heap.init":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.non-heap.init":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.heap.used":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.non-heap.used":{"$ref":"#/definitions/JVMMetrics"},"jvm.memory.heap.max":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.runnable.count":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.timed_waiting.count":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.waiting.count":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.blocked.count":{"$ref":"#/definitions/JVMMetrics"},"jvm.threads.count":{"$ref":"#/definitions/JVMMetrics"}}},"MetricsInfo":{"type":"object","properties":{"gauges":{"$ref":"#/definitions/Gauges"},"timers":{"$ref":"#/definitions/Timers"}}},"ServiceAccessInfo":{"type":"object","properties":{"serviceType":{"type":"string"},"serviceName":{"type":"string"},"version":{"type":"string"},"accessAddr":{"type":"string"}}},"MicroServiceFullInfo":{"type":"object","required":["protocol","serviceName","url"],"properties":{"serviceName":{"type":"string"},"version":{"type":"string","example":"v1"},"url":{"type":"string","example":"/api/serviceName/v1","description":"Target Service URL,start with /"},"protocol":{"type":"string","example":"REST","description":"Service Protocol","enum":["REST","UI","MQ","FTP","SNMP","TCP","UDP"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"lb_policy":{"type":"string","example":"hash","description":"lb policy","enum":["round-robin","hash","least_conn"]},"namespace":{"type":"string"},"nodes":{"type":"array","uniqueItems":true,"items":{"$ref":"#/definitions/NodeInfo"}},"status":{"type":"string"}}},"NodeInfo":{"type":"object","required":["ip","port"],"properties":{"ip":{"type":"string"},"port":{"type":"string"},"ttl":{"type":"integer","format":"int32"},"nodeId":{"type":"string"},"expiration":{"type":"string","format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"CustomRouteInfo":{"type":"object","required":["servers","serviceName","url"],"properties":{"serviceName":{"type":"string"},"url":{"type":"string","example":"/test","description":"Target Service URL,start with /"},"control":{"type":"string","example":"0","description":"[control Range] 0:default 1:readonly 2:hidden ","enum":["0","1","2"]},"status":{"type":"string","example":"1","description":"[status] 1:abled 0:disabled ","enum":["0","1"]},"visualRange":{"type":"string","example":"1","description":"[visual Range]interSystem:0,inSystem:1","enum":["0","1"]},"useOwnUpstream":{"type":"string","example":"0","description":"[LB Policy]non_ip_hash:0,ip_hash:1","enum":["0","1"]},"servers":{"type":"array","items":{"$ref":"#/definitions/RouteServer"}}}},"Timers":{"type":"object","properties":{"org.openo.msb.resources.ApiRouteResource.addApiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.deleteApiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.getApiDocs":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.getApiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.getApiRoutes":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.getServerIP":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.ApiRouteResource.updateApiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.addIuiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.deleteIuiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.getIuiRoute":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.getIuiRoutes":{"$ref":"#/definitions/HttpMetrics"},"org.openo.msb.resources.IuiRouteResource.updateIuiRoute":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.get-requests":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.post-requests":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.put-requests":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.delete-requests":{"$ref":"#/definitions/HttpMetrics"},"io.dropwizard.jetty.MutableServletContextHandler.other-requests":{"$ref":"#/definitions/HttpMetrics"}}}}};
- const workflows = {plan1: {
- id: 'workflow1',
- name: 'workflow1',
- nodes: [],
- configs: {
- microservices: [{
- definition: "/s/swagger",
- name: "test",
- swaggerJson: JSON.stringify(swagger),
- version: "v2"
- }]
- }
- }, plan2: {
- id: 'workflow2',
- name: 'workflow2',
- nodes: [],
- configs: {
- microservices: []
- }
- },
- plan3: workflowFJH,
- };
- return { workflows, swagger};
+ const workflows = {
+ "1": {
+ planName: "plan1",
+ plan: {
+ id: 'workflow1',
+ name: 'workflow1',
+ nodes: [],
+ configs: {
+ microservices: [{
+ definition: "/s/swagger",
+ name: "test",
+ swaggerJson: JSON.stringify(swagger),
+ version: "v2"
+ }]
+ }
+ },
+ },
+ "2": {
+ planName: "plan2",
+ plan: {
+ id: 'workflow2',
+ name: 'workflow2',
+ nodes: [],
+ configs: {
+ microservices: []
+ }
+ },
+ },
+ "3": {
+ planName: "plan3",
+ plan: workflowFJH,
+ } ,
+ };
+
+ const mockarray = [];
+ const mockobject = {};
+
+ const setting = {
+ "BackendType":"Catalog"
+ }
+
+ return { workflows, swagger, mockarray,mockobject, setting};
}
}
diff --git a/sdc-workflow-designer-ui/src/app/services/data-access/mockdata.ts b/sdc-workflow-designer-ui/src/app/services/data/mockdata.ts
index b7f9f90c..b7f9f90c 100644
--- a/sdc-workflow-designer-ui/src/app/services/data-access/mockdata.ts
+++ b/sdc-workflow-designer-ui/src/app/services/data/mockdata.ts
diff --git a/sdc-workflow-designer-ui/src/app/services/data/sdc.service.ts b/sdc-workflow-designer-ui/src/app/services/data/sdc.service.ts
new file mode 100644
index 00000000..0e2f1118
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/data/sdc.service.ts
@@ -0,0 +1,86 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+
+import { Injectable } from '@angular/core';
+import { Observable } from "rxjs/Observable";
+import { WorkflowNode } from "../../model/workflow/workflow-node";
+import { HttpService } from "../../util/http.service";
+import { PlanModel } from "../../model/plan-model";
+import { BackendService } from './backend.service';
+import { NodeTemplate } from '../../model/topology/node-template';
+
+/**
+ * SdcService
+ * provides data access from sdc
+ */
+@Injectable()
+export class SdcService extends BackendService {
+ private workflowId: string;
+
+ public getBackendType(): string {
+ return "SDC";
+ }
+ public setParameters(params: any) {
+ this.workflowId = params;
+ this.loadPlans().subscribe(plans => {
+ const map = new Map<string, any>();
+ for(let id of Object.keys(plans)) {
+ map.set(id, plans[id]);
+ }
+ this.broadcastService.broadcast(this.broadcastService.workflows, map);
+ });
+ }
+ public loadNodeTemplates(): Observable<NodeTemplate[]> {
+ // TODO load data from sdc
+ const url = 'api/mockarray';
+ return this.httpService.get(url).map(response => response.data);
+ }
+ public loadTopologyProperties(nodeTemplate: NodeTemplate): Observable<string[]> {
+ // TODO load data from sdc
+ const url = 'api/mockarray';
+ return this.httpService.get(url).map(response => response.data);
+ }
+ public loadNodeTemplateInterfaces(nodeTemplate: NodeTemplate): Observable<string[]> {
+ // TODO load data from sdc
+ const url = 'api/mockarray';
+ return this.httpService.get(url).map(response => response.data);
+ }
+ public loadNodeTemplateOperations(nodeTemplate: NodeTemplate, interfaceName: string): Observable<string[]> {
+ // TODO load data from sdc
+ const url = 'api/mockarray';
+ return this.httpService.get(url).map(response => response.data);
+ }
+ public loadNodeTemplateOperationParameter(nodeTemplate: NodeTemplate, interfaceName: string, operation: string): Observable<any> {
+ // TODO load data from sdc
+ const url = 'api/mockobject';
+ return this.httpService.get(url).map(response => response.data);
+ }
+
+ public loadPlans(): Observable<any> {
+ // TODO load data from sdc
+ const url = 'api/workflows';
+ return this.httpService.get(url).map(response => response.data);
+ }
+
+ public loadPlan(): Observable<PlanModel> {
+ // TODO load data from sdc
+ const url = `api/workflows/${this.workflowId}`;
+ return this.httpService.get(url).map(response => response.data as PlanModel);
+ }
+
+ public save(data: any): Observable<boolean> {
+ // TODO save workflow design to sdc
+ const url = `api/workflows/${data.name}`;
+ return this.httpService.put(url, JSON.stringify(data.planModel)).map(() => true);
+ }
+
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/data-access/swagger.ts b/sdc-workflow-designer-ui/src/app/services/data/swagger.ts
index 5a9cc939..5a9cc939 100644
--- a/sdc-workflow-designer-ui/src/app/services/data-access/swagger.ts
+++ b/sdc-workflow-designer-ui/src/app/services/data/swagger.ts
diff --git a/sdc-workflow-designer-ui/src/app/services/rest.service.ts b/sdc-workflow-designer-ui/src/app/services/rest.service.ts
index a4489180..52bddfe3 100644
--- a/sdc-workflow-designer-ui/src/app/services/rest.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/rest.service.ts
@@ -39,22 +39,22 @@ export class RestService {
// this.initSwaggerInfoByMSB();
}
- // public addRestConfig(): RestConfig {
- // let index = 0;
- // this.restConfigs.forEach(config => {
- // const currentId = parseInt(config.id);
- // if (currentId > index) {
- // index = currentId;
- // }
- // });
+ public addRestConfig(): RestConfig {
+ let index = 0;
+ this.restConfigs.forEach(config => {
+ const currentId = parseInt(config.id);
+ if (currentId > index) {
+ index = currentId;
+ }
+ });
- // index += 1;
+ index += 1;
- // const restConfig = new RestConfig(index.toString(), 'new Config', '', '', false);
- // this.restConfigs.push(restConfig);
+ const restConfig = new RestConfig(index.toString(), 'new Config', '', '', '');
+ this.restConfigs.push(restConfig);
- // return restConfig;
- // }
+ return restConfig;
+ }
// public initSwaggerInfo(restConfig: RestConfig) {
// if (restConfig.dynamic && restConfig.definition) {
@@ -125,7 +125,7 @@ export class RestService {
// this service don't have sawgger file.
if ('/activiti-rest' !== serviceInfo.publish_url) {
const id = serviceInfo.serviceName + '.' + serviceInfo.version;
- restConfigs.push(new RestConfig(id, serviceInfo.serviceName, serviceInfo.version, serviceInfo.publish_url));
+ restConfigs.push(new RestConfig(id, serviceInfo.serviceName, serviceInfo.version, serviceInfo.publish_url, ''));
let swaggerUrl = '';
if (undefined !== serviceInfo.swagger_url && '' !== serviceInfo.swagger_url) {
swaggerUrl = serviceInfo.publish_url + '/' + serviceInfo.swagger_url;
diff --git a/sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts b/sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts
new file mode 100644
index 00000000..0fe25d0b
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/setting.service.spec.ts
@@ -0,0 +1,15 @@
+import { TestBed, inject } from '@angular/core/testing';
+
+import { SettingService } from './setting.service';
+
+describe('SettingService', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [SettingService]
+ });
+ });
+
+ it('should be created', inject([SettingService], (service: SettingService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/sdc-workflow-designer-ui/src/app/services/setting.service.ts b/sdc-workflow-designer-ui/src/app/services/setting.service.ts
new file mode 100644
index 00000000..558620fc
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/services/setting.service.ts
@@ -0,0 +1,21 @@
+import { Injectable } from '@angular/core';
+import { Observable } from "rxjs";
+
+import { HttpService } from '../util/http.service';
+
+@Injectable()
+export class SettingService {
+
+ constructor(private http: HttpService) { }
+
+ public getSetting(): Observable<any> {
+ const options: any = {
+ headers: {
+ Accept: 'application/json',
+ }
+ };
+ // return this.http.get('assets/global-setting.json', options);
+ return this.http.get('/api/setting', options);
+ }
+
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/workflow.service.ts b/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
index 6b3a18c8..127629c9 100644
--- a/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
@@ -11,7 +11,7 @@
*/
import { Injectable } from '@angular/core';
-import { DataAccessService } from "./data-access/data-access.service";
+import { DataService } from "./data/data.service";
import { Observable } from "rxjs/Observable";
import { PlanModel } from "../model/plan-model";
import { BroadcastService } from "./broadcast.service";
@@ -23,54 +23,42 @@ import { BroadcastService } from "./broadcast.service";
@Injectable()
export class WorkflowService {
- public workflows = new Map<number, any>();
+ public workflows = new Map<string, any>();
public planModel: PlanModel;
private planName : string;
- public workflowIndex = 0;
- constructor(private broadcastService: BroadcastService, private dataAccessService: DataAccessService) {
- this.dataAccessService.catalogService.loadWorkflows().subscribe(workflows => {
- this.workflowIndex = 0;
- for(let key in workflows) {
- this.workflows.set(this.workflowIndex, {
- "planName": key,
- "plan": workflows[key]
- });
- this.workflowIndex++ ;
- }
- this.broadcastWorkflows();
- });
- this.broadcastService.planModel.subscribe(workflow => this.planModel = workflow);
+ constructor(private broadcastService: BroadcastService, private dataAccessService: DataService) {
+ this.broadcastService.workflows$.subscribe(workflows => this.workflows = workflows);
+ this.broadcastService.planModel$.subscribe(workflow => this.planModel = workflow);
}
- public save(): Observable<boolean> {
+ public save() {
console.log(this.planModel);
console.log(JSON.stringify(this.planModel));
- return this.dataAccessService.catalogService.saveWorkflow(this.planName, this.planModel);
+ this.broadcastService.broadcast(this.broadcastService.saveEvent, {"name": this.planName, "planModel": this.planModel});
}
- public getPlanName(planId: number): string {
+ public getPlanName(planId: string): string {
const planInfo = this.workflows.get(planId);
return planInfo ? planInfo.planName: null;
}
- public getPlanModel(planId: number): PlanModel {
+ public getPlanModel(planId: string): PlanModel {
const planInfo = this.workflows.get(planId);
return planInfo ? planInfo.plan: null;
}
- public getWorkflows(): Map<number, any> {
+ public getWorkflows(): Map<string, any> {
return this.workflows;
}
public addWorkflow() {
- this.workflows.set(this.workflowIndex, {"planName": "newPlan", "plan": new PlanModel()});
- this.workflowIndex++;
+ this.workflows.set(this.getPlanId(), {"planName": "newPlan", "plan": new PlanModel()});
this.broadcastWorkflows();
}
- public deleteWorkflow(planId: number): PlanModel {
+ public deleteWorkflow(planId: string): PlanModel {
this.workflows.delete(planId);
this.broadcastWorkflows();
@@ -80,4 +68,12 @@ export class WorkflowService {
public broadcastWorkflows() {
this.broadcastService.broadcast(this.broadcastService.workflows, this.workflows);
}
+
+ private getPlanId(): string {
+ for(let index=0; index <= this.workflows.size; index++) {
+ if(!this.workflows.has(index + "")) {
+ return index + "";
+ }
+ }
+ }
}