@things-factory/rack-base 8.0.0-beta.1 → 8.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist-client/bootstrap.d.ts +1 -0
  2. package/dist-client/bootstrap.js +2 -0
  3. package/dist-client/bootstrap.js.map +1 -0
  4. package/dist-client/index.js +2 -0
  5. package/dist-client/index.js.map +1 -0
  6. package/dist-client/pages/cell/cell-importer.d.ts +23 -0
  7. package/dist-client/pages/cell/cell-importer.js +94 -0
  8. package/dist-client/pages/cell/cell-importer.js.map +1 -0
  9. package/dist-client/pages/cell/cell-list-page.d.ts +54 -0
  10. package/dist-client/pages/cell/cell-list-page.js +290 -0
  11. package/dist-client/pages/cell/cell-list-page.js.map +1 -0
  12. package/dist-client/pages/rack/rack-importer.d.ts +23 -0
  13. package/dist-client/pages/rack/rack-importer.js +94 -0
  14. package/dist-client/pages/rack/rack-importer.js.map +1 -0
  15. package/dist-client/pages/rack/rack-list-page.d.ts +54 -0
  16. package/dist-client/pages/rack/rack-list-page.js +294 -0
  17. package/dist-client/pages/rack/rack-list-page.js.map +1 -0
  18. package/dist-client/route.d.ts +1 -0
  19. package/dist-client/route.js +11 -0
  20. package/dist-client/route.js.map +1 -0
  21. package/dist-client/tsconfig.tsbuildinfo +1 -0
  22. package/package.json +6 -6
  23. package/client/bootstrap.ts +0 -1
  24. package/client/pages/cell/cell-importer.ts +0 -87
  25. package/client/pages/cell/cell-list-page.ts +0 -308
  26. package/client/pages/rack/rack-importer.ts +0 -87
  27. package/client/pages/rack/rack-list-page.ts +0 -312
  28. package/client/route.ts +0 -11
  29. package/server/index.ts +0 -1
  30. package/server/migrations/index.ts +0 -9
  31. package/server/routes.ts +0 -26
  32. package/server/service/cell/cell-mutation.ts +0 -133
  33. package/server/service/cell/cell-query.ts +0 -50
  34. package/server/service/cell/cell-type.ts +0 -96
  35. package/server/service/cell/cell.ts +0 -112
  36. package/server/service/cell/index.ts +0 -6
  37. package/server/service/index.ts +0 -22
  38. package/server/service/rack/index.ts +0 -6
  39. package/server/service/rack/rack-mutation.ts +0 -133
  40. package/server/service/rack/rack-query.ts +0 -64
  41. package/server/service/rack/rack-type.ts +0 -54
  42. package/server/service/rack/rack.ts +0 -76
  43. /package/{client/index.ts → dist-client/index.d.ts} +0 -0
