Skip to content

Commit cb9b56a

Browse files
committed
Refine workflow editor save modal
1 parent f883594 commit cb9b56a

File tree

7 files changed

+36
-45
lines changed

7 files changed

+36
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ To Be Added.
2121
## Dependencies
2222
What you need to run this app:
2323
* `node` and `npm` (`brew install node`)
24-
* Ensure you're running the latest versions Node `v6.x.x`+ (or `v7.x.x`) and NPM `3.x.x`+
24+
* Ensure you're running the latest versions Node `v8.x.x` and NPM `5.x.x`+
2525

2626
> 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)
2727

src/app/header/header.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<header class="header-6">
22
<div class="branding">
33
<a class="nav-link">
4-
<img src="../../assets/logo-icon.png" alt="">
4+
<img src="../../assets/rackhd-icon.png" alt="">
55
<span class="title" style="padding-left: 10px">RackHD</span>
66
</a>
77
</div>

src/app/header/header.component.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,3 @@ header {
44
width: 100vw;
55
z-index: 9999;
66
}
7-
.app-header {
8-
.logo-placeholder {
9-
color: white;
10-
font-size: x-large;
11-
}
12-
.branding {
13-
img {
14-
height: 60px;
15-
width: 60px;
16-
}
17-
}
18-
}

src/app/workflow-center/workflow-editor/workflow-editor.component.html

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
</button>
2323
<div class="editor-dropdown">
2424
<dropdown-group [data]="workflowStore" [columns]="columns" [placeholders]="placeholders" [fields]="fields"
25-
needSearchIcon=true
26-
(selected)="onSelected($event)" (cleared)="onRefresh()">
27-
</dropdown-group>
25+
needSearchIcon=true
26+
(selected)="onSelected($event)" (cleared)="onRefresh()">
27+
</dropdown-group>
2828
</div>
2929
</div>
3030
<div #jsoneditor id="jsoneditor"></div>
@@ -33,31 +33,21 @@
3333

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

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

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

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

49-
<h3 class="modal-title" *ngIf="isShowModal && (!saveConfirmed)">{{saveGraphInfo.status}}</h3>
50-
51-
<div class="modal-body" *ngIf="isShowModal && (!saveConfirmed)">
52-
<p>{{saveGraphInfo.notes}}</p>
53-
</div>
54-
<div class="modal-footer" *ngIf="isShowModal && (!saveConfirmed) && saveGraphInfo.type === 1">
47+
<div class="modal-footer" *ngIf="isShowModal && saveGraphInfo.type === 1">
5548
<button class="btn btn-outline" type="button" (click)="isShowModal = false">No</button>
5649
<button class="btn btn-primary" type="button" (click)="jumpRunWorkflow()">Yes</button>
5750
</div>
58-
<div class="modal-footer" *ngIf="isShowModal && (!saveConfirmed) && saveGraphInfo.type === 2">
59-
<button class="btn btn-primary" type="button" (click)="isShowModal = false">Confirm</button>
60-
</div>
6151
</clr-modal>
6252

6353
<clr-modal [(clrModalOpen)]="isWaitOnMismatch" [clrModalSize]="'lg'">

src/app/workflow-center/workflow-editor/workflow-editor.component.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
float: right;
44
}
55
.workflow-json-operation {
6-
padding-bottom: 45px;
76
display: inline-flex;
7+
padding-bottom: 60px;
88
width: 100%;
99

1010
p {
@@ -34,3 +34,7 @@
3434
}
3535
}
3636
}
37+
38+
.red-title {
39+
color: #ff0000; //Red
40+
}

src/app/workflow-center/workflow-editor/workflow-editor.component.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { GraphService } from '../../services/rackhd/graph.service';
55
import { JSONEditor } from '../../utils/json-editor';
66

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

109
@Component({
1110
selector: 'app-workflow-editor',
@@ -17,8 +16,8 @@ export class WorkflowEditorComponent implements OnInit {
1716
selectWorkflow: any;
1817
editor: any;
1918
isShowModal: boolean;
20-
saveConfirmed: boolean;
21-
saveGraphInfo = SAVE_INFO_INIT;
19+
saveGraphInfo: any = {};
20+
isWorkflowValid: boolean;
2221

2322
workflowStore: any[] = [];
2423

@@ -35,7 +34,6 @@ export class WorkflowEditorComponent implements OnInit {
3534
clearInput() {
3635
this.onWorkflowChanged(this.graphService.getInitGraph());
3736
this.pushDataToCanvas();
38-
this.saveGraphInfo = SAVE_INFO_INIT;
3937
}
4038

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

6563
ngOnInit() {
6664
this.isShowModal = false;
67-
this.saveConfirmed = false;
6865
this.selectWorkflow = this.graphService.getInitGraph();
6966
let container = document.getElementById('jsoneditor');
70-
let canvas = document.getElementById('mycanvas');
71-
canvas.setAttribute('height', "1000px");
72-
canvas.setAttribute('width', "800px");
7367
let options = {mode: 'code'};
7468
this.editor = new JSONEditor(container, options);
7569
this.updateEditor(this.selectWorkflow);
@@ -124,7 +118,22 @@ export class WorkflowEditorComponent implements OnInit {
124118
}
125119

126120
saveConfirm() {
127-
this.saveConfirmed = true;
121+
this.isWorkflowValid = this.selectWorkflow && this.selectWorkflow.injectableName
122+
&& this.selectWorkflow.friendlyName && _.startsWith(this.selectWorkflow.injectableName, "Graph.")
123+
&& this.selectWorkflow.tasks && (this.selectWorkflow.tasks.length > 0);
124+
if (this.isWorkflowValid) {
125+
this.saveGraphInfo = {
126+
status: "Are you sure to save " + this.selectWorkflow.injectableName,
127+
notes: '',
128+
type: 0
129+
}
130+
} else {
131+
this.saveGraphInfo = {
132+
status: "Invalid workflow payload!",
133+
notes: "Please make sure 'injectableName', 'friendlyName' and 'tasks' are not empty! Make sure 'injectableName' starts with 'Graph.'",
134+
type: 0
135+
};
136+
}
128137
this.isShowModal = true;
129138
}
130139

@@ -135,7 +144,7 @@ export class WorkflowEditorComponent implements OnInit {
135144
res => {
136145
this.saveGraphInfo = {
137146
status: "Saved Successfully!",
138-
notes: 'The workflow ' + this.selectWorkflow.injectableName + ' has been saved successfully. Do you want to run it now?',
147+
notes: 'Workflow ' + this.selectWorkflow.injectableName + ' has been saved successfully. Do you want to run it now?',
139148
type: 1
140149
};
141150
},

0 commit comments

Comments
 (0)