summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-ui/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'sdc-workflow-designer-ui/src/app')
-rw-r--r--sdc-workflow-designer-ui/src/app/app.module.ts2
-rw-r--r--sdc-workflow-designer-ui/src/app/components/property/properties.component.html1
-rw-r--r--sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.html44
-rw-r--r--sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.ts113
-rw-r--r--sdc-workflow-designer-ui/src/app/model/workflow/rest-parameter.ts20
-rw-r--r--sdc-workflow-designer-ui/src/app/model/workflow/rest-task.ts25
-rw-r--r--sdc-workflow-designer-ui/src/app/services/workflow-config.service.ts10
-rw-r--r--sdc-workflow-designer-ui/src/app/services/workflow.service.ts4
8 files changed, 219 insertions, 0 deletions
diff --git a/sdc-workflow-designer-ui/src/app/app.module.ts b/sdc-workflow-designer-ui/src/app/app.module.ts
index 19b7b055..302f5b78 100644
--- a/sdc-workflow-designer-ui/src/app/app.module.ts
+++ b/sdc-workflow-designer-ui/src/app/app.module.ts
@@ -36,6 +36,7 @@ import { MicroserviceComponent } from "./components/menu/microservice/microservi
import { MicroserviceListComponent } from "./components/menu/microservice/microservice-list/microservice-list.component";
import { ModalModule } from "ngx-bootstrap/modal";
import { WorkflowConfigService } from "./services/workflow-config.service";
+import { RestTaskComponent } from "./components/property/rest-task/rest-task.component";
@NgModule({
declarations: [
@@ -48,6 +49,7 @@ import { WorkflowConfigService } from "./services/workflow-config.service";
NodeComponent,
ParameterComponent,
PropertiesComponent,
+ RestTaskComponent,
StartEventParametersComponent,
ToolbarComponent,
],
diff --git a/sdc-workflow-designer-ui/src/app/components/property/properties.component.html b/sdc-workflow-designer-ui/src/app/components/property/properties.component.html
index d7a8500d..2ca5c690 100644
--- a/sdc-workflow-designer-ui/src/app/components/property/properties.component.html
+++ b/sdc-workflow-designer-ui/src/app/components/property/properties.component.html
@@ -40,4 +40,5 @@
<!-- TODO add property for different node types -->
<b4t-start-event-parameters *ngIf="'startEvent' == node.type" [node]="node"></b4t-start-event-parameters>
+ <b4t-rest-task *ngIf="node.type == 'restTask'" [node]="node"></b4t-rest-task>
</div>
diff --git a/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.html b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.html
new file mode 100644
index 00000000..75422581
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.html
@@ -0,0 +1,44 @@
+<!--
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+-->
+
+<div class="form-group row">
+ <label class="col-md-3 form-control-label text-md-right">Service</label>
+ <div class="col-md-9">
+ <select class="form-control" [ngModel]="selectedMicroservice"
+ (ngModelChange)="serviceChanged($event)">
+ <option *ngFor="let microservice of microservices" [ngValue]=microservice>{{getText4Microservice(microservice)}}</option>
+ </select>
+ </div>
+</div>
+
+<div class="form-group row">
+ <label class="col-md-3 form-control-label text-md-right">Path</label>
+ <div class="col-md-9">
+ <select class="form-control" [ngModel]="node.url"
+ (ngModelChange)="urlChanged($event)">
+ <option *ngFor="let interface of restInterfaces" value="{{interface}}">{{interface}}</option>
+ </select>
+ </div>
+</div>
+
+<div class="form-group row">
+ <label class="col-md-3 form-control-label text-md-right">Method</label>
+ <div class="col-md-9">
+ <select class="form-control" [ngModel]="node.method"
+ (ngModelChange)="methodChanged($event)">
+ <option *ngFor="let operation of restOperations" value="{{operation}}">{{operation}}</option>
+ </select>
+ </div>
+</div>
+<hr>
diff --git a/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.ts b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.ts
new file mode 100644
index 00000000..654d19b9
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.ts
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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 { AfterViewInit, Component, Input, OnInit } from '@angular/core';
+import { Subscription } from 'rxjs/Subscription';
+
+import { Swagger, SwaggerMethod, SwaggerParameter, SwaggerResponse } from '../../../model/swagger';
+import { ValueSource } from '../../../model/value-source.enum';
+import { ValueType } from '../../../model/value-type.enum';
+import { RestTask } from '../../../model/workflow/rest-task';
+import { BroadcastService } from '../../../services/broadcast.service';
+import { WorkflowConfigService } from '../../../services/workflow-config.service';
+import { Microservice } from "../../../model/workflow/microservice";
+
+@Component({
+ selector: 'b4t-rest-task',
+ templateUrl: 'rest-task.component.html',
+})
+export class RestTaskComponent implements AfterViewInit, OnInit {
+ @Input() public node: RestTask;
+ public swaggerJson: any = {};
+ public restInterfaces: any[];
+ public restOperations: any = [];
+ public microservices: Microservice[];
+ public selectedMicroservice: Microservice;
+ private swagger: Swagger;
+
+ constructor(private broadcastService: BroadcastService,
+ private configService: WorkflowConfigService) { }
+
+ ngOnInit(): void {
+ this.microservices = this.configService.getMicroservices();
+ this.selectedMicroservice = this.microservices.find(service =>
+ (this.node.serviceName === service.name && this.node.serviceVersion === service.version));
+ }
+ public ngAfterViewInit() {
+ setTimeout(() => {
+ this.loadInterfaces();
+ }, 0);
+ }
+
+ public getText4Microservice(microservice: Microservice): string {
+ return `${microservice.name} [${microservice.version}] `;
+ }
+
+ public serviceChanged(service: Microservice) {
+ this.selectedMicroservice = service;
+ this.node.serviceName = service.name;
+ this.node.serviceVersion = service.version;
+ this.urlChanged('');
+ this.loadInterfaces();
+ }
+
+ public urlChanged(url: string) {
+ this.node.url = url;
+
+ this.node.consumes = [];
+ this.node.produces = [];
+ this.methodChanged('');
+
+ this.loadOperations();
+ }
+
+ public methodChanged(method: string) {
+ this.node.method = method;
+
+ this.node.parameters = [];
+ this.node.responses = [];
+
+ this.updateMethodInfo();
+ }
+
+
+ private loadInterfaces() {
+ if (this.node.serviceName && this.node.serviceVersion) {
+ this.swagger = this.configService.getSwaggerInfo(this.node.serviceName, this.node.serviceVersion);
+
+ if (this.swagger) {
+ this.restInterfaces = [];
+ for (const key of Object.keys(this.swagger.paths)) {
+ this.restInterfaces.push(key);
+ }
+ this.loadOperations();
+ } else {
+ // TODO error handler
+ }
+ }
+ }
+
+ private loadOperations() {
+ if (this.node.url) {
+ const swaggerPath: any = this.swagger.paths[this.node.url];
+
+ this.restOperations = [];
+ for (const key of Object.keys(swaggerPath)) {
+ this.restOperations.push(key);
+ }
+ }
+ }
+
+ private updateMethodInfo() {
+ // TODO update parameters
+ console.log('rest task updated');
+ }
+}
diff --git a/sdc-workflow-designer-ui/src/app/model/workflow/rest-parameter.ts b/sdc-workflow-designer-ui/src/app/model/workflow/rest-parameter.ts
new file mode 100644
index 00000000..ecea3541
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/model/workflow/rest-parameter.ts
@@ -0,0 +1,20 @@
+/**
+ * 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 { Parameter } from './parameter';
+import { WorkflowNode } from './workflow-node';
+
+export class RestParameter extends Parameter {
+ constructor(name: string, value: string, valueSource: string, type: string,
+ public position: string, public schema: any) {
+ super(name, value, valueSource, type);
+ }
+}
diff --git a/sdc-workflow-designer-ui/src/app/model/workflow/rest-task.ts b/sdc-workflow-designer-ui/src/app/model/workflow/rest-task.ts
new file mode 100644
index 00000000..2b3045df
--- /dev/null
+++ b/sdc-workflow-designer-ui/src/app/model/workflow/rest-task.ts
@@ -0,0 +1,25 @@
+/**
+ * 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 { RestParameter } from './rest-parameter';
+import { WorkflowNode } from './workflow-node';
+
+export class RestTask extends WorkflowNode {
+ public serviceName: string;
+ public serviceVersion: string;
+ public url: string;
+ public method: string;
+ public operationId: string;
+ public produces: string[] = [];
+ public consumes: string[] = [];
+ public parameters: RestParameter[] = [];
+ public responses: any[] = [];
+}
diff --git a/sdc-workflow-designer-ui/src/app/services/workflow-config.service.ts b/sdc-workflow-designer-ui/src/app/services/workflow-config.service.ts
index 00a2b9ef..469fde92 100644
--- a/sdc-workflow-designer-ui/src/app/services/workflow-config.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/workflow-config.service.ts
@@ -15,6 +15,7 @@ import { WorkflowService } from "./workflow.service";
import { Microservice } from "../model/workflow/microservice";
import { Observable } from "rxjs/Rx";
import { HttpService } from "../util/http.service";
+import { Swagger } from "../model/swagger";
/**
* WorkflowConfigService
@@ -36,4 +37,13 @@ export class WorkflowConfigService {
};
return this.httpService.get(url).map(response => response.data);
}
+
+ public getSwaggerInfo(serviceName: string, version: string): Swagger {
+ const microservice = this.getMicroservices().find(service => (service.name === serviceName && service.version === version));
+ if(microservice) {
+ return microservice.swagger;
+ } else {
+ return undefined;
+ }
+ }
}
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 09e0e55e..3a6c5df1 100644
--- a/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
+++ b/sdc-workflow-designer-ui/src/app/services/workflow.service.ts
@@ -19,6 +19,7 @@ import { Position } from "../model/workflow/position";
import { NodeType } from "../model/workflow/node-type.enum";
import { StartEvent } from "../model/workflow/start-event";
import { SequenceFlow } from "../model/workflow/sequence-flow";
+import { RestTask } from "../model/workflow/rest-task";
/**
* WorkflowService
@@ -44,6 +45,9 @@ export class WorkflowService {
case NodeType[NodeType.startEvent]:
node = new StartEvent(this.createId(), name, type, new Position(top, left), []);
break;
+ case NodeType[NodeType.restTask]:
+ node = new RestTask(this.createId(), name, type, new Position(top, left), []);
+ break;
default:
node = new WorkflowNode(this.createId(), name, type, new Position(top, left), []);
break;