1
1
<template >
2
2
<div class =" wizard-tab-content" >
3
3
<WizardTab v-if =" !noProcessSelection" :pos =" tabPos[0]" :parent =" parent" title =" Process" :beforeChange =" checkProcessRequirements" >
4
- <ChooseUserDefinedProcess :value =" process" :namespace =" processNamespace" @input =" submitProcess" />
4
+ <ChooseUserDefinedProcess :value =" process" :namespace =" processNamespace" :url = " processUrl " @input =" submitProcess" />
5
5
</WizardTab >
6
6
<WizardTab :pos =" tabPos[1]" :parent =" parent" title =" Parameters" :beforeChange =" checkParameterRequirements" >
7
7
<ChooseProcessParameters v-if =" processSpec" v-model =" args" :process =" processSpec" />
@@ -37,6 +37,7 @@ export default {
37
37
loading: false ,
38
38
noProcessSelection: false ,
39
39
process: null ,
40
+ processUrl: null ,
40
41
processSpec: null ,
41
42
processNamespace: ' user' ,
42
43
args: {},
@@ -58,16 +59,20 @@ export default {
58
59
if (! this .process || ! this .processSpec ) {
59
60
return null ;
60
61
}
61
- let [id, namespace] = Utils .extractUDPParams (this .process );
62
+ let node = {
63
+ process_id: this .process ,
64
+ arguments: this .args ,
65
+ result: true
66
+ };
67
+ if (Utils .hasText (this .processNamespace )) {
68
+ node .namespace = this .processNamespace ;
69
+ }
70
+ if (Utils .hasText (this .processSpec .summary )) {
71
+ node .description = this .processSpec .summary ;
72
+ }
62
73
return {
63
74
process_graph: {
64
- [id]: {
65
- process_id: id,
66
- namespace,
67
- description: this .processSpec .summary ,
68
- arguments: this .args ,
69
- result: true
70
- }
75
+ [this .process ]: node
71
76
}
72
77
};
73
78
}
@@ -88,30 +93,70 @@ export default {
88
93
},
89
94
methods: {
90
95
... Utils .mapActions ([' loadProcess' ]),
91
- submitProcess (item ) {
92
- this .process = item .id ;
93
- if (item .namespace ) {
94
- this .processNamespace = item .namespace ;
96
+ submitProcess (item , isUrl = false ) {
97
+ if (isUrl) {
98
+ this .processUrl = item;
99
+ }
100
+ else {
101
+ this .process = item .id ;
102
+ if (item .namespace ) {
103
+ this .processNamespace = item .namespace ;
104
+ }
105
+ this .parent .nextTab ();
95
106
}
96
- this .parent .nextTab ();
107
+ },
108
+ async loadFromUrl (url ) {
109
+ if (! Utils .isUrl (url)) {
110
+ throw new Error (' Please provide a valid URL!' );
111
+ }
112
+ let data;
113
+ try {
114
+ const response = await axios (url);
115
+ data = response .data ;
116
+ } catch (error) {
117
+ throw new Error (' Failed to load process from the given URL' );
118
+ }
119
+ if (typeof data === ' string' ) {
120
+ try {
121
+ data = JSON .parse (data);
122
+ } catch (error) {
123
+ throw new Error (' Process is not valid JSON' );
124
+ }
125
+ }
126
+ if (! Utils .isObject (data)) {
127
+ throw new Error (' Process does not contain any data' );
128
+ }
129
+ if (! Utils .hasText (data .id )) {
130
+ throw new Error (' Process does not contain an id' );
131
+ }
132
+ if (! Utils .isObject (data .process_graph )) {
133
+ throw new Error (' Process does not contain a process graph' );
134
+ }
135
+ return data;
97
136
},
98
137
async checkProcessRequirements () {
99
138
this .loading = true ;
100
- try {
139
+ if (this .processUrl ) {
140
+ const process = await this .loadFromUrl (this .processUrl );
141
+ this .processes .add (process , this .processUrl );
142
+ this .processNamespace = this .processUrl ;
143
+ this .process = process .id ;
144
+ this .processSpec = process ;
145
+ }
146
+ else if (this .process ) {
101
147
this .processSpec = await this .loadProcess ({
102
148
id: this .process ,
103
149
namespace: this .processNamespace
104
150
});
105
- this .loading = false ;
106
- if (this .processSpec ) {
107
- this .jobTitle = this .processSpec .id ;
108
- }
109
- return true ;
110
- } catch (error) {
111
- this .loading = false ;
112
- console .warn (error);
113
- return false ;
114
151
}
152
+ else {
153
+ throw new Error (' Please select a user-defined process' );
154
+ }
155
+ this .loading = false ;
156
+ if (this .processSpec ) {
157
+ this .jobTitle = this .processSpec .id ;
158
+ }
159
+ return true ;
115
160
},
116
161
checkParameterRequirements () {
117
162
if (this .graph ) {
0 commit comments