Skip to content

Commit

Permalink
Merge pull request #105 from pengz1/Fix-canvas-waitOns-issues
Browse files Browse the repository at this point in the history
Fix canvas wait ons issues
  • Loading branch information
pengz1 authored Jun 28, 2018
2 parents d1f9d85 + cb9b56a commit 23bb52e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To Be Added.
## Dependencies
What you need to run this app:
* `node` and `npm` (`brew install node`)
* Ensure you're running the latest versions Node `v6.x.x`+ (or `v7.x.x`) and NPM `3.x.x`+
* Ensure you're running the latest versions Node `v8.x.x` and NPM `5.x.x`+

> If you have `nvm` installed, which is highly recommended (`brew install nvm`) you can do a `nvm install --lts && nvm use` in `$` to run with the latest Node LTS. You can also have this `zsh` done for you [automatically](https://github.com/creationix/nvm#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file)
Expand Down
19 changes: 14 additions & 5 deletions src/app/canvas-graph/canvas-graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ export class CanvasGraphComponent implements OnInit {
}
}

afterInputDisconnect(taskToBeChanged) {
this.changeTaskWaitOn(taskToBeChanged);
afterInputDisconnect(taskToBeChanged, preTask, preTaskResult) {
this.changeTaskWaitOn(taskToBeChanged, preTask, preTaskResult);
}

afterClick(e, node) {
Expand Down Expand Up @@ -189,14 +189,14 @@ export class CanvasGraphComponent implements OnInit {
if (!preTask && !waitOnText) {
_.forEach(this.workflow && this.workflow.tasks, (task) => {
if (_.isEqual(task, taskToBeChanged)) {
delete task['waitOn'];
delete task['waitOn'][preTask];
}
});
} else {
//this.workflow may be undefined.
_.forEach(this.workflow && this.workflow.tasks, (task) => {
if (_.isEqual(task, taskToBeChanged)) {
task['waitOn'] = _.set({}, preTask.label, waitOnText);
task['waitOn'] = _.assign(task["waitOn"] || {}, {[preTask.label]: waitOnText});
}
});
}
Expand Down Expand Up @@ -325,7 +325,11 @@ export class CanvasGraphComponent implements OnInit {
let options = [];
if (!self.editable) return options;
if (node.removable !== false)
options.push(null, {content: 'Remove', callback: self.removeNode.bind(self)});
options.push(
null,
{content: 'Remove', callback: self.removeNode.bind(self)},
{content: 'AddInput', callback: self.addInput.bind(self)}
);
if (node.graph && node.graph.onGetNodeMenuOptions)
node.graph.onGetNodeMenuOptions(options, node);
return options;
Expand All @@ -337,6 +341,11 @@ export class CanvasGraphComponent implements OnInit {
global.LGraphCanvas.onMenuNodeRemove(value, options, e, menu, node);
}

addInput(value, options, e, menu, node){
node.addInput("waitOn", global.LiteGraph.EVENT);
// this.afterWorkflowUpdate();
}

drawNodes() {
if (!this.workflow) return;

Expand Down
2 changes: 1 addition & 1 deletion src/app/header/header.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<header class="header-6">
<div class="branding">
<a class="nav-link">
<img src="../../assets/logo-icon.png" alt="">
<img src="../../assets/rackhd-icon.png" alt="">
<span class="title" style="padding-left: 10px">RackHD</span>
</a>
</div>
Expand Down
12 changes: 0 additions & 12 deletions src/app/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,3 @@ header {
width: 100vw;
z-index: 9999;
}
.app-header {
.logo-placeholder {
color: white;
font-size: x-large;
}
.branding {
img {
height: 60px;
width: 60px;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
</button>
<div class="editor-dropdown">
<dropdown-group [data]="workflowStore" [columns]="columns" [placeholders]="placeholders" [fields]="fields"
needSearchIcon=true
(selected)="onSelected($event)" (cleared)="onRefresh()">
</dropdown-group>
needSearchIcon=true
(selected)="onSelected($event)" (cleared)="onRefresh()">
</dropdown-group>
</div>
</div>
<div #jsoneditor id="jsoneditor"></div>
Expand All @@ -33,31 +33,21 @@

<clr-modal [(clrModalOpen)]="isShowModal" [clrModalSize]="'xl'">

<div class="modal-title" *ngIf="saveConfirmed && (selectWorkflow.injectableName == '')">
<h3 style="color:red">No workflow selected.</h3>
</div>
<h3 class="modal-title" [ngClass]="{'red-title': !isWorkflowValid}">{{saveGraphInfo.status}}</h3>

<div class="modal-body" *ngIf="saveConfirmed && !(selectWorkflow.injectableName == '')">
<p>Are you sure to save {{this.editor.get().injectableName}} ?</p>
<div class="modal-body">
<p>{{saveGraphInfo.notes}}</p>
</div>

<div class="modal-footer" *ngIf="saveConfirmed && !(selectWorkflow.injectableName == '')">
<button class="btn btn-outline" type="button" (click)="saveConfirmed = false; isShowModal = false;">No</button>
<button class="btn btn-primary" type="button" (click)="saveConfirmed = false; saveWorkflow()">Yes</button>
<div class="modal-footer" *ngIf="isWorkflowValid && isShowModal && saveGraphInfo.type === 0">
<button class="btn btn-outline" type="button" (click)="isShowModal = false;">No</button>
<button class="btn btn-primary" type="button" (click)="saveWorkflow()">Yes</button>
</div>

<h3 class="modal-title" *ngIf="isShowModal && (!saveConfirmed)">{{saveGraphInfo.status}}</h3>

<div class="modal-body" *ngIf="isShowModal && (!saveConfirmed)">
<p>{{saveGraphInfo.notes}}</p>
</div>
<div class="modal-footer" *ngIf="isShowModal && (!saveConfirmed) && saveGraphInfo.type === 1">
<div class="modal-footer" *ngIf="isShowModal && saveGraphInfo.type === 1">
<button class="btn btn-outline" type="button" (click)="isShowModal = false">No</button>
<button class="btn btn-primary" type="button" (click)="jumpRunWorkflow()">Yes</button>
</div>
<div class="modal-footer" *ngIf="isShowModal && (!saveConfirmed) && saveGraphInfo.type === 2">
<button class="btn btn-primary" type="button" (click)="isShowModal = false">Confirm</button>
</div>
</clr-modal>

<clr-modal [(clrModalOpen)]="isWaitOnMismatch" [clrModalSize]="'lg'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
float: right;
}
.workflow-json-operation {
padding-bottom: 45px;
display: inline-flex;
padding-bottom: 60px;
width: 100%;

p {
Expand Down Expand Up @@ -34,3 +34,7 @@
}
}
}

.red-title {
color: #ff0000; //Red
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { GraphService } from '../../services/rackhd/graph.service';
import { JSONEditor } from '../../utils/json-editor';

const global = (window as any);
const SAVE_INFO_INIT = {status: "Saving", notes: 'Waiting...', type: 0};

@Component({
selector: 'app-workflow-editor',
Expand All @@ -17,8 +16,8 @@ export class WorkflowEditorComponent implements OnInit {
selectWorkflow: any;
editor: any;
isShowModal: boolean;
saveConfirmed: boolean;
saveGraphInfo = SAVE_INFO_INIT;
saveGraphInfo: any = {};
isWorkflowValid: boolean;

workflowStore: any[] = [];

Expand All @@ -35,7 +34,6 @@ export class WorkflowEditorComponent implements OnInit {
clearInput() {
this.onWorkflowChanged(this.graphService.getInitGraph());
this.pushDataToCanvas();
this.saveGraphInfo = SAVE_INFO_INIT;
}

putWorkflowIntoCanvas(injectableName: string) {
Expand Down Expand Up @@ -64,12 +62,8 @@ export class WorkflowEditorComponent implements OnInit {

ngOnInit() {
this.isShowModal = false;
this.saveConfirmed = false;
this.selectWorkflow = this.graphService.getInitGraph();
let container = document.getElementById('jsoneditor');
let canvas = document.getElementById('mycanvas');
canvas.setAttribute('height', "1000px");
canvas.setAttribute('width', "800px");
let options = {mode: 'code'};
this.editor = new JSONEditor(container, options);
this.updateEditor(this.selectWorkflow);
Expand Down Expand Up @@ -124,7 +118,22 @@ export class WorkflowEditorComponent implements OnInit {
}

saveConfirm() {
this.saveConfirmed = true;
this.isWorkflowValid = this.selectWorkflow && this.selectWorkflow.injectableName
&& this.selectWorkflow.friendlyName && _.startsWith(this.selectWorkflow.injectableName, "Graph.")
&& this.selectWorkflow.tasks && (this.selectWorkflow.tasks.length > 0);
if (this.isWorkflowValid) {
this.saveGraphInfo = {
status: "Are you sure to save " + this.selectWorkflow.injectableName,
notes: '',
type: 0
}
} else {
this.saveGraphInfo = {
status: "Invalid workflow payload!",
notes: "Please make sure 'injectableName', 'friendlyName' and 'tasks' are not empty! Make sure 'injectableName' starts with 'Graph.'",
type: 0
};
}
this.isShowModal = true;
}

Expand All @@ -135,7 +144,7 @@ export class WorkflowEditorComponent implements OnInit {
res => {
this.saveGraphInfo = {
status: "Saved Successfully!",
notes: 'The workflow ' + this.selectWorkflow.injectableName + ' has been saved successfully. Do you want to run it now?',
notes: 'Workflow ' + this.selectWorkflow.injectableName + ' has been saved successfully. Do you want to run it now?',
type: 1
};
},
Expand Down
File renamed without changes

0 comments on commit 23bb52e

Please sign in to comment.