@things-factory/dataset 8.0.0-beta.9 → 8.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. package/client/activities/activity-data-collect-edit.ts +105 -0
  2. package/client/activities/activity-data-collect-view.ts +91 -0
  3. package/client/activities/activity-data-review-edit.ts +278 -0
  4. package/client/activities/activity-data-review-view.ts +226 -0
  5. package/client/activities/activity-ooc-resolve-edit.ts +195 -0
  6. package/client/activities/activity-ooc-resolve-view.ts +143 -0
  7. package/client/activities/activity-ooc-review-edit.ts +173 -0
  8. package/client/activities/activity-ooc-review-view.ts +129 -0
  9. package/client/bootstrap.ts +35 -0
  10. package/client/components/data-entry-form.ts +109 -0
  11. package/client/index.ts +1 -0
  12. package/client/pages/data-archive/data-archive-list-page.ts +277 -0
  13. package/client/pages/data-archive/data-archive-request-popup.ts +177 -0
  14. package/client/pages/data-entry/data-entry-list-page.ts +464 -0
  15. package/client/pages/data-key-set/data-key-item-list.ts +183 -0
  16. package/client/pages/data-key-set/data-key-set-importer.ts +89 -0
  17. package/client/pages/data-key-set/data-key-set-list-page.ts +413 -0
  18. package/client/pages/data-ooc/data-ooc-list-page.ts +549 -0
  19. package/client/pages/data-ooc/data-ooc-page.ts +164 -0
  20. package/client/pages/data-ooc/data-ooc-view.ts +236 -0
  21. package/client/pages/data-ooc/data-oocs-page.ts +200 -0
  22. package/client/pages/data-report/data-report-embed-page.ts +108 -0
  23. package/client/pages/data-report/data-report-list-page.ts +454 -0
  24. package/client/pages/data-report/data-report-samples-page.ts +174 -0
  25. package/client/pages/data-report/jasper-report-oocs-page.ts +110 -0
  26. package/client/pages/data-report/jasper-report-samples-crosstab-page.ts +110 -0
  27. package/client/pages/data-report/jasper-report-samples-page.ts +110 -0
  28. package/client/pages/data-sample/data-sample-list-page.ts +442 -0
  29. package/client/pages/data-sample/data-sample-page.ts +55 -0
  30. package/client/pages/data-sample/data-sample-search-page.ts +424 -0
  31. package/client/pages/data-sample/data-sample-view.ts +292 -0
  32. package/client/pages/data-sample/data-samples-page.ts +249 -0
  33. package/client/pages/data-sensor/data-sensor-list-page.ts +456 -0
  34. package/client/pages/data-set/data-item-list.ts +304 -0
  35. package/client/pages/data-set/data-set-importer.ts +89 -0
  36. package/client/pages/data-set/data-set-list-page.ts +1078 -0
  37. package/client/pages/data-summary/data-summary-list-page.ts +363 -0
  38. package/client/pages/data-summary/data-summary-period-page.ts +439 -0
  39. package/client/pages/data-summary/data-summary-search-page.ts +426 -0
  40. package/client/pages/data-summary/data-summary-view.ts +133 -0
  41. package/client/route.ts +91 -0
  42. package/client/tsconfig.json +13 -0
  43. package/dist-client/activities/activity-data-review-edit.js +19 -10
  44. package/dist-client/activities/activity-data-review-edit.js.map +1 -1
  45. package/dist-client/activities/activity-data-review-view.js +80 -0
  46. package/dist-client/activities/activity-data-review-view.js.map +1 -1
  47. package/dist-client/pages/data-entry/data-entry-list-page.js +2 -2
  48. package/dist-client/pages/data-entry/data-entry-list-page.js.map +1 -1
  49. package/dist-client/tsconfig.tsbuildinfo +1 -1
  50. package/dist-server/controllers/create-data-ooc.js +2 -0
  51. package/dist-server/controllers/create-data-ooc.js.map +1 -1
  52. package/dist-server/service/data-archive/index.d.ts +1 -1
  53. package/dist-server/service/data-ooc/index.d.ts +1 -1
  54. package/dist-server/service/data-sample/data-sample-query.d.ts +1 -1
  55. package/dist-server/service/data-sample/data-sample-query.js +3 -3
  56. package/dist-server/service/data-sample/data-sample-query.js.map +1 -1
  57. package/dist-server/service/data-sample/index.d.ts +1 -1
  58. package/dist-server/service/data-set/index.d.ts +1 -1
  59. package/dist-server/service/index.d.ts +2 -2
  60. package/dist-server/tsconfig.tsbuildinfo +1 -1
  61. package/package.json +26 -26
  62. package/server/activities/activity-data-collect.ts +100 -0
  63. package/server/activities/activity-data-review.ts +109 -0
  64. package/server/activities/activity-ooc-resolve.ts +123 -0
  65. package/server/activities/activity-ooc-review.ts +95 -0
  66. package/server/activities/index.ts +11 -0
  67. package/server/controllers/create-data-ooc.ts +80 -0
  68. package/server/controllers/create-data-sample.ts +323 -0
  69. package/server/controllers/data-use-case.ts +98 -0
  70. package/server/controllers/finalize-data-collection.ts +388 -0
  71. package/server/controllers/index.ts +6 -0
  72. package/server/controllers/issue-data-collection-task.ts +70 -0
  73. package/server/controllers/issue-ooc-resolve.ts +58 -0
  74. package/server/controllers/issue-ooc-review.ts +52 -0
  75. package/server/controllers/jasper-report.ts +186 -0
  76. package/server/controllers/query-data-summary-by-period.ts +178 -0
  77. package/server/controllers/shiny-report.ts +54 -0
  78. package/server/engine/index.ts +1 -0
  79. package/server/engine/task/create-data-sample.ts +100 -0
  80. package/server/engine/task/index.ts +2 -0
  81. package/server/engine/task/issue-collect-data.ts +45 -0
  82. package/server/index.ts +8 -0
  83. package/server/routes.ts +188 -0
  84. package/server/service/data-archive/data-archive-mutation.ts +273 -0
  85. package/server/service/data-archive/data-archive-query.ts +58 -0
  86. package/server/service/data-archive/data-archive-type.ts +48 -0
  87. package/server/service/data-archive/data-archive.ts +69 -0
  88. package/server/service/data-archive/index.ts +6 -0
  89. package/server/service/data-key-set/data-key-item-type.ts +31 -0
  90. package/server/service/data-key-set/data-key-set-mutation.ts +201 -0
  91. package/server/service/data-key-set/data-key-set-query.ts +68 -0
  92. package/server/service/data-key-set/data-key-set-type.ts +70 -0
  93. package/server/service/data-key-set/data-key-set.ts +86 -0
  94. package/server/service/data-key-set/index.ts +6 -0
  95. package/server/service/data-ooc/data-ooc-mutation.ts +154 -0
  96. package/server/service/data-ooc/data-ooc-query.ts +106 -0
  97. package/server/service/data-ooc/data-ooc-subscription.ts +48 -0
  98. package/server/service/data-ooc/data-ooc-type.ts +71 -0
  99. package/server/service/data-ooc/data-ooc.ts +259 -0
  100. package/server/service/data-ooc/index.ts +7 -0
  101. package/server/service/data-sample/data-sample-mutation.ts +18 -0
  102. package/server/service/data-sample/data-sample-query.ts +215 -0
  103. package/server/service/data-sample/data-sample-type.ts +47 -0
  104. package/server/service/data-sample/data-sample.ts +193 -0
  105. package/server/service/data-sample/index.ts +6 -0
  106. package/server/service/data-sensor/data-sensor-mutation.ts +116 -0
  107. package/server/service/data-sensor/data-sensor-query.ts +76 -0
  108. package/server/service/data-sensor/data-sensor-type.ts +104 -0
  109. package/server/service/data-sensor/data-sensor.ts +126 -0
  110. package/server/service/data-sensor/index.ts +6 -0
  111. package/server/service/data-set/data-item-type.ts +155 -0
  112. package/server/service/data-set/data-set-mutation.ts +552 -0
  113. package/server/service/data-set/data-set-query.ts +461 -0
  114. package/server/service/data-set/data-set-type.ts +204 -0
  115. package/server/service/data-set/data-set.ts +326 -0
  116. package/server/service/data-set/index.ts +6 -0
  117. package/server/service/data-set-history/data-set-history-query.ts +126 -0
  118. package/server/service/data-set-history/data-set-history-type.ts +12 -0
  119. package/server/service/data-set-history/data-set-history.ts +217 -0
  120. package/server/service/data-set-history/event-subscriber.ts +17 -0
  121. package/server/service/data-set-history/index.ts +7 -0
  122. package/server/service/data-spec/data-spec-manager.ts +21 -0
  123. package/server/service/data-spec/data-spec-query.ts +21 -0
  124. package/server/service/data-spec/data-spec.ts +45 -0
  125. package/server/service/data-spec/index.ts +5 -0
  126. package/server/service/data-summary/data-summary-mutation.ts +45 -0
  127. package/server/service/data-summary/data-summary-query.ts +179 -0
  128. package/server/service/data-summary/data-summary-type.ts +86 -0
  129. package/server/service/data-summary/data-summary.ts +170 -0
  130. package/server/service/data-summary/index.ts +7 -0
  131. package/server/service/index.ts +57 -0
  132. package/server/tsconfig.json +10 -0
  133. package/server/utils/config-resolver.ts +29 -0
  134. package/server/utils/index.ts +1 -0
