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