@things-factory/rack-base 8.0.37 → 9.0.0-9.0.0-beta.59.0
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/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +2 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/cell/cell-importer.d.ts +23 -0
- package/dist-client/pages/cell/cell-importer.js +94 -0
- package/dist-client/pages/cell/cell-importer.js.map +1 -0
- package/dist-client/pages/cell/cell-list-page.d.ts +54 -0
- package/dist-client/pages/cell/cell-list-page.js +290 -0
- package/dist-client/pages/cell/cell-list-page.js.map +1 -0
- package/dist-client/pages/rack/rack-importer.d.ts +23 -0
- package/dist-client/pages/rack/rack-importer.js +94 -0
- package/dist-client/pages/rack/rack-importer.js.map +1 -0
- package/dist-client/pages/rack/rack-list-page.d.ts +54 -0
- package/dist-client/pages/rack/rack-list-page.js +294 -0
- package/dist-client/pages/rack/rack-list-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +11 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -8
- package/client/bootstrap.ts +0 -1
- package/client/pages/cell/cell-importer.ts +0 -87
- package/client/pages/cell/cell-list-page.ts +0 -308
- package/client/pages/rack/rack-importer.ts +0 -87
- package/client/pages/rack/rack-list-page.ts +0 -312
- package/client/route.ts +0 -11
- package/server/index.ts +0 -1
- package/server/migrations/index.ts +0 -9
- package/server/routes.ts +0 -26
- package/server/service/cell/cell-mutation.ts +0 -133
- package/server/service/cell/cell-query.ts +0 -50
- package/server/service/cell/cell-type.ts +0 -96
- package/server/service/cell/cell.ts +0 -112
- package/server/service/cell/index.ts +0 -6
- package/server/service/index.ts +0 -22
- package/server/service/rack/index.ts +0 -6
- package/server/service/rack/rack-mutation.ts +0 -133
- package/server/service/rack/rack-query.ts +0 -64
- package/server/service/rack/rack-type.ts +0 -54
- package/server/service/rack/rack.ts +0 -76
- /package/{client/index.ts → dist-client/index.d.ts} +0 -0
|
@@ -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
package/server/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './service'
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const glob = require('glob')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
export var migrations = []
|
|
5
|
-
|
|
6
|
-
glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
|
|
7
|
-
if (file.indexOf('index.js') !== -1) return
|
|
8
|
-
migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
|
|
9
|
-
})
|
package/server/routes.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
|
|
2
|
-
/*
|
|
3
|
-
* can add global public routes to application (auth not required, tenancy not required)
|
|
4
|
-
*
|
|
5
|
-
* ex) routes.get('/path', async(context, next) => {})
|
|
6
|
-
* ex) routes.post('/path', async(context, next) => {})
|
|
7
|
-
*/
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
|
|
11
|
-
/*
|
|
12
|
-
* can add global private routes to application (auth required, tenancy not required)
|
|
13
|
-
*/
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
|
|
17
|
-
/*
|
|
18
|
-
* can add domain public routes to application (auth not required, tenancy required)
|
|
19
|
-
*/
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
|
|
23
|
-
/*
|
|
24
|
-
* can add domain private routes to application (auth required, tenancy required)
|
|
25
|
-
*/
|
|
26
|
-
})
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
-
import { In } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { deleteAttachmentsByRef } from '@things-factory/attachment-base'
|
|
5
|
-
|
|
6
|
-
import { Cell } from './cell'
|
|
7
|
-
import { CellPatch, NewCell } from './cell-type'
|
|
8
|
-
|
|
9
|
-
@Resolver(Cell)
|
|
10
|
-
export class CellMutation {
|
|
11
|
-
@Directive('@transaction')
|
|
12
|
-
@Mutation(returns => Cell, { description: 'To create new Cell' })
|
|
13
|
-
async createCell(@Arg('cell') cell: NewCell, @Ctx() context: ResolverContext): Promise<Cell> {
|
|
14
|
-
const { domain, user, tx } = context.state
|
|
15
|
-
|
|
16
|
-
return await tx.getRepository(Cell).save({
|
|
17
|
-
...cell,
|
|
18
|
-
domain,
|
|
19
|
-
creator: user,
|
|
20
|
-
updater: user
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@Directive('@transaction')
|
|
25
|
-
@Mutation(returns => Cell, { description: 'To modify Cell information' })
|
|
26
|
-
async updateCell(
|
|
27
|
-
@Arg('id') id: string,
|
|
28
|
-
@Arg('patch') patch: CellPatch,
|
|
29
|
-
@Ctx() context: ResolverContext
|
|
30
|
-
): Promise<Cell> {
|
|
31
|
-
const { domain, user, tx } = context.state
|
|
32
|
-
|
|
33
|
-
const repository = tx.getRepository(Cell)
|
|
34
|
-
const cell = await repository.findOne({
|
|
35
|
-
where: { domain: { id: domain.id }, id }
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
return await repository.save({
|
|
39
|
-
...cell,
|
|
40
|
-
...patch,
|
|
41
|
-
updater: user
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Directive('@transaction')
|
|
46
|
-
@Mutation(returns => [Cell], { description: "To modify multiple Cells' information" })
|
|
47
|
-
async updateMultipleCell(
|
|
48
|
-
@Arg('patches', type => [CellPatch]) patches: CellPatch[],
|
|
49
|
-
@Ctx() context: ResolverContext
|
|
50
|
-
): Promise<Cell[]> {
|
|
51
|
-
const { domain, user, tx } = context.state
|
|
52
|
-
|
|
53
|
-
let results = []
|
|
54
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
55
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
56
|
-
const cellRepo = tx.getRepository(Cell)
|
|
57
|
-
|
|
58
|
-
if (_createRecords.length > 0) {
|
|
59
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
60
|
-
const newRecord = _createRecords[i]
|
|
61
|
-
|
|
62
|
-
const result = await cellRepo.save({
|
|
63
|
-
...newRecord,
|
|
64
|
-
domain,
|
|
65
|
-
creator: user,
|
|
66
|
-
updater: user
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
results.push({ ...result, cuFlag: '+' })
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (_updateRecords.length > 0) {
|
|
74
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
75
|
-
const updateRecord = _updateRecords[i]
|
|
76
|
-
const cell = await cellRepo.findOneBy({ id: updateRecord.id })
|
|
77
|
-
|
|
78
|
-
const result = await cellRepo.save({
|
|
79
|
-
...cell,
|
|
80
|
-
...updateRecord,
|
|
81
|
-
updater: user
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return results
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
@Directive('@transaction')
|
|
92
|
-
@Mutation(returns => Boolean, { description: 'To delete Cell' })
|
|
93
|
-
async deleteCell(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
94
|
-
const { domain, tx } = context.state
|
|
95
|
-
|
|
96
|
-
await tx.getRepository(Cell).delete({ domain: { id: domain.id }, id })
|
|
97
|
-
await deleteAttachmentsByRef(null, { refBys: [id] }, context)
|
|
98
|
-
|
|
99
|
-
return true
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@Directive('@transaction')
|
|
103
|
-
@Mutation(returns => Boolean, { description: 'To delete multiple Cells' })
|
|
104
|
-
async deleteCells(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
|
|
105
|
-
const { domain, tx } = context.state
|
|
106
|
-
|
|
107
|
-
await tx.getRepository(Cell).delete({
|
|
108
|
-
domain: { id: domain.id },
|
|
109
|
-
id: In(ids)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
await deleteAttachmentsByRef(null, { refBys: ids }, context)
|
|
113
|
-
|
|
114
|
-
return true
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@Directive('@transaction')
|
|
118
|
-
@Mutation(returns => Boolean, { description: 'To import multiple Cells' })
|
|
119
|
-
async importCells(
|
|
120
|
-
@Arg('cells', type => [CellPatch]) cells: CellPatch[],
|
|
121
|
-
@Ctx() context: ResolverContext
|
|
122
|
-
): Promise<boolean> {
|
|
123
|
-
const { domain, tx } = context.state
|
|
124
|
-
|
|
125
|
-
await Promise.all(
|
|
126
|
-
cells.map(async (cell: CellPatch) => {
|
|
127
|
-
const createdCell: Cell = await tx.getRepository(Cell).save({ domain, ...cell })
|
|
128
|
-
})
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
return true
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
5
|
-
|
|
6
|
-
import { Cell } from './cell'
|
|
7
|
-
import { CellList } from './cell-type'
|
|
8
|
-
|
|
9
|
-
@Resolver(Cell)
|
|
10
|
-
export class CellQuery {
|
|
11
|
-
@Query(returns => Cell!, { nullable: true, description: 'To fetch a Cell' })
|
|
12
|
-
async cell(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Cell> {
|
|
13
|
-
const { domain } = context.state
|
|
14
|
-
|
|
15
|
-
return await getRepository(Cell).findOne({
|
|
16
|
-
where: { domain: { id: domain.id }, id }
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@Query(returns => CellList, { description: 'To fetch multiple Cells' })
|
|
21
|
-
async cells(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CellList> {
|
|
22
|
-
const { domain } = context.state
|
|
23
|
-
|
|
24
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
25
|
-
domain,
|
|
26
|
-
params,
|
|
27
|
-
repository: await getRepository(Cell),
|
|
28
|
-
searchables: ['name', 'description']
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
32
|
-
|
|
33
|
-
return { items, total }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@FieldResolver(type => Domain)
|
|
37
|
-
async domain(@Root() cell: Cell): Promise<Domain> {
|
|
38
|
-
return await getRepository(Domain).findOneBy({ id: cell.domainId })
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@FieldResolver(type => User)
|
|
42
|
-
async updater(@Root() cell: Cell): Promise<User> {
|
|
43
|
-
return await getRepository(User).findOneBy({ id: cell.updaterId })
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@FieldResolver(type => User)
|
|
47
|
-
async creator(@Root() cell: Cell): Promise<User> {
|
|
48
|
-
return await getRepository(User).findOneBy({ id: cell.creatorId })
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { Cell } from './cell'
|
|
4
|
-
|
|
5
|
-
@InputType()
|
|
6
|
-
export class NewCell {
|
|
7
|
-
@Field({ nullable: true })
|
|
8
|
-
stationCd: string
|
|
9
|
-
|
|
10
|
-
@Field()
|
|
11
|
-
equipCd: string
|
|
12
|
-
|
|
13
|
-
@Field()
|
|
14
|
-
cellCd: string
|
|
15
|
-
|
|
16
|
-
@Field()
|
|
17
|
-
indCd: string
|
|
18
|
-
|
|
19
|
-
@Field()
|
|
20
|
-
channelNo: string
|
|
21
|
-
|
|
22
|
-
@Field()
|
|
23
|
-
panNo: string
|
|
24
|
-
|
|
25
|
-
@Field({ nullable: true })
|
|
26
|
-
equipZone?: string
|
|
27
|
-
|
|
28
|
-
@Field({ nullable: true })
|
|
29
|
-
sideCd?: string
|
|
30
|
-
|
|
31
|
-
@Field({ nullable: true })
|
|
32
|
-
cellSeq?: number
|
|
33
|
-
|
|
34
|
-
@Field({ nullable: true })
|
|
35
|
-
printerCd?: string
|
|
36
|
-
|
|
37
|
-
@Field({ nullable: true })
|
|
38
|
-
activeFlag?: boolean
|
|
39
|
-
|
|
40
|
-
@Field({ nullable: true })
|
|
41
|
-
status?: string
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@InputType()
|
|
45
|
-
export class CellPatch {
|
|
46
|
-
@Field(type => ID, { nullable: true })
|
|
47
|
-
id?: string
|
|
48
|
-
|
|
49
|
-
@Field({ nullable: true })
|
|
50
|
-
stationCd?: string
|
|
51
|
-
|
|
52
|
-
@Field({ nullable: true })
|
|
53
|
-
equipCd?: string
|
|
54
|
-
|
|
55
|
-
@Field({ nullable: true })
|
|
56
|
-
cellCd?: string
|
|
57
|
-
|
|
58
|
-
@Field({ nullable: true })
|
|
59
|
-
indCd?: string
|
|
60
|
-
|
|
61
|
-
@Field({ nullable: true })
|
|
62
|
-
channelNo?: string
|
|
63
|
-
|
|
64
|
-
@Field({ nullable: true })
|
|
65
|
-
panNo?: string
|
|
66
|
-
|
|
67
|
-
@Field({ nullable: true })
|
|
68
|
-
equipZone?: string
|
|
69
|
-
|
|
70
|
-
@Field({ nullable: true })
|
|
71
|
-
sideCd?: string
|
|
72
|
-
|
|
73
|
-
@Field({ nullable: true })
|
|
74
|
-
cellSeq?: number
|
|
75
|
-
|
|
76
|
-
@Field({ nullable: true })
|
|
77
|
-
printerCd?: string
|
|
78
|
-
|
|
79
|
-
@Field({ nullable: true })
|
|
80
|
-
activeFlag?: boolean
|
|
81
|
-
|
|
82
|
-
@Field({ nullable: true })
|
|
83
|
-
status?: string
|
|
84
|
-
|
|
85
|
-
@Field({ nullable: true })
|
|
86
|
-
cuFlag?: string
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@ObjectType()
|
|
90
|
-
export class CellList {
|
|
91
|
-
@Field(type => [Cell])
|
|
92
|
-
items: Cell[]
|
|
93
|
-
|
|
94
|
-
@Field(type => Int)
|
|
95
|
-
total: number
|
|
96
|
-
}
|