@optimajet/workflow-designer 16.1.0 → 16.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +229 -229
- package/bin/index.js +65 -65
- package/bin/template/index.html +18 -18
- package/bin/template/index.js +20 -20
- package/dist/workflowdesigner.min.css +1413 -1413
- package/dist/workflowdesignerfull.esm.min.js +1 -1
- package/dist/workflowdesignerfull.min.js +1 -1
- package/index.js +10 -10
- package/localization/index.js +11 -11
- package/module.js +10 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,229 +1,229 @@
|
|
|
1
|
-
# WorkflowEngine Designer
|
|
2
|
-
|
|
3
|
-
## Introduction
|
|
4
|
-
|
|
5
|
-
WorkflowEngine Designer is a library developed to facilitate the use of this component. It provides a convenient way to interact and create the Workflow Designer on your web page.
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
To run the example below, you should create the WorkflowEngine backend capable of handling requests from the Workflow Designer.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```shell
|
|
14
|
-
npm install @optimajet/workflow-designer
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Basic Usage
|
|
18
|
-
|
|
19
|
-
```javascript
|
|
20
|
-
import WorkflowDesigner from '@optimajet/workflow-designer'
|
|
21
|
-
//import '@optimajet/workflow-designer/localization/workflowdesigner.localization_ru'
|
|
22
|
-
|
|
23
|
-
const data = {
|
|
24
|
-
schemecode: "<YOUR_SCHEME_CODE_VALUE>",
|
|
25
|
-
processid: undefined
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
var wfdesigner = new WorkflowDesigner({
|
|
29
|
-
apiurl: '<YOUR_API_URL_VALUE>',
|
|
30
|
-
renderTo: 'root',
|
|
31
|
-
graphwidth: window.innerWidth,
|
|
32
|
-
graphheight: window.innerHeight,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (wfdesigner.exists(data)) {
|
|
36
|
-
wfdesigner.load(data);
|
|
37
|
-
} else {
|
|
38
|
-
wfdesigner.create();
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
This code snippet is everything you need to initially display the Workflow Designer on your web page. Let's analyze it in more detail:
|
|
43
|
-
|
|
44
|
-
```javascript
|
|
45
|
-
import WorkflowDesigner from '@optimajet/workflow-designer'
|
|
46
|
-
//import '@optimajet/workflow-designer/localization/workflowdesigner.localization_ru'
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
This section is responsible for importing the `WorkflowDesigner` constructor. By uncommenting line 2, you can localize the workflow designer. By default, the workflow designer has the English localization.
|
|
50
|
-
|
|
51
|
-
```javascript
|
|
52
|
-
const data = {
|
|
53
|
-
schemecode: "<YOUR_SCHEME_CODE_VALUE>",
|
|
54
|
-
processid: undefined
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
var wfdesigner = new WorkflowDesigner({
|
|
58
|
-
apiurl: '<YOUR_API_URL_VALUE>',
|
|
59
|
-
renderTo: 'root',
|
|
60
|
-
graphwidth: window.innerWidth,
|
|
61
|
-
graphheight: window.innerHeight,
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
In this section:
|
|
66
|
-
|
|
67
|
-
- `schemecode` - is the code for the Workflow diagram to be displayed in the Workflow Designer.
|
|
68
|
-
- `processid` - is the identifier of the WorkflowEngine process.
|
|
69
|
-
|
|
70
|
-
- the `WorkflowDesigner` constructor takes an object with the designer settings and creates a new instance of the WorkflowDesigner class. The example specifies all the necessary parameters of the designer, namely: the HTTP address of the WorkflowAPI for interacting with the back-end of the application (`apiurl`), the available width (` graphwidth`) and height (`graphheight`) for displaying the WorkflowDesigner window, and the element ID, inside which the entire WorkflowDesigner interface is rendered (`renderTo`). For a more detailed list of the parameters, see the **Designer** section of the documentation page about the WorkflowEngine.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
If you want to display the Workflow scheme in the Workflow Designer interface, set the required value to the `schemecode` variable, and assign the `undefined` value to the `processid`. In case you want to display the Workflow process, set the `undefined` value to the `schemecode`, and the required value to the `processid` variable of the WorkflowEngine process identifier.
|
|
74
|
-
|
|
75
|
-
```javascript
|
|
76
|
-
if (wfdesigner.exists(data)) {
|
|
77
|
-
wfdesigner.load(data);
|
|
78
|
-
} else {
|
|
79
|
-
wfdesigner.create();
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
This section checks whether the above data exist and available for loading and displaying in the WorkflowDesigner. If the specified data exist, then they are loaded and rendered. Otherwise, a new empty Workflow diagram will be created.
|
|
84
|
-
|
|
85
|
-
## Building and Running the Example
|
|
86
|
-
|
|
87
|
-
We use the webpack package to build our example.
|
|
88
|
-
|
|
89
|
-
```shell
|
|
90
|
-
npm i -D webpack webpack-cli
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Next, add the packages necessary for the correct webpack setup
|
|
94
|
-
|
|
95
|
-
```shell
|
|
96
|
-
npm i -D @babel/preset-env @babel/core babel-loader css-loader html-webpack-plugin mini-css-extract-plugin terser-webpack-plugin
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
The basic webpack configuration looks like this:
|
|
100
|
-
|
|
101
|
-
```js
|
|
102
|
-
const HtmlWebpackPlugin = require('html-webpack-plugin'); // for generate an HTML5 file
|
|
103
|
-
const path = require('path')
|
|
104
|
-
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); // to extract CSS into separate files
|
|
105
|
-
const TerserPlugin = require('terser-webpack-plugin'); // to minify your JavaScript
|
|
106
|
-
const webpack = require('webpack');
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
module.exports = () => ({
|
|
110
|
-
entry: {
|
|
111
|
-
wfesample: './src/index.js',
|
|
112
|
-
},
|
|
113
|
-
output: {
|
|
114
|
-
path: path.resolve(__dirname, 'dist'),
|
|
115
|
-
filename: '[name].min.js',
|
|
116
|
-
libraryTarget: "umd",
|
|
117
|
-
},
|
|
118
|
-
mode:'production',
|
|
119
|
-
|
|
120
|
-
optimization: {
|
|
121
|
-
minimizer: [new TerserPlugin()],
|
|
122
|
-
},
|
|
123
|
-
module: {
|
|
124
|
-
rules: [
|
|
125
|
-
{
|
|
126
|
-
test: /\.css$/i,
|
|
127
|
-
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
test: /\.m?js$/,
|
|
131
|
-
exclude: /(node_modules|bower_components)/,
|
|
132
|
-
use: {
|
|
133
|
-
loader: 'babel-loader',
|
|
134
|
-
options: {
|
|
135
|
-
presets: ['@babel/preset-env']
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
plugins: [
|
|
142
|
-
new HtmlWebpackPlugin({ template: './src/index.html' }),
|
|
143
|
-
new MiniCssExtractPlugin(),
|
|
144
|
-
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /en/),
|
|
145
|
-
]
|
|
146
|
-
});
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## IE11 Support
|
|
150
|
-
|
|
151
|
-
To support successful performance of the designer in IE11, we should slightly modify the webpack configuration in `webpack.config.js`, but first we should add another package to transpile and modify our JavaScript.
|
|
152
|
-
|
|
153
|
-
```shell
|
|
154
|
-
npm i -D @babel/plugin-proposal-decorators
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Now, add the `target: ['web', 'es5']` property in the webpack config, and change the `babel-loader` rule in`module.rules` to the following:
|
|
158
|
-
|
|
159
|
-
```js
|
|
160
|
-
//...
|
|
161
|
-
rules: [
|
|
162
|
-
//...
|
|
163
|
-
{
|
|
164
|
-
test: /\.(js|jsx)$/,
|
|
165
|
-
exclude: /@babel(?:\/|\\{1,2})runtime|core-js/,
|
|
166
|
-
use: {
|
|
167
|
-
loader: 'babel-loader',
|
|
168
|
-
options: {
|
|
169
|
-
babelrc: false,
|
|
170
|
-
configFile: path.resolve(__dirname, 'babel.config.js'),
|
|
171
|
-
compact: false,
|
|
172
|
-
cacheDirectory: true,
|
|
173
|
-
sourceMaps: false,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
//...
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
The only thing left to do is to create the `babel.config.js` file in the project root. The file should contain the following babel configuration:
|
|
182
|
-
|
|
183
|
-
```js
|
|
184
|
-
module.exports = function (api) {
|
|
185
|
-
api.cache(true);
|
|
186
|
-
const presets = [
|
|
187
|
-
[
|
|
188
|
-
'@babel/preset-env',
|
|
189
|
-
{
|
|
190
|
-
corejs:"3",
|
|
191
|
-
useBuiltIns: 'entry',
|
|
192
|
-
targets: {
|
|
193
|
-
browsers: [
|
|
194
|
-
"edge >= 16",
|
|
195
|
-
"safari >= 9",
|
|
196
|
-
"firefox >= 57",
|
|
197
|
-
"ie >= 11",
|
|
198
|
-
"ios >= 9",
|
|
199
|
-
"chrome >= 49"
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
]
|
|
204
|
-
];
|
|
205
|
-
const plugins= [
|
|
206
|
-
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
|
|
207
|
-
["@babel/plugin-proposal-class-properties", { "loose": true }],
|
|
208
|
-
["@babel/plugin-transform-spread"]
|
|
209
|
-
];
|
|
210
|
-
return {
|
|
211
|
-
presets,
|
|
212
|
-
plugins
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
The configuration is completed successfully, so you can enjoy using the WorkflowDesigner in IE11.
|
|
218
|
-
|
|
219
|
-
## Hotkeys:
|
|
220
|
-
Ctrl + A - Select All
|
|
221
|
-
Ctrl + C - Copy selected items
|
|
222
|
-
Ctrl + E - New Activity
|
|
223
|
-
Ctrl + I - Extended info
|
|
224
|
-
Ctrl + Y - Redo
|
|
225
|
-
Ctrl + Z - Undo
|
|
226
|
-
Arrows - Moving selected items
|
|
227
|
-
Delete - Delete
|
|
228
|
-
Alt + Enter - Full Screen Mode
|
|
229
|
-
Ctrl + M - Move mode
|
|
1
|
+
# WorkflowEngine Designer
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
WorkflowEngine Designer is a library developed to facilitate the use of this component. It provides a convenient way to interact and create the Workflow Designer on your web page.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
To run the example below, you should create the WorkflowEngine backend capable of handling requests from the Workflow Designer.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
npm install @optimajet/workflow-designer
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Basic Usage
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
import WorkflowDesigner from '@optimajet/workflow-designer'
|
|
21
|
+
//import '@optimajet/workflow-designer/localization/workflowdesigner.localization_ru'
|
|
22
|
+
|
|
23
|
+
const data = {
|
|
24
|
+
schemecode: "<YOUR_SCHEME_CODE_VALUE>",
|
|
25
|
+
processid: undefined
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var wfdesigner = new WorkflowDesigner({
|
|
29
|
+
apiurl: '<YOUR_API_URL_VALUE>',
|
|
30
|
+
renderTo: 'root',
|
|
31
|
+
graphwidth: window.innerWidth,
|
|
32
|
+
graphheight: window.innerHeight,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (wfdesigner.exists(data)) {
|
|
36
|
+
wfdesigner.load(data);
|
|
37
|
+
} else {
|
|
38
|
+
wfdesigner.create();
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This code snippet is everything you need to initially display the Workflow Designer on your web page. Let's analyze it in more detail:
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
import WorkflowDesigner from '@optimajet/workflow-designer'
|
|
46
|
+
//import '@optimajet/workflow-designer/localization/workflowdesigner.localization_ru'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This section is responsible for importing the `WorkflowDesigner` constructor. By uncommenting line 2, you can localize the workflow designer. By default, the workflow designer has the English localization.
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const data = {
|
|
53
|
+
schemecode: "<YOUR_SCHEME_CODE_VALUE>",
|
|
54
|
+
processid: undefined
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var wfdesigner = new WorkflowDesigner({
|
|
58
|
+
apiurl: '<YOUR_API_URL_VALUE>',
|
|
59
|
+
renderTo: 'root',
|
|
60
|
+
graphwidth: window.innerWidth,
|
|
61
|
+
graphheight: window.innerHeight,
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
In this section:
|
|
66
|
+
|
|
67
|
+
- `schemecode` - is the code for the Workflow diagram to be displayed in the Workflow Designer.
|
|
68
|
+
- `processid` - is the identifier of the WorkflowEngine process.
|
|
69
|
+
|
|
70
|
+
- the `WorkflowDesigner` constructor takes an object with the designer settings and creates a new instance of the WorkflowDesigner class. The example specifies all the necessary parameters of the designer, namely: the HTTP address of the WorkflowAPI for interacting with the back-end of the application (`apiurl`), the available width (` graphwidth`) and height (`graphheight`) for displaying the WorkflowDesigner window, and the element ID, inside which the entire WorkflowDesigner interface is rendered (`renderTo`). For a more detailed list of the parameters, see the **Designer** section of the documentation page about the WorkflowEngine.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
If you want to display the Workflow scheme in the Workflow Designer interface, set the required value to the `schemecode` variable, and assign the `undefined` value to the `processid`. In case you want to display the Workflow process, set the `undefined` value to the `schemecode`, and the required value to the `processid` variable of the WorkflowEngine process identifier.
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
if (wfdesigner.exists(data)) {
|
|
77
|
+
wfdesigner.load(data);
|
|
78
|
+
} else {
|
|
79
|
+
wfdesigner.create();
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This section checks whether the above data exist and available for loading and displaying in the WorkflowDesigner. If the specified data exist, then they are loaded and rendered. Otherwise, a new empty Workflow diagram will be created.
|
|
84
|
+
|
|
85
|
+
## Building and Running the Example
|
|
86
|
+
|
|
87
|
+
We use the webpack package to build our example.
|
|
88
|
+
|
|
89
|
+
```shell
|
|
90
|
+
npm i -D webpack webpack-cli
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Next, add the packages necessary for the correct webpack setup
|
|
94
|
+
|
|
95
|
+
```shell
|
|
96
|
+
npm i -D @babel/preset-env @babel/core babel-loader css-loader html-webpack-plugin mini-css-extract-plugin terser-webpack-plugin
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The basic webpack configuration looks like this:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin'); // for generate an HTML5 file
|
|
103
|
+
const path = require('path')
|
|
104
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); // to extract CSS into separate files
|
|
105
|
+
const TerserPlugin = require('terser-webpack-plugin'); // to minify your JavaScript
|
|
106
|
+
const webpack = require('webpack');
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
module.exports = () => ({
|
|
110
|
+
entry: {
|
|
111
|
+
wfesample: './src/index.js',
|
|
112
|
+
},
|
|
113
|
+
output: {
|
|
114
|
+
path: path.resolve(__dirname, 'dist'),
|
|
115
|
+
filename: '[name].min.js',
|
|
116
|
+
libraryTarget: "umd",
|
|
117
|
+
},
|
|
118
|
+
mode:'production',
|
|
119
|
+
|
|
120
|
+
optimization: {
|
|
121
|
+
minimizer: [new TerserPlugin()],
|
|
122
|
+
},
|
|
123
|
+
module: {
|
|
124
|
+
rules: [
|
|
125
|
+
{
|
|
126
|
+
test: /\.css$/i,
|
|
127
|
+
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
test: /\.m?js$/,
|
|
131
|
+
exclude: /(node_modules|bower_components)/,
|
|
132
|
+
use: {
|
|
133
|
+
loader: 'babel-loader',
|
|
134
|
+
options: {
|
|
135
|
+
presets: ['@babel/preset-env']
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
plugins: [
|
|
142
|
+
new HtmlWebpackPlugin({ template: './src/index.html' }),
|
|
143
|
+
new MiniCssExtractPlugin(),
|
|
144
|
+
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /en/),
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## IE11 Support
|
|
150
|
+
|
|
151
|
+
To support successful performance of the designer in IE11, we should slightly modify the webpack configuration in `webpack.config.js`, but first we should add another package to transpile and modify our JavaScript.
|
|
152
|
+
|
|
153
|
+
```shell
|
|
154
|
+
npm i -D @babel/plugin-proposal-decorators
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Now, add the `target: ['web', 'es5']` property in the webpack config, and change the `babel-loader` rule in`module.rules` to the following:
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
//...
|
|
161
|
+
rules: [
|
|
162
|
+
//...
|
|
163
|
+
{
|
|
164
|
+
test: /\.(js|jsx)$/,
|
|
165
|
+
exclude: /@babel(?:\/|\\{1,2})runtime|core-js/,
|
|
166
|
+
use: {
|
|
167
|
+
loader: 'babel-loader',
|
|
168
|
+
options: {
|
|
169
|
+
babelrc: false,
|
|
170
|
+
configFile: path.resolve(__dirname, 'babel.config.js'),
|
|
171
|
+
compact: false,
|
|
172
|
+
cacheDirectory: true,
|
|
173
|
+
sourceMaps: false,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
//...
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The only thing left to do is to create the `babel.config.js` file in the project root. The file should contain the following babel configuration:
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
module.exports = function (api) {
|
|
185
|
+
api.cache(true);
|
|
186
|
+
const presets = [
|
|
187
|
+
[
|
|
188
|
+
'@babel/preset-env',
|
|
189
|
+
{
|
|
190
|
+
corejs:"3",
|
|
191
|
+
useBuiltIns: 'entry',
|
|
192
|
+
targets: {
|
|
193
|
+
browsers: [
|
|
194
|
+
"edge >= 16",
|
|
195
|
+
"safari >= 9",
|
|
196
|
+
"firefox >= 57",
|
|
197
|
+
"ie >= 11",
|
|
198
|
+
"ios >= 9",
|
|
199
|
+
"chrome >= 49"
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
];
|
|
205
|
+
const plugins= [
|
|
206
|
+
["@babel/plugin-proposal-decorators", { decoratorsBeforeExport: true }],
|
|
207
|
+
["@babel/plugin-proposal-class-properties", { "loose": true }],
|
|
208
|
+
["@babel/plugin-transform-spread"]
|
|
209
|
+
];
|
|
210
|
+
return {
|
|
211
|
+
presets,
|
|
212
|
+
plugins
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The configuration is completed successfully, so you can enjoy using the WorkflowDesigner in IE11.
|
|
218
|
+
|
|
219
|
+
## Hotkeys:
|
|
220
|
+
Ctrl + A - Select All
|
|
221
|
+
Ctrl + C - Copy selected items
|
|
222
|
+
Ctrl + E - New Activity
|
|
223
|
+
Ctrl + I - Extended info
|
|
224
|
+
Ctrl + Y - Redo
|
|
225
|
+
Ctrl + Z - Undo
|
|
226
|
+
Arrows - Moving selected items
|
|
227
|
+
Delete - Delete
|
|
228
|
+
Alt + Enter - Full Screen Mode
|
|
229
|
+
Ctrl + M - Move mode
|
package/bin/index.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const {exec} = require('child_process');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const fs = require('fs')
|
|
7
|
-
const util = require('util');
|
|
8
|
-
const fsPromises = require('node:fs/promises');
|
|
9
|
-
const crypto = require('node:crypto')
|
|
10
|
-
|
|
11
|
-
function runCommand(command) {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
exec(command, (error) => {
|
|
14
|
-
if (error) {
|
|
15
|
-
reject(error);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
resolve();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function passSettings(file, url, schemeCode) {
|
|
24
|
-
const readFile = util.promisify(fs.readFile);
|
|
25
|
-
const writeFile = util.promisify(fs.writeFile);
|
|
26
|
-
|
|
27
|
-
const data = await readFile(file);
|
|
28
|
-
const result = data.toString()
|
|
29
|
-
.replace(/URL_PLACEHOLDER/g, url)
|
|
30
|
-
.replace(/SCHEME_CODE_PLACEHOLDER/g, schemeCode);
|
|
31
|
-
await writeFile(file, result);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function createTempFolder(sourcePath) {
|
|
35
|
-
const args = process.argv.slice(2).join('|');
|
|
36
|
-
const digest = crypto.createHash('sha256')
|
|
37
|
-
.update(args)
|
|
38
|
-
.digest('hex');
|
|
39
|
-
|
|
40
|
-
const tempPath = path.join(sourcePath, '..', `workflow-designer-${digest}`);
|
|
41
|
-
await fsPromises.mkdir(tempPath, {recursive: true});
|
|
42
|
-
await fsPromises.copyFile(path.resolve(sourcePath, 'index.js'), path.resolve(tempPath, 'index.js'));
|
|
43
|
-
await fsPromises.copyFile(path.resolve(sourcePath, 'index.html'), path.resolve(tempPath, 'index.html'));
|
|
44
|
-
return tempPath
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function main() {
|
|
48
|
-
const args = process.argv.slice(2);
|
|
49
|
-
|
|
50
|
-
const templateDirectory = path.resolve(__dirname, '..', 'bin', 'template');
|
|
51
|
-
const tempFolderName = await createTempFolder(templateDirectory);
|
|
52
|
-
|
|
53
|
-
const jsFile = path.resolve(tempFolderName, 'index.js');
|
|
54
|
-
const htmlFile = path.resolve(tempFolderName, 'index.html');
|
|
55
|
-
|
|
56
|
-
const designerUrl = args[0] ?? 'https://demo.workflowengine.io/Designer/API';
|
|
57
|
-
const schemeCode = args[1] ?? 'SimpleWF';
|
|
58
|
-
await passSettings(jsFile, designerUrl, schemeCode);
|
|
59
|
-
|
|
60
|
-
const platform = os.platform();
|
|
61
|
-
const command = platform === 'win32' ? `start ${htmlFile}` : `open ${htmlFile}`;
|
|
62
|
-
await runCommand(command);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
main().catch(console.error);
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const {exec} = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const fs = require('fs')
|
|
7
|
+
const util = require('util');
|
|
8
|
+
const fsPromises = require('node:fs/promises');
|
|
9
|
+
const crypto = require('node:crypto')
|
|
10
|
+
|
|
11
|
+
function runCommand(command) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
exec(command, (error) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
resolve();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function passSettings(file, url, schemeCode) {
|
|
24
|
+
const readFile = util.promisify(fs.readFile);
|
|
25
|
+
const writeFile = util.promisify(fs.writeFile);
|
|
26
|
+
|
|
27
|
+
const data = await readFile(file);
|
|
28
|
+
const result = data.toString()
|
|
29
|
+
.replace(/URL_PLACEHOLDER/g, url)
|
|
30
|
+
.replace(/SCHEME_CODE_PLACEHOLDER/g, schemeCode);
|
|
31
|
+
await writeFile(file, result);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function createTempFolder(sourcePath) {
|
|
35
|
+
const args = process.argv.slice(2).join('|');
|
|
36
|
+
const digest = crypto.createHash('sha256')
|
|
37
|
+
.update(args)
|
|
38
|
+
.digest('hex');
|
|
39
|
+
|
|
40
|
+
const tempPath = path.join(sourcePath, '..', `workflow-designer-${digest}`);
|
|
41
|
+
await fsPromises.mkdir(tempPath, {recursive: true});
|
|
42
|
+
await fsPromises.copyFile(path.resolve(sourcePath, 'index.js'), path.resolve(tempPath, 'index.js'));
|
|
43
|
+
await fsPromises.copyFile(path.resolve(sourcePath, 'index.html'), path.resolve(tempPath, 'index.html'));
|
|
44
|
+
return tempPath
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function main() {
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
|
|
50
|
+
const templateDirectory = path.resolve(__dirname, '..', 'bin', 'template');
|
|
51
|
+
const tempFolderName = await createTempFolder(templateDirectory);
|
|
52
|
+
|
|
53
|
+
const jsFile = path.resolve(tempFolderName, 'index.js');
|
|
54
|
+
const htmlFile = path.resolve(tempFolderName, 'index.html');
|
|
55
|
+
|
|
56
|
+
const designerUrl = args[0] ?? 'https://demo.workflowengine.io/Designer/API';
|
|
57
|
+
const schemeCode = args[1] ?? 'SimpleWF';
|
|
58
|
+
await passSettings(jsFile, designerUrl, schemeCode);
|
|
59
|
+
|
|
60
|
+
const platform = os.platform();
|
|
61
|
+
const command = platform === 'win32' ? `start ${htmlFile}` : `open ${htmlFile}`;
|
|
62
|
+
await runCommand(command);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main().catch(console.error);
|
package/bin/template/index.html
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>WorkflowEngine Designer</title>
|
|
6
|
-
<link rel="stylesheet" href="../../dist/workflowdesigner.min.css">
|
|
7
|
-
</head>
|
|
8
|
-
<body style="margin: 0">
|
|
9
|
-
<div id="root"></div>
|
|
10
|
-
|
|
11
|
-
<script
|
|
12
|
-
src="https://code.jquery.com/jquery-3.7.1.min.js"
|
|
13
|
-
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
|
|
14
|
-
crossorigin="anonymous"></script>
|
|
15
|
-
<script src="../../dist/workflowdesignerfull.min.js"></script>
|
|
16
|
-
<script src="./index.js"></script>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>WorkflowEngine Designer</title>
|
|
6
|
+
<link rel="stylesheet" href="../../dist/workflowdesigner.min.css">
|
|
7
|
+
</head>
|
|
8
|
+
<body style="margin: 0">
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
|
|
11
|
+
<script
|
|
12
|
+
src="https://code.jquery.com/jquery-3.7.1.min.js"
|
|
13
|
+
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
|
|
14
|
+
crossorigin="anonymous"></script>
|
|
15
|
+
<script src="../../dist/workflowdesignerfull.min.js"></script>
|
|
16
|
+
<script src="./index.js"></script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
package/bin/template/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var wfdesigner = new WorkflowDesigner({
|
|
2
|
-
apiurl: 'URL_PLACEHOLDER',
|
|
3
|
-
name: 'wfe',
|
|
4
|
-
language: 'en',
|
|
5
|
-
renderTo: 'root',
|
|
6
|
-
graphwidth: window.innerWidth,
|
|
7
|
-
graphheight: window.innerHeight,
|
|
8
|
-
showSaveButton: true,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const data = {
|
|
12
|
-
schemecode: 'SCHEME_CODE_PLACEHOLDER',
|
|
13
|
-
processid: ''
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
if (wfdesigner.exists(data)) {
|
|
17
|
-
wfdesigner.load(data);
|
|
18
|
-
} else {
|
|
19
|
-
wfdesigner.create(data.schemecode);
|
|
20
|
-
}
|
|
1
|
+
var wfdesigner = new WorkflowDesigner({
|
|
2
|
+
apiurl: 'URL_PLACEHOLDER',
|
|
3
|
+
name: 'wfe',
|
|
4
|
+
language: 'en',
|
|
5
|
+
renderTo: 'root',
|
|
6
|
+
graphwidth: window.innerWidth,
|
|
7
|
+
graphheight: window.innerHeight,
|
|
8
|
+
showSaveButton: true,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const data = {
|
|
12
|
+
schemecode: 'SCHEME_CODE_PLACEHOLDER',
|
|
13
|
+
processid: ''
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
if (wfdesigner.exists(data)) {
|
|
17
|
+
wfdesigner.load(data);
|
|
18
|
+
} else {
|
|
19
|
+
wfdesigner.create(data.schemecode);
|
|
20
|
+
}
|