@things-factory/integration-ui 6.2.34 → 6.2.35

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.
@@ -0,0 +1,260 @@
1
+ import '@operato/data-grist'
2
+
3
+ import { css, html } from 'lit'
4
+ import { customElement, property, query } from 'lit/decorators.js'
5
+ import { connect } from 'pwa-helpers/connect-mixin'
6
+ import gql from 'graphql-tag'
7
+
8
+ import { PageView, store } from '@operato/shell'
9
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
10
+ import { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'
11
+ import { client } from '@operato/graphql'
12
+ import { i18next, localize } from '@operato/i18n'
13
+ import { notify, openPopup } from '@operato/layout'
14
+ import { OxPopup, OxPrompt } from '@operato/popup'
15
+ import { isMobileDevice } from '@operato/utils'
16
+
17
+ @customElement('state-register-page')
18
+ export class StateRegisterListPage extends connect(store)(localize(i18next)(PageView)) {
19
+ static styles = [
20
+ ScrollbarStyles,
21
+ CommonGristStyles,
22
+ css`
23
+ :host {
24
+ display: flex;
25
+
26
+ width: 100%;
27
+
28
+ --grid-record-emphasized-background-color: red;
29
+ --grid-record-emphasized-color: yellow;
30
+ }
31
+ `
32
+ ]
33
+
34
+ @property({ type: Object }) gristConfig: any
35
+ @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
36
+
37
+ @query('ox-grist') private grist!: DataGrist
38
+
39
+ get context() {
40
+ return {
41
+ title: i18next.t('title.state-register'),
42
+ search: {
43
+ handler: (search: string) => {
44
+ this.grist.searchText = search
45
+ },
46
+ value: this.grist.searchText
47
+ },
48
+ help: 'integration/ui/state-register',
49
+ actions: [
50
+ {
51
+ title: i18next.t('button.save'),
52
+ action: this._updateStateRegister.bind(this),
53
+ ...CommonButtonStyles.save
54
+ },
55
+ {
56
+ title: i18next.t('button.delete'),
57
+ action: this._deleteStateRegister.bind(this),
58
+ ...CommonButtonStyles.delete
59
+ }
60
+ ]
61
+ }
62
+ }
63
+
64
+ render() {
65
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
66
+
67
+ return html`
68
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}> </ox-grist>
69
+ `
70
+ }
71
+
72
+ async pageInitialized(lifecycle: any) {
73
+ this.gristConfig = {
74
+ list: {
75
+ fields: ['name', 'description'],
76
+ details: ['type', 'state', 'wroteAt']
77
+ },
78
+ columns: [
79
+ { type: 'gutter', gutterName: 'sequence' },
80
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
81
+ {
82
+ type: 'string',
83
+ name: 'name',
84
+ header: i18next.t('field.name'),
85
+ record: {
86
+ editable: true
87
+ },
88
+ filter: 'search',
89
+ sortable: true,
90
+ width: 150
91
+ },
92
+ {
93
+ type: 'string',
94
+ name: 'description',
95
+ header: i18next.t('field.description'),
96
+ record: {
97
+ editable: true
98
+ },
99
+ filter: 'search',
100
+ width: 200
101
+ },
102
+ {
103
+ type: 'string',
104
+ name: 'type',
105
+ header: i18next.t('field.type'),
106
+ record: {
107
+ editable: true
108
+ },
109
+ filter: 'search',
110
+ sortable: true,
111
+ width: 150
112
+ },
113
+ {
114
+ type: 'number',
115
+ name: 'ttl',
116
+ header: i18next.t('field.ttl-seconds'),
117
+ record: {
118
+ editable: true
119
+ },
120
+ width: 100
121
+ },
122
+ {
123
+ type: 'json5',
124
+ name: 'state',
125
+ header: i18next.t('field.state-value'),
126
+ record: {
127
+ editable: false
128
+ },
129
+ width: 200
130
+ },
131
+ {
132
+ type: 'datetime',
133
+ name: 'wroteAt',
134
+ header: i18next.t('field.wrote-at'),
135
+ record: {
136
+ editable: false
137
+ },
138
+ sortable: true,
139
+ width: 180
140
+ }
141
+ ],
142
+ rows: {
143
+ selectable: {
144
+ multiple: true
145
+ }
146
+ },
147
+ sorters: [
148
+ {
149
+ name: 'name'
150
+ }
151
+ ]
152
+ }
153
+ }
154
+
155
+ async pageUpdated(changes: any, lifecycle: any) {
156
+ if (this.active) {
157
+ // do something here when this page just became as active
158
+ }
159
+ }
160
+
161
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
162
+ const response = await client.query({
163
+ query: gql`
164
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
165
+ responses: stateRegisters(filters: $filters, pagination: $pagination, sortings: $sortings) {
166
+ items {
167
+ id
168
+ name
169
+ description
170
+ type
171
+ ttl
172
+ state
173
+ writer {
174
+ id
175
+ name
176
+ }
177
+ wroteAt
178
+ }
179
+ total
180
+ }
181
+ }
182
+ `,
183
+ variables: {
184
+ filters,
185
+ pagination: { page, limit },
186
+ sortings
187
+ }
188
+ })
189
+
190
+ return {
191
+ total: response.data.responses.total || 0,
192
+ records: response.data.responses.items || []
193
+ }
194
+ }
195
+
196
+ async _deleteStateRegister() {
197
+ if (
198
+ await OxPrompt.open({
199
+ title: i18next.t('text.are_you_sure'),
200
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
201
+ confirmButton: { text: i18next.t('button.confirm') },
202
+ cancelButton: { text: i18next.t('button.cancel') }
203
+ })
204
+ ) {
205
+ const ids = this.grist.selected.map(record => record.id)
206
+ if (ids && ids.length > 0) {
207
+ const response = await client.mutate({
208
+ mutation: gql`
209
+ mutation ($ids: [String!]!) {
210
+ deleteStateRegisters(ids: $ids)
211
+ }
212
+ `,
213
+ variables: {
214
+ ids
215
+ }
216
+ })
217
+
218
+ if (!response.errors) {
219
+ this.grist.fetch()
220
+ notify({
221
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
222
+ })
223
+ }
224
+ }
225
+ }
226
+ }
227
+
228
+ async _updateStateRegister() {
229
+ let patches = this.grist.dirtyRecords
230
+ if (patches && patches.length) {
231
+ patches = patches.map(patch => {
232
+ let patchField: any = patch.id ? { id: patch.id } : {}
233
+ const dirtyFields = patch.__dirtyfields__
234
+ for (let key in dirtyFields) {
235
+ patchField[key] = dirtyFields[key].after
236
+ }
237
+ patchField.cuFlag = patch.__dirty__
238
+
239
+ return patchField
240
+ })
241
+
242
+ const response = await client.mutate({
243
+ mutation: gql`
244
+ mutation ($patches: [StateRegisterPatch!]!) {
245
+ updateMultipleStateRegister(patches: $patches) {
246
+ name
247
+ }
248
+ }
249
+ `,
250
+ variables: {
251
+ patches
252
+ }
253
+ })
254
+
255
+ if (!response.errors) {
256
+ this.grist.fetch()
257
+ }
258
+ }
259
+ }
260
+ }
package/client/route.ts CHANGED
@@ -12,6 +12,10 @@ export default function route(page) {
12
12
  import('./pages/integration-monitor')
13
13
  return page
14
14
 
15
+ case 'state-register-page':
16
+ import('./pages/state-register')
17
+ return page
18
+
15
19
  case 'integration-analysis':
16
20
  import('./pages/integration-analysis')
17
21
  return page
@@ -18,6 +18,7 @@ export class ScenarioInstanceLogView extends connect(store)(LitElement) {
18
18
  background-color: var(--theme-white-color);
19
19
  padding: var(--padding-wide);
20
20
  }
21
+
21
22
  :host([active]) {
22
23
  padding: 0;
23
24
  }
@@ -31,6 +32,15 @@ export class ScenarioInstanceLogView extends connect(store)(LitElement) {
31
32
 
32
33
  font-size: var(--fontsize-small);
33
34
  }
35
+
36
+ div.error {
37
+ color: red;
38
+ }
39
+
40
+ div.warn {
41
+ color: orange;
42
+ }
43
+
34
44
  span {
35
45
  color: var(--secondary-text-color);
36
46
  }
@@ -61,7 +71,11 @@ export class ScenarioInstanceLogView extends connect(store)(LitElement) {
61
71
  <div content>
62
72
  ${logs.map(
63
73
  ({ timestamp, message, level }) =>
64
- html` <div><span>${new Date(timestamp).toLocaleString()}</span> <strong>${level}</strong> ${message}</div> `
74
+ html`
75
+ <div class="${level}">
76
+ <span>${new Date(timestamp).toLocaleString()}</span> <strong>${level}</strong> ${message}
77
+ </div>
78
+ `
65
79
  )}
66
80
  </div>
67
81
  `
@@ -0,0 +1,45 @@
1
+ import '@operato/data-grist';
2
+ import { PageView } from '@operato/shell';
3
+ import { FetchOption } from '@operato/data-grist';
4
+ declare const StateRegisterListPage_base: (new (...args: any[]) => {
5
+ _storeUnsubscribe: import("redux").Unsubscribe;
6
+ connectedCallback(): void;
7
+ disconnectedCallback(): void;
8
+ stateChanged(_state: unknown): void;
9
+ readonly isConnected: boolean;
10
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
11
+ export declare class StateRegisterListPage extends StateRegisterListPage_base {
12
+ static styles: import("lit").CSSResult[];
13
+ gristConfig: any;
14
+ mode: 'CARD' | 'GRID' | 'LIST';
15
+ private grist;
16
+ get context(): {
17
+ title: string;
18
+ search: {
19
+ handler: (search: string) => void;
20
+ value: string;
21
+ };
22
+ help: string;
23
+ actions: {
24
+ icon: string;
25
+ emphasis: {
26
+ raised: boolean;
27
+ outlined: boolean;
28
+ dense: boolean;
29
+ danger: boolean;
30
+ };
31
+ title: string;
32
+ action: () => Promise<void>;
33
+ }[];
34
+ };
35
+ render(): import("lit-html").TemplateResult<1>;
36
+ pageInitialized(lifecycle: any): Promise<void>;
37
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
38
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
39
+ total: any;
40
+ records: any;
41
+ }>;
42
+ _deleteStateRegister(): Promise<void>;
43
+ _updateStateRegister(): Promise<void>;
44
+ }
45
+ export {};
@@ -0,0 +1,250 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist';
3
+ import { css, html } from 'lit';
4
+ import { customElement, property, query } from 'lit/decorators.js';
5
+ import { connect } from 'pwa-helpers/connect-mixin';
6
+ import gql from 'graphql-tag';
7
+ import { PageView, store } from '@operato/shell';
8
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
9
+ import { DataGrist } from '@operato/data-grist';
10
+ import { client } from '@operato/graphql';
11
+ import { i18next, localize } from '@operato/i18n';
12
+ import { notify } from '@operato/layout';
13
+ import { OxPrompt } from '@operato/popup';
14
+ import { isMobileDevice } from '@operato/utils';
15
+ let StateRegisterListPage = class StateRegisterListPage extends connect(store)(localize(i18next)(PageView)) {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.mode = isMobileDevice() ? 'CARD' : 'GRID';
19
+ }
20
+ get context() {
21
+ return {
22
+ title: i18next.t('title.state-register'),
23
+ search: {
24
+ handler: (search) => {
25
+ this.grist.searchText = search;
26
+ },
27
+ value: this.grist.searchText
28
+ },
29
+ help: 'integration/ui/state-register',
30
+ actions: [
31
+ Object.assign({ title: i18next.t('button.save'), action: this._updateStateRegister.bind(this) }, CommonButtonStyles.save),
32
+ Object.assign({ title: i18next.t('button.delete'), action: this._deleteStateRegister.bind(this) }, CommonButtonStyles.delete)
33
+ ]
34
+ };
35
+ }
36
+ render() {
37
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
38
+ return html `
39
+ <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}> </ox-grist>
40
+ `;
41
+ }
42
+ async pageInitialized(lifecycle) {
43
+ this.gristConfig = {
44
+ list: {
45
+ fields: ['name', 'description'],
46
+ details: ['type', 'state', 'wroteAt']
47
+ },
48
+ columns: [
49
+ { type: 'gutter', gutterName: 'sequence' },
50
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
51
+ {
52
+ type: 'string',
53
+ name: 'name',
54
+ header: i18next.t('field.name'),
55
+ record: {
56
+ editable: true
57
+ },
58
+ filter: 'search',
59
+ sortable: true,
60
+ width: 150
61
+ },
62
+ {
63
+ type: 'string',
64
+ name: 'description',
65
+ header: i18next.t('field.description'),
66
+ record: {
67
+ editable: true
68
+ },
69
+ filter: 'search',
70
+ width: 200
71
+ },
72
+ {
73
+ type: 'string',
74
+ name: 'type',
75
+ header: i18next.t('field.type'),
76
+ record: {
77
+ editable: true
78
+ },
79
+ filter: 'search',
80
+ sortable: true,
81
+ width: 150
82
+ },
83
+ {
84
+ type: 'number',
85
+ name: 'ttl',
86
+ header: i18next.t('field.ttl-seconds'),
87
+ record: {
88
+ editable: true
89
+ },
90
+ width: 100
91
+ },
92
+ {
93
+ type: 'json5',
94
+ name: 'state',
95
+ header: i18next.t('field.state-value'),
96
+ record: {
97
+ editable: false
98
+ },
99
+ width: 200
100
+ },
101
+ {
102
+ type: 'datetime',
103
+ name: 'wroteAt',
104
+ header: i18next.t('field.wrote-at'),
105
+ record: {
106
+ editable: false
107
+ },
108
+ sortable: true,
109
+ width: 180
110
+ }
111
+ ],
112
+ rows: {
113
+ selectable: {
114
+ multiple: true
115
+ }
116
+ },
117
+ sorters: [
118
+ {
119
+ name: 'name'
120
+ }
121
+ ]
122
+ };
123
+ }
124
+ async pageUpdated(changes, lifecycle) {
125
+ if (this.active) {
126
+ // do something here when this page just became as active
127
+ }
128
+ }
129
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
130
+ const response = await client.query({
131
+ query: gql `
132
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
133
+ responses: stateRegisters(filters: $filters, pagination: $pagination, sortings: $sortings) {
134
+ items {
135
+ id
136
+ name
137
+ description
138
+ type
139
+ ttl
140
+ state
141
+ writer {
142
+ id
143
+ name
144
+ }
145
+ wroteAt
146
+ }
147
+ total
148
+ }
149
+ }
150
+ `,
151
+ variables: {
152
+ filters,
153
+ pagination: { page, limit },
154
+ sortings
155
+ }
156
+ });
157
+ return {
158
+ total: response.data.responses.total || 0,
159
+ records: response.data.responses.items || []
160
+ };
161
+ }
162
+ async _deleteStateRegister() {
163
+ if (await OxPrompt.open({
164
+ title: i18next.t('text.are_you_sure'),
165
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
166
+ confirmButton: { text: i18next.t('button.confirm') },
167
+ cancelButton: { text: i18next.t('button.cancel') }
168
+ })) {
169
+ const ids = this.grist.selected.map(record => record.id);
170
+ if (ids && ids.length > 0) {
171
+ const response = await client.mutate({
172
+ mutation: gql `
173
+ mutation ($ids: [String!]!) {
174
+ deleteStateRegisters(ids: $ids)
175
+ }
176
+ `,
177
+ variables: {
178
+ ids
179
+ }
180
+ });
181
+ if (!response.errors) {
182
+ this.grist.fetch();
183
+ notify({
184
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
185
+ });
186
+ }
187
+ }
188
+ }
189
+ }
190
+ async _updateStateRegister() {
191
+ let patches = this.grist.dirtyRecords;
192
+ if (patches && patches.length) {
193
+ patches = patches.map(patch => {
194
+ let patchField = patch.id ? { id: patch.id } : {};
195
+ const dirtyFields = patch.__dirtyfields__;
196
+ for (let key in dirtyFields) {
197
+ patchField[key] = dirtyFields[key].after;
198
+ }
199
+ patchField.cuFlag = patch.__dirty__;
200
+ return patchField;
201
+ });
202
+ const response = await client.mutate({
203
+ mutation: gql `
204
+ mutation ($patches: [StateRegisterPatch!]!) {
205
+ updateMultipleStateRegister(patches: $patches) {
206
+ name
207
+ }
208
+ }
209
+ `,
210
+ variables: {
211
+ patches
212
+ }
213
+ });
214
+ if (!response.errors) {
215
+ this.grist.fetch();
216
+ }
217
+ }
218
+ }
219
+ };
220
+ StateRegisterListPage.styles = [
221
+ ScrollbarStyles,
222
+ CommonGristStyles,
223
+ css `
224
+ :host {
225
+ display: flex;
226
+
227
+ width: 100%;
228
+
229
+ --grid-record-emphasized-background-color: red;
230
+ --grid-record-emphasized-color: yellow;
231
+ }
232
+ `
233
+ ];
234
+ __decorate([
235
+ property({ type: Object }),
236
+ __metadata("design:type", Object)
237
+ ], StateRegisterListPage.prototype, "gristConfig", void 0);
238
+ __decorate([
239
+ property({ type: String }),
240
+ __metadata("design:type", String)
241
+ ], StateRegisterListPage.prototype, "mode", void 0);
242
+ __decorate([
243
+ query('ox-grist'),
244
+ __metadata("design:type", DataGrist)
245
+ ], StateRegisterListPage.prototype, "grist", void 0);
246
+ StateRegisterListPage = __decorate([
247
+ customElement('state-register-page')
248
+ ], StateRegisterListPage);
249
+ export { StateRegisterListPage };
250
+ //# sourceMappingURL=state-register.js.map
@@ -0,0 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,MAAM,CAAC;gBACnC,QAAQ,EAAE,GAAG,CAAA;;;;;;SAMZ;gBACD,SAAS,EAAE;oBACT,OAAO;iBACR;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;aACnB;SACF;IACH,CAAC;;AAhPM,4BAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;KASF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;0DAAiB;AAC5C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAoE;AAE/F;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;oDAAA;AAnBjC,qBAAqB;IADjC,aAAa,CAAC,qBAAqB,CAAC;GACxB,qBAAqB,CAkPjC;SAlPY,qBAAqB","sourcesContent":["import '@operato/data-grist'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { PageView, store } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { OxPopup, OxPrompt } from '@operato/popup'\nimport { isMobileDevice } from '@operato/utils'\n\n@customElement('state-register-page')\nexport class StateRegisterListPage extends connect(store)(localize(i18next)(PageView)) {\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n `\n ]\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.state-register'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist.searchText\n },\n help: 'integration/ui/state-register',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateStateRegister.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteStateRegister.bind(this),\n ...CommonButtonStyles.delete\n }\n ]\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}> </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['name', 'description'],\n details: ['type', 'state', 'wroteAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n editable: true\n },\n filter: 'search',\n width: 200\n },\n {\n type: 'string',\n name: 'type',\n header: i18next.t('field.type'),\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'number',\n name: 'ttl',\n header: i18next.t('field.ttl-seconds'),\n record: {\n editable: true\n },\n width: 100\n },\n {\n type: 'json5',\n name: 'state',\n header: i18next.t('field.state-value'),\n record: {\n editable: false\n },\n width: 200\n },\n {\n type: 'datetime',\n name: 'wroteAt',\n header: i18next.t('field.wrote-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: any, lifecycle: any) {\n if (this.active) {\n // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: stateRegisters(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n type\n ttl\n state\n writer {\n id\n name\n }\n wroteAt\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 _deleteStateRegister() {\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\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 deleteStateRegisters(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 _updateStateRegister() {\n let 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 patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [StateRegisterPatch!]!) {\n updateMultipleStateRegister(patches: $patches) {\n name\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n}\n"]}
@@ -9,6 +9,9 @@ export default function route(page) {
9
9
  case 'integration-monitor':
10
10
  import('./pages/integration-monitor');
11
11
  return page;
12
+ case 'state-register-page':
13
+ import('./pages/state-register');
14
+ return page;
12
15
  case 'integration-analysis':
13
16
  import('./pages/integration-analysis');
14
17
  return page;
@@ -1 +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;QAEb,KAAK,sBAAsB;YACzB,MAAM,CAAC,8BAA8B,CAAC,CAAA;YACtC,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 case 'integration-analysis':\n import('./pages/integration-analysis')\n return page\n }\n}\n"]}
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;QAEb,KAAK,qBAAqB;YACxB,MAAM,CAAC,wBAAwB,CAAC,CAAA;YAChC,OAAO,IAAI,CAAA;QAEb,KAAK,sBAAsB;YACzB,MAAM,CAAC,8BAA8B,CAAC,CAAA;YACtC,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 case 'state-register-page':\n import('./pages/state-register')\n return page\n\n case 'integration-analysis':\n import('./pages/integration-analysis')\n return page\n }\n}\n"]}