@things-factory/dataset 6.0.0-alpha.6 → 6.0.0-alpha.8
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 +23 -19
- package/assets/diagram.jpg +0 -0
- package/client/pages/data-archive/data-archive-list-page.js +290 -0
- package/client/pages/data-archive/data-archive-request-popup.js +180 -0
- package/client/pages/data-key-set/data-key-set-list-page.js +1 -1
- package/client/pages/data-report/data-report-list-page.js +2 -2
- package/client/pages/data-set/data-set-list-page.js +1 -1
- package/client/route.js +4 -0
- package/config/config.development.js +11 -0
- package/config/config.production.js +11 -0
- package/dist-server/controllers/jasper-report.js +4 -4
- package/dist-server/controllers/jasper-report.js.map +1 -1
- package/dist-server/controllers/shiny-report.js +4 -7
- package/dist-server/controllers/shiny-report.js.map +1 -1
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/data-archive/data-archive-mutation.js +227 -0
- package/dist-server/service/data-archive/data-archive-mutation.js.map +1 -0
- package/dist-server/service/data-archive/data-archive-query.js +83 -0
- package/dist-server/service/data-archive/data-archive-query.js.map +1 -0
- package/dist-server/service/data-archive/data-archive-type.js +74 -0
- package/dist-server/service/data-archive/data-archive-type.js.map +1 -0
- package/dist-server/service/data-archive/data-archive.js +79 -0
- package/dist-server/service/data-archive/data-archive.js.map +1 -0
- package/dist-server/service/data-archive/index.js +9 -0
- package/dist-server/service/data-archive/index.js.map +1 -0
- package/dist-server/service/data-set/data-set-mutation.js +1 -1
- package/dist-server/service/data-set/data-set-mutation.js.map +1 -1
- package/dist-server/service/index.js +5 -2
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/config-resolver.js +33 -0
- package/dist-server/utils/config-resolver.js.map +1 -0
- package/dist-server/utils/index.js +5 -0
- package/dist-server/utils/index.js.map +1 -0
- package/helps/dataset/data-archive.md +9 -0
- package/helps/dataset/data-entry-list.md +2 -0
- package/helps/dataset/data-key-set.md +10 -0
- package/helps/dataset/data-ooc.md +11 -0
- package/helps/dataset/data-report-list.md +4 -0
- package/helps/dataset/data-sample-search.md +2 -0
- package/helps/dataset/data-sample.md +11 -0
- package/helps/dataset/data-sensor.md +13 -0
- package/helps/dataset/data-set.md +28 -0
- package/helps/dataset/ui/data-item-list.md +19 -0
- package/helps/dataset/ui/data-key-item-list.md +2 -0
- package/package.json +8 -8
- package/server/controllers/jasper-report.ts +5 -4
- package/server/controllers/shiny-report.ts +4 -7
- package/server/routes.ts +1 -0
- package/server/service/data-archive/data-archive-mutation.ts +282 -0
- package/server/service/data-archive/data-archive-query.ts +55 -0
- package/server/service/data-archive/data-archive-type.ts +49 -0
- package/server/service/data-archive/data-archive.ts +69 -0
- package/server/service/data-archive/index.ts +6 -0
- package/server/service/data-set/data-set-mutation.ts +1 -1
- package/server/service/index.ts +5 -2
- package/server/utils/config-resolver.ts +29 -0
- package/server/utils/index.ts +1 -0
- package/things-factory.config.js +4 -0
- package/translations/en.json +18 -3
- package/translations/ko.json +15 -1
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
package/README.md
CHANGED
@@ -1,11 +1,27 @@
|
|
1
1
|
# dataset
|
2
|
-
##
|
2
|
+
## dataset relation diagram
|
3
|
+

