@things-factory/dataset 5.0.0-alpha.40 → 5.0.0-alpha.43
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/README.md +4 -8
- package/assets/data-samples.jpg +0 -0
- package/client/pages/data-ooc/data-ooc-list-page.js +43 -48
- package/client/pages/data-report/data-report-embed-page.js +113 -0
- package/client/pages/data-report/data-report-list-page.js +12 -10
- package/client/pages/data-report/jasper-report-oocs-page.js +120 -0
- package/client/pages/data-report/jasper-report-samples-crosstab-page.js +120 -0
- package/client/pages/data-report/jasper-report-samples-page.js +120 -0
- package/client/pages/data-sample/data-sample-list-page.js +43 -48
- package/client/pages/data-sensor/data-sensor-list-page.js +37 -53
- package/client/pages/data-set/data-set-list-page.js +30 -45
- package/client/route.js +16 -0
- package/config/config.development.js +13 -0
- package/config/config.production.js +1 -0
- package/dist-server/controllers/jasper-report.js +156 -0
- package/dist-server/controllers/jasper-report.js.map +1 -0
- package/dist-server/routes.js +4 -0
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/data-set/data-set-mutation.js +37 -7
- package/dist-server/service/data-set/data-set-mutation.js.map +1 -1
- package/dist-server/service/data-set/data-set-query.js +23 -0
- package/dist-server/service/data-set/data-set-query.js.map +1 -1
- package/dist-server/service/data-set/data-set-type.js +13 -4
- package/dist-server/service/data-set/data-set-type.js.map +1 -1
- package/dist-server/service/data-set/data-set.js +4 -0
- package/dist-server/service/data-set/data-set.js.map +1 -1
- package/package.json +17 -16
- package/server/controllers/jasper-report.ts +170 -0
- package/server/routes.ts +4 -0
- package/server/service/data-set/data-set-mutation.ts +51 -8
- package/server/service/data-set/data-set-query.ts +21 -0
- package/server/service/data-set/data-set-type.ts +7 -0
- package/server/service/data-set/data-set.ts +3 -0
- package/things-factory.config.js +17 -1
- package/translations/en.json +1 -0
- package/translations/ko.json +1 -0
@@ -3,6 +3,7 @@ import { EntityManager, In } from 'typeorm'
|
|
3
3
|
import uuid from 'uuid/v4'
|
4
4
|
|
5
5
|
import { Domain } from '@things-factory/shell'
|
6
|
+
import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
|
6
7
|
|
7
8
|
import { DataItem } from '../data-item/data-item'
|
8
9
|
import { DataSet } from './data-set'
|
@@ -16,12 +17,16 @@ export class DataSetMutation {
|
|
16
17
|
async createDataSet(@Arg('dataSet') dataSet: NewDataSet, @Ctx() context: any): Promise<DataSet> {
|
17
18
|
const { domain, user, tx } = context.state
|
18
19
|
|
19
|
-
|
20
|
+
const result = await tx.getRepository(DataSet).save({
|
20
21
|
...dataSet,
|
21
22
|
domain,
|
22
23
|
creator: user,
|
23
24
|
updater: user
|
24
25
|
})
|
26
|
+
|
27
|
+
await this._createAttachment(context, dataSet.reportTemplate, { refId: result.id, cuFlag: '+' })
|
28
|
+
|
29
|
+
return result
|
25
30
|
}
|
26
31
|
|
27
32
|
@Directive('@privilege(category: "data-set", privilege: "mutation", domainOwnerGranted: true)')
|
@@ -35,11 +40,15 @@ export class DataSetMutation {
|
|
35
40
|
where: { domain, id }
|
36
41
|
})
|
37
42
|
|
38
|
-
|
43
|
+
const result = await repository.save({
|
39
44
|
...dataSet,
|
40
45
|
...patch,
|
41
46
|
updater: user
|
42
47
|
})
|
48
|
+
|
49
|
+
await this._createAttachment(context, dataSet.reportTemplate, { refId: result.id, cuFlag: 'M' })
|
50
|
+
|
51
|
+
return result
|
43
52
|
}
|
44
53
|
|
45
54
|
@Directive('@privilege(category: "data-set", privilege: "mutation", domainOwnerGranted: true)')
|
@@ -57,6 +66,7 @@ export class DataSetMutation {
|
|
57
66
|
const dataSetRepo = tx.getRepository(DataSet)
|
58
67
|
|
59
68
|
if (_createRecords.length > 0) {
|
69
|
+
const cuFlag = '+'
|
60
70
|
for (let i = 0; i < _createRecords.length; i++) {
|
61
71
|
const newRecord = _createRecords[i]
|
62
72
|
|
@@ -67,11 +77,14 @@ export class DataSetMutation {
|
|
67
77
|
updater: user
|
68
78
|
})
|
69
79
|
|
70
|
-
|
80
|
+
await this._createAttachment(context, newRecord.reportTemplate, { refId: result.id, cuFlag })
|
81
|
+
|
82
|
+
results.push({ ...result, cuFlag })
|
71
83
|
}
|
72
84
|
}
|
73
85
|
|
74
86
|
if (_updateRecords.length > 0) {
|
87
|
+
const cuFlag = 'M'
|
75
88
|
for (let i = 0; i < _updateRecords.length; i++) {
|
76
89
|
const newRecord = _updateRecords[i]
|
77
90
|
const dataSet = await dataSetRepo.findOne(newRecord.id)
|
@@ -82,7 +95,9 @@ export class DataSetMutation {
|
|
82
95
|
updater: user
|
83
96
|
})
|
84
97
|
|
85
|
-
|
98
|
+
await this._createAttachment(context, newRecord.reportTemplate, { refId: result.id, cuFlag })
|
99
|
+
|
100
|
+
results.push({ ...result, cuFlag })
|
86
101
|
}
|
87
102
|
}
|
88
103
|
|
@@ -96,6 +111,7 @@ export class DataSetMutation {
|
|
96
111
|
const { domain, tx } = context.state
|
97
112
|
|
98
113
|
await tx.getRepository(DataSet).delete({ domain, id })
|
114
|
+
await deleteAttachmentsByRef(null, { refBys: [`report-${id}`] }, context)
|
99
115
|
return true
|
100
116
|
}
|
101
117
|
|
@@ -110,6 +126,8 @@ export class DataSetMutation {
|
|
110
126
|
id: In(ids)
|
111
127
|
})
|
112
128
|
|
129
|
+
await deleteAttachmentsByRef(null, { refBys: ids.map(id => `report-${id}`) } , context)
|
130
|
+
|
113
131
|
return true
|
114
132
|
}
|
115
133
|
|
@@ -169,10 +187,16 @@ export class DataSetMutation {
|
|
169
187
|
name: dataItem.name,
|
170
188
|
description: dataItem.description,
|
171
189
|
sequence: dataItem.sequence,
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
190
|
+
tag: dataItem.tag,
|
191
|
+
active: dataItem.active,
|
192
|
+
type: dataItem.type,
|
193
|
+
quota: dataItem.quota,
|
194
|
+
spec: dataItem.spec,
|
195
|
+
unit: dataItem.unit,
|
196
|
+
options: dataItem.options,
|
197
|
+
hidden: dataItem.hidden,
|
198
|
+
// connection: dataItem.connection,
|
199
|
+
// params: dataItem.params,
|
176
200
|
domain,
|
177
201
|
creator: user,
|
178
202
|
updater: user
|
@@ -203,4 +227,23 @@ export class DataSetMutation {
|
|
203
227
|
return dataSet
|
204
228
|
})
|
205
229
|
}
|
230
|
+
|
231
|
+
|
232
|
+
async _createAttachment(context, attachment, { refId, cuFlag }) {
|
233
|
+
if (attachment) {
|
234
|
+
const attachmentRef = 'report-' + refId
|
235
|
+
cuFlag == 'M' && await deleteAttachmentsByRef(null, { refBys: [attachmentRef] }, context)
|
236
|
+
await createAttachment(
|
237
|
+
null,
|
238
|
+
{
|
239
|
+
attachment: {
|
240
|
+
file: attachment,
|
241
|
+
refBy: attachmentRef
|
242
|
+
}
|
243
|
+
},
|
244
|
+
context
|
245
|
+
)
|
246
|
+
}
|
247
|
+
}
|
206
248
|
}
|
249
|
+
|
@@ -4,6 +4,7 @@ import { getRepository } from 'typeorm'
|
|
4
4
|
import { Role, User } from '@things-factory/auth-base'
|
5
5
|
import { Board } from '@things-factory/board-service'
|
6
6
|
import { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
|
7
|
+
import { Attachment } from '@things-factory/attachment-base'
|
7
8
|
|
8
9
|
import { DataItem } from '../data-item/data-item'
|
9
10
|
import { DataSample } from '../data-sample/data-sample'
|
@@ -52,6 +53,10 @@ export class DataSetQuery {
|
|
52
53
|
})
|
53
54
|
const roles = user.roles.filter(role => role.domainId === domain.id).map(role => role.id)
|
54
55
|
|
56
|
+
if (!roles.length) {
|
57
|
+
return { items: [], total: 0 }
|
58
|
+
}
|
59
|
+
|
55
60
|
const queryBuilder = getQueryBuilderFromListParams({
|
56
61
|
repository: getRepository(DataSet),
|
57
62
|
params,
|
@@ -78,6 +83,10 @@ export class DataSetQuery {
|
|
78
83
|
})
|
79
84
|
const roles = user.roles.filter(role => role.domainId === domain.id).map(role => role.id)
|
80
85
|
|
86
|
+
if (!roles.length) {
|
87
|
+
return { items: [], total: 0 }
|
88
|
+
}
|
89
|
+
|
81
90
|
const queryBuilder = getQueryBuilderFromListParams({
|
82
91
|
repository: getRepository(DataSet),
|
83
92
|
params,
|
@@ -183,4 +192,16 @@ export class DataSetQuery {
|
|
183
192
|
|
184
193
|
return interval.prev().toDate()
|
185
194
|
}
|
195
|
+
|
196
|
+
@FieldResolver(type => String)
|
197
|
+
async reportTemplate(@Root() dataset: DataSet): Promise<string | undefined> {
|
198
|
+
const attachment: Attachment = await getRepository(Attachment).findOne({
|
199
|
+
where: {
|
200
|
+
domain: dataset.domainId,
|
201
|
+
refBy: `report-${dataset.id}`
|
202
|
+
}
|
203
|
+
})
|
204
|
+
|
205
|
+
return attachment?.path
|
206
|
+
}
|
186
207
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
2
|
+
import { FileUpload, GraphQLUpload } from 'graphql-upload'
|
2
3
|
|
3
4
|
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
4
5
|
|
@@ -53,6 +54,9 @@ export class NewDataSet {
|
|
53
54
|
|
54
55
|
@Field({ nullable: true })
|
55
56
|
reportView?: string
|
57
|
+
|
58
|
+
@Field(type => GraphQLUpload, { nullable: true })
|
59
|
+
reportTemplate?: FileUpload
|
56
60
|
}
|
57
61
|
|
58
62
|
@InputType()
|
@@ -108,6 +112,9 @@ export class DataSetPatch {
|
|
108
112
|
@Field({ nullable: true })
|
109
113
|
reportView?: string
|
110
114
|
|
115
|
+
@Field(type => GraphQLUpload, { nullable: true })
|
116
|
+
reportTemplate?: FileUpload
|
117
|
+
|
111
118
|
@Field()
|
112
119
|
cuFlag: string
|
113
120
|
}
|
package/things-factory.config.js
CHANGED
@@ -27,7 +27,23 @@ export default {
|
|
27
27
|
{
|
28
28
|
tagname: 'data-report-list-page',
|
29
29
|
page: 'data-report-list'
|
30
|
-
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
tagname: 'jasper-report-samples-page',
|
33
|
+
page: 'jasper-report-samples'
|
34
|
+
},
|
35
|
+
{
|
36
|
+
tagname: 'jasper-report-samples-crosstab-page',
|
37
|
+
page: 'jasper-report-samples-crosstab'
|
38
|
+
},
|
39
|
+
{
|
40
|
+
tagname: 'jasper-report-oocs-page',
|
41
|
+
page: 'jasper-report-oocs'
|
42
|
+
},
|
43
|
+
{
|
44
|
+
tagname: 'data-report-embed-page',
|
45
|
+
page: 'data-report-embed'
|
46
|
+
},
|
31
47
|
],
|
32
48
|
bootstrap
|
33
49
|
}
|
package/translations/en.json
CHANGED
package/translations/ko.json
CHANGED