@things-factory/dataset 8.0.0 → 9.0.0-beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. package/dist-client/activities/activity-data-review-edit.d.ts +5 -1
  2. package/dist-client/activities/activity-data-review-edit.js +143 -5
  3. package/dist-client/activities/activity-data-review-edit.js.map +1 -1
  4. package/dist-client/pages/data-entry/data-entry-list-page.js +2 -2
  5. package/dist-client/pages/data-entry/data-entry-list-page.js.map +1 -1
  6. package/dist-client/tsconfig.tsbuildinfo +1 -1
  7. package/dist-server/activities/activity-data-review.js +18 -5
  8. package/dist-server/activities/activity-data-review.js.map +1 -1
  9. package/dist-server/activities/activity-ooc-review.js +13 -52
  10. package/dist-server/activities/activity-ooc-review.js.map +1 -1
  11. package/dist-server/controllers/create-data-ooc.d.ts +4 -0
  12. package/dist-server/controllers/create-data-ooc.js +65 -0
  13. package/dist-server/controllers/create-data-ooc.js.map +1 -0
  14. package/dist-server/controllers/create-data-sample.js +4 -94
  15. package/dist-server/controllers/create-data-sample.js.map +1 -1
  16. package/dist-server/controllers/index.d.ts +3 -0
  17. package/dist-server/controllers/index.js +3 -0
  18. package/dist-server/controllers/index.js.map +1 -1
  19. package/dist-server/controllers/issue-ooc-resolve.d.ts +3 -0
  20. package/dist-server/controllers/issue-ooc-resolve.js +49 -0
  21. package/dist-server/controllers/issue-ooc-resolve.js.map +1 -0
  22. package/dist-server/controllers/issue-ooc-review.d.ts +3 -0
  23. package/dist-server/controllers/issue-ooc-review.js +47 -0
  24. package/dist-server/controllers/issue-ooc-review.js.map +1 -0
  25. package/dist-server/service/data-sample/data-sample-query.d.ts +1 -1
  26. package/dist-server/service/data-sample/data-sample-query.js +3 -3
  27. package/dist-server/service/data-sample/data-sample-query.js.map +1 -1
  28. package/dist-server/service/index.d.ts +1 -1
  29. package/dist-server/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +26 -26
  31. package/translations/en.json +3 -0
  32. package/translations/ja.json +3 -0
  33. package/translations/ko.json +3 -0
  34. package/translations/ms.json +3 -0
  35. package/translations/zh.json +3 -0
  36. package/client/activities/activity-data-collect-edit.ts +0 -105
  37. package/client/activities/activity-data-collect-view.ts +0 -91
  38. package/client/activities/activity-data-review-edit.ts +0 -133
  39. package/client/activities/activity-data-review-view.ts +0 -145
  40. package/client/activities/activity-ooc-resolve-edit.ts +0 -195
  41. package/client/activities/activity-ooc-resolve-view.ts +0 -143
  42. package/client/activities/activity-ooc-review-edit.ts +0 -173
  43. package/client/activities/activity-ooc-review-view.ts +0 -129
  44. package/client/bootstrap.ts +0 -35
  45. package/client/components/data-entry-form.ts +0 -109
  46. package/client/index.ts +0 -1
  47. package/client/pages/data-archive/data-archive-list-page.ts +0 -277
  48. package/client/pages/data-archive/data-archive-request-popup.ts +0 -177
  49. package/client/pages/data-entry/data-entry-list-page.ts +0 -464
  50. package/client/pages/data-key-set/data-key-item-list.ts +0 -183
  51. package/client/pages/data-key-set/data-key-set-importer.ts +0 -89
  52. package/client/pages/data-key-set/data-key-set-list-page.ts +0 -413
  53. package/client/pages/data-ooc/data-ooc-list-page.ts +0 -549
  54. package/client/pages/data-ooc/data-ooc-page.ts +0 -164
  55. package/client/pages/data-ooc/data-ooc-view.ts +0 -236
  56. package/client/pages/data-ooc/data-oocs-page.ts +0 -200
  57. package/client/pages/data-report/data-report-embed-page.ts +0 -108
  58. package/client/pages/data-report/data-report-list-page.ts +0 -454
  59. package/client/pages/data-report/data-report-samples-page.ts +0 -174
  60. package/client/pages/data-report/jasper-report-oocs-page.ts +0 -110
  61. package/client/pages/data-report/jasper-report-samples-crosstab-page.ts +0 -110
  62. package/client/pages/data-report/jasper-report-samples-page.ts +0 -110
  63. package/client/pages/data-sample/data-sample-list-page.ts +0 -442
  64. package/client/pages/data-sample/data-sample-page.ts +0 -55
  65. package/client/pages/data-sample/data-sample-search-page.ts +0 -424
  66. package/client/pages/data-sample/data-sample-view.ts +0 -292
  67. package/client/pages/data-sample/data-samples-page.ts +0 -249
  68. package/client/pages/data-sensor/data-sensor-list-page.ts +0 -456
  69. package/client/pages/data-set/data-item-list.ts +0 -304
  70. package/client/pages/data-set/data-set-importer.ts +0 -89
  71. package/client/pages/data-set/data-set-list-page.ts +0 -1078
  72. package/client/pages/data-summary/data-summary-list-page.ts +0 -363
  73. package/client/pages/data-summary/data-summary-period-page.ts +0 -439
  74. package/client/pages/data-summary/data-summary-search-page.ts +0 -426
  75. package/client/pages/data-summary/data-summary-view.ts +0 -133
  76. package/client/route.ts +0 -91
  77. package/client/tsconfig.json +0 -13
  78. package/server/activities/activity-data-collect.ts +0 -100
  79. package/server/activities/activity-data-review.ts +0 -82
  80. package/server/activities/activity-ooc-resolve.ts +0 -123
  81. package/server/activities/activity-ooc-review.ts +0 -144
  82. package/server/activities/index.ts +0 -11
  83. package/server/controllers/create-data-sample.ts +0 -426
  84. package/server/controllers/data-use-case.ts +0 -98
  85. package/server/controllers/finalize-data-collection.ts +0 -388
  86. package/server/controllers/index.ts +0 -3
  87. package/server/controllers/issue-data-collection-task.ts +0 -70
  88. package/server/controllers/jasper-report.ts +0 -186
  89. package/server/controllers/query-data-summary-by-period.ts +0 -178
  90. package/server/controllers/shiny-report.ts +0 -54
  91. package/server/engine/index.ts +0 -1
  92. package/server/engine/task/create-data-sample.ts +0 -100
  93. package/server/engine/task/index.ts +0 -2
  94. package/server/engine/task/issue-collect-data.ts +0 -45
  95. package/server/index.ts +0 -8
  96. package/server/routes.ts +0 -188
  97. package/server/service/data-archive/data-archive-mutation.ts +0 -273
  98. package/server/service/data-archive/data-archive-query.ts +0 -58
  99. package/server/service/data-archive/data-archive-type.ts +0 -48
  100. package/server/service/data-archive/data-archive.ts +0 -69
  101. package/server/service/data-archive/index.ts +0 -6
  102. package/server/service/data-key-set/data-key-item-type.ts +0 -31
  103. package/server/service/data-key-set/data-key-set-mutation.ts +0 -201
  104. package/server/service/data-key-set/data-key-set-query.ts +0 -68
  105. package/server/service/data-key-set/data-key-set-type.ts +0 -70
  106. package/server/service/data-key-set/data-key-set.ts +0 -86
  107. package/server/service/data-key-set/index.ts +0 -6
  108. package/server/service/data-ooc/data-ooc-mutation.ts +0 -154
  109. package/server/service/data-ooc/data-ooc-query.ts +0 -106
  110. package/server/service/data-ooc/data-ooc-subscription.ts +0 -48
  111. package/server/service/data-ooc/data-ooc-type.ts +0 -71
  112. package/server/service/data-ooc/data-ooc.ts +0 -259
  113. package/server/service/data-ooc/index.ts +0 -7
  114. package/server/service/data-sample/data-sample-mutation.ts +0 -18
  115. package/server/service/data-sample/data-sample-query.ts +0 -215
  116. package/server/service/data-sample/data-sample-type.ts +0 -47
  117. package/server/service/data-sample/data-sample.ts +0 -193
  118. package/server/service/data-sample/index.ts +0 -6
  119. package/server/service/data-sensor/data-sensor-mutation.ts +0 -116
  120. package/server/service/data-sensor/data-sensor-query.ts +0 -76
  121. package/server/service/data-sensor/data-sensor-type.ts +0 -104
  122. package/server/service/data-sensor/data-sensor.ts +0 -126
  123. package/server/service/data-sensor/index.ts +0 -6
  124. package/server/service/data-set/data-item-type.ts +0 -155
  125. package/server/service/data-set/data-set-mutation.ts +0 -552
  126. package/server/service/data-set/data-set-query.ts +0 -461
  127. package/server/service/data-set/data-set-type.ts +0 -204
  128. package/server/service/data-set/data-set.ts +0 -326
  129. package/server/service/data-set/index.ts +0 -6
  130. package/server/service/data-set-history/data-set-history-query.ts +0 -126
  131. package/server/service/data-set-history/data-set-history-type.ts +0 -12
  132. package/server/service/data-set-history/data-set-history.ts +0 -217
  133. package/server/service/data-set-history/event-subscriber.ts +0 -17
  134. package/server/service/data-set-history/index.ts +0 -7
  135. package/server/service/data-spec/data-spec-manager.ts +0 -21
  136. package/server/service/data-spec/data-spec-query.ts +0 -21
  137. package/server/service/data-spec/data-spec.ts +0 -45
  138. package/server/service/data-spec/index.ts +0 -5
  139. package/server/service/data-summary/data-summary-mutation.ts +0 -45
  140. package/server/service/data-summary/data-summary-query.ts +0 -179
  141. package/server/service/data-summary/data-summary-type.ts +0 -86
  142. package/server/service/data-summary/data-summary.ts +0 -170
  143. package/server/service/data-summary/index.ts +0 -7
  144. package/server/service/index.ts +0 -57
  145. package/server/tsconfig.json +0 -10
  146. package/server/utils/config-resolver.ts +0 -29
  147. package/server/utils/index.ts +0 -1