|
4
|
+
- data_sets 하나가 여러 data_items 를 갖습니다. data_sets와 data_items 조합으로 CCP 항목들을 정의합니다.
|
5
|
+
- data_sets는 또한 data_key_sets를 참고할 수 있습니다. data_key_sets에서는 data_samples, data_oocs의 조회 인덱스를 위한 key(key_01~key_05)를 정의합니다. data_samples, data_oocs 데이타 생성 시점에, data 컬럼 값으로 부터 별도 컬럼(key_##)에 해당 값을 저장합니다.
|
6
|
+
- data_set_histories에는 data_sets의 변경 내역이 추가됩니다. data_sets의 id는 data_set_histories에 original_id로 추가됩니다. data_set_histories를 사용하려면 original_id 와 version이 필요합니다.
|
7
|
+
- data_sensors에는 자동 수집되는 디바이스 정보를 정의합니다. data_sets를 참고하여 CCP를 관리하도록 합니다.
|
8
|
+
- data_samples에는 입력받은 실제 데이터가 저장됩니다.
|
9
|
+
- data_oocs에는 data_sets의 CCP 스펙을 벗어나는 경우, data_samples의 데이터를 복사하여 추가됩니다.
|
10
|
+
- data_archives에는 다운로드 받기 위한 요청 정보 및 상태가 저장됩니다.
|
11
|
+
|
12
|
+
## Architecture for collecting data samples
|
3
13
|

|
14
|
+
data_samples, data_oocs, data_set_histories의 테이블 변경 사항은 Database CDC로 Kafka에 전송 및 저장되고 토픽별로 다음의 lambda 들이 트리거되어 S3로 저장합니다. 이 S3 데이터는 Glue Crawler, Glue Data Catalog를 거쳐 Athena에서 조회할 수 있습니다. hive 스타일의 S3 파티션 정보들을 업데이트 하는 작업이 스케줄링되어 작동하고, 파티션 정보가 업데이트 된 S3파일들이 Athena에서 조회되므로 실시간으로 데이터가 반영되지는 않습니다.
|
15
|
+
- [func-data-samples-to-s3](https://github.com/operatochef/serverless/tree/main/func-data-samples-to-s3)
|
16
|
+
- [func-data-oocs-to-s3](https://github.com/operatochef/serverless/tree/main/func-data-oocs-to-s3)
|
17
|
+
- [func-data-set-histories-to-s3](https://github.com/operatochef/serverless/tree/main/func-data-set-histories-to-s3)
|
18
|
+
|
19
|
+
개발용으로는 reference-app을 사용하고 있으며, 여기서는 func-dev-* 로 시작하는 lambda들을 사용합니다.
|
4
20
|
## data-report process
|
5
21
|

|
6
22
|
|
7
23
|
'shiny' uses the next lambda. But 'jasper' is not using this lambda now. Consider using the same data service.
|
8
|
-
- https://github.com/operatochef/serverless/tree/main/func-transform-data-samples
|
24
|
+
- [func-transform-data-samples](https://github.com/operatochef/serverless/tree/main/func-transform-data-samples)
|
9
25
|
|
10
26
|
## Partition Keys
|
11
27
|
At the early stage, partition keys are desinged for dynamic partitioning for Athena. But It will be required so many AWS Glue crawlers also by each 'data-sets'.
|
@@ -27,7 +43,8 @@ Now partition keys are fixed
|
|
27
43
|
Partitions can be indices. You can create new indices with combination of partitions.
|
28
44
|
It affects query performance and finding partitions.
|
29
45
|

|
30
|
-
|
46
|
+
|
47
|
+
## Timestamp of Data Samples
|
31
48
|
sample data could have an own timestamp if it is from a sensor data.
|
32
49
|
'collected_at' uses this timestamp.
|
33
50
|
Manual type of data is used 'Date.now() and new Date()'
|
@@ -36,19 +53,6 @@ Graphql might affect timezone of server os for Date type field.
|
|
36
53
|
Or use ``` process.env.TZ = 'UTC' ```.
|
37
54
|
Now applied in 'create-data-samples.ts'
|
38
55
|
|
39
|
-
##
|
40
|
-
|
41
|
-
|
42
|
-
select
|
43
|
-
data::json#>>'{product,0}' as product,
|
44
|
-
data::json#>>'{operation,0}' as operation
|
45
|
-
from data_samples ds
|
46
|
-
where 1=1
|
47
|
-
and data_set_id = 'f1e394cb-9ace-4686-af14-817c619ae512'
|
48
|
-
and data_set_version = 3
|
49
|
-
and data::json#>>'{operation,0}' = '세척'
|
50
|
-
order by created_at desc;
|
51
|
-
```
|
52
|
-
|
53
|
-
Reference.
|
54
|
-
- [1] https://www.postgresql.org/docs/11/functions-json.html
|
56
|
+
## Data Archive
|
57
|
+
제출용 데이터를 위해 data_samples를 다운로드 하는 기능입니다. csv.gz 형태로 다운로드 가능한 임시 url을 제공합니다. 해당 기능을 위해 [func-data-set-download](https://github.com/operatochef/serverless/tree/main/func-data-set-download) lambda를 사용합니다. 이는 수동 수집용 데이터에 적합합니다. 자동 수집 데이터는 lambda로 처리하기에는 많은 메모리가 필요할 수 있습니다. 따라서, 데이타셋 유형별 처리가 필요할 것 같습니다.
|
58
|
+
Glue Job을 이용한 처리를 진행해보았으나, 시간이 너무 오래걸리는 문제가 있었습니다. 해당 내용은 AWS ibex계정의 Glue Jobs - 'reference_app_samples_archive' 리소스를 참고바랍니다.
|
Binary file
|
@@ -0,0 +1,290 @@
|
|
1
|
+
import '@operato/data-grist'
|
2
|
+
|
3
|
+
import gql from 'graphql-tag'
|
4
|
+
import { css, html } from 'lit'
|
5
|
+
import { connect } from 'pwa-helpers/connect-mixin'
|
6
|
+
|
7
|
+
import { client } from '@operato/graphql'
|
8
|
+
import { i18next, localize } from '@operato/i18n'
|
9
|
+
import { openPopup } from '@operato/layout'
|
10
|
+
import { PageView, store } from '@operato/shell'
|
11
|
+
import { CommonGristStyles, ScrollbarStyles } from '@operato/styles'
|
12
|
+
import { isMobileDevice } from '@operato/utils'
|
13
|
+
|
14
|
+
import './data-archive-request-popup'
|
15
|
+
|
16
|
+
export class DataArchiveListPage extends connect(store)(localize(i18next)(PageView)) {
|
17
|
+
static get properties() {
|
18
|
+
return {
|
19
|
+
active: String,
|
20
|
+
gristConfig: Object,
|
21
|
+
mode: String
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
static get styles() {
|
26
|
+
return [
|
27
|
+
ScrollbarStyles,
|
28
|
+
CommonGristStyles,
|
29
|
+
css`
|
30
|
+
:host {
|
31
|
+
display: flex;
|
32
|
+
flex-direction: column;
|
33
|
+
|
34
|
+
overflow: hidden;
|
35
|
+
}
|
36
|
+
|
37
|
+
ox-grist {
|
38
|
+
overflow-y: auto;
|
39
|
+
flex: 1;
|
40
|
+
}
|
41
|
+
`
|
42
|
+
]
|
43
|
+
}
|
44
|
+
|
45
|
+
get context() {
|
46
|
+
return {
|
47
|
+
title: i18next.t('title.data-archive list'),
|
48
|
+
help: 'dataset/data-archive',
|
49
|
+
actions: [],
|
50
|
+
exportable: {
|
51
|
+
name: i18next.t('title.data-archive list'),
|
52
|
+
data: this._exportableData.bind(this)
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
render() {
|
58
|
+
const mode = this.mode || (isMobileDevice() ? 'LIST' : 'GRID')
|
59
|
+
|
60
|
+
return html`
|
61
|
+
<ox-grist
|
62
|
+
.mode=${mode}
|
63
|
+
.config=${this.gristConfig}
|
64
|
+
.fetchHandler=${this.fetchHandler.bind(this)}
|
65
|
+
?url-params-sensitive=${false /* this.active */}
|
66
|
+
>
|
67
|
+
<div slot="headroom">
|
68
|
+
<div id="filters">
|
69
|
+
<ox-filters-form autofocus></ox-filters-form>
|
70
|
+
</div>
|
71
|
+
|
72
|
+
<div id="sorters">
|
73
|
+
Sort
|
74
|
+
<mwc-icon
|
75
|
+
@click=${e => {
|
76
|
+
const target = e.currentTarget
|
77
|
+
this.renderRoot.querySelector('#sorter-control').open({
|
78
|
+
right: 0,
|
79
|
+
top: target.offsetTop + target.offsetHeight
|
80
|
+
})
|
81
|
+
}}
|
82
|
+
>expand_more</mwc-icon
|
83
|
+
>
|
84
|
+
<ox-popup id="sorter-control">
|
85
|
+
<ox-sorters-control> </ox-sorters-control>
|
86
|
+
</ox-popup>
|
87
|
+
</div>
|
88
|
+
|
89
|
+
<div id="modes">
|
90
|
+
<mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
|
91
|
+
<mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</mwc-icon>
|
92
|
+
<mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
|
93
|
+
</div>
|
94
|
+
|
95
|
+
<mwc-button
|
96
|
+
dense
|
97
|
+
raised
|
98
|
+
label=${i18next.t('button.request')}
|
99
|
+
@click=${this.openArchivePopup.bind(this)}
|
100
|
+
icon="archive"
|
101
|
+
></mwc-button>
|
102
|
+
</div>
|
103
|
+
</ox-grist>
|
104
|
+
`
|
105
|
+
}
|
106
|
+
|
107
|
+
get grist() {
|
108
|
+
return this.renderRoot.querySelector('ox-grist')
|
109
|
+
}
|
110
|
+
|
111
|
+
async pageInitialized(lifecycle) {
|
112
|
+
const today = new Date().toISOString().split('T')[0]
|
113
|
+
|
114
|
+
this.gristConfig = {
|
115
|
+
list: { fields: ['updater', 'updatedAt'] },
|
116
|
+
columns: [
|
117
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
118
|
+
// { type: 'gutter', gutterName: 'row-selector', multiple: true },
|
119
|
+
{
|
120
|
+
type: 'resource-object',
|
121
|
+
name: 'creator',
|
122
|
+
header: i18next.t('field.creator'),
|
123
|
+
sortable: true,
|
124
|
+
width: 120,
|
125
|
+
imex: true
|
126
|
+
},
|
127
|
+
{
|
128
|
+
type: 'datetime',
|
129
|
+
name: 'createdAt',
|
130
|
+
header: i18next.t('field.created_at'),
|
131
|
+
sortable: true,
|
132
|
+
width: 180,
|
133
|
+
imex: true
|
134
|
+
},
|
135
|
+
{
|
136
|
+
type: 'datetime',
|
137
|
+
name: 'updatedAt',
|
138
|
+
header: i18next.t('field.updated_at'),
|
139
|
+
sortable: true,
|
140
|
+
width: 180,
|
141
|
+
imex: true
|
142
|
+
},
|
143
|
+
{
|
144
|
+
type: 'json5',
|
145
|
+
name: 'requestParams',
|
146
|
+
header: i18next.t('field.request-params'),
|
147
|
+
record: {
|
148
|
+
editable: false
|
149
|
+
},
|
150
|
+
width: 200,
|
151
|
+
imex: true
|
152
|
+
},
|
153
|
+
{
|
154
|
+
type: 'string',
|
155
|
+
name: 'downloadUrl',
|
156
|
+
label: true,
|
157
|
+
header: i18next.t('field.download-url'),
|
158
|
+
record: {
|
159
|
+
editable: false
|
160
|
+
},
|
161
|
+
width: 240,
|
162
|
+
imex: true
|
163
|
+
},
|
164
|
+
{
|
165
|
+
type: 'string',
|
166
|
+
name: 'status',
|
167
|
+
label: true,
|
168
|
+
header: i18next.t('field.status'),
|
169
|
+
record: {
|
170
|
+
editable: false
|
171
|
+
},
|
172
|
+
sortable: true,
|
173
|
+
width: 120,
|
174
|
+
imex: true
|
175
|
+
}
|
176
|
+
],
|
177
|
+
rows: {
|
178
|
+
appendable: false,
|
179
|
+
selectable: {
|
180
|
+
multiple: true
|
181
|
+
}
|
182
|
+
},
|
183
|
+
sorters: [
|
184
|
+
{
|
185
|
+
name: 'createdAt',
|
186
|
+
desc: true
|
187
|
+
}
|
188
|
+
]
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
closePopupAndRefesh() {
|
193
|
+
this.popup && this.popup.close()
|
194
|
+
this.grist.fetch()
|
195
|
+
}
|
196
|
+
|
197
|
+
async openArchivePopup() {
|
198
|
+
this.popup = openPopup(
|
199
|
+
html`
|
200
|
+
<data-archive-request-popup
|
201
|
+
@requested="${this.closePopupAndRefesh.bind(this)}"
|
202
|
+
@created="${this.closePopupAndRefesh.bind(this)}"
|
203
|
+
></data-archive-request-popup>`,
|
204
|
+
{
|
205
|
+
backdrop: true,
|
206
|
+
size: 'small',
|
207
|
+
title: i18next.t('title.data-archive request popup')
|
208
|
+
})
|
209
|
+
}
|
210
|
+
|
211
|
+
async fetchHandler({ page, limit, sortings = [], filters = [] }) {
|
212
|
+
const response = await client.query({
|
213
|
+
query: gql`
|
214
|
+
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
215
|
+
responses: dataArchives(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
216
|
+
items {
|
217
|
+
id
|
218
|
+
type
|
219
|
+
requestParams
|
220
|
+
downloadUrl
|
221
|
+
status
|
222
|
+
creator {
|
223
|
+
id
|
224
|
+
name
|
225
|
+
}
|
226
|
+
updater {
|
227
|
+
id
|
228
|
+
name
|
229
|
+
}
|
230
|
+
updatedAt
|
231
|
+
createdAt
|
232
|
+
}
|
233
|
+
total
|
234
|
+
}
|
235
|
+
}
|
236
|
+
`,
|
237
|
+
variables: {
|
238
|
+
filters,
|
239
|
+
pagination: { page, limit },
|
240
|
+
sortings
|
241
|
+
}
|
242
|
+
})
|
243
|
+
|
244
|
+
return {
|
245
|
+
total: response.data.responses.total || 0,
|
246
|
+
records: response.data.responses.items || []
|
247
|
+
}
|
248
|
+
}
|
249
|
+
|
250
|
+
_exportableData() {
|
251
|
+
let records = []
|
252
|
+
if (this.grist.selected && this.grist.selected.length > 0) {
|
253
|
+
records = this.grist.selected
|
254
|
+
} else {
|
255
|
+
records = this.grist.data.records
|
256
|
+
}
|
257
|
+
|
258
|
+
var headerSetting = this.grist.compiledConfig.columns
|
259
|
+
.filter(column => column.type !== 'gutter' && column.record !== undefined && column.imex !== undefined)
|
260
|
+
.map(column => {
|
261
|
+
return column.imex === true
|
262
|
+
? {
|
263
|
+
header: column.header.renderer(),
|
264
|
+
key: column.name,
|
265
|
+
width: column.width,
|
266
|
+
type: column.type
|
267
|
+
}
|
268
|
+
: column.imex
|
269
|
+
})
|
270
|
+
|
271
|
+
var data = records.map(item => {
|
272
|
+
return {
|
273
|
+
id: item.id,
|
274
|
+
...this.gristConfig.columns
|
275
|
+
.filter(column => column.type !== 'gutter' && column.record !== undefined && column.imex !== undefined)
|
276
|
+
.reduce((record, column) => {
|
277
|
+
const key = column.imex === true ? column.name : column.imex.key
|
278
|
+
record[key] = key
|
279
|
+
.split('.')
|
280
|
+
.reduce((obj, key) => (obj && obj[key] !== 'undefined' ? obj[key] : undefined), item)
|
281
|
+
return record
|
282
|
+
}, {})
|
283
|
+
}
|
284
|
+
})
|
285
|
+
|
286
|
+
return { header: headerSetting, data: data }
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
window.customElements.define('data-archive-list-page', DataArchiveListPage)
|
@@ -0,0 +1,180 @@
|
|
1
|
+
import { SingleColumnFormStyles } from '@things-factory/form-ui'
|
2
|
+
import '@things-factory/grist-ui'
|
3
|
+
import { i18next, localize } from '@things-factory/i18n-base'
|
4
|
+
import { client, CustomAlert } from '@things-factory/shell'
|
5
|
+
import gql from 'graphql-tag'
|
6
|
+
import { css, html, LitElement } from 'lit-element'
|
7
|
+
import moment from 'moment-timezone'
|
8
|
+
|
9
|
+
class DataArchiveRequestPopup extends localize(i18next)(LitElement) {
|
10
|
+
static get properties() {
|
11
|
+
return {
|
12
|
+
dataSetTypes: Array
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
static get styles() {
|
17
|
+
return [
|
18
|
+
SingleColumnFormStyles,
|
19
|
+
css`
|
20
|
+
:host {
|
21
|
+
padding: 10px;
|
22
|
+
display: flex;
|
23
|
+
flex-direction: column;
|
24
|
+
overflow-x: overlay;
|
25
|
+
background-color: var(--main-section-background-color);
|
26
|
+
}
|
27
|
+
.button-container {
|
28
|
+
padding: var(--button-container-padding);
|
29
|
+
margin: var(--button-container-margin);
|
30
|
+
text-align: var(--button-container-align);
|
31
|
+
background-color: var(--button-container-background);
|
32
|
+
height: var(--button-container-height);
|
33
|
+
}
|
34
|
+
`
|
35
|
+
]
|
36
|
+
}
|
37
|
+
|
38
|
+
render() {
|
39
|
+
return html`
|
40
|
+
<form id="input-form" name="generation" class="single-column-form" @submit=${e => this.onSubmit(e)}>
|
41
|
+
<fieldset>
|
42
|
+
<label>${i18next.t('label.start-date')}</label>
|
43
|
+
<input type="month" name="startDate" required/>
|
44
|
+
<label>${i18next.t('label.end-date')}</label>
|
45
|
+
<input type="month" name="endDate" .value=${moment().format('YYYY-MM')}/>
|
46
|
+
<label>${i18next.t('label.data-set-type')}</label>
|
47
|
+
<select name="type" required>
|
48
|
+
${(this.dataSetTypes || []).map(
|
49
|
+
t => html`<option value="${t && t.value}">${t && t.display}</option>`
|
50
|
+
)}
|
51
|
+
</select>
|
52
|
+
</fieldset>
|
53
|
+
</form>
|
54
|
+
|
55
|
+
<div class="button-container">
|
56
|
+
<mwc-button raised @click="${this.requestArchive}" label="${i18next.t('button.submit')}"></mwc-button>
|
57
|
+
</div>
|
58
|
+
`
|
59
|
+
}
|
60
|
+
|
61
|
+
async firstUpdated() {
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
async onSubmit(e) {
|
66
|
+
e.preventDefault()
|
67
|
+
this.requestArchive()
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
serializeFormData() {
|
72
|
+
const obj = {}
|
73
|
+
|
74
|
+
Array.from(this.shadowRoot.querySelectorAll('form#input-form input, select')).forEach(field => {
|
75
|
+
if (!field.hasAttribute('hidden') && field.value) {
|
76
|
+
obj[field.name] = field.type === 'checkbox' ? field.checked : field.value
|
77
|
+
}
|
78
|
+
})
|
79
|
+
|
80
|
+
if (obj['startDate']) {
|
81
|
+
obj['startDate'] += '-01'
|
82
|
+
}
|
83
|
+
|
84
|
+
if (obj['endDate']) {
|
85
|
+
const endDate = moment(obj['endDate']).endOf('month')
|
86
|
+
const today = moment()
|
87
|
+
const format = 'YYYY-MM-DD'
|
88
|
+
|
89
|
+
obj['endDate'] = endDate > today ? today.format(format) : endDate.format(format)
|
90
|
+
}
|
91
|
+
|
92
|
+
return obj
|
93
|
+
}
|
94
|
+
|
95
|
+
/** request download url. */
|
96
|
+
async requestArchive() {
|
97
|
+
// #1 request download url
|
98
|
+
const dataArchive = {
|
99
|
+
requestParams: this.serializeFormData(),
|
100
|
+
status: 'requested'
|
101
|
+
}
|
102
|
+
|
103
|
+
const response = await client.mutate({
|
104
|
+
mutation: gql`
|
105
|
+
mutation createDataArchive($dataArchive: NewDataArchive!) {
|
106
|
+
createDataArchive(dataArchive: $dataArchive) {
|
107
|
+
id
|
108
|
+
status
|
109
|
+
}
|
110
|
+
}
|
111
|
+
`,
|
112
|
+
variables: { dataArchive }
|
113
|
+
})
|
114
|
+
|
115
|
+
if (!response.errors) {
|
116
|
+
this.dispatchEvent(new CustomEvent('requested', {}))
|
117
|
+
|
118
|
+
const { createDataArchive: { id } } = response.data
|
119
|
+
dataArchive['id'] = id
|
120
|
+
|
121
|
+
this._generateArchiveAndDownloadUrl(dataArchive)
|
122
|
+
|
123
|
+
await CustomAlert({
|
124
|
+
type: 'info',
|
125
|
+
title: i18next.t('title.ready'),
|
126
|
+
text: i18next.t('text.data-archive waits'),
|
127
|
+
confirmButton: { text: i18next.t('button.confirm') }
|
128
|
+
})
|
129
|
+
|
130
|
+
} else {
|
131
|
+
console.error(response.errors)
|
132
|
+
this.showToast(i18next.t('text.failed'))
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
async _generateArchiveAndDownloadUrl(dataArchive) {
|
137
|
+
const response = await client.mutate({
|
138
|
+
mutation: gql`
|
139
|
+
mutation generatePresignedUrl($patch: DataArchivePatch!) {
|
140
|
+
generatePresignedUrl(patch: $patch) {
|
141
|
+
id
|
142
|
+
downloadUrl
|
143
|
+
status
|
144
|
+
}
|
145
|
+
}
|
146
|
+
`,
|
147
|
+
variables: { patch: dataArchive }
|
148
|
+
})
|
149
|
+
|
150
|
+
if (!response.errors) {
|
151
|
+
this.showToast(i18next.t('title.data-archive downloads ready'))
|
152
|
+
this.dispatchEvent(new CustomEvent('created', {}))
|
153
|
+
} else {
|
154
|
+
console.error(response.errors)
|
155
|
+
this.showToast(i18next.t('text.failed'))
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
showToast(message) {
|
160
|
+
document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))
|
161
|
+
}
|
162
|
+
|
163
|
+
constructor() {
|
164
|
+
super()
|
165
|
+
|
166
|
+
this.dataSetTypes = [
|
167
|
+
{},
|
168
|
+
{
|
169
|
+
display: i18next.t('text.manually collected'),
|
170
|
+
value: 'manual'
|
171
|
+
},
|
172
|
+
{
|
173
|
+
display: i18next.t('text.automatically collected'),
|
174
|
+
value: 'automatic'
|
175
|
+
}
|
176
|
+
]
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
window.customElements.define('data-archive-request-popup', DataArchiveRequestPopup)
|
@@ -156,7 +156,7 @@ export class DataKeySetListPage extends connect(store)(localize(i18next)(PageVie
|
|
156
156
|
if (!record.id) return
|
157
157
|
const popup = openPopup(html` <data-key-item-list .dataKeySet=${record}></data-key-item-list> `, {
|
158
158
|
backdrop: true,
|
159
|
-
help: '
|
159
|
+
help: 'dataset/ui/data-key-item-list',
|
160
160
|
size: 'large',
|
161
161
|
title: i18next.t('title.data-key-item list')
|
162
162
|
})
|
@@ -137,8 +137,8 @@ export class DataReportListPage extends connect(store)(localize(i18next)(PageVie
|
|
137
137
|
|
138
138
|
get context() {
|
139
139
|
return {
|
140
|
-
title: i18next.t('title.data-
|
141
|
-
help: 'dataset/data-
|
140
|
+
title: i18next.t('title.data-report list'),
|
141
|
+
help: 'dataset/data-report-list'
|
142
142
|
}
|
143
143
|
}
|
144
144
|
|
@@ -225,7 +225,7 @@ export class DataSetListPage extends connect(store)(localize(i18next)(PageView))
|
|
225
225
|
if (!record.id) return
|
226
226
|
const popup = openPopup(html` <data-item-list .dataSet=${record}></data-item-list> `, {
|
227
227
|
backdrop: true,
|
228
|
-
help: '
|
228
|
+
help: 'dataset/ui/data-item-list',
|
229
229
|
size: 'large',
|
230
230
|
title: i18next.t('title.data-item list')
|
231
231
|
})
|
package/client/route.js
CHANGED
@@ -31,6 +31,10 @@ export default function route(page) {
|
|
31
31
|
case 'data-report-list':
|
32
32
|
import('./pages/data-report/data-report-list-page.js')
|
33
33
|
return page
|
34
|
+
|
35
|
+
case 'data-archive-list':
|
36
|
+
import('./pages/data-archive/data-archive-list-page.js')
|
37
|
+
return page
|
34
38
|
|
35
39
|
// case 'jasper-report-samples':
|
36
40
|
// import('./pages/data-report/jasper-report-samples-page.js')
|
@@ -4,11 +4,12 @@ exports.renderJasperReport = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
6
6
|
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
7
|
+
const config_resolver_1 = require("../utils/config-resolver");
|
7
8
|
const attachment_base_1 = require("@things-factory/attachment-base");
|
8
9
|
const aws_base_1 = require("@things-factory/aws-base");
|
9
10
|
const env_1 = require("@things-factory/env");
|
10
11
|
const dataReportConfig = env_1.config.get('dataReport');
|
11
|
-
const { jasper: { endpoint:
|
12
|
+
const { jasper: { endpoint: ENDPOINT, datasource: { database: DATABASE } } } = dataReportConfig || {
|
12
13
|
jasper: {
|
13
14
|
endpoint: {},
|
14
15
|
datasource: {}
|
@@ -151,9 +152,8 @@ async function renderJasperReport(context) {
|
|
151
152
|
formData.append('jsonString', JSON.stringify(parsedData));
|
152
153
|
formData.append('parameters', JSON.stringify(parameters));
|
153
154
|
const { reportView } = query;
|
154
|
-
const
|
155
|
-
const
|
156
|
-
const response = await (0, node_fetch_1.default)(reportUrl, {
|
155
|
+
const url = (0, config_resolver_1.getEndpointUrl)(ENDPOINT, reportView);
|
156
|
+
const response = await (0, node_fetch_1.default)(url, {
|
157
157
|
method: 'POST',
|
158
158
|
body: formData
|
159
159
|
});
|