@things-factory/integration-ui 9.2.5 → 10.0.0-beta.10

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.
@@ -2,10 +2,9 @@ import '@operato/data-grist'
2
2
 
3
3
  import { css, html } from 'lit'
4
4
  import { customElement, property, query } from 'lit/decorators.js'
5
- import { connect } from 'pwa-helpers/connect-mixin.js'
6
5
  import gql from 'graphql-tag'
7
6
 
8
- import { PageView, store } from '@operato/shell'
7
+ import { PageView } from '@operato/shell'
9
8
  import { CommonHeaderStyles, CommonGristStyles, CommonButtonStyles, ScrollbarStyles } from '@operato/styles'
10
9
  import { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'
11
10
  import { client } from '@operato/graphql'
@@ -16,25 +15,22 @@ import { isMobileDevice } from '@operato/utils'
16
15
  import { p13n } from '@operato/p13n'
17
16
 
18
17
  @customElement('state-register-page')
19
- export class StateRegisterListPage extends connect(store)(p13n(localize(i18next)(PageView))) {
20
- static styles = [
18
+ export class StateRegisterListPage extends p13n(localize(i18next)(PageView)) { static styles = [
21
19
  ScrollbarStyles,
22
20
  CommonGristStyles,
23
21
  CommonHeaderStyles,
24
22
  css`
25
- :host {
26
- display: flex;
23
+ :host { display: flex;
27
24
 
28
25
  width: 100%;
29
26
 
30
27
  --grid-record-emphasized-background-color: #8b0000;
31
28
  --grid-record-emphasized-color: #ff6b6b;
32
- }
29
+ }
33
30
 
34
- ox-grist {
35
- overflow-y: auto;
31
+ ox-grist { overflow-y: auto;
36
32
  flex: 1;
37
- }
33
+ }
38
34
  `
39
35
  ]
40
36
 
@@ -43,33 +39,26 @@ export class StateRegisterListPage extends connect(store)(p13n(localize(i18next)
43
39
 
44
40
  @query('ox-grist') private grist!: DataGrist
45
41
 
46
- get context() {
47
- return {
48
- title: i18next.t('title.state-register'),
49
- search: {
50
- handler: (search: string) => {
51
- this.grist.searchText = search
52
- },
42
+ get context() { return { title: i18next.t('title.state-register'),
43
+ search: { handler: (search: string) => { this.grist.searchText = search
44
+ },
53
45
  value: this.grist.searchText
54
- },
46
+ },
55
47
  help: 'integration/ui/state-register',
56
48
  actions: [
57
- {
58
- title: i18next.t('button.save'),
49
+ { title: i18next.t('button.save'),
59
50
  action: this._updateStateRegister.bind(this),
60
51
  ...CommonButtonStyles.save
61
- },
62
- {
63
- title: i18next.t('button.delete'),
52
+ },
53
+ { title: i18next.t('button.delete'),
64
54
  action: this._deleteStateRegister.bind(this),
65
55
  ...CommonButtonStyles.delete
66
- }
56
+ }
67
57
  ]
68
- }
69
- }
58
+ }
59
+ }
70
60
 
71
- render() {
72
- const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
61
+ render() { const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
73
62
 
74
63
  return html`
75
64
  <ox-grist
@@ -81,140 +70,108 @@ export class StateRegisterListPage extends connect(store)(p13n(localize(i18next)
81
70
  <ox-grist-personalizer slot="setting"></ox-grist-personalizer>
82
71
  </ox-grist>
83
72
  `
84
- }
73
+ }
85
74
 
86
- async pageInitialized(lifecycle: any) {
87
- this.gristConfig = {
88
- list: {
89
- fields: ['name', 'description'],
75
+ async pageInitialized(lifecycle: any) { this.gristConfig = { list: { fields: ['name', 'description'],
90
76
  details: ['type', 'state', 'wroteAt']
91
- },
77
+ },
92
78
  columns: [
93
79
  { type: 'gutter', gutterName: 'sequence' },
94
80
  { type: 'gutter', gutterName: 'row-selector', multiple: true },
95
- {
96
- type: 'string',
81
+ { type: 'string',
97
82
  name: 'name',
98
83
  header: i18next.t('field.name'),
99
- record: {
100
- editable: true
101
- },
84
+ record: { editable: true
85
+ },
102
86
  filter: 'search',
103
87
  sortable: true,
104
88
  width: 150,
105
89
  description: i18next.t('field.name-publish-tag-desc') // name이 publish tag 역할을 한다는 설명
106
- },
107
- {
108
- type: 'string',
90
+ },
91
+ { type: 'string',
109
92
  name: 'description',
110
93
  header: i18next.t('field.description'),
111
- record: {
112
- editable: true
113
- },
94
+ record: { editable: true
95
+ },
114
96
  filter: 'search',
115
97
  width: 200
116
- },
117
- {
118
- type: 'string',
98
+ },
99
+ { type: 'string',
119
100
  name: 'group',
120
101
  header: i18next.t('field.group'),
121
- record: {
122
- editable: true
123
- },
102
+ record: { editable: true
103
+ },
124
104
  filter: 'search',
125
105
  sortable: true,
126
106
  width: 150
127
- },
128
- {
129
- type: 'boolean',
107
+ },
108
+ { type: 'boolean',
130
109
  name: 'autoPublish',
131
110
  header: i18next.t('field.auto-publish'),
132
- record: {
133
- editable: true
134
- },
111
+ record: { editable: true
112
+ },
135
113
  width: 120
136
- },
137
- {
138
- type: 'select',
114
+ },
115
+ { type: 'select',
139
116
  name: 'type',
140
117
  header: i18next.t('field.type'),
141
- record: {
142
- editable: true,
118
+ record: { editable: true,
143
119
  options: [
144
120
  {},
145
- {
146
- display: 'text',
121
+ { display: 'text',
147
122
  value: 'text'
148
- },
149
- {
150
- display: 'number',
123
+ },
124
+ { display: 'number',
151
125
  value: 'number'
152
- },
153
- {
154
- display: 'object',
126
+ },
127
+ { display: 'object',
155
128
  value: 'object'
156
- }
129
+ }
157
130
  ]
158
- },
131
+ },
159
132
  filter: 'search',
160
133
  sortable: true,
161
134
  width: 150
162
- },
163
- {
164
- type: 'number',
135
+ },
136
+ { type: 'number',
165
137
  name: 'ttl',
166
138
  header: i18next.t('field.ttl-seconds'),
167
- record: {
168
- editable: true
169
- },
139
+ record: { editable: true
140
+ },
170
141
  width: 100
171
- },
172
- {
173
- type: 'data',
142
+ },
143
+ { type: 'data',
174
144
  name: 'state',
175
145
  header: i18next.t('field.state-value'),
176
- record: {
177
- editable: true // 사용자가 state를 편집할 수 있도록 변경
178
- },
146
+ record: { editable: true // 사용자가 state를 편집할 수 있도록 변경
147
+ },
179
148
  width: 200
180
- },
181
- {
182
- type: 'datetime',
149
+ },
150
+ { type: 'datetime',
183
151
  name: 'wroteAt',
184
152
  header: i18next.t('field.wrote-at'),
185
- record: {
186
- editable: false
187
- },
153
+ record: { editable: false
154
+ },
188
155
  sortable: true,
189
156
  width: 180
190
- }
157
+ }
191
158
  ],
192
- rows: {
193
- selectable: {
194
- multiple: true
195
- }
196
- },
159
+ rows: { selectable: { multiple: true
160
+ }
161
+ },
197
162
  sorters: [
198
- {
199
- name: 'name'
200
- }
163
+ { name: 'name'
164
+ }
201
165
  ]
202
- }
203
- }
166
+ }
167
+ }
204
168
 
205
- async pageUpdated(changes: any, lifecycle: any) {
206
- if (this.active) {
207
- // do something here when this page just became as active
208
- }
209
- }
169
+ async pageUpdated(changes: any, lifecycle: any) { if (this.active) { // do something here when this page just became as active
170
+ }
171
+ }
210
172
 
211
- async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
212
- const response = await client.query({
213
- query: gql`
214
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
215
- responses: stateRegisters(filters: $filters, pagination: $pagination, sortings: $sortings) {
216
- items {
217
- id
173
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) { const response = await client.query({ query: gql`
174
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: stateRegisters(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id
218
175
  name
219
176
  description
220
177
  group
@@ -224,91 +181,70 @@ export class StateRegisterListPage extends connect(store)(p13n(localize(i18next)
224
181
  ttl
225
182
  state
226
183
  autoPublish
227
- writer {
228
- id
184
+ writer { id
229
185
  name
230
- }
186
+ }
231
187
  wroteAt
232
- }
188
+ }
233
189
  total
234
- }
235
- }
190
+ }
191
+ }
236
192
  `,
237
- variables: {
238
- filters,
193
+ variables: { filters,
239
194
  pagination: { page, limit },
240
195
  sortings
241
- }
242
- })
196
+ }
197
+ })
243
198
 
244
- return {
245
- total: response.data.responses.total || 0,
199
+ return { total: response.data.responses.total || 0,
246
200
  records: response.data.responses.items || []
247
- }
248
- }
201
+ }
202
+ }
249
203
 
250
- async _deleteStateRegister() {
251
- if (
252
- await OxPrompt.open({
253
- title: i18next.t('text.are_you_sure'),
204
+ async _deleteStateRegister() { if (
205
+ await OxPrompt.open({ title: i18next.t('text.are_you_sure'),
254
206
  text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
255
207
  confirmButton: { text: i18next.t('button.confirm') },
256
208
  cancelButton: { text: i18next.t('button.cancel') }
257
- })
258
- ) {
259
- const ids = this.grist.selected.map(record => record.id)
260
- if (ids && ids.length > 0) {
261
- const response = await client.mutate({
262
- mutation: gql`
263
- mutation ($ids: [String!]!) {
264
- deleteStateRegisters(ids: $ids)
265
- }
209
+ })
210
+ ) { const ids = this.grist.selected.map(record => record.id)
211
+ if (ids && ids.length > 0) { const response = await client.mutate({ mutation: gql`
212
+ mutation ($ids: [String!]!) { deleteStateRegisters(ids: $ids)
213
+ }
266
214
  `,
267
- variables: {
268
- ids
269
- }
270
- })
271
-
272
- if (!response.errors) {
273
- this.grist.fetch()
274
- notify({
275
- message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
276
- })
277
- }
278
- }
279
- }
280
- }
281
-
282
- async _updateStateRegister() {
283
- let patches = this.grist.dirtyRecords
284
- if (patches && patches.length) {
285
- patches = patches.map(patch => {
286
- let patchField: any = patch.id ? { id: patch.id } : {}
215
+ variables: { ids
216
+ }
217
+ })
218
+
219
+ if (!response.errors) { this.grist.fetch()
220
+ notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
221
+ })
222
+ }
223
+ }
224
+ }
225
+ }
226
+
227
+ async _updateStateRegister() { let patches = this.grist.dirtyRecords
228
+ if (patches && patches.length) { patches = patches.map(patch => { let patchField: any = patch.id ? { id: patch.id } : {}
287
229
  const dirtyFields = patch.__dirtyfields__
288
- for (let key in dirtyFields) {
289
- patchField[key] = dirtyFields[key].after
290
- }
230
+ for (let key in dirtyFields) { patchField[key] = dirtyFields[key].after
231
+ }
291
232
  patchField.cuFlag = patch.__dirty__
292
233
 
293
234
  return patchField
294
- })
235
+ })
295
236
 