@@ -1,109 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/dataset/ox-data-entry-form.js'
3
-
4
- import gql from 'graphql-tag'
5
- import { css, html, LitElement } from 'lit'
6
- import { customElement, property, query, state } from 'lit/decorators.js'
7
-
8
- import { client } from '@operato/graphql'
9
- import { i18next, localize } from '@operato/i18n'
10
- import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
11
- import { OxDataEntryForm } from '@operato/dataset/ox-data-entry-form.js'
12
- import { DataSet } from '@operato/dataset'
13
-
14
- @customElement('data-entry-form')
15
- export class DataEntryForm extends localize(i18next)(LitElement) {
16
- static styles = [
17
- CommonHeaderStyles,
18
- ScrollbarStyles,
19
- css`
20
- :host {
21
- display: flex;
22
- flex-direction: column;
23
-
24
- background-color: var(--md-sys-color-surface);
25
- }
26
-
27
- ox-data-entry-form {
28
- flex: 1;
29
- padding: 10px;
30
- overflow: auto;
31
- }
32
-
33
- .footer span {
34
- font-size: 0.8em;
35
- color: var(--md-sys-color-on-surface);
36
- line-height: 1.5;
37
- padding: 10px;
38
- }
39
- `
40
- ]
41
-
42
- @property({ type: Object }) dataSet?: DataSet & { id: string }
43
-
44
- @state() dataSample?: { id: string; collectedAt: Date }
45
-
46
- @query('ox-data-entry-form') entryForm!: OxDataEntryForm
47
-
48
- render() {
49
- return html`
50
- <ox-data-entry-form .dataSet=${this.dataSet}></ox-data-entry-form>
51
-
52
- <div class="footer">
53
- <div filler></div>
54
- ${!this.dataSample
55
- ? html`
56
- <button @click=${this.updateDataItems.bind(this)} done>
57
- <md-icon>save</md-icon>${i18next.t('button.save')}
58
- </button>
59
- `
60
- : html` <span>${i18next.t('field.collected-at')}: ${this.dataSample.collectedAt.toLocaleString()}</span> `}
61
- </div>
62
- `
63
- }
64
-
65
- private async updateDataItems() {
66
- //@ts-ignore TODO replace with following line and confirm
67
- const data = this.entryForm.buildValue()
68
-
69
- const dataSample = {
70
- dataSet: {
71
- id: this.dataSet?.id
72
- },
73
- data
74
- } as any
75
-
76
- if (this.dataSample?.collectedAt) {
77
- dataSample.collectedAt = this.dataSample.collectedAt
78
- }
79
-
80
- const response = await client.mutate({
81
- mutation: gql`
82
- mutation ($dataSample: NewDataSample!) {
83
- createDataSample(dataSample: $dataSample) {
84
- id
85
- collectedAt
86
- }
87
- }
88
- `,
89
- variables: {
90
- dataSample
91
- },
92
- context: {
93
- hasUpload: true
94
- }
95
- })
96
-
97
- if (!response.errors) {
98
- const { id, collectedAt } = response.data.createDataSample
99
- this.dataSample = {
100
- id,
101
- collectedAt: new Date(collectedAt)
102
- }
103
-
104
- document.dispatchEvent(
105
- new CustomEvent('notify', { detail: { message: i18next.t('text.data sample created successfully') } })
106
- )
107
- }
108
- }
109
- }
package/client/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './components/data-entry-form.js'
@@ -1,277 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/data-grist'
3
- import '@operato/context/ox-context-page-toolbar.js'
4
-
5
- import gql from 'graphql-tag'
6
- import { css, html } from 'lit'
7
- import { customElement, property, query, state } from 'lit/decorators.js'
8
- import { connect } from 'pwa-helpers/connect-mixin'
9
-
10
- import { DataGrist, FetchOption, GristRecord } from '@operato/data-grist'
11
- import { client } from '@operato/graphql'
12
- import { i18next, localize } from '@operato/i18n'
13
- import { PopupHandle, openPopup } from '@operato/layout'
14
- import { PageView, store } from '@operato/shell'
15
- import { CommonButtonStyles, CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
16
- import { isMobileDevice } from '@operato/utils'
17
-
18
- import './data-archive-request-popup'
19
-
20
- @customElement('data-archive-list-page')
21
- export class DataArchiveListPage extends connect(store)(localize(i18next)(PageView)) {
22
- static styles = [
23
- ScrollbarStyles,
24
- CommonHeaderStyles,
25
- css`
26
- :host {
27
- display: flex;
28
- flex-direction: column;
29
-
30
- overflow: hidden;
31
- }
32
-
33
- ox-grist {
34
- overflow-y: auto;
35
- flex: 1;
36
- }
37
-
38
- .header {
39
- grid-template-areas: 'filters actions';
40
- }
41
- `
42
- ]
43
-
44
- @state() gristConfig: any
45
- @state() mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'
46
-
47
- @query('ox-grist') private grist!: DataGrist
48
-
49
- private popup?: PopupHandle
50
-
51
- get context() {
52
- return {
53
- title: i18next.t('title.data-archive list'),
54
- search: {
55
- handler: (search: string) => {
56
- this.grist.searchText = search
57
- },
58
- value: this.grist?.searchText || ''
59
- },
60
- filter: {
61
- handler: () => {
62
- this.grist.toggleHeadroom()
63
- }
64
- },
65
- help: 'dataset/data-archive',
66
- actions: [
67
- {
68
- title: i18next.t('button.request-archive'),
69
- action: this.openArchivePopup.bind(this),
70
- icon: 'archive'
71
- }
72
- ],
73
- exportable: {
74
- name: i18next.t('title.data-archive list'),
75
- data: this._exportableData.bind(this)
76
- },
77
- toolbar: false
78
- }
79
- }
80
-
81
- render() {
82
- const mode = this.mode || (isMobileDevice() ? 'LIST' : 'GRID')
83
-
84
- return html`
85
- <ox-grist
86
- .mode=${mode}
87
- .config=${this.gristConfig}
88
- .fetchHandler=${this.fetchHandler.bind(this)}
89
- ?url-params-sensitive=${false /* this.active */}
90
- >
91
- <div slot="headroom" class="header">
92
- <!-- <div class="filters">
93
- <ox-filters-form class="filter" autofocus without-search></ox-filters-form>
94
- </div> -->
95
-
96
- <ox-context-page-toolbar class="actions" .context=${this.context}></ox-context-page-toolbar>
97
- </div>
98
- </ox-grist>
99
- `
100
- }
101
-
102
- async pageInitialized(lifecycle) {
103
- this.gristConfig = {
104
- list: { fields: ['updater', 'updatedAt'] },
105
- columns: [
106
- { type: 'gutter', gutterName: 'sequence' },
107
- // { type: 'gutter', gutterName: 'row-selector', multiple: true },
108
- {
109
- type: 'resource-object',
110
- name: 'creator',
111
- header: i18next.t('field.creator'),
112
- sortable: true,
113
- width: 120,
114
- imex: true
115
- },
116
- {
117
- type: 'datetime',
118
- name: 'createdAt',
119
- header: i18next.t('field.created_at'),
120
- sortable: true,
121
- width: 180,
122
- imex: true
123
- },
124
- {
125
- type: 'datetime',
126
- name: 'updatedAt',
127
- header: i18next.t('field.updated_at'),
128
- sortable: true,
129
- width: 180,
130
- imex: true
131
- },
132
- {
133
- type: 'json5',
134
- name: 'requestParams',
135
- header: i18next.t('field.request-params'),
136
- record: {
137
- editable: false
138
- },
139
- width: 200,
140
- imex: true
141
- },
142
- {
143
- type: 'string',
144
- name: 'downloadUrl',
145
- label: true,
146
- header: i18next.t('field.download-url'),
147
- record: {
148
- editable: false
149
- },
150
- width: 240,
151
- imex: true
152
- },
153
- {
154
- type: 'string',
155
- name: 'status',
156
- label: true,
157
- header: i18next.t('field.status'),
158
- record: {
159
- editable: false
160
- },
161
- sortable: true,
162
- width: 120,
163
- imex: true
164
- }
165
- ],
166
- rows: {
167
- appendable: false,
168
- selectable: {
169
- multiple: true
170
- }
171
- },
172
- sorters: [
173
- {
174
- name: 'createdAt',
175
- desc: true
176
- }
177
- ]
178
- }
179
- }
180
-
181
- closePopupAndRefesh() {
182
- this.popup?.close()
183
- this.grist.fetch()
184
- }
185
-
186
- async openArchivePopup() {
187
- this.popup = openPopup(
188
- html` <data-archive-request-popup
189
- @requested=${this.closePopupAndRefesh.bind(this)}
190
- @created=${this.closePopupAndRefesh.bind(this)}
191
- ></data-archive-request-popup>`,
192
- {
193
- backdrop: true,
194
- size: 'small',
195
- title: i18next.t('title.data-archive request popup')
196
- }
197
- )
198
- }
199
-
200
- async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) {
201
- const response = await client.query({
202
- query: gql`
203
- query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
204
- responses: dataArchives(filters: $filters, pagination: $pagination, sortings: $sortings) {
205
- items {
206
- id
207
- type
208
- requestParams
209
- downloadUrl
210
- status
211
- creator {
212
- id
213
- name
214
- }
215
- updater {
216
- id
217
- name
218
- }
219
- updatedAt
220
- createdAt
221
- }
222
- total
223
- }
224
- }
225
- `,
226
- variables: {
227
- filters,
228
- pagination: { page, limit },
229
- sortings
230
- }
231
- })
232
-
233
- return {
234
- total: response.data.responses.total || 0,
235
- records: response.data.responses.items || []
236
- }
237
- }
238
-
239
- _exportableData() {
240
- let records = [] as GristRecord[]
241
- if (this.grist.selected && this.grist.selected.length > 0) {
242
- records = this.grist.selected
243
- } else {
244
- records = this.grist.data.records
245
- }
246
-
247
- var headerSetting = this.grist.compiledConfig.columns
248
- .filter(column => column.type !== 'gutter' && column.record !== undefined && column.imex !== undefined)
249
- .map(column => {
250
- return column.imex === true
251
- ? {
252
- header: column.header.renderer(column),
253
- key: column.name,
254
- width: column.width,
255
- type: column.type
256
- }
257
- : column.imex
258
- })
259
-
260
- var data = records.map(item => {
261
- return {
262
- id: item.id,
263
- ...this.gristConfig.columns
264
- .filter(column => column.type !== 'gutter' && column.record !== undefined && column.imex !== undefined)
265
- .reduce((record, column) => {
266
- const key = column.imex === true ? column.name : column.imex.key
267
- record[key] = key
268
- .split('.')
269
- .reduce((obj, key) => (obj && obj[key] !== 'undefined' ? obj[key] : undefined), item)
270
- return record
271
- }, {})
272
- }
273
- })
274
-
275
- return { header: headerSetting, data: data }
276
- }
277
- }
@@ -1,177 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
-
3
- import gql from 'graphql-tag'
4
- import { css, html, LitElement } from 'lit'
5
- import { customElement, property, query, state } from 'lit/decorators.js'
6
-
7
- import { i18next, localize } from '@operato/i18n'
8
- import { client } from '@operato/graphql'
9
- import { SingleColumnFormStyles } from '@operato/form'
10
- import { CommonHeaderStyles } from '@operato/styles'
11
-
12
- import moment from '@operato/moment-timezone-es'
13
- import { CustomAlert } from '@operato/shell'
14
-
15
- @customElement('data-archive-request-popup')
16
- class DataArchiveRequestPopup extends localize(i18next)(LitElement) {
17
- static styles = [
18
- CommonHeaderStyles,
19
- SingleColumnFormStyles,
20
- css`
21
- :host {
22
- padding: 10px;
23
- display: flex;
24
- flex-direction: column;
25
- overflow-x: overlay;
26
- background-color: var(--md-sys-color-background);
27
- }
28
-
29
- form {
30
- overflow: auto;
31
- }
32
- `
33
- ]
34
-
35
- @state() dataSetTypes: any
36
-
37
- render() {
38
- return html`
39
- <form id="input-form" name="generation" class="single-column-form" @submit=${e => this.onSubmit(e)}>
40
- <fieldset>
41
- <label>${i18next.t('label.start-date')}</label>
42
- <input type="month" name="startDate" required />
43
- <label>${i18next.t('label.end-date')}</label>
44
- <input type="month" name="endDate" .value=${moment().format('YYYY-MM')} />
45
- <label>${i18next.t('label.data-set-type')}</label>
46
- <select name="type" required>
47
- ${(this.dataSetTypes || []).map(t => html`<option value=${t && t.value}>${t && t.display}</option>`)}
48
- </select>
49
- </fieldset>
50
- </form>
51
-
52
- <div class="footer">
53
- <div filler></div>
54
- <button @click=${this.requestArchive} done>
55
- <md-icon>archive</md-icon>${String(i18next.t('button.submit'))}
56
- </button>
57
- </div>
58
- `
59
- }
60
-
61
- async firstUpdated() {}
62
-
63
- async onSubmit(e) {
64
- e.preventDefault()
65
- this.requestArchive()
66
- }
67
-
68
- serializeFormData() {
69
- const obj = {}
70
-
71
- Array.from(this.shadowRoot!.querySelectorAll('form#input-form input, select')).forEach((field: Element) => {
72
- const input = field as HTMLInputElement
73
- if (!input.hasAttribute('hidden') && input.value) {
74
- obj[input.name] = input.type === 'checkbox' ? input.checked : input.value
75
- }
76
- })
77
-
78
- if (obj['startDate']) {
79
- obj['startDate'] += '-01'
80
- }
81
-
82
- if (obj['endDate']) {
83
- const endDate = moment(obj['endDate']).endOf('month')
84
- const today = moment()
85
- const format = 'YYYY-MM-DD'
86
-
87
- obj['endDate'] = endDate > today ? today.format(format) : endDate.format(format)
88
- }
89
-
90
- return obj
91
- }
92
-
93
- /** request download url. */
94
- async requestArchive() {
95
- // #1 request download url
96
- const dataArchive = {
97
- requestParams: this.serializeFormData(),
98
- status: 'requested'
99
- }
100
-
101
- const response = await client.mutate({
102
- mutation: gql`
103
- mutation createDataArchive($dataArchive: NewDataArchive!) {
104
- createDataArchive(dataArchive: $dataArchive) {
105
- id
106
- status
107
- }
108
- }
109
- `,
110
- variables: { dataArchive }
111
- })
112
-
113
- if (!response.errors) {
114
- this.dispatchEvent(new CustomEvent('requested', {}))
115
-
116
- const {
117
- createDataArchive: { id }
118
- } = 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
- } else {
130
- console.error(response.errors)
131
- this.showToast(i18next.t('text.failed'))
132
- }
133
- }
134
-
135
- async _generateArchiveAndDownloadUrl(dataArchive) {
136
- const response = await client.mutate({
137
- mutation: gql`
138
- mutation generatePresignedUrl($patch: DataArchivePatch!) {
139
- generatePresignedUrl(patch: $patch) {
140
- id
141
- downloadUrl
142
- status
143
- }
144
- }
145
- `,
146
- variables: { patch: dataArchive }
147
- })
148
-
149
- if (!response.errors) {
150
- this.showToast(i18next.t('title.data-archive downloads ready'))
151
- this.dispatchEvent(new CustomEvent('created', {}))
152
- } else {
153
- console.error(response.errors)
154
- this.showToast(i18next.t('text.failed'))
155
- }
156
- }
157
-
158
- showToast(message) {
159
- document.dispatchEvent(new CustomEvent('notify', { detail: { message } }))
160
- }
161
-
162
- constructor() {
163
- super()
164
-
165
- this.dataSetTypes = [
166
- {},
167
- {
168
- display: i18next.t('text.manually collected'),
169
- value: 'manual'
170
- },
171
- {
172
- display: i18next.t('text.automatically collected'),
173
- value: 'automatic'
174
- }
175
- ]
176
- }
177
- }