@things-factory/integration-ui 9.1.19 → 10.0.0-beta.2
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/client/pages/connection.ts +209 -326
- package/client/pages/scenario.ts +260 -408
- package/client/pages/state-register.ts +117 -181
- package/client/viewparts/scenario-instance-log-view.ts +1 -4
- package/client/viewparts/scenario-instance-view.ts +5 -9
- package/dist-client/pages/connection.d.ts +0 -6
- package/dist-client/pages/connection.js +91 -172
- package/dist-client/pages/connection.js.map +1 -1
- package/dist-client/pages/scenario.d.ts +0 -6
- package/dist-client/pages/scenario.js +113 -212
- package/dist-client/pages/scenario.js.map +1 -1
- package/dist-client/pages/state-register.d.ts +0 -6
- package/dist-client/pages/state-register.js +55 -105
- package/dist-client/pages/state-register.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/scenario-instance-log-view.d.ts +1 -9
- package/dist-client/viewparts/scenario-instance-log-view.js +1 -3
- package/dist-client/viewparts/scenario-instance-log-view.js.map +1 -1
- package/dist-client/viewparts/scenario-instance-view.d.ts +2 -11
- package/dist-client/viewparts/scenario-instance-view.js +7 -11
- package/dist-client/viewparts/scenario-instance-view.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
package/client/pages/scenario.ts
CHANGED
|
@@ -5,43 +5,36 @@ import './scenario-importer.js'
|
|
|
5
5
|
import gql from 'graphql-tag'
|
|
6
6
|
import { css, html } from 'lit'
|
|
7
7
|
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
8
|
-
import { connect } from 'pwa-helpers/connect-mixin.js'
|
|
9
|
-
|
|
10
8
|
import { DataGrist } from '@operato/data-grist/ox-grist.js'
|
|
11
9
|
import { client } from '@operato/graphql'
|
|
12
10
|
import { i18next, localize } from '@operato/i18n'
|
|
13
11
|
import { notify, openPopup } from '@operato/layout'
|
|
14
|
-
import { navigate, PageView
|
|
12
|
+
import { navigate, PageView } from '@operato/shell'
|
|
15
13
|
import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
|
|
16
14
|
import { isMobileDevice } from '@operato/utils'
|
|
17
15
|
import { FetchOption } from '@operato/data-grist'
|
|
18
16
|
import { p13n } from '@operato/p13n'
|
|
19
17
|
|
|
20
|
-
function IS_SCENARIO_RUNNING(state) {
|
|
21
|
-
return state && state !== 'UNLOADED'
|
|
18
|
+
function IS_SCENARIO_RUNNING(state) { return state && state !== 'UNLOADED'
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
@customElement('scenario-page')
|
|
25
|
-
export class Scenario extends
|
|
26
|
-
static get styles() {
|
|
27
|
-
return [
|
|
22
|
+
export class Scenario extends p13n(localize(i18next)(PageView)) { static get styles() { return [
|
|
28
23
|
CommonGristStyles,
|
|
29
24
|
ScrollbarStyles,
|
|
30
25
|
css`
|
|
31
|
-
:host {
|
|
32
|
-
display: flex;
|
|
26
|
+
:host { display: flex;
|
|
33
27
|
flex-direction: column;
|
|
34
28
|
|
|
35
29
|
overflow: hidden;
|
|
36
|
-
|
|
30
|
+
}
|
|
37
31
|
|
|
38
|
-
ox-grist {
|
|
39
|
-
overflow-y: auto;
|
|
32
|
+
ox-grist { overflow-y: auto;
|
|
40
33
|
flex: 1;
|
|
41
|
-
|
|
34
|
+
}
|
|
42
35
|
`
|
|
43
36
|
]
|
|
44
|
-
|
|
37
|
+
}
|
|
45
38
|
|
|
46
39
|
@property({ type: Boolean }) active: boolean = false
|
|
47
40
|
@property({ type: Object }) gristConfig: any
|
|
@@ -49,59 +42,45 @@ export class Scenario extends connect(store)(p13n(localize(i18next)(PageView)))
|
|
|
49
42
|
|
|
50
43
|
@query('ox-grist') grist!: DataGrist
|
|
51
44
|
|
|
52
|
-
get context() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
search: {
|
|
56
|
-
handler: search => {
|
|
57
|
-
this.grist.searchText = search
|
|
58
|
-
},
|
|
45
|
+
get context() { return { title: i18next.t('text.scenario list'),
|
|
46
|
+
search: { handler: search => { this.grist.searchText = search
|
|
47
|
+
},
|
|
59
48
|
value: this.grist?.searchText || ''
|
|
60
|
-
|
|
49
|
+
},
|
|
61
50
|
// 필터가 설정되면, 아래 코멘트 해제
|
|
62
|
-
// filter: {
|
|
63
|
-
// handler: () => {
|
|
64
|
-
// const display = this.headroom.style.display
|
|
51
|
+
// filter: { // handler: () => { // const display = this.headroom.style.display
|
|
65
52
|
// this.headroom.style.display = display !== 'none' ? 'none' : 'flex'
|
|
66
|
-
//
|
|
53
|
+
// }
|
|
67
54
|
// },
|
|
68
55
|
help: 'integration/ui/scenario',
|
|
69
56
|
actions: [
|
|
70
|
-
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
navigate('integration-monitor')
|
|
74
|
-
},
|
|
57
|
+
{ title: i18next.t('button.start monitor'),
|
|
58
|
+
action: () => { navigate('integration-monitor')
|
|
59
|
+
},
|
|
75
60
|
...CommonButtonStyles.preview
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
title: i18next.t('button.copy'),
|
|
61
|
+
},
|
|
62
|
+
{ title: i18next.t('button.copy'),
|
|
79
63
|
action: this._copyScenario.bind(this),
|
|
80
64
|
...CommonButtonStyles.copy
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
title: i18next.t('button.save'),
|
|
65
|
+
},
|
|
66
|
+
{ title: i18next.t('button.save'),
|
|
84
67
|
action: this._updateScenario.bind(this),
|
|
85
68
|
...CommonButtonStyles.save
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
title: i18next.t('button.delete'),
|
|
69
|
+
},
|
|
70
|
+
{ title: i18next.t('button.delete'),
|
|
89
71
|
action: this._deleteScenario.bind(this),
|
|
90
72
|
...CommonButtonStyles.delete
|
|
91
|
-
|
|
73
|
+
}
|
|
92
74
|
],
|
|
93
|
-
exportable: {
|
|
94
|
-
name: i18next.t('text.scenario list'),
|
|
75
|
+
exportable: { name: i18next.t('text.scenario list'),
|
|
95
76
|
data: this.exportHandler.bind(this)
|
|
96
|
-
|
|
97
|
-
importable: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
render() {
|
|
104
|
-
return html`
|
|
77
|
+
},
|
|
78
|
+
importable: { handler: this.importHandler.bind(this)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
render() { return html`
|
|
105
84
|
<ox-grist
|
|
106
85
|
.mode=${isMobileDevice() ? 'LIST' : 'GRID'}
|
|
107
86
|
.config=${this.gristConfig}
|
|
@@ -111,36 +90,27 @@ export class Scenario extends connect(store)(p13n(localize(i18next)(PageView)))
|
|
|
111
90
|
<ox-grist-personalizer slot="setting"></ox-grist-personalizer>
|
|
112
91
|
</ox-grist>
|
|
113
92
|
`
|
|
114
|
-
|
|
93
|
+
}
|
|
115
94
|
|
|
116
|
-
async pageInitialized(lifecycle) {
|
|
117
|
-
this.fetchTaskTypes()
|
|
95
|
+
async pageInitialized(lifecycle) { this.fetchTaskTypes()
|
|
118
96
|
|
|
119
|
-
this.gristConfig = {
|
|
120
|
-
list: { fields: ['name', 'description', 'schedule', 'active'] },
|
|
97
|
+
this.gristConfig = { list: { fields: ['name', 'description', 'schedule', 'active'] },
|
|
121
98
|
columns: [
|
|
122
99
|
{ type: 'gutter', gutterName: 'sequence', fixed: true },
|
|
123
100
|
{ type: 'gutter', gutterName: 'row-selector', multiple: true, fixed: true },
|
|
124
|
-
{
|
|
125
|
-
type: 'gutter',
|
|
101
|
+
{ type: 'gutter',
|
|
126
102
|
gutterName: 'button',
|
|
127
103
|
icon: record => (!record ? 'calendar_add_on' : !record.id || !record.scheduleId ? '' : 'event_available'),
|
|
128
104
|
title: i18next.t('button.schedule-task'),
|
|
129
|
-
handlers: {
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
type: 'gutter',
|
|
105
|
+
handlers: { click: (columns, data, column, record, rowIndex) => { if (!record || !record.id || (!record.scheduleId && !record.schedule)) { return
|
|
106
|
+
}
|
|
107
|
+
if (record.scheduleId) { this.stopScenarioSchedule(record)
|
|
108
|
+
} else { this.startScenarioSchedule(record)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{ type: 'gutter',
|
|
144
114
|
gutterName: 'button',
|
|
145
115
|
name: 'state',
|
|
146
116
|
fixed: true,
|
|
@@ -156,31 +126,23 @@ export class Scenario extends connect(store)(p13n(localize(i18next)(PageView)))
|
|
|
156
126
|
: i18next.t('button.start')
|
|
157
127
|
: '',
|
|
158
128
|
width: 72,
|
|
159
|
-
handlers: {
|
|
160
|
-
click: (columns, data, column, record, rowIndex) => {
|
|
161
|
-
if (!record || !record.name) {
|
|
162
|
-
/* TODO record가 새로 추가된 것이면 리턴하도록 한다. */
|
|
129
|
+
handlers: { click: (columns, data, column, record, rowIndex) => { if (!record || !record.name) { /* TODO record가 새로 추가된 것이면 리턴하도록 한다. */
|
|
163
130
|
return
|
|
164
|
-
|
|
165
|
-
if (IS_SCENARIO_RUNNING(record.state)) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
type: 'gutter',
|
|
131
|
+
}
|
|
132
|
+
if (IS_SCENARIO_RUNNING(record.state)) { this.stopScenario(record)
|
|
133
|
+
} else { this.startScenario(record)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{ type: 'gutter',
|
|
175
139
|
gutterName: 'button',
|
|
176
140
|
fixed: true,
|
|
177
141
|
icon: record => (!record ? 'reorder' : record.id ? 'reorder' : ''),
|
|
178
142
|
iconOnly: false,
|
|
179
143
|
title: record => (!record ? i18next.t('button.detail') : record.id ? i18next.t('button.detail') : ''),
|
|
180
144
|
width: 72,
|
|
181
|
-
handlers: {
|
|
182
|
-
click: (columns, data, column, record, rowIndex) => {
|
|
183
|
-
if (!record.id) return
|
|
145
|
+
handlers: { click: (columns, data, column, record, rowIndex) => { if (!record.id) return
|
|
184
146
|
openPopup(
|
|
185
147
|
html`
|
|
186
148
|
<scenario-detail
|
|
@@ -189,173 +151,136 @@ export class Scenario extends connect(store)(p13n(localize(i18next)(PageView)))
|
|
|
189
151
|
@requestRefresh="${() => this.grist.fetch()}"
|
|
190
152
|
></scenario-detail>
|
|
191
153
|
`,
|
|
192
|
-
{
|
|
193
|
-
backdrop: true,
|
|
154
|
+
{ backdrop: true,
|
|
194
155
|
help: 'integration/ui/scenario-detail',
|
|
195
156
|
size: 'large',
|
|
196
157
|
title: i18next.t('title.scenario-detail')
|
|
197
|
-
|
|
158
|
+
}
|
|
198
159
|
)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
{
|
|
203
|
-
type: 'string',
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
{ type: 'string',
|
|
204
164
|
name: 'name',
|
|
205
165
|
fixed: true,
|
|
206
166
|
label: true,
|
|
207
167
|
header: i18next.t('field.name'),
|
|
208
|
-
record: {
|
|
209
|
-
editable: true,
|
|
168
|
+
record: { editable: true,
|
|
210
169
|
mandatory: true
|
|
211
|
-
|
|
170
|
+
},
|
|
212
171
|
filter: 'search',
|
|
213
172
|
sortable: true,
|
|
214
173
|
width: 300,
|
|
215
|
-
validation: function (after, before, record, column) {
|
|
216
|
-
|
|
217
|
-
if (IS_SCENARIO_RUNNING(record.state)) {
|
|
218
|
-
notify({
|
|
219
|
-
level: 'warn',
|
|
174
|
+
validation: function (after, before, record, column) { /* connected 상태에서는 이름을 바꿀 수 없다. */
|
|
175
|
+
if (IS_SCENARIO_RUNNING(record.state)) { notify({ level: 'warn',
|
|
220
176
|
message: 'scenario name cannot be changed during execution.'
|
|
221
|
-
|
|
177
|
+
})
|
|
222
178
|
return false
|
|
223
|
-
|
|
179
|
+
}
|
|
224
180
|
return true
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
{
|
|
228
|
-
type: 'string',
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{ type: 'string',
|
|
229
184
|
name: 'type',
|
|
230
185
|
header: i18next.t('field.type'),
|
|
231
|
-
record: {
|
|
232
|
-
|
|
233
|
-
},
|
|
186
|
+
record: { editable: true
|
|
187
|
+
},
|
|
234
188
|
filter: 'search',
|
|
235
189
|
sortable: true,
|
|
236
190
|
width: 100
|
|
237
|
-
|
|
238
|
-
{
|
|
239
|
-
type: 'string',
|
|
191
|
+
},
|
|
192
|
+
{ type: 'string',
|
|
240
193
|
name: 'description',
|
|
241
194
|
label: true,
|
|
242
195
|
header: i18next.t('field.description'),
|
|
243
|
-
record: {
|
|
244
|
-
|
|
245
|
-
},
|
|
196
|
+
record: { editable: true
|
|
197
|
+
},
|
|
246
198
|
filter: 'search',
|
|
247
199
|
width: 400
|
|
248
|
-
|
|
249
|
-
{
|
|
250
|
-
type: 'select',
|
|
200
|
+
},
|
|
201
|
+
{ type: 'select',
|
|
251
202
|
name: 'iteration',
|
|
252
203
|
header: i18next.t('field.iteration-scope'),
|
|
253
|
-
record: {
|
|
254
|
-
editable: true,
|
|
204
|
+
record: { editable: true,
|
|
255
205
|
options: ['', 'SELF', 'CHILDREN', 'SELF & CHILDREN']
|
|
256
|
-
|
|
206
|
+
},
|
|
257
207
|
width: 120
|
|
258
|
-
|
|
259
|
-
{
|
|
260
|
-
type: 'crontab',
|
|
208
|
+
},
|
|
209
|
+
{ type: 'crontab',
|
|
261
210
|
name: 'schedule',
|
|
262
211
|
label: true,
|
|
263
212
|
header: i18next.t('field.schedule'),
|
|
264
|
-
record: {
|
|
265
|
-
|
|
266
|
-
},
|
|
213
|
+
record: { editable: true
|
|
214
|
+
},
|
|
267
215
|
width: 110
|
|
268
|
-
|
|
269
|
-
{
|
|
270
|
-
type: 'timezone',
|
|
216
|
+
},
|
|
217
|
+
{ type: 'timezone',
|
|
271
218
|
name: 'timezone',
|
|
272
219
|
header: i18next.t('field.timezone'),
|
|
273
|
-
record: {
|
|
274
|
-
|
|
275
|
-
},
|
|
220
|
+
record: { editable: true
|
|
221
|
+
},
|
|
276
222
|
width: 120
|
|
277
|
-
|
|
278
|
-
{
|
|
279
|
-
type: 'number',
|
|
223
|
+
},
|
|
224
|
+
{ type: 'number',
|
|
280
225
|
name: 'ttl',
|
|
281
226
|
header: i18next.t('field.ttl-seconds'),
|
|
282
|
-
record: {
|
|
283
|
-
|
|
284
|
-
},
|
|
227
|
+
record: { editable: true
|
|
228
|
+
},
|
|
285
229
|
width: 80
|
|
286
|
-
|
|
287
|
-
{
|
|
288
|
-
type: 'resource-object',
|
|
230
|
+
},
|
|
231
|
+
{ type: 'resource-object',
|
|
289
232
|
name: 'role',
|
|
290
233
|
label: true,
|
|
291
234
|
header: i18next.t('field.required role'),
|
|
292
|
-
record: {
|
|
293
|
-
|
|
294
|
-
options: {
|
|
295
|
-
title: i18next.t('title.lookup role'),
|
|
235
|
+
record: { editable: true,
|
|
236
|
+
options: { title: i18next.t('title.lookup role'),
|
|
296
237
|
queryName: 'roles'
|
|
297
|
-
|
|
298
|
-
|
|
238
|
+
}
|
|
239
|
+
},
|
|
299
240
|
width: 200
|
|
300
|
-
|
|
301
|
-
{
|
|
302
|
-
type: 'checkbox',
|
|
241
|
+
},
|
|
242
|
+
{ type: 'checkbox',
|
|
303
243
|
name: 'active',
|
|
304
244
|
label: true,
|
|
305
245
|
header: i18next.t('field.startup-scenario'),
|
|
306
|
-
record: {
|
|
307
|
-
align: 'center',
|
|
246
|
+
record: { align: 'center',
|
|
308
247
|
editable: true
|
|
309
|
-
|
|
248
|
+
},
|
|
310
249
|
sortable: true,
|
|
311
250
|
width: 60
|
|
312
|
-
|
|
313
|
-
{
|
|
314
|
-
type: 'object',
|
|
251
|
+
},
|
|
252
|
+
{ type: 'object',
|
|
315
253
|
name: 'updater',
|
|
316
254
|
header: i18next.t('field.updater'),
|
|
317
|
-
record: {
|
|
318
|
-
|
|
319
|
-
},
|
|
255
|
+
record: { editable: false
|
|
256
|
+
},
|
|
320
257
|
width: 85
|
|
321
|
-
|
|
322
|
-
{
|
|
323
|
-
type: 'datetime',
|
|
258
|
+
},
|
|
259
|
+
{ type: 'datetime',
|
|
324
260
|
name: 'updatedAt',
|
|
325
261
|
header: i18next.t('field.updated_at'),
|
|
326
|
-
record: {
|
|
327
|
-
|
|
328
|
-
},
|
|
262
|
+
record: { editable: false
|
|
263
|
+
},
|
|
329
264
|
sortable: true,
|
|
330
265
|
width: 180
|
|
331
|
-
|
|
266
|
+
}
|
|
332
267
|
],
|
|
333
|
-
rows: {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
},
|
|
268
|
+
rows: { selectable: { multiple: true
|
|
269
|
+
}
|
|
270
|
+
},
|
|
338
271
|
sorters: [
|
|
339
|
-
{
|
|
340
|
-
|
|
341
|
-
}
|
|
272
|
+
{ name: 'name'
|
|
273
|
+
}
|
|
342
274
|
]
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
async pageUpdated(changes, lifecycle) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) {
|
|
353
|
-
const response = await client.query({
|
|
354
|
-
query: gql`
|
|
355
|
-
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
356
|
-
responses: scenarios(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
357
|
-
items {
|
|
358
|
-
id
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async pageUpdated(changes, lifecycle) { if (this.active) { this.grist.fetch()
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) { const response = await client.query({ query: gql`
|
|
283
|
+
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: scenarios(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id
|
|
359
284
|
name
|
|
360
285
|
type
|
|
361
286
|
description
|
|
@@ -366,18 +291,15 @@ export class Scenario extends connect(store)(p13n(localize(i18next)(PageView)))
|
|
|
366
291
|
scheduleId
|
|
367
292
|
timezone
|
|
368
293
|
ttl
|
|
369
|
-
role {
|
|
370
|
-
id
|
|
294
|
+
role { id
|
|
371
295
|
name
|
|
372
296
|
description
|
|
373
|
-
|
|
374
|
-
updater {
|
|
375
|
-
id
|
|
297
|
+
}
|
|
298
|
+
updater { id
|
|
376
299
|
name
|
|
377
|
-
|
|
300
|
+
}
|
|
378
301
|
updatedAt
|
|
379
|
-
steps {
|
|
380
|
-
name
|
|
302
|
+
steps { name
|
|
381
303
|
description
|
|
382
304
|
sequence
|
|
383
305
|
task
|
|
@@ -385,277 +307,207 @@ export class Scenario extends connect(store)(p13n(localize(i18next)(PageView)))
|
|
|
385
307
|
log
|
|
386
308
|
connection
|
|
387
309
|
params
|
|
388
|
-
|
|
389
|
-
|
|
310
|
+
}
|
|
311
|
+
}
|
|
390
312
|
total
|
|
391
|
-
|
|
392
|
-
|
|
313
|
+
}
|
|
314
|
+
}
|
|
393
315
|
`,
|
|
394
|
-
variables: {
|
|
395
|
-
filters,
|
|
316
|
+
variables: { filters,
|
|
396
317
|
pagination: { page, limit },
|
|
397
318
|
sortings
|
|
398
|
-
|
|
399
|
-
|
|
319
|
+
}
|
|
320
|
+
})
|
|
400
321
|
|
|
401
|
-
return {
|
|
402
|
-
total: response.data.responses.total || 0,
|
|
322
|
+
return { total: response.data.responses.total || 0,
|
|
403
323
|
records: response.data.responses.items || []
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
async fetchTaskTypes() {
|
|
408
|
-
|
|
409
|
-
query: gql`
|
|
410
|
-
query {
|
|
411
|
-
taskTypes {
|
|
412
|
-
items {
|
|
413
|
-
name
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async fetchTaskTypes() { const response = await client.query({ query: gql`
|
|
328
|
+
query { taskTypes { items { name
|
|
414
329
|
description
|
|
415
330
|
help
|
|
416
|
-
parameterSpec {
|
|
417
|
-
type
|
|
331
|
+
parameterSpec { type
|
|
418
332
|
name
|
|
419
333
|
label
|
|
420
334
|
placeholder
|
|
421
335
|
property
|
|
422
336
|
styles
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
427
341
|
`
|
|
428
|
-
|
|
342
|
+
})
|
|
429
343
|
|
|
430
|
-
if (!response.errors) {
|
|
431
|
-
this.taskTypes = response.data.taskTypes.items.reduce((taskTypes, taskType) => {
|
|
432
|
-
taskTypes[taskType.name] = taskType
|
|
344
|
+
if (!response.errors) { this.taskTypes = response.data.taskTypes.items.reduce((taskTypes, taskType) => { taskTypes[taskType.name] = taskType
|
|
433
345
|
return taskTypes
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (ids && ids.length > 0) {
|
|
444
|
-
const response = await client.mutate({
|
|
445
|
-
mutation: gql`
|
|
446
|
-
mutation ($ids: [String!]!) {
|
|
447
|
-
deleteScenarios(ids: $ids)
|
|
448
|
-
}
|
|
346
|
+
}, {})
|
|
347
|
+
} else { console.error('fetch taskTypes error')
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async _deleteScenario() { if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) { const ids = this.grist.selected.map(record => record.id)
|
|
352
|
+
if (ids && ids.length > 0) { const response = await client.mutate({ mutation: gql`
|
|
353
|
+
mutation ($ids: [String!]!) { deleteScenarios(ids: $ids)
|
|
354
|
+
}
|
|
449
355
|
`,
|
|
450
|
-
variables: {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
async _copyScenario() {
|
|
466
|
-
var selected = this.grist.selected
|
|
356
|
+
variables: { ids
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
if (!response.errors) { this.grist.fetch()
|
|
361
|
+
notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
|
|
362
|
+
})
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async _copyScenario() { var selected = this.grist.selected
|
|
467
369
|
if (selected.length == 0) return
|
|
468
370
|
|
|
469
371
|
if (!confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.copy') }))) return
|
|
470
|
-
var response = await client.mutate({
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
id
|
|
475
|
-
}
|
|
476
|
-
}
|
|
372
|
+
var response = await client.mutate({ mutation: gql`
|
|
373
|
+
mutation ($ids: [String!]!) { copyScenarios(ids: $ids) { id
|
|
374
|
+
}
|
|
375
|
+
}
|
|
477
376
|
`,
|
|
478
|
-
variables: {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
})
|
|
377
|
+
variables: { ids: selected.map(r => r.id)
|
|
378
|
+
}
|
|
379
|
+
})
|
|
482
380
|
|
|
483
381
|
if (!response.errors) this.grist.fetch()
|
|
484
|
-
|
|
382
|
+
}
|
|
485
383
|
|
|
486
|
-
async _updateScenario() {
|
|
487
|
-
|
|
488
|
-
if (patches && patches.length) {
|
|
489
|
-
patches = patches.map(patch => {
|
|
490
|
-
let patchField: any = patch.id ? { id: patch.id } : {}
|
|
384
|
+
async _updateScenario() { var patches = this.grist.dirtyRecords
|
|
385
|
+
if (patches && patches.length) { patches = patches.map(patch => { let patchField: any = patch.id ? { id: patch.id } : {}
|
|
491
386
|
const dirtyFields = patch.__dirtyfields__
|
|
492
|
-
for (let key in dirtyFields) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
}
|
|
387
|
+
for (let key in dirtyFields) { if (['message', 'step', 'steps', 'progress', 'rounds'].indexOf(key) == -1) { patchField[key] = dirtyFields[key].after
|
|
388
|
+
}
|
|
389
|
+
}
|
|
497
390
|
patchField.cuFlag = patch.__dirty__
|
|
498
391
|
|
|
499
392
|
return patchField
|
|
500
|
-
|
|
393
|
+
})
|
|
501
394
|
|
|
502
|
-
const response = await client.mutate({
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
name
|
|
507
|
-
}
|
|
508
|
-
}
|
|
395
|
+
const response = await client.mutate({ mutation: gql`
|
|
396
|
+
mutation ($patches: [ScenarioPatch!]!) { updateMultipleScenario(patches: $patches) { name
|
|
397
|
+
}
|
|
398
|
+
}
|
|
509
399
|
`,
|
|
510
|
-
variables: {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
})
|
|
400
|
+
variables: { patches
|
|
401
|
+
}
|
|
402
|
+
})
|
|
514
403
|
|
|
515
404
|
if (!response.errors) this.grist.fetch()
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
async startScenario(record) {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
startScenario(scenarioName: $scenarioName, instanceName: $instanceName) {
|
|
524
|
-
state
|
|
525
|
-
}
|
|
526
|
-
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
async startScenario(record) { var { data, errors } = await client.mutate({ mutation: gql`
|
|
409
|
+
mutation ($scenarioName: String!, $instanceName: String) { startScenario(scenarioName: $scenarioName, instanceName: $instanceName) { state
|
|
410
|
+
}
|
|
411
|
+
}
|
|
527
412
|
`,
|
|
528
|
-
variables: {
|
|
529
|
-
scenarioName: record.name,
|
|
413
|
+
variables: { scenarioName: record.name,
|
|
530
414
|
instanceName: record.name
|
|
531
|
-
|
|
532
|
-
|
|
415
|
+
}
|
|
416
|
+
})
|
|
533
417
|
|
|
534
|
-
if (data && data.startScenario) {
|
|
535
|
-
record.state = data.startScenario.state
|
|
418
|
+
if (data && data.startScenario) { record.state = data.startScenario.state
|
|
536
419
|
|
|
537
|
-
notify({
|
|
538
|
-
level: 'info',
|
|
420
|
+
notify({ level: 'info',
|
|
539
421
|
message: `${IS_SCENARIO_RUNNING(state) ? 'success' : 'fail'} to start scenario : ${record.name}`
|
|
540
|
-
|
|
541
|
-
|
|
422
|
+
})
|
|
423
|
+
}
|
|
542
424
|
|
|
543
425
|
this.grist.fetch()
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
async stopScenario(record) {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
stopScenario(instanceName: $instanceName) {
|
|
551
|
-
state
|
|
552
|
-
}
|
|
553
|
-
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async stopScenario(record) { var response = await client.mutate({ mutation: gql`
|
|
429
|
+
mutation ($instanceName: String!) { stopScenario(instanceName: $instanceName) { state
|
|
430
|
+
}
|
|
431
|
+
}
|
|
554
432
|
`,
|
|
555
|
-
variables: {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
})
|
|
433
|
+
variables: { instanceName: record.name
|
|
434
|
+
}
|
|
435
|
+
})
|
|
559
436
|
|
|
560
|
-
if (!response.errors) {
|
|
561
|
-
notify({
|
|
562
|
-
level: 'info',
|
|
437
|
+
if (!response.errors) { notify({ level: 'info',
|
|
563
438
|
message: `success to stop scenario : ${record.name}`
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
notify({
|
|
567
|
-
level: 'error',
|
|
439
|
+
})
|
|
440
|
+
} else { notify({ level: 'error',
|
|
568
441
|
message: `${response.errors.map(error => error.message).join('\n')}`
|
|
569
|
-
|
|
570
|
-
|
|
442
|
+
})
|
|
443
|
+
}
|
|
571
444
|
|
|
572
445
|
this.grist.fetch()
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
async startScenarioSchedule(record) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
startScenarioSchedule(scenarioId: $scenarioId) {
|
|
580
|
-
scheduleId
|
|
581
|
-
}
|
|
582
|
-
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
async startScenarioSchedule(record) { var response = await client.mutate({ mutation: gql`
|
|
449
|
+
mutation ($scenarioId: String!) { startScenarioSchedule(scenarioId: $scenarioId) { scheduleId
|
|
450
|
+
}
|
|
451
|
+
}
|
|
583
452
|
`,
|
|
584
|
-
variables: {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
})
|
|
453
|
+
variables: { scenarioId: record.id
|
|
454
|
+
}
|
|
455
|
+
})
|
|
588
456
|
|
|
589
457
|
const scheduleId = response.data.startScenarioSchedule.scheduleId
|
|
590
458
|
record.scheduleId = scheduleId
|
|
591
459
|
|
|
592
|
-
notify({
|
|
593
|
-
level: 'info',
|
|
460
|
+
notify({ level: 'info',
|
|
594
461
|
message: `${record.scheduleId ? 'success' : 'fail'} to start scenario schedule : ${record.name}`
|
|
595
|
-
|
|
462
|
+
})
|
|
596
463
|
|
|
597
464
|
this.grist.fetch()
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
async stopScenarioSchedule(record) {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
stopScenarioSchedule(scenarioId: $scenarioId) {
|
|
605
|
-
scheduleId
|
|
606
|
-
}
|
|
607
|
-
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
async stopScenarioSchedule(record) { var response = await client.mutate({ mutation: gql`
|
|
468
|
+
mutation ($scenarioId: String!) { stopScenarioSchedule(scenarioId: $scenarioId) { scheduleId
|
|
469
|
+
}
|
|
470
|
+
}
|
|
608
471
|
`,
|
|
609
|
-
variables: {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
if (!response.errors) {
|
|
615
|
-
notify({
|
|
616
|
-
level: 'info',
|
|
472
|
+
variables: { scenarioId: record.id
|
|
473
|
+
}
|
|
474
|
+
})
|
|
475
|
+
|
|
476
|
+
if (!response.errors) { notify({ level: 'info',
|
|
617
477
|
message: `success to stop scenario schedule : ${record.name}`
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
notify({
|
|
621
|
-
level: 'error',
|
|
478
|
+
})
|
|
479
|
+
} else { notify({ level: 'error',
|
|
622
480
|
message: `${response.errors.map(error => error.message).join('\n')}`
|
|
623
|
-
|
|
624
|
-
|
|
481
|
+
})
|
|
482
|
+
}
|
|
625
483
|
|
|
626
484
|
this.grist.fetch()
|
|
627
|
-
|
|
485
|
+
}
|
|
628
486
|
|
|
629
|
-
async exportHandler() {
|
|
630
|
-
const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records
|
|
487
|
+
async exportHandler() { const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records
|
|
631
488
|
const targetFieldSet = new Set(['id', 'name', 'type', 'description', 'schedule', 'timezone', 'steps'])
|
|
632
489
|
|
|
633
|
-
return exportTargets.map(scenario => {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
tempObj[field] = scenario[field]
|
|
637
|
-
}
|
|
490
|
+
return exportTargets.map(scenario => { let tempObj = {}
|
|
491
|
+
for (const field of targetFieldSet) { tempObj[field] = scenario[field]
|
|
492
|
+
}
|
|
638
493
|
|
|
639
494
|
return tempObj
|
|
640
|
-
|
|
641
|
-
|
|
495
|
+
})
|
|
496
|
+
}
|
|
642
497
|
|
|
643
|
-
async importHandler(records) {
|
|
644
|
-
openPopup(
|
|
498
|
+
async importHandler(records) { openPopup(
|
|
645
499
|
html`
|
|
646
500
|
<scenario-importer
|
|
647
501
|
.scenarios="${records}"
|
|
648
|
-
@imported="${() => {
|
|
649
|
-
history.back()
|
|
502
|
+
@imported="${() => { history.back()
|
|
650
503
|
this.grist.fetch()
|
|
651
|
-
|
|
504
|
+
}}"
|
|
652
505
|
></scenario-importer>
|
|
653
506
|
`,
|
|
654
|
-
{
|
|
655
|
-
backdrop: true,
|
|
507
|
+
{ backdrop: true,
|
|
656
508
|
size: 'large',
|
|
657
509
|
title: i18next.t('title.import scenario')
|
|
658
|
-
|
|
510
|
+
}
|
|
659
511
|
)
|
|
660
|
-
|
|
512
|
+
}
|
|
661
513
|
}
|