diff options
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts | 119 |
1 files changed, 107 insertions, 12 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts index be98eec88..ba8b2f0f1 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/designer.store.ts @@ -22,8 +22,9 @@ limitations under the License. import {Injectable} from '@angular/core'; import {Store} from '../../../../common/core/stores/Store'; import {DesignerService} from './designer.service'; -import {ModelType} from '../model/ModelType.model'; -import {DesignerDashboardState} from '../model/designer-dashboard.state'; +import {DesignerDashboardState} from './model/designer.dashboard.state'; +import { DeclarativeWorkflow } from './model/designer.workflow'; +import { NodeTemplate } from './model/desinger.nodeTemplate.model'; @Injectable({ @@ -35,15 +36,109 @@ export class DesignerStore extends Store<DesignerDashboardState> { super(new DesignerDashboardState()); } - public getFuntions() { - const modelDefinitionType = 'node_type'; - this.designerService.getFunctions(modelDefinitionType).subscribe( - (modelType: ModelType[]) => { - console.log(modelType); - this.setState({ - ...this.state, - functions: modelType, - }); - }); + /** + * adds empty workflow with name only. + * called when blank action is added to the board + * declarative workflow just contain the steps but its order is determind by dg-graph + */ + addDeclarativeWorkFlow(workflowName: string) { + this.setState({ + ...this.state, + template: { + ...this.state.template, + workflows: { + ...this.state.template.workflows, + [workflowName]: new DeclarativeWorkflow() + } + } + }); + } + + addStepToDeclarativeWorkFlow(workflowName: string, stepName: string, stepType: string) { + this.setState({ + ...this.state, + template: { + ...this.state.template, + workflows: { + ...this.state.template.workflows, + [workflowName]: { + ...this.state.template.workflows[workflowName], + steps: { + [stepName]: { + target: stepType, + description: '' + } + } + } + } + } + }); + } + + saveSourceContent(code: string) { + const topologyTemplate = JSON.parse(code); + this.setState({ + ...this.state, + sourceContent: code, + template: topologyTemplate + }); + } + + + /** + * adding node tempates is a separate action of adding the steps to the workflow + * you can add node template and don't add workflow step when you add dependencies for the + * dg-generic function for example + */ + addNodeTemplate(nodeTemplateName: string, type: string) { + this.setState({ + ...this.state, + template: { + ...this.state.template, + node_templates: { + ...this.state.template.node_templates, + [nodeTemplateName]: new NodeTemplate(type) + } + } + }); + } + + addDgGenericNodeTemplate(nodeTemplateName: string) { + const node = new NodeTemplate('dg-generic'); + node.properties = { + 'dependency-node-templates': [] + }; + this.setState({ + ...this.state, + template: { + ...this.state.template, + node_templates: { + ...this.state.template.node_templates, + [nodeTemplateName]: node + } + } + }); + } + + addDgGenericDependency(dgGenericNodeName: string, dependency: string) { + const props = this.state.template.node_templates[dgGenericNodeName].properties; + this.setState({ + ...this.state, + template: { + ...this.state.template, + node_templates: { + ...this.state.template.node_templates, + [dgGenericNodeName]: { + ...this.state.template.node_templates[dgGenericNodeName], + properties: { + 'dependency-node-templates': [ + ...props['dependency-node-templates'], + dependency + ] + } + } + } + } + }); } } |