@things-factory/process 9.1.19 → 10.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import '@operato/data-grist';
3
3
  import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
4
- import { PageView, store } from '@operato/shell';
4
+ import { PageView } from '@operato/shell';
5
5
  import { css, html } from 'lit';
6
6
  import { customElement, property, query } from 'lit/decorators.js';
7
7
  import { ScopedElementsMixin } from '@open-wc/scoped-elements';
@@ -10,10 +10,9 @@ import { client } from '@operato/graphql';
10
10
  import { i18next, localize } from '@operato/i18n';
11
11
  import { notify, openPopup } from '@operato/layout';
12
12
  import { isMobileDevice } from '@operato/utils';
13
- import { connect } from 'pwa-helpers/connect-mixin';
14
13
  import gql from 'graphql-tag';
15
14
  import { GatewayImporter } from './gateway-importer';
16
- let GatewayListPage = class GatewayListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
15
+ let GatewayListPage = class GatewayListPage extends localize(i18next)(ScopedElementsMixin(PageView)) {
17
16
  constructor() {
18
17
  super(...arguments);
19
18
  this.mode = isMobileDevice() ? 'CARD' : 'GRID';
@@ -23,65 +22,52 @@ let GatewayListPage = class GatewayListPage extends connect(store)(localize(i18n
23
22
  CommonGristStyles,
24
23
  CommonHeaderStyles,
25
24
  css `
26
- :host {
27
- display: flex;
25
+ :host { display: flex;
28
26
 
29
27
  width: 100%;
30
28
 
31
29
  --grid-record-emphasized-background-color: #8b0000;
32
30
  --grid-record-emphasized-color: #ff6b6b;
33
- }
31
+ }
34
32
 
35
- ox-grist {
36
- overflow-y: auto;
33
+ ox-grist { overflow-y: auto;
37
34
  flex: 1;
38
- }
35
+ }
39
36
 
40
- ox-filters-form {
41
- flex: 1;
42
- }
37
+ ox-filters-form { flex: 1;
38
+ }
43
39
  `
44
40
  ]; }
45
41
  static get scopedElements() {
46
- return {
47
- 'gateway-importer': GatewayImporter
42
+ return { 'gateway-importer': GatewayImporter
48
43
  };
49
44
  }
50
45
  get context() {
51
- return {
52
- title: i18next.t('title.gateway list'),
53
- search: {
54
- handler: (search) => {
46
+ return { title: i18next.t('title.gateway list'),
47
+ search: { handler: (search) => {
55
48
  this.grist.searchText = search;
56
49
  },
57
- value: this.grist?.searchText || ''
58
- },
59
- filter: {
60
- handler: () => {
50
+ value: this.grist?.searchText || '' },
51
+ filter: { handler: () => {
61
52
  this.grist.toggleHeadroom();
62
53
  }
63
54
  },
64
55
  help: 'process/gateway',
65
56
  actions: [
66
- {
67
- title: i18next.t('button.save'),
57
+ { title: i18next.t('button.save'),
68
58
  action: this._updateGateway.bind(this),
69
59
  ...CommonButtonStyles.save
70
60
  },
71
- {
72
- title: i18next.t('button.delete'),
61
+ { title: i18next.t('button.delete'),
73
62
  action: this._deleteGateway.bind(this),
74
63
  ...CommonButtonStyles.delete
75
64
  }
76
65
  ],
77
- exportable: {
78
- name: i18next.t('title.gateway list'),
66
+ exportable: { name: i18next.t('title.gateway list'),
79
67
  data: this.exportHandler.bind(this)
80
68
  },
81
- importable: {
82
- handler: this.importHandler.bind(this)
83
- }
84
- };
69
+ importable: { handler: this.importHandler.bind(this)
70
+ } };
85
71
  }
86
72
  render() {
87
73
  const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
@@ -102,113 +88,90 @@ let GatewayListPage = class GatewayListPage extends connect(store)(localize(i18n
102
88
  `;
103
89
  }
104
90
  async pageInitialized(lifecycle) {
105
- this.gristConfig = {
106
- list: {
107
- fields: ['name', 'description'],
91
+ this.gristConfig = { list: { fields: ['name', 'description'],
108
92
  details: ['active', 'updatedAt']
109
93
  },
110
94
  columns: [
111
95
  { type: 'gutter', gutterName: 'sequence' },
112
96
  { type: 'gutter', gutterName: 'row-selector', multiple: true },
113
- {
114
- type: 'string',
97
+ { type: 'string',
115
98
  name: 'name',
116
99
  header: i18next.t('field.name'),
117
- record: {
118
- editable: true
100
+ record: { editable: true
119
101
  },
120
102
  filter: 'search',
121
103
  sortable: true,
122
104
  width: 150
123
105
  },
124
- {
125
- type: 'string',
106
+ { type: 'string',
126
107
  name: 'description',
127
108
  header: i18next.t('field.description'),
128
- record: {
129
- editable: true
109
+ record: { editable: true
130
110
  },
131
111
  filter: 'search',
132
112
  width: 200
133
113
  },
134
- {
135
- type: 'checkbox',
114
+ { type: 'checkbox',
136
115
  name: 'active',
137
116
  label: true,
138
117
  header: i18next.t('field.active'),
139
- record: {
140
- editable: true
118
+ record: { editable: true
141
119
  },
142
120
  filter: true,
143
121
  sortable: true,
144
122
  width: 60
145
123
  },
146
- {
147
- type: 'resource-object',
124
+ { type: 'resource-object',
148
125
  name: 'updater',
149
126
  header: i18next.t('field.updater'),
150
- record: {
151
- editable: false
127
+ record: { editable: false
152
128
  },
153
129
  sortable: true,
154
130
  width: 120
155
131
  },
156
- {
157
- type: 'datetime',
132
+ { type: 'datetime',
158
133
  name: 'updatedAt',
159
134
  header: i18next.t('field.updated_at'),
160
- record: {
161
- editable: false
135
+ record: { editable: false
162
136
  },
163
137
  sortable: true,
164
138
  width: 180
165
139
  }
166
140
  ],
167
- rows: {
168
- selectable: {
169
- multiple: true
141
+ rows: { selectable: { multiple: true
170
142
  }
171
143
  },
172
144
  sorters: [
173
- {
174
- name: 'name'
145
+ { name: 'name'
175
146
  }
176
147
  ]
177
148
  };
178
149
  }
179
150
  async pageUpdated(changes, lifecycle) {
180
- if (this.active) {
181
- // do something here when this page just became as active
151
+ if (this.active) { // do something here when this page just became as active
182
152
  }
183
153
  }
184
154
  async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
185
- const response = await client.query({
186
- query: gql `
187
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
188
- responses: gateways(filters: $filters, pagination: $pagination, sortings: $sortings) {
189
- items {
190
- id
155
+ const response = await client.query({ query: gql `
156
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: gateways(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id
191
157
  name
192
158
  description
193
159
  active
194
- updater {
195
- id
160
+ updater { id
196
161
  name
197
- }
162
+ }
198
163
  updatedAt
199
- }
164
+ }
200
165
  total
201
- }
202
- }
166
+ }
167
+ }
203
168
  `,
204
- variables: {
205
- filters,
169
+ variables: { filters,
206
170
  pagination: { page, limit },
207
171
  sortings
208
172
  }
209
173
  });
210
- return {
211
- total: response.data.responses.total || 0,
174
+ return { total: response.data.responses.total || 0,
212
175
  records: response.data.responses.items || []
213
176
  };
214
177
  }
@@ -216,20 +179,16 @@ let GatewayListPage = class GatewayListPage extends connect(store)(localize(i18n
216
179
  if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
217
180
  const ids = this.grist.selected.map(record => record.id);
218
181
  if (ids && ids.length > 0) {
219
- const response = await client.mutate({
220
- mutation: gql `
221
- mutation ($ids: [String!]!) {
222
- deleteGateways(ids: $ids)
223
- }
182
+ const response = await client.mutate({ mutation: gql `
183
+ mutation ($ids: [String!]!) { deleteGateways(ids: $ids)
184
+ }
224
185
  `,
225
- variables: {
226
- ids
186
+ variables: { ids
227
187
  }
228
188
  });
229
189
  if (!response.errors) {
230
190
  this.grist.fetch();
231
- notify({
232
- message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
191
+ notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
233
192
  });
234
193
  }
235
194
  }
@@ -247,16 +206,12 @@ let GatewayListPage = class GatewayListPage extends connect(store)(localize(i18n
247
206
  patchField.cuFlag = patch.__dirty__;
248
207
  return patchField;
249
208
  });
250
- const response = await client.mutate({
251
- mutation: gql `
252
- mutation ($patches: [GatewayPatch!]!) {
253
- updateMultipleGateway(patches: $patches) {
254
- name
255
- }
256
- }
209
+ const response = await client.mutate({ mutation: gql `
210
+ mutation ($patches: [GatewayPatch!]!) { updateMultipleGateway(patches: $patches) { name
211
+ }
212
+ }
257
213
  `,
258
- variables: {
259
- patches
214
+ variables: { patches
260
215
  }
261
216
  });
262
217
  if (!response.errors) {
@@ -284,8 +239,7 @@ let GatewayListPage = class GatewayListPage extends connect(store)(localize(i18n
284
239
  this.grist.fetch();
285
240
  }}
286
241
  ></gateway-importer>
287
- `, {
288
- backdrop: true,
242
+ `, { backdrop: true,
289
243
  size: 'large',
290
244
  title: i18next.t('title.import gateway')
291
245
  });
@@ -1 +1 @@
1
- {"version":3,"file":"gateway-list-page.js","sourceRoot":"","sources":["../../../client/pages/gateway/gateway-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5G,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAgB,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG7C,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,OAAO,CAAC,KAAK,CAAC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AAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA+S3B","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView, store } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport gql from 'graphql-tag'\n\nimport { GatewayImporter } from './gateway-importer'\n\n@customElement('gateway-list-page')\nexport class GatewayListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist {\n overflow-y: auto;\n flex: 1;\n }\n\n ox-filters-form {\n flex: 1;\n }\n `\n ]\n\n static get scopedElements() {\n return {\n 'gateway-importer': GatewayImporter\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.gateway list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'process/gateway',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this._updateGateway.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this._deleteGateway.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: {\n name: i18next.t('title.gateway list'),\n data: this.exportHandler.bind(this)\n },\n importable: {\n handler: this.importHandler.bind(this)\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)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['name', 'description'],\n details: ['active', 'updatedAt']\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: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n record: {\n editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n {\n type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: {\n editable: false\n },\n sortable: true,\n width: 120\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: 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: gateways(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n description\n active\n updater {\n id\n name\n }\n updatedAt\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 _deleteGateway() {\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 deleteGateways(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 _updateGateway() {\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: [GatewayPatch!]!) {\n updateMultipleGateway(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 async exportHandler() {\n const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(gateway => {\n let tempObj = {}\n for (const field of targetFieldSet) {\n tempObj[field] = gateway[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) {\n const popup = openPopup(\n html`\n <gateway-importer\n .gateways=${records}\n @imported=${() => {\n history.back()\n this.grist.fetch()\n }}\n ></gateway-importer>\n `,\n {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.import gateway')\n }\n )\n\n popup.onclosed = () => {\n this.grist.fetch()\n }\n }\n}\n"]}
1
+ {"version":3,"file":"gateway-list-page.js","sourceRoot":"","sources":["../../../client/pages/gateway/gateway-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAgB,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG7C,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAA9E;;QA2BuB,SAAI,GAA6B,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;IAiNjG,CAAC;aA5OgG,WA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AAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAA;QAEvE,OAAO,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YAAS,IAAI,OAAO,GAAG,EAAE,CAAA;YAC1D,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;gBAAS,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;YAClF,CAAC;YAEI,OAAO,OAAO,CAAA;QACnB,CAAC,CAAC,CAAA;IACF,CAAC;IAEA,KAAK,CAAC,aAAa,CAAC,OAAO;QAAQ,MAAM,KAAK,GAAG,SAAS,CACtD,IAAI,CAAA;;sBAEY,OAAO;sBACP,GAAG,EAAE;YAAe,OAAO,CAAC,IAAI,EAAE,CAAA;YAC5C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAC7B,CAAC;;OAEK,EACD,EAAU,QAAQ,EAAE,IAAI;YACtB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC;SAC9C,CACG,CAAA;QAED,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE;YAAS,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpD,CAAC,CAAA;IACD,CAAC;;AAjN4B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;8CAAA;AA7BjC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA4O3B","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { PageView } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { isMobileDevice } from '@operato/utils'\n\nimport gql from 'graphql-tag'\n\nimport { GatewayImporter } from './gateway-importer'\n\n@customElement('gateway-list-page')\nexport class GatewayListPage extends localize(i18next)(ScopedElementsMixin(PageView)) { static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host { display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-grist { overflow-y: auto;\n flex: 1;\n }\n\n ox-filters-form { flex: 1;\n }\n `\n ]\n\n static get scopedElements() { return { 'gateway-importer': GatewayImporter\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() { return { title: i18next.t('title.gateway list'),\n search: { handler: (search: string) => { this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: { handler: () => { this.grist.toggleHeadroom()\n }\n },\n help: 'process/gateway',\n actions: [\n { title: i18next.t('button.save'),\n action: this._updateGateway.bind(this),\n ...CommonButtonStyles.save\n },\n { title: i18next.t('button.delete'),\n action: this._deleteGateway.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: { name: i18next.t('title.gateway list'),\n data: this.exportHandler.bind(this)\n },\n importable: { handler: this.importHandler.bind(this)\n }\n }\n }\n\n render() { const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) { this.gristConfig = { list: { fields: ['name', 'description'],\n details: ['active', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: { editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n { type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: { editable: true\n },\n filter: 'search',\n width: 200\n },\n { type: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n record: { editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n { type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: { editable: false\n },\n sortable: true,\n width: 120\n },\n { type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: { selectable: { multiple: true\n }\n },\n sorters: [\n { name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) { if (this.active) { // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) { const response = await client.query({ query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: gateways(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id\n name\n description\n active\n updater { id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: { filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return { total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n async _deleteGateway() { if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) { const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) { const response = await client.mutate({ mutation: gql`\n mutation ($ids: [String!]!) { deleteGateways(ids: $ids)\n }\n `,\n variables: { ids\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async _updateGateway() { let patches = this.grist.dirtyRecords\n if (patches && patches.length) { patches = patches.map(patch => { let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) { patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({ mutation: gql`\n mutation ($patches: [GatewayPatch!]!) { updateMultipleGateway(patches: $patches) { name\n }\n }\n `,\n variables: { patches\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n }\n }\n }\n\n async exportHandler() { const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(gateway => { let tempObj = {}\n for (const field of targetFieldSet) { tempObj[field] = gateway[field]\n }\n\n return tempObj\n })\n }\n\n async importHandler(records) { const popup = openPopup(\n html`\n <gateway-importer\n .gateways=${records}\n @imported=${() => { history.back()\n this.grist.fetch()\n }}\n ></gateway-importer>\n `,\n { backdrop: true,\n size: 'large',\n title: i18next.t('title.import gateway')\n }\n )\n\n popup.onclosed = () => { this.grist.fetch()\n }\n }\n}\n"]}
@@ -1,10 +1,9 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { html } from 'lit';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
- import { connect } from 'pwa-helpers/connect-mixin.js';
5
4
  import { store, PageView } from '@operato/shell';
6
5
  const logo = new URL('/assets/images/hatiolab-logo.png', import.meta.url).href;
7
- let ProcessMain = class ProcessMain extends connect(store)(PageView) {
6
+ let ProcessMain = class ProcessMain extends PageView {
8
7
  render() {
9
8
  return html `
10
9
  <section>
@@ -13,8 +12,18 @@ let ProcessMain = class ProcessMain extends connect(store)(PageView) {
13
12
  </section>
14
13
  `;
15
14
  }
16
- stateChanged(state) {
17
- this.process = state.process.state_main;
15
+ connectedCallback() {
16
+ super.connectedCallback();
17
+ this._applyState();
18
+ this._unsubscribe = store.subscribe(() => this._applyState());
19
+ }
20
+ disconnectedCallback() {
21
+ super.disconnectedCallback();
22
+ this._unsubscribe?.();
23
+ }
24
+ _applyState() {
25
+ const __state__ = store.getState();
26
+ this.process = __state__.process.state_main;
18
27
  }
19
28
  };
20
29
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../client/pages/main.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEhD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,kCAAkC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAG9E,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;IAGhD,MAAM;QACJ,OAAO,IAAI,CAAA;;;mBAGI,IAAI;;KAElB,CAAA;IACH,CAAC;IAED,YAAY,CAAC,KAAK;QAChB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAA;IACzC,CAAC;CACF,CAAA;AAd6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CAAiB;AADxC,WAAW;IADhB,aAAa,CAAC,cAAc,CAAC;GACxB,WAAW,CAehB","sourcesContent":["import { html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\nimport { store, PageView } from '@operato/shell'\n\nconst logo = new URL('/assets/images/hatiolab-logo.png', import.meta.url).href\n\n@customElement('process-main')\nclass ProcessMain extends connect(store)(PageView) {\n @property({ type: String }) process?: string\n\n render() {\n return html`\n <section>\n <h2>Process</h2>\n <img src=${logo}>\n </section>\n `\n }\n\n stateChanged(state) {\n this.process = state.process.state_main\n }\n}\n\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../client/pages/main.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEhD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,kCAAkC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;AAG9E,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,QAAQ;IAGhC,MAAM;QACJ,OAAO,IAAI,CAAA;;;mBAGI,IAAI;;KAElB,CAAA;IACH,CAAC;IAKD,iBAAiB;QAEf,KAAK,CAAC,iBAAiB,EAAE,CAAA;QAEzB,IAAI,CAAC,WAAW,EAAE,CAAA;QAElB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;IAE/D,CAAC;IAGD,oBAAoB;QAElB,KAAK,CAAC,oBAAoB,EAAE,CAAA;QAE5B,IAAI,CAAC,YAAY,EAAE,EAAE,CAAA;IAEvB,CAAC;IAGO,WAAW;QAEjB,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAS,CAAA;QAC7C,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,UAAU,CAAA;IAEzC,CAAC;CACF,CAAA;AAxC6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CAAiB;AADxC,WAAW;IADhB,aAAa,CAAC,cAAc,CAAC;GACxB,WAAW,CAyChB","sourcesContent":["import { html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { store, PageView } from '@operato/shell'\n\nconst logo = new URL('/assets/images/hatiolab-logo.png', import.meta.url).href\n\n@customElement('process-main')\nclass ProcessMain extends PageView {\n @property({ type: String }) process?: string\n\n render() {\n return html`\n <section>\n <h2>Process</h2>\n <img src=${logo}>\n </section>\n `\n }\n\n private _unsubscribe?: () => void\n\n\n connectedCallback() {\n\n super.connectedCallback()\n\n this._applyState()\n\n this._unsubscribe = store.subscribe(() => this._applyState())\n\n }\n\n\n disconnectedCallback() {\n\n super.disconnectedCallback()\n\n this._unsubscribe?.()\n\n }\n\n\n private _applyState() {\n\n const __state__ = store.getState() as any\nthis.process = __state__.process.state_main\n\n }\n}\n\n"]}
@@ -2,13 +2,7 @@ import '@operato/data-grist';
2
2
  import { PageView } from '@operato/shell';
3
3
  import { FetchOption } from '@operato/data-grist';
4
4
  import { ProcessImporter } from './process-importer';
5
- declare const ProcessListPage_base: (new (...args: any[]) => {
6
- _storeUnsubscribe: import("redux").Unsubscribe;
7
- connectedCallback(): void;
8
- disconnectedCallback(): void;
9
- stateChanged(_state: unknown): void;
10
- readonly isConnected: boolean;
11
- }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
5
+ declare const ProcessListPage_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
12
6
  export declare class ProcessListPage extends ProcessListPage_base {
13
7
  static styles: import("lit").CSSResult[];
14
8
  static get scopedElements(): {