@things-factory/dataset 6.1.61 → 6.1.63
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/client/components/data-entry-form.ts +3 -0
- package/dist-client/components/data-entry-form.js +3 -0
- package/dist-client/components/data-entry-form.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/create-data-sample.js +53 -0
- package/dist-server/controllers/create-data-sample.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/server/controllers/create-data-sample.ts +65 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/dataset",
|
3
|
-
"version": "6.1.
|
3
|
+
"version": "6.1.63",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "dist-client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -40,15 +40,15 @@
|
|
40
40
|
"@things-factory/aws-base": "^6.1.48",
|
41
41
|
"@things-factory/board-service": "^6.1.55",
|
42
42
|
"@things-factory/env": "^6.1.48",
|
43
|
-
"@things-factory/organization": "^6.1.
|
43
|
+
"@things-factory/organization": "^6.1.63",
|
44
44
|
"@things-factory/scheduler-client": "^6.1.48",
|
45
45
|
"@things-factory/shell": "^6.1.48",
|
46
46
|
"@things-factory/work-shift": "^6.1.48",
|
47
|
-
"@things-factory/worklist": "^6.1.
|
47
|
+
"@things-factory/worklist": "^6.1.63",
|
48
48
|
"cron-parser": "^4.3.0",
|
49
49
|
"moment-timezone": "^0.5.40",
|
50
50
|
"simple-statistics": "^7.8.3",
|
51
51
|
"statistics": "^3.3.0"
|
52
52
|
},
|
53
|
-
"gitHead": "
|
53
|
+
"gitHead": "8fe392456b1fe6a06df7eaae92be3ef00ce5a743"
|
54
54
|
}
|
@@ -12,6 +12,7 @@ import { NewDataSample } from '../service/data-sample/data-sample-type'
|
|
12
12
|
import { DataSet } from '../service/data-set/data-set'
|
13
13
|
import { DataUseCase } from './data-use-case'
|
14
14
|
import { Activity } from '@things-factory/worklist'
|
15
|
+
import { Attachment, createAttachment } from '@things-factory/attachment-base'
|
15
16
|
|
16
17
|
import { issue } from '@things-factory/worklist/dist-server/controllers/activity-instance/issue'
|
17
18
|
|
@@ -103,6 +104,64 @@ export async function createDataSample(dataSample: NewDataSample, context: Resol
|
|
103
104
|
}
|
104
105
|
})
|
105
106
|
|
107
|
+
/*
|
108
|
+
pre-processing for file attachment.
|
109
|
+
currently only support type of [FileUpload].
|
110
|
+
If [FileUpload[]] type needed, add 'files' type for dataset
|
111
|
+
*/
|
112
|
+
|
113
|
+
const data = dataSample.data
|
114
|
+
const attachments = []
|
115
|
+
|
116
|
+
for (let dataItem of dataItems) {
|
117
|
+
if (dataItem.type == 'file') {
|
118
|
+
const tag = dataItem.tag
|
119
|
+
const filesArray = data[tag]
|
120
|
+
|
121
|
+
if (tag && filesArray && filesArray.length > 0) {
|
122
|
+
let pathsArray = []
|
123
|
+
|
124
|
+
for (let files of filesArray) {
|
125
|
+
let paths = []
|
126
|
+
|
127
|
+
for (let file of files) {
|
128
|
+
if (file) {
|
129
|
+
const attachment = await createAttachment(
|
130
|
+
null,
|
131
|
+
{
|
132
|
+
attachment: {
|
133
|
+
file: file.file,
|
134
|
+
refType: DataSample.name
|
135
|
+
}
|
136
|
+
},
|
137
|
+
context
|
138
|
+
)
|
139
|
+
|
140
|
+
const fetched = await tx.getRepository(Attachment).findOneBy({ id: attachment.id })
|
141
|
+
if (fetched) {
|
142
|
+
attachments.push(fetched)
|
143
|
+
paths.push({
|
144
|
+
id: fetched.id,
|
145
|
+
mimetype: fetched.mimetype,
|
146
|
+
name: fetched.name,
|
147
|
+
fullpath: fetched.fullpath
|
148
|
+
})
|
149
|
+
} else {
|
150
|
+
throw `Failed to save file(${attachment.name})`
|
151
|
+
}
|
152
|
+
} else {
|
153
|
+
paths.push(null)
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
pathsArray.push(paths)
|
158
|
+
}
|
159
|
+
|
160
|
+
data[tag] = pathsArray
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
106
165
|
const result = await tx.getRepository(DataSample).save({
|
107
166
|
...old,
|
108
167
|
name: dataSet.name,
|
@@ -124,6 +183,12 @@ export async function createDataSample(dataSample: NewDataSample, context: Resol
|
|
124
183
|
updater: user
|
125
184
|
})
|
126
185
|
|
186
|
+
/* post-process for for file attachment. */
|
187
|
+
if (attachments.length > 0) {
|
188
|
+
attachments.forEach(attachment => (attachment.refId = result.id))
|
189
|
+
tx.getRepository(Attachment).save(attachments)
|
190
|
+
}
|
191
|
+
|
127
192
|
if (ooc || oos) {
|
128
193
|
const dataOoc = await tx.getRepository(DataOoc).save({
|
129
194
|
...result,
|