296
- const response = await client.mutate({
297
- mutation: gql`
298
- mutation ($patches: [StateRegisterPatch!]!) {
299
- updateMultipleStateRegister(patches: $patches) {
300
- name
301
- }
302
- }
237
+ const response = await client.mutate({ mutation: gql`
238
+ mutation ($patches: [StateRegisterPatch!]!) { updateMultipleStateRegister(patches: $patches) { name
239
+ }
240
+ }
303
241
  `,
304
- variables: {
305
- patches
306
- }
307
- })
308
-
309
- if (!response.errors) {
310
- this.grist.fetch()
311
- }
312
- }
313
- }
242
+ variables: { patches
243
+ }
244
+ })
245
+
246
+ if (!response.errors) { this.grist.fetch()
247
+ }
248
+ }
249
+ }
314
250
  }
@@ -5,14 +5,11 @@ import gql from 'graphql-tag'
5
5
 
6
6
  import { css, html, LitElement, nothing } from 'lit'
7
7
  import { customElement, property, query } from 'lit/decorators.js'
8
- import { connect } from 'pwa-helpers/connect-mixin.js'
9
-
10
8
  import { subscribe } from '@operato/graphql'
11
- import { store } from '@operato/shell'
12
9
  import { ScrollbarStyles } from '@operato/styles'
13
10
 
14
11
  @customElement('scenario-instance-log-view')
15
- export class ScenarioInstanceLogView extends connect(store)(LitElement) {
12
+ export class ScenarioInstanceLogView extends LitElement {
16
13
  static styles = [
17
14
  ScrollbarStyles,
18
15
  css`
@@ -3,14 +3,13 @@ import './scenario-instance-log-view.js'
3
3
  import gql from 'graphql-tag'
4
4
  import { css, html, LitElement } from 'lit'
5
5
  import { customElement, property, query } from 'lit/decorators.js'
6
- import { connect } from 'pwa-helpers/connect-mixin.js'
7
6
 
8
7
  import { subscribe } from '@operato/graphql'
9
- import { store } from '@operato/shell'
8
+ import { AppController } from '@operato/shell'
10
9
  import { ScrollbarStyles } from '@operato/styles'
11
10
 
12
11
  @customElement('scenario-instance-view')
13
- export class ScenarioInstanceView extends connect(store)(LitElement) {
12
+ export class ScenarioInstanceView extends LitElement {
14
13
  static styles = [
15
14
  ScrollbarStyles,
16
15
  css`
@@ -124,7 +123,8 @@ export class ScenarioInstanceView extends connect(store)(LitElement) {
124
123
  @property({ type: String }) tab?: string
125
124
  @property({ type: String }) step?: string
126
125
  @property({ type: String }) key?: string
127
- @property({ type: String }) contextPath?: string
126
+
127
+ private _appCtrl = new AppController(this)
128
128
 
129
129
  subscription: any
130
130
 
@@ -132,7 +132,7 @@ export class ScenarioInstanceView extends connect(store)(LitElement) {
132
132
  const tab = this.tab || 'info'
133
133
  const { scenarioName, instanceName, description, state, progress, variables, data, message } = this.instance || {}
134
134
  const { rate = 0, steps = 0, step = 0, rounds = 0 } = progress || {}
135
- const diagram = `${this.contextPath || ''}/scenario-view/${this.scenarioName}`
135
+ const diagram = `${this._appCtrl.contextPath || ''}/scenario-view/${this.scenarioName}`
136
136
 
137
137
  return html`
138
138
  <div content>
@@ -178,10 +178,6 @@ export class ScenarioInstanceView extends connect(store)(LitElement) {
178
178
  this.stopSubscribe()
179
179
  }
180
180
 
181
- stateChanged(state) {
182
- this.contextPath = state.app.contextPath
183
- }
184
-
185
181
  renderDataObject(data) {
186
182
  const keys = Object.keys(data || {})
187
183
 
@@ -4,12 +4,6 @@ import { DataGrist } from '@operato/data-grist/ox-grist.js';
4
4
  import { PageView } from '@operato/shell';
5
5
  import { FetchOption } from '@operato/data-grist';
6
6
  declare const Connection_base: (new (...args: any[]) => {
7
- _storeUnsubscribe: import("redux").Unsubscribe;
8
- connectedCallback(): void;
9
- disconnectedCallback(): void;
10
- stateChanged(_state: unknown): void;
11
- readonly isConnected: boolean;
12
- }) & (new (...args: any[]) => {
13
7
  __preferenceProviders: {
14
8
  [element: string]: import("@operato/p13n").PagePreferenceProvider;
15
9
  };