@@ -0,0 +1,105 @@
1
+ import '@operato/dataset/ox-data-entry-form.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 { client } from '@operato/graphql'
8
+ import { i18next, localize } from '@operato/i18n'
9
+ import { ScrollbarStyles } from '@operato/styles'
10
+ import { OxDataEntryForm } from '@operato/dataset/ox-data-entry-form.js'
11
+ import { DataSet } from '@operato/dataset'
12
+
13
+ @customElement('activity-data-collect-edit')
14
+ export class DataCollectActivityEdit extends localize(i18next)(LitElement) {
15
+ static styles = [
16
+ ScrollbarStyles,
17
+ css`
18
+ :host {
19
+ display: flex;
20
+ flex-direction: column;
21
+
22
+ background-color: var(--md-sys-color-surface);
23
+ }
24
+
25
+ ox-data-entry-form {
26
+ flex: 1;
27
+ padding: 10px;
28
+ overflow: auto;
29
+ }
30
+ `
31
+ ]
32
+
33
+ @property({ type: Object }) input?: any
34
+ @property({ type: Object }) output?: any
35
+
36
+ @state() dataSet?: DataSet & { id: string }
37
+
38
+ @query('ox-data-entry-form') entryForm!: OxDataEntryForm
39
+
40
+ render() {
41
+ return html`
42
+ <ox-data-entry-form
43
+ .dataSet=${this.dataSet}
44
+ .value=${this.output}
45
+ @change=${this._updateDataItems}
46
+ ></ox-data-entry-form>
47
+ `
48
+ }
49
+
50
+ async _updateDataItems(e: CustomEvent) {
51
+ e.stopPropagation()
52
+
53
+ this.output = this.entryForm.value
54
+
55
+ this.dispatchEvent(
56
+ new CustomEvent('change', {
57
+ detail: this.output
58
+ })
59
+ )
60
+ }
61
+
62
+ updated(changes) {
63
+ if (changes.has('input')) {
64
+ this.fetchDataSet()
65
+ }
66
+ }
67
+
68
+ async fetchDataSet() {
69
+ const id = this.input.dataSetId
70
+
71
+ if (id) {
72
+ const response = await client.query({
73
+ query: gql`
74
+ query ($id: String!) {
75
+ dataSet(id: $id) {
76
+ id
77
+ name
78
+ description
79
+ useCase
80
+ dataItems {
81
+ name
82
+ description
83
+ active
84
+ hidden
85
+ tag
86
+ group
87
+ type
88
+ unit
89
+ options
90
+ quota
91
+ spec
92
+ stat
93
+ }
94
+ }
95
+ }
96
+ `,
97
+ variables: {
98
+ id
99
+ }
100
+ })
101
+
102
+ this.dataSet = response.data.dataSet
103
+ }
104
+ }
105
+ }
@@ -0,0 +1,91 @@
1
+ import '@operato/dataset/ox-data-entry-view.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 { client } from '@operato/graphql'
8
+ import { i18next, localize } from '@operato/i18n'
9
+ import { ScrollbarStyles } from '@operato/styles'
10
+ import { DataSet } from '@operato/dataset'
11
+
12
+ @customElement('activity-data-collect-view')
13
+ export class DataCollectActivityView extends localize(i18next)(LitElement) {
14
+ static styles = [
15
+ ScrollbarStyles,
16
+ css`
17
+ :host {
18
+ display: flex;
19
+ flex-direction: column;
20
+
21
+ background-color: var(--md-sys-color-surface);
22
+ }
23
+
24
+ ox-data-entry-view {
25
+ flex: 1;
26
+ padding: 10px;
27
+ overflow: auto;
28
+ }
29
+
30
+ @media print {
31
+ :host {
32
+ display: block;
33
+ overflow: visible;
34
+ }
35
+ }
36
+ `
37
+ ]
38
+
39
+ @property({ type: Object }) input?: any
40
+ @property({ type: Object }) output?: any
41
+
42
+ @state() dataSet?: DataSet & { id: string }
43
+
44
+ render() {
45
+ return html` <ox-data-entry-view .dataSet=${this.dataSet} .value=${this.output}></ox-data-entry-view>`
46
+ }
47
+
48
+ updated(changes) {
49
+ if (changes.has('input')) {
50
+ this.fetchDataSet()
51
+ }
52
+ }
53
+
54
+ async fetchDataSet() {
55
+ const id = this.input.dataSetId
56
+
57
+ if (id) {
58
+ const response = await client.query({
59
+ query: gql`
60
+ query ($id: String!) {
61
+ dataSet(id: $id) {
62
+ id
63
+ name
64
+ description
65
+ useCase
66
+ dataItems {
67
+ name
68
+ description
69
+ active
70
+ hidden
71
+ tag
72
+ group
73
+ type
74
+ unit
75
+ options
76
+ quota
77
+ spec
78
+ stat
79
+ }
80
+ }
81
+ }
82
+ `,
83
+ variables: {
84
+ id
85
+ }
86
+ })
87
+
88
+ this.dataSet = response.data.dataSet
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,278 @@
1
+ import '@material/web/icon/icon.js'
2
+ import '@material/web/radio/radio.js'
3
+ import '@operato/dataset/ox-data-entry-form.js'
4
+
5
+ import gql from 'graphql-tag'
6
+ import { css, html, LitElement } from 'lit'
7
+ import { customElement, property, query, state } from 'lit/decorators.js'
8
+
9
+ import { i18next, localize } from '@operato/i18n'
10
+ import { ScrollbarStyles } from '@operato/styles'
11
+ import { client } from '@operato/graphql'
12
+
13
+ @customElement('activity-data-review-edit')
14
+ export class DataReviewActivityEdit extends localize(i18next)(LitElement) {
15
+ static styles = [
16
+ ScrollbarStyles,
17
+ css`
18
+ :host {
19
+ display: flex;
20
+ flex-direction: column;
21
+
22
+ background-color: var(--md-sys-color-surface);
23
+ }
24
+
25
+ div[content] {
26
+ flex: 1;
27
+ flex-direction: column;
28
+
29
+ display: flex;
30
+ overflow: auto;
31
+ }
32
+
33
+ ox-data-sample-view {
34
+ flex: 1;
35
+ padding: var(--spacing-large);
36
+ overflow: auto;
37
+ }
38
+
39
+ div[role='radiogroup'] {
40
+ display: flex;
41
+ flex-direction: row;
42
+ gap: var(--spacing-medium);
43
+
44
+ label {
45
+ display: flex;
46
+ flex-direction: row;
47
+
48
+ gap: var(--spacing-small);
49
+ align-items: center;
50
+ }
51
+ }
52
+
53
+ label {
54
+ display: flex;
55
+ flex-direction: column;
56
+
57
+ padding: var(--spacing-large);
58
+
59
+ h2 {
60
+ display: flex;
61
+
62
+ color: var(--title-text-color);
63
+ text-transform: capitalize;
64
+ margin: var(--title-margin);
65
+ align-items: center;
66
+ }
67
+
68
+ div {
69
+ padding: var(--spacing-large);
70
+ font: var(--input-field-font);
71
+ border: var(--md-sys-color-outline) solid 1px;
72
+ border-radius: var(--spacing-small);
73
+ background-color: var(--md-sys-color-surface-variant);
74
+ }
75
+
76
+ div[instruction] {
77
+ min-height: 200px;
78
+ }
79
+
80
+ md-icon {
81
+ color: var(--status-danger-color);
82
+ }
83
+
84
+ textarea {
85
+ margin: var(--spacing-medium);
86
+ padding: var(--spacing-medium);
87
+ margin: 0;
88
+ font: var(--input-field-font);
89
+ color: var(--md-sys-color-on-surface);
90
+ border: var(--md-sys-color-outline) solid 1px;
91
+ border-radius: var(--spacing-small);
92
+ background-color: var(--md-sys-color-surface-variant);
93
+
94
+ resize: none;
95
+ outline: none;
96
+ min-height: 200px;
97
+ }
98
+ }
99
+ `
100
+ ]
101
+
102
+ @property({ type: Object }) input?: any
103
+ @property({ type: Object }) output?: any
104
+ @property({ type: Object }) activityThread?: any
105
+
106
+ @state() dataSample?: any
107
+
108
+ @query('form') form!: HTMLFormElement
109
+
110
+ render() {
111
+ const { instruction, judgment } = this.output || {}
112
+ const { state } = this.activityThread || {}
113
+ const editable = state == 'unassigned' || state == 'assigned' || state == 'started' || state == 'submitted'
114
+
115
+ return html`
116
+ <div content>
117
+ <ox-data-sample-view .dataSample=${this.dataSample}></ox-data-sample-view>
118
+ </div>
119
+
120
+ <form @change=${this.onChangeInstruction}>
121
+ ${editable
122
+ ? html`
123
+ <label>
124
+ <h2><md-icon>build_circle</md-icon>&nbsp;<span>${i18next.t('label.judgment')}</span></h2>
125
+ <div role="radiogroup" aria-label="An example group of radio buttons">
126
+ <label>
127
+ <md-radio
128
+ name="judgment"
129
+ value="normal"
130
+ ?checked=${judgment == 'normal'}
131
+ aria-label=${i18next.t('label.judgment-normal')}
132
+ ></md-radio>
133
+ ${i18next.t('label.judgment-normal')}
134
+ </label>
135
+ <label>
136
+ <md-radio
137
+ name="judgment"
138
+ value="abnormal"
139
+ ?checked=${judgment == 'abnormal'}
140
+ aria-label=${i18next.t('label.judgment-abnormal')}
141
+ ></md-radio
142
+ >${i18next.t('label.judgment-abnormal')}
143
+ </label>
144
+ </div>
145
+ </label>
146
+
147
+ <label>
148
+ <h2><md-icon>build_circle</md-icon>&nbsp;<span>${i18next.t('label.corrective instruction')}</span></h2>
149
+ <textarea
150
+ name="instruction"
151
+ placeholder=${String(i18next.t('text.corrective instruction placeholder'))}
152
+ .value=${instruction || ''}
153
+ instruction
154
+ ></textarea>
155
+ </label>
156
+ `
157
+ : html`
158
+ <label>
159
+ <h2><md-icon>build_circle</md-icon>&nbsp;<span>${i18next.t('label.judgment')}</span></h2>
160
+ <div role="radiogroup" aria-label="An example group of radio buttons">
161
+ <label>
162
+ <md-radio
163
+ value="normal"
164
+ ?checked=${judgment == 'normal'}
165
+ aria-label=${i18next.t('label.judgment-normal')}
166
+ disabled
167
+ ></md-radio>
168
+ ${i18next.t('label.judgment-normal')}
169
+ </label>
170
+ <label>
171
+ <md-radio
172
+ value="abnormal"
173
+ ?checked=${judgment == 'abnormal'}
174
+ aria-label=${i18next.t('label.judgment-abnormal')}
175
+ disabled
176
+ ></md-radio
177
+ >${i18next.t('label.judgment-abnormal')}
178
+ </label>
179
+ </div>
180
+ </label>
181
+
182
+ <label>
183
+ <h2><md-icon>build_circle</md-icon>&nbsp;<span>${i18next.t('label.corrective instruction')}</span></h2>
184
+ <div instruction>${instruction}</div>
185
+ </label>
186
+ `}
187
+ </form>
188
+ `
189
+ }
190
+
191
+ onChangeInstruction(e: Event) {
192
+ var output = {}
193
+
194
+ const formData = new FormData(this.form)
195
+ formData.forEach((value, key) => {
196
+ output[key] = value
197
+ })
198
+
199
+ this.output = output
200
+
201
+ this.dispatchEvent(
202
+ new CustomEvent('change', {
203
+ detail: this.output
204
+ })
205
+ )
206
+ }
207
+
208
+ updated(changes) {
209
+ if (changes.has('input')) {
210
+ this.fetchDataSample()
211
+ }
212
+ }
213
+
214
+ async fetchDataSample() {
215
+ const { dataSampleId, dataSample } = this.input || {}
216
+
217
+ if (dataSample) {
218
+ /* only for backwards compatibility - should be deleted later */
219
+ this.dataSample = dataSample
220
+ } else if (dataSampleId) {
221
+ const response = await client.query({
222
+ query: gql`
223
+ query ($id: String!) {
224
+ dataSample(id: $id) {
225
+ id
226
+ name
227
+ description
228
+ useCase
229
+ key01
230
+ key02
231
+ key03
232
+ key04
233
+ key05
234
+ data
235
+ ooc
236
+ oos
237
+ dataSet {
238
+ id
239
+ name
240
+ description
241
+ }
242
+ dataItems {
243
+ name
244
+ description
245
+ active
246
+ hidden
247
+ tag
248
+ group
249
+ type
250
+ unit
251
+ options
252
+ quota
253
+ spec
254
+ stat
255
+ }
256
+ judgment
257
+ workDate
258
+ workShift
259
+ updater {
260
+ id
261
+ name
262
+ }
263
+ updatedAt
264
+ collectedAt
265
+ }
266
+ }
267
+ `,
268
+ variables: {
269
+ id: dataSampleId
270
+ }
271
+ })
272
+
273
+ this.dataSample = {
274
+ ...response.data.dataSample
275
+ }
276
+ }
277
+ }
278
+ }
@@ -0,0 +1,226 @@
1
+ import '@operato/dataset/ox-data-entry-form.js'
2
+
3
+ import gql from 'graphql-tag'
4
+ import { css, html, LitElement } from 'lit'
5
+ import { customElement, property, state } from 'lit/decorators.js'
6
+
7
+ import { i18next, localize } from '@operato/i18n'
8
+ import { ScrollbarStyles } from '@operato/styles'
9
+ import { client } from '@operato/graphql'
10
+
11
+ @customElement('activity-data-review-view')
12
+ export class DataReviewActivityView extends localize(i18next)(LitElement) {
13
+ static styles = [
14
+ ScrollbarStyles,
15
+ css`
16
+ :host {
17
+ display: flex;
18
+ flex-direction: column;
19
+
20
+ background-color: var(--md-sys-color-surface);
21
+ }
22
+
23
+ div[content] {
24
+ flex: 1;
25
+ flex-direction: column;
26
+
27
+ display: flex;
28
+ overflow: auto;
29
+ }
30
+
31
+ ox-data-sample-view {
32
+ flex: 1;
33
+ padding: var(--spacing-large);
34
+ overflow: auto;
35
+ }
36
+
37
+ div[role='radiogroup'] {
38
+ display: flex;
39
+ flex-direction: row;
40
+ gap: var(--spacing-medium);
41
+
42
+ label {
43
+ display: flex;
44
+ flex-direction: row;
45
+
46
+ gap: var(--spacing-small);
47
+ align-items: center;
48
+ }
49
+ }
50
+
51
+ label {
52
+ display: flex;
53
+ flex-direction: column;
54
+
55
+ padding: var(--spacing-large);
56
+
57
+ h2 {
58
+ display: flex;
59
+
60
+ color: var(--title-text-color);
61
+ text-transform: capitalize;
62
+ margin: var(--title-margin);
63
+ align-items: center;
64
+ }
65
+
66
+ div {
67
+ padding: var(--spacing-large);
68
+ font: var(--input-field-font);
69
+ border: var(--md-sys-color-outline) solid 1px;
70
+ border-radius: var(--spacing-small);
71
+ background-color: var(--md-sys-color-surface-variant);
72
+ }
73
+
74
+ div[instruction] {
75
+ min-height: 200px;
76
+ }
77
+
78
+ md-icon {
79
+ color: var(--status-danger-color);
80
+ }
81
+ }
82
+
83
+ @media print {
84
+ :host {
85
+ display: block;
86
+ overflow: visible;
87
+ }
88
+
89
+ div[content] {
90
+ display: block;
91
+ overflow: visible;
92
+ }
93
+ }
94
+ `
95
+ ]
96
+
97
+ @property({ type: Object }) input?: any
98
+ @property({ type: Object }) output?: any
99
+
100
+ @state() dataSample?: any
101
+
102
+ render() {
103
+ const { judgment, instruction } = this.output || {}
104
+
105
+ return html`
106
+ <div content>
107
+ <ox-data-sample-view .dataSample=${this.dataSample}></ox-data-sample-view>
108
+ </div>
109
+
110
+ <form>
111
+ <label>
112
+ <h2><md-icon>build_circle</md-icon>&nbsp;<span>${i18next.t('label.judgment')}</span></h2>
113
+ <div role="radiogroup" aria-label="An example group of radio buttons">
114
+ <label>
115
+ <md-radio
116
+ name="judgment"
117
+ value="normal"
118
+ ?checked=${judgment == 'normal'}
119
+ aria-label=${i18next.t('label.judgment-normal')}
120
+ disabled
121
+ ></md-radio>
122
+ ${i18next.t('label.judgment-normal')}
123
+ </label>
124
+ <label>
125
+ <md-radio
126
+ name="judgment"
127
+ value="abnormal"
128
+ ?checked=${judgment == 'abnormal'}
129
+ aria-label=${i18next.t('label.judgment-abnormal')}
130
+ disabled
131
+ ></md-radio
132
+ >${i18next.t('label.judgment-abnormal')}
133
+ </label>
134
+ </div>
135
+ </label>
136
+
137
+ <label>
138
+ <h2><md-icon>build_circle</md-icon>&nbsp;<span>${i18next.t('label.corrective instruction')}</span></h2>
139
+ <div instruction>${instruction}</div>
140
+ </label>
141
+ </form>
142
+ `
143
+ }
144
+
145
+ onChangeInstruction(e: Event) {
146
+ this.output ||= {}
147
+ this.output.instruction = (e.target as HTMLTextAreaElement).value
148
+
149
+ this.dispatchEvent(
150
+ new CustomEvent('change', {
151
+ detail: this.output
152
+ })
153
+ )
154
+ }
155
+
156
+ updated(changes) {
157
+ if (changes.has('input')) {
158
+ this.fetchDataAssign()
159
+ }
160
+ }
161
+
162
+ async fetchDataAssign() {
163
+ const { dataSampleId, dataSample } = this.input || {}
164
+
165
+ if (dataSample) {
166
+ /* only for backwards compatibility - should be deleted later */
167
+ this.dataSample = dataSample
168
+ } else if (dataSampleId) {
169
+ const response = await client.query({
170
+ query: gql`
171
+ query ($id: String!) {
172
+ dataSample(id: $id) {
173
+ id
174
+ name
175
+ description
176
+ useCase
177
+ key01
178
+ key02
179
+ key03
180
+ key04
181
+ key05
182
+ data
183
+ ooc
184
+ oos
185
+ dataSet {
186
+ id
187
+ name
188
+ description
189
+ }
190
+ dataItems {
191
+ name
192
+ description
193
+ active
194
+ hidden
195
+ tag
196
+ group
197
+ type
198
+ unit
199
+ options
200
+ quota
201
+ spec
202
+ stat
203
+ }
204
+ judgment
205
+ workDate
206
+ workShift
207
+ updater {
208
+ id
209
+ name
210
+ }
211
+ updatedAt
212
+ collectedAt
213
+ }
214
+ }
215
+ `,
216
+ variables: {
217
+ id: dataSampleId
218
+ }
219
+ })
220
+
221
+ this.dataSample = {
222
+ ...response.data.dataSample
223
+ }
224
+ }
225
+ }
226
+ }