@@ -1,308 +0,0 @@
1
- import '@operato/data-grist'
2
-
3
- import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
4
- import { PageView, store } from '@operato/shell'
5
- import { css, html } from 'lit'
6
- import { customElement, property, query } from 'lit/decorators.js'
7
- import { ScopedElementsMixin } from '@open-wc/scoped-elements'
8
- import { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'
9
- import { client } from '@operato/graphql'
10
- import { i18next, localize } from '@operato/i18n'
11
- import { notify, openPopup } from '@operato/layout'
12
- import { isMobileDevice } from '@operato/utils'
13
-
14
- import { connect } from 'pwa-helpers/connect-mixin'
15
- import gql from 'graphql-tag'
16
-
17
- import { CellImporter } from './cell-importer'
18
-
19
- @customElement('cell-list-page')
20
- export class CellListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
21
- static styles = [
22
- ScrollbarStyles,
23
- CommonGristStyles,
24
- CommonHeaderStyles,
25
- css`
26
- :host {
27
- display: flex;
28
-
29
- width: 100%;
30
-
31
- --grid-record-emphasized-background-color: #8b0000;
32
- --grid-record-emphasized-color: #ff6b6b;
33
- }
34
-
35
- ox-grist {
36
- overflow-y: auto;
37
- flex: 1;
38
- }
39
- `
40
- ]
41
-
42
- static get scopedElements() {
43
- return {
44
- 'cell-importer': CellImporter
45
- }
46
- }
47
-
48
- @property({ type: Object }) gristConfig: any
49
- @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
50
-
51
- @query('ox-grist') private grist!: DataGrist
52
-
53
- get context() {
54
- return {
55
- title: i18next.t('title.cell list'),
56
- help: 'rack-base/cell',
57
- actions: [
58
- {
59
- title: i18next.t('button.save'),
60
- action: this._updateCell.bind(this),
61
- ...CommonButtonStyles.save
62
- },
63
- {
64
- title: i18next.t('button.delete'),
65
- action: this._deleteCell.bind(this),
66
- ...CommonButtonStyles.delete
67
- }
68
- ],
69
- exportable: {
70
- name: i18next.t('title.cell list'),
71
- data: this.exportHandler.bind(this)
72
- },
73
- importable: {
74
- handler: this.importHandler.bind(this)
75
- }
76
- }
77
- }
78
-
79
- render() {
80
- const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
81
-
82
- return html`
83
- <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
84
- <div slot="headroom" class="header">
85
- <div class="filters">
86
- <ox-filters-form autofocus></ox-filters-form>
87
-
88
- <div id="modes">
89
- <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
90
- <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
91
- <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
92
- </div>
93
- </div>
94
- </div>
95
- </ox-grist>
96
- `
97
- }
98
-
99
- async pageInitialized(lifecycle: any) {
100
- this.gristConfig = {
101
- list: {
102
- fields: ['name', 'description'],
103
- details: ['active', 'updatedAt']
104
- },
105
- columns: [
106
- { type: 'gutter', gutterName: 'sequence' },
107
- { type: 'gutter', gutterName: 'row-selector', multiple: true },
108
- {
109
- type: 'string',
110
- name: 'name',
111
- header: i18next.t('field.name'),
112
- record: {
113
- editable: true
114
- },
115
- filter: 'search',
116
- sortable: true,
117
- width: 150
118
- },
119
- {
120
- type: 'string',
121
- name: 'description',
122
- header: i18next.t('field.description'),
123
- record: {
124
- editable: true
125
- },
126
- filter: 'search',
127
- width: 200
128
- },
129
- {
130
- type: 'checkbox',
131
- name: 'active',
132
- label: true,
133
- header: i18next.t('field.active'),
134
- record: {
135
- editable: true
136
- },
137
- filter: true,
138
- sortable: true,
139
- width: 60
140
- },
141
- {
142
- type: 'resource-object',
143
- name: 'updater',
144
- header: i18next.t('field.updater'),
145
- record: {
146
- editable: false
147
- },
148
- sortable: true,
149
- width: 120
150
- },
151
- {
152
- type: 'datetime',
153
- name: 'updatedAt',
154
- header: i18next.t('field.updated_at'),
155
- record: {
156
- editable: false
157
- },
158
- sortable: true,
159
- width: 180
160
- }
161
- ],
162
- rows: {
163
- selectable: {
164
- multiple: true
165
- }
166
- },
167
- sorters: [
168
- {
169
- name: 'name'
170
- }
171
- ]
172
- }
173
- }
174
-
175
- async pageUpdated(changes: any, lifecycle: any) {
176
- if (this.active) {
177
- // do something here when this page just became as active
178
- }
179
- }
180
-
181
- async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
182
- const response = await client.query({
183
- query: gql`
184
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
185
- responses: cells(filters: $filters, pagination: $pagination, sortings: $sortings) {
186
- items {
187
- id
188
- name
189
- description
190
- active
191
- updater {
192
- id
193
- name
194
- }
195
- updatedAt
196
- }
197
- total
198
- }
199
- }
200
- `,
201
- variables: {
202
- filters,
203
- pagination: { page, limit },
204
- sortings
205
- }
206
- })
207
-
208
- return {
209
- total: response.data.responses.total || 0,
210
- records: response.data.responses.items || []
211
- }
212
- }
213
-
214
- async _deleteCell() {
215
- if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
216
- const ids = this.grist.selected.map(record => record.id)
217
- if (ids && ids.length > 0) {
218
- const response = await client.mutate({
219
- mutation: gql`
220
- mutation ($ids: [String!]!) {
221
- deleteCells(ids: $ids)
222
- }
223
- `,
224
- variables: {
225
- ids
226
- }
227
- })
228
-
229
- if (!response.errors) {
230
- this.grist.fetch()
231
- notify({
232
- message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
233
- })
234
- }
235
- }
236
- }
237
- }
238
-
239
- async _updateCell() {
240
- let patches = this.grist.dirtyRecords
241
- if (patches && patches.length) {
242
- patches = patches.map(patch => {
243
- let patchField: any = patch.id ? { id: patch.id } : {}
244
- const dirtyFields = patch.__dirtyfields__
245
- for (let key in dirtyFields) {
246
- patchField[key] = dirtyFields[key].after
247
- }
248
- patchField.cuFlag = patch.__dirty__
249
-
250
- return patchField
251
- })
252
-
253
- const response = await client.mutate({
254
- mutation: gql`
255
- mutation ($patches: [CellPatch!]!) {
256
- updateMultipleCell(patches: $patches) {
257
- name
258
- }
259
- }
260
- `,
261
- variables: {
262
- patches
263
- }
264
- })
265
-
266
- if (!response.errors) {
267
- this.grist.fetch()
268
- }
269
- }
270
- }
271
-
272
- async exportHandler() {
273
- const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records
274
- const targetFieldSet = new Set(['id', 'name', 'description', 'active'])
275
-
276
- return exportTargets.map(cell => {
277
- let tempObj = {}
278
- for (const field of targetFieldSet) {
279
- tempObj[field] = cell[field]
280
- }
281
-
282
- return tempObj
283
- })
284
- }
285
-
286
- async importHandler(records) {
287
- const popup = openPopup(
288
- html`
289
- <cell-importer
290
- .cells=${records}
291
- @imported=${() => {
292
- history.back()
293
- this.grist.fetch()
294
- }}
295
- ></cell-importer>
296
- `,
297
- {
298
- backdrop: true,
299
- size: 'large',
300
- title: i18next.t('title.import cell')
301
- }
302
- )
303
-
304
- popup.onclosed = () => {
305
- this.grist.fetch()
306
- }
307
- }
308
- }
@@ -1,87 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/data-grist'
3
-
4
- import gql from 'graphql-tag'
5
- import { css, html, LitElement } from 'lit'
6
- import { property } from 'lit/decorators.js'
7
-
8
- import { client } from '@operato/graphql'
9
- import { i18next } from '@operato/i18n'
10
- import { isMobileDevice } from '@operato/utils'
11
- import { CommonHeaderStyles } from '@operato/styles'
12
-
13
- export class RackImporter extends LitElement {
14
- static styles = [
15
- CommonHeaderStyles,
16
- css`
17
- :host {
18
- display: flex;
19
- flex-direction: column;
20
-
21
- background-color: var(--md-sys-color-surface);
22
- }
23
-
24
- ox-grist {
25
- flex: 1;
26
- }
27
- `
28
- ]
29
-
30
- @property({ type: Array }) racks: any[] = []
31
- @property({ type: Object }) columns = {
32
- list: { fields: ['name', 'description'] },
33
- pagination: { infinite: true },
34
- columns: [
35
- {
36
- type: 'string',
37
- name: 'name',
38
- header: i18next.t('field.name'),
39
- width: 150
40
- },
41
- {
42
- type: 'string',
43
- name: 'description',
44
- header: i18next.t('field.description'),
45
- width: 200
46
- },
47
- {
48
- type: 'checkbox',
49
- name: 'active',
50
- header: i18next.t('field.active'),
51
- width: 60
52
- }
53
- ]
54
- }
55
-
56
- render() {
57
- return html`
58
- <ox-grist
59
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
60
- .config=${this.columns}
61
- .data=${{
62
- records: this.racks
63
- }}
64
- ></ox-grist>
65
-
66
- <div class="footer">
67
- <div filler></div>
68
- <button @click=${this.save.bind(this)} done><md-icon>save</md-icon>${i18next.t('button.save')}</button>
69
- </div>
70
- `
71
- }
72
-
73
- async save() {
74
- const response = await client.mutate({
75
- mutation: gql`
76
- mutation importRacks($racks: [RackPatch!]!) {
77
- importRacks(racks: $racks)
78
- }
79
- `,
80
- variables: { racks: this.racks }
81
- })
82
-
83
- if (response.errors?.length) return
84
-
85
- this.dispatchEvent(new CustomEvent('imported'))
86
- }
87
- }
@@ -1,312 +0,0 @@
1
- import '@operato/data-grist'
2
-
3
- import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
4
- import { PageView, store } from '@operato/shell'
5
- import { css, html } from 'lit'
6
- import { customElement, property, query } from 'lit/decorators.js'
7
- import { ScopedElementsMixin } from '@open-wc/scoped-elements'
8
- import { ColumnConfig, DataGrist, FetchOption } from '@operato/data-grist'
9
- import { client } from '@operato/graphql'
10
- import { i18next, localize } from '@operato/i18n'
11
- import { notify, openPopup } from '@operato/layout'
12
- import { isMobileDevice } from '@operato/utils'
13
-
14
- import { connect } from 'pwa-helpers/connect-mixin'
15
- import gql from 'graphql-tag'
16
-
17
- import { RackImporter } from './rack-importer'
18
-
19
- @customElement('rack-list-page')
20
- export class RackListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
21
- static styles = [
22
- ScrollbarStyles,
23
- CommonGristStyles,
24
- CommonHeaderStyles,
25
- css`
26
- :host {
27
- display: flex;
28
-
29
- width: 100%;
30
-
31
- --grid-record-emphasized-background-color: #8b0000;
32
- --grid-record-emphasized-color: #ff6b6b;
33
- }
34
-
35
- ox-grist {
36
- overflow-y: auto;
37
- flex: 1;
38
- }
39
-
40
- ox-filters-form {
41
- flex: 1;
42
- }
43
- `
44
- ]
45
-
46
- static get scopedElements() {
47
- return {
48
- 'rack-importer': RackImporter
49
- }
50
- }
51
-
52
- @property({ type: Object }) gristConfig: any
53
- @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
54
-
55
- @query('ox-grist') private grist!: DataGrist
56
-
57
- get context() {
58
- return {
59
- title: i18next.t('title.rack list'),
60
- help: 'rack-base/rack',
61
- actions: [
62
- {
63
- title: i18next.t('button.save'),
64
- action: this._updateRack.bind(this),
65
- ...CommonButtonStyles.save
66
- },
67
- {
68
- title: i18next.t('button.delete'),
69
- action: this._deleteRack.bind(this),
70
- ...CommonButtonStyles.delete
71
- }
72
- ],
73
- exportable: {
74
- name: i18next.t('title.rack list'),
75
- data: this.exportHandler.bind(this)
76
- },
77
- importable: {
78
- handler: this.importHandler.bind(this)
79
- }
80
- }
81
- }
82
-
83
- render() {
84
- const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')
85
-
86
- return html`
87
- <ox-grist .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
88
- <div slot="headroom" class="header">
89
- <div class="filters">
90
- <ox-filters-form autofocus></ox-filters-form>
91
-
92
- <div id="modes">
93
- <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>
94
- <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>
95
- <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
96
- </div>
97
- </div>
98
- </div>
99
- </ox-grist>
100
- `
101
- }
102
-
103
- async pageInitialized(lifecycle: any) {
104
- this.gristConfig = {
105
- list: {
106
- fields: ['name', 'description'],
107
- details: ['active', 'updatedAt']
108
- },
109
- columns: [
110
- { type: 'gutter', gutterName: 'sequence' },
111
- { type: 'gutter', gutterName: 'row-selector', multiple: true },
112
- {
113
- type: 'string',
114
- name: 'name',
115
- header: i18next.t('field.name'),
116
- record: {
117
- editable: true
118
- },
119
- filter: 'search',
120
- sortable: true,
121
- width: 150
122
- },
123
- {
124
- type: 'string',
125
- name: 'description',
126
- header: i18next.t('field.description'),
127
- record: {
128
- editable: true
129
- },
130
- filter: 'search',
131
- width: 200
132
- },
133
- {
134
- type: 'checkbox',
135
- name: 'active',
136
- label: true,
137
- header: i18next.t('field.active'),
138
- record: {
139
- editable: true
140
- },
141
- filter: true,
142
- sortable: true,
143
- width: 60
144
- },
145
- {
146
- type: 'resource-object',
147
- name: 'updater',
148
- header: i18next.t('field.updater'),
149
- record: {
150
- editable: false
151
- },
152
- sortable: true,
153
- width: 120
154
- },
155
- {
156
- type: 'datetime',
157
- name: 'updatedAt',
158
- header: i18next.t('field.updated_at'),
159
- record: {
160
- editable: false
161
- },
162
- sortable: true,
163
- width: 180
164
- }
165
- ],
166
- rows: {
167
- selectable: {
168
- multiple: true
169
- }
170
- },
171
- sorters: [
172
- {
173
- name: 'name'
174
- }
175
- ]
176
- }
177
- }
178
-
179
- async pageUpdated(changes: any, lifecycle: any) {
180
- if (this.active) {
181
- // do something here when this page just became as active
182
- }
183
- }
184
-
185
- async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
186
- const response = await client.query({
187
- query: gql`
188
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
189
- responses: racks(filters: $filters, pagination: $pagination, sortings: $sortings) {
190
- items {
191
- id
192
- name
193
- description
194
- active
195
- updater {
196
- id
197
- name
198
- }
199
- updatedAt
200
- }
201
- total
202
- }
203
- }
204
- `,
205
- variables: {
206
- filters,
207
- pagination: { page, limit },
208
- sortings
209
- }
210
- })
211
-
212
- return {
213
- total: response.data.responses.total || 0,
214
- records: response.data.responses.items || []
215
- }
216
- }
217
-
218
- async _deleteRack() {
219
- if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
220
- const ids = this.grist.selected.map(record => record.id)
221
- if (ids && ids.length > 0) {
222
- const response = await client.mutate({
223
- mutation: gql`
224
- mutation ($ids: [String!]!) {
225
- deleteRacks(ids: $ids)
226
- }
227
- `,
228
- variables: {
229
- ids
230
- }
231
- })
232
-
233
- if (!response.errors) {
234
- this.grist.fetch()
235
- notify({
236
- message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
237
- })
238
- }
239
- }
240
- }
241
- }
242
-
243
- async _updateRack() {
244
- let patches = this.grist.dirtyRecords
245
- if (patches && patches.length) {
246
- patches = patches.map(patch => {
247
- let patchField: any = patch.id ? { id: patch.id } : {}
248
- const dirtyFields = patch.__dirtyfields__
249
- for (let key in dirtyFields) {
250
- patchField[key] = dirtyFields[key].after
251
- }
252
- patchField.cuFlag = patch.__dirty__
253
-
254
- return patchField
255
- })
256
-
257
- const response = await client.mutate({
258
- mutation: gql`
259
- mutation ($patches: [RackPatch!]!) {
260
- updateMultipleRack(patches: $patches) {
261
- name
262
- }
263
- }
264
- `,
265
- variables: {
266
- patches
267
- }
268
- })
269
-
270
- if (!response.errors) {
271
- this.grist.fetch()
272
- }
273
- }
274
- }
275
-
276
- async exportHandler() {
277
- const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records
278
- const targetFieldSet = new Set(['id', 'name', 'description', 'active'])
279
-
280
- return exportTargets.map(rack => {
281
- let tempObj = {}
282
- for (const field of targetFieldSet) {
283
- tempObj[field] = rack[field]
284
- }
285
-
286
- return tempObj
287
- })
288
- }
289
-
290
- async importHandler(records) {
291
- const popup = openPopup(
292
- html`
293
- <rack-importer
294
- .racks=${records}
295
- @imported=${() => {
296
- history.back()
297
- this.grist.fetch()
298
- }}
299
- ></rack-importer>
300
- `,
301
- {
302
- backdrop: true,
303
- size: 'large',
304
- title: i18next.t('title.import rack')
305
- }
306
- )
307
-
308
- popup.onclosed = () => {
309
- this.grist.fetch()
310
- }
311
- }
312
- }
package/client/route.ts DELETED
@@ -1,11 +0,0 @@
1
- export default function route(page: string) {
2
- switch (page) {
3
- case 'cell-list-page':
4
- import('./pages/cell/cell-list-page')
5
- return page
6
-
7
- case 'rack-list':
8
- import('./pages/rack/rack-list-page')
9
- return page
10
- }
11
- }
package/server/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './service'