@things-factory/dataset 6.0.25 → 6.0.28

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.
Files changed (193) hide show
  1. package/README.md +26 -11
  2. package/assets/images/data-collect.png +0 -0
  3. package/assets/images/ooc.png +0 -0
  4. package/assets/images/oos.png +0 -0
  5. package/client/{bootstrap.js → bootstrap.ts} +5 -1
  6. package/client/components/data-collect-activity-view.ts +100 -0
  7. package/client/components/{data-entry-form.js → data-entry-form.ts} +30 -33
  8. package/client/components/ooc-resolve-activity-view.ts +174 -0
  9. package/client/components/ooc-review-activity-view.ts +153 -0
  10. package/client/pages/data-archive/{data-archive-list-page.js → data-archive-list-page.ts} +67 -53
  11. package/client/pages/data-archive/{data-archive-request-popup.js → data-archive-request-popup.ts} +41 -39
  12. package/client/pages/data-entry/{data-entry-list-page.js → data-entry-list-page.ts} +41 -38
  13. package/client/pages/data-key-set/{data-key-item-list.js → data-key-item-list.ts} +31 -39
  14. package/client/pages/data-key-set/data-key-set-importer.ts +95 -0
  15. package/client/pages/data-key-set/{data-key-set-list-page.js → data-key-set-list-page.ts} +54 -35
  16. package/client/pages/data-ooc/{data-ooc-list-page.js → data-ooc-list-page.ts} +56 -36
  17. package/client/pages/data-ooc/data-ooc-view-page.ts +115 -0
  18. package/client/pages/data-ooc/data-ooc-view.ts +124 -0
  19. package/client/pages/data-report/{data-report-embed-page.js → data-report-embed-page.ts} +25 -34
  20. package/client/pages/data-report/{data-report-list-page.js → data-report-list-page.ts} +49 -43
  21. package/client/pages/data-report/{data-report-samples-page.js → data-report-samples-page.ts} +29 -43
  22. package/client/pages/data-report/{jasper-report-oocs-page.js → jasper-report-oocs-page.ts} +22 -34
  23. package/client/pages/data-report/{jasper-report-samples-crosstab-page.js → jasper-report-samples-crosstab-page.ts} +22 -34
  24. package/client/pages/data-report/{jasper-report-samples-page.js → jasper-report-samples-page.ts} +22 -34
  25. package/client/pages/data-sample/{data-sample-list-page.js → data-sample-list-page.ts} +49 -36
  26. package/client/pages/data-sample/{data-sample-search-page.js → data-sample-search-page.ts} +53 -39
  27. package/client/pages/data-sample/{data-sample-view.js → data-sample-view.ts} +29 -33
  28. package/client/pages/data-sensor/{data-sensor-list-page.js → data-sensor-list-page.ts} +41 -35
  29. package/client/pages/data-set/{data-item-list.js → data-item-list.ts} +31 -37
  30. package/client/pages/data-set/data-set-importer.ts +96 -0
  31. package/client/pages/data-set/{data-set-list-page.js → data-set-list-page.ts} +173 -40
  32. package/client/{route.js → route.ts} +5 -1
  33. package/client/tsconfig.json +11 -0
  34. package/config/config.development.js +30 -30
  35. package/config/config.production.js +31 -31
  36. package/dist-client/bootstrap.d.ts +5 -0
  37. package/dist-client/bootstrap.js +16 -0
  38. package/dist-client/bootstrap.js.map +1 -0
  39. package/dist-client/components/data-collect-activity-view.d.ts +19 -0
  40. package/dist-client/components/data-collect-activity-view.js +101 -0
  41. package/dist-client/components/data-collect-activity-view.js.map +1 -0
  42. package/dist-client/components/data-entry-form.d.ts +15 -0
  43. package/dist-client/components/data-entry-form.js +83 -0
  44. package/dist-client/components/data-entry-form.js.map +1 -0
  45. package/dist-client/components/data-ooc-activity-view.d.ts +1 -0
  46. package/dist-client/components/data-ooc-activity-view.js +154 -0
  47. package/dist-client/components/data-ooc-activity-view.js.map +1 -0
  48. package/dist-client/components/ooc-resolve-activity-view.d.ts +1 -0
  49. package/dist-client/components/ooc-resolve-activity-view.js +175 -0
  50. package/dist-client/components/ooc-resolve-activity-view.js.map +1 -0
  51. package/dist-client/components/ooc-review-activity-view.d.ts +1 -0
  52. package/dist-client/components/ooc-review-activity-view.js +155 -0
  53. package/dist-client/components/ooc-review-activity-view.js.map +1 -0
  54. package/dist-client/index.d.ts +1 -0
  55. package/dist-client/index.js +2 -0
  56. package/dist-client/index.js.map +1 -0
  57. package/dist-client/pages/data-archive/data-archive-list-page.d.ts +71 -0
  58. package/dist-client/pages/data-archive/data-archive-list-page.js +287 -0
  59. package/dist-client/pages/data-archive/data-archive-list-page.js.map +1 -0
  60. package/dist-client/pages/data-archive/data-archive-request-popup.d.ts +1 -0
  61. package/dist-client/pages/data-archive/data-archive-request-popup.js +161 -0
  62. package/dist-client/pages/data-archive/data-archive-request-popup.js.map +1 -0
  63. package/dist-client/pages/data-entry/data-entry-list-page.d.ts +36 -0
  64. package/dist-client/pages/data-entry/data-entry-list-page.js +383 -0
  65. package/dist-client/pages/data-entry/data-entry-list-page.js.map +1 -0
  66. package/dist-client/pages/data-key-set/data-key-item-list.d.ts +18 -0
  67. package/dist-client/pages/data-key-set/data-key-item-list.js +188 -0
  68. package/dist-client/pages/data-key-set/data-key-item-list.js.map +1 -0
  69. package/dist-client/pages/data-key-set/data-key-set-importer.d.ts +9 -0
  70. package/dist-client/pages/data-key-set/data-key-set-importer.js +100 -0
  71. package/dist-client/pages/data-key-set/data-key-set-importer.js.map +1 -0
  72. package/dist-client/pages/data-key-set/data-key-set-list-page.d.ts +60 -0
  73. package/dist-client/pages/data-key-set/data-key-set-list-page.js +450 -0
  74. package/dist-client/pages/data-key-set/data-key-set-list-page.js.map +1 -0
  75. package/dist-client/pages/data-ooc/data-ooc-list-page.d.ts +58 -0
  76. package/dist-client/pages/data-ooc/data-ooc-list-page.js +479 -0
  77. package/dist-client/pages/data-ooc/data-ooc-list-page.js.map +1 -0
  78. package/dist-client/pages/data-ooc/data-ooc-view-page.d.ts +18 -0
  79. package/dist-client/pages/data-ooc/data-ooc-view-page.js +114 -0
  80. package/dist-client/pages/data-ooc/data-ooc-view-page.js.map +1 -0
  81. package/dist-client/pages/data-ooc/data-ooc-view.d.ts +15 -0
  82. package/dist-client/pages/data-ooc/data-ooc-view.js +130 -0
  83. package/dist-client/pages/data-ooc/data-ooc-view.js.map +1 -0
  84. package/dist-client/pages/data-report/data-report-embed-page.d.ts +36 -0
  85. package/dist-client/pages/data-report/data-report-embed-page.js +101 -0
  86. package/dist-client/pages/data-report/data-report-embed-page.js.map +1 -0
  87. package/dist-client/pages/data-report/data-report-list-page.d.ts +36 -0
  88. package/dist-client/pages/data-report/data-report-list-page.js +431 -0
  89. package/dist-client/pages/data-report/data-report-list-page.js.map +1 -0
  90. package/dist-client/pages/data-report/data-report-samples-page.d.ts +32 -0
  91. package/dist-client/pages/data-report/data-report-samples-page.js +164 -0
  92. package/dist-client/pages/data-report/data-report-samples-page.js.map +1 -0
  93. package/dist-client/pages/data-report/jasper-report-oocs-page.d.ts +2 -0
  94. package/dist-client/pages/data-report/jasper-report-oocs-page.js +101 -0
  95. package/dist-client/pages/data-report/jasper-report-oocs-page.js.map +1 -0
  96. package/dist-client/pages/data-report/jasper-report-samples-crosstab-page.d.ts +2 -0
  97. package/dist-client/pages/data-report/jasper-report-samples-crosstab-page.js +101 -0
  98. package/dist-client/pages/data-report/jasper-report-samples-crosstab-page.js.map +1 -0
  99. package/dist-client/pages/data-report/jasper-report-samples-page.d.ts +2 -0
  100. package/dist-client/pages/data-report/jasper-report-samples-page.js +101 -0
  101. package/dist-client/pages/data-report/jasper-report-samples-page.js.map +1 -0
  102. package/dist-client/pages/data-sample/data-sample-list-page.d.ts +58 -0
  103. package/dist-client/pages/data-sample/data-sample-list-page.js +412 -0
  104. package/dist-client/pages/data-sample/data-sample-list-page.js.map +1 -0
  105. package/dist-client/pages/data-sample/data-sample-search-page.d.ts +63 -0
  106. package/dist-client/pages/data-sample/data-sample-search-page.js +413 -0
  107. package/dist-client/pages/data-sample/data-sample-search-page.js.map +1 -0
  108. package/dist-client/pages/data-sample/data-sample-view.d.ts +1 -0
  109. package/dist-client/pages/data-sample/data-sample-view.js +109 -0
  110. package/dist-client/pages/data-sample/data-sample-view.js.map +1 -0
  111. package/dist-client/pages/data-sensor/data-sensor-list-page.d.ts +49 -0
  112. package/dist-client/pages/data-sensor/data-sensor-list-page.js +419 -0
  113. package/dist-client/pages/data-sensor/data-sensor-list-page.js.map +1 -0
  114. package/dist-client/pages/data-set/data-item-list.d.ts +1 -0
  115. package/dist-client/pages/data-set/data-item-list.js +267 -0
  116. package/dist-client/pages/data-set/data-item-list.js.map +1 -0
  117. package/dist-client/pages/data-set/data-set-importer.d.ts +10 -0
  118. package/dist-client/pages/data-set/data-set-importer.js +103 -0
  119. package/dist-client/pages/data-set/data-set-importer.js.map +1 -0
  120. package/dist-client/pages/data-set/data-set-list-page.d.ts +73 -0
  121. package/dist-client/pages/data-set/data-set-list-page.js +861 -0
  122. package/dist-client/pages/data-set/data-set-list-page.js.map +1 -0
  123. package/dist-client/route.d.ts +1 -0
  124. package/dist-client/route.js +50 -0
  125. package/dist-client/route.js.map +1 -0
  126. package/dist-client/tsconfig.tsbuildinfo +1 -0
  127. package/dist-server/controllers/activity-template/activity-data-collect.js +82 -0
  128. package/dist-server/controllers/activity-template/activity-data-collect.js.map +1 -0
  129. package/dist-server/controllers/activity-template/activity-ooc-resolve.js +100 -0
  130. package/dist-server/controllers/activity-template/activity-ooc-resolve.js.map +1 -0
  131. package/dist-server/controllers/activity-template/activity-ooc-review.js +107 -0
  132. package/dist-server/controllers/activity-template/activity-ooc-review.js.map +1 -0
  133. package/dist-server/controllers/activity-template/activity-ooc.js +59 -0
  134. package/dist-server/controllers/activity-template/activity-ooc.js.map +1 -0
  135. package/dist-server/controllers/create-data-sample.js +53 -14
  136. package/dist-server/controllers/create-data-sample.js.map +1 -1
  137. package/dist-server/controllers/data-use-case.js +1 -1
  138. package/dist-server/controllers/data-use-case.js.map +1 -1
  139. package/dist-server/controllers/index.js +7 -0
  140. package/dist-server/controllers/index.js.map +1 -1
  141. package/dist-server/index.js +1 -2
  142. package/dist-server/index.js.map +1 -1
  143. package/dist-server/routes.js +47 -3
  144. package/dist-server/routes.js.map +1 -1
  145. package/dist-server/service/data-ooc/data-ooc-query.js +22 -2
  146. package/dist-server/service/data-ooc/data-ooc-query.js.map +1 -1
  147. package/dist-server/service/data-ooc/data-ooc.js +26 -0
  148. package/dist-server/service/data-ooc/data-ooc.js.map +1 -1
  149. package/dist-server/service/data-set/data-set-mutation.js +88 -0
  150. package/dist-server/service/data-set/data-set-mutation.js.map +1 -1
  151. package/dist-server/service/data-set/data-set-query.js +38 -4
  152. package/dist-server/service/data-set/data-set-query.js.map +1 -1
  153. package/dist-server/service/data-set/data-set-type.js +16 -0
  154. package/dist-server/service/data-set/data-set-type.js.map +1 -1
  155. package/dist-server/service/data-set/data-set.js +55 -3
  156. package/dist-server/service/data-set/data-set.js.map +1 -1
  157. package/dist-server/service/data-set-history/data-set-history-query.js +4 -3
  158. package/dist-server/service/data-set-history/data-set-history-query.js.map +1 -1
  159. package/dist-server/tsconfig.tsbuildinfo +1 -1
  160. package/helps/dataset/data-ooc.md +5 -4
  161. package/package.json +17 -12
  162. package/server/controllers/activity-template/activity-data-collect.ts +84 -0
  163. package/server/controllers/activity-template/activity-ooc-resolve.ts +114 -0
  164. package/server/controllers/activity-template/activity-ooc-review.ts +118 -0
  165. package/server/controllers/create-data-sample.ts +61 -21
  166. package/server/controllers/data-use-case.ts +1 -1
  167. package/server/controllers/index.ts +11 -0
  168. package/server/index.ts +1 -2
  169. package/server/routes.ts +62 -5
  170. package/server/service/data-ooc/data-ooc-query.ts +12 -2
  171. package/server/service/data-ooc/data-ooc.ts +23 -0
  172. package/server/service/data-set/data-set-mutation.ts +99 -0
  173. package/server/service/data-set/data-set-query.ts +39 -5
  174. package/server/service/data-set/data-set-type.ts +14 -0
  175. package/server/service/data-set/data-set.ts +43 -2
  176. package/server/service/data-set-history/data-set-history-query.ts +4 -3
  177. package/server/tsconfig.json +10 -0
  178. package/things-factory.config.js +6 -2
  179. package/translations/en.json +3 -1
  180. package/translations/ko.json +3 -1
  181. package/translations/ms.json +3 -0
  182. package/translations/zh.json +3 -0
  183. package/client/pages/data-key-set/data-key-set-importer.js +0 -105
  184. package/client/pages/data-ooc/data-ooc-view.js +0 -188
  185. package/client/pages/data-set/data-set-importer.js +0 -103
  186. package/server/middlewares/index.ts +0 -3
  187. package/server/migrations/index.ts +0 -9
  188. package/tsconfig.json +0 -9
  189. /package/assets/{data-report.jpg → images/data-report.jpg} +0 -0
  190. /package/assets/{data-samples.jpg → images/data-samples.jpg} +0 -0
  191. /package/assets/{diagram.jpg → images/dataset-diagram.jpg} +0 -0
  192. /package/assets/{glue-table-indices.png → images/glue-table-indices-for-dataset.png} +0 -0
  193. /package/client/{index.js → index.ts} +0 -0
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # dataset
2
+
2
3
  ## dataset relation diagram
3
- ![ERD Diagram](./assets/diagram.jpg)
4
+
5
+ ![Dataset ERD Diagram](./assets/images/dataset-diagram.jpg)
6
+
4
7
  - 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_##)에 해당 값을 저장합니다.
8
+ - data*sets는 또한 data_key_sets를 참고할 수 있습니다. data_key_sets에서는 data_samples, data_oocs의 조회 인덱스를 위한 key(key_01~key_05)를 정의합니다. data_samples, data_oocs 데이타 생성 시점에, data 컬럼 값으로 부터 별도 컬럼(key*##)에 해당 값을 저장합니다.
6
9
  - data_set_histories에는 data_sets의 변경 내역이 추가됩니다. data_sets의 id는 data_set_histories에 original_id로 추가됩니다. data_set_histories를 사용하려면 original_id 와 version이 필요합니다.
7
10
  - data_sensors에는 자동 수집되는 디바이스 정보를 정의합니다. data_sets를 참고하여 CCP를 관리하도록 합니다.
8
11
  - data_samples에는 입력받은 실제 데이터가 저장됩니다.
@@ -10,29 +13,38 @@
10
13
  - data_archives에는 다운로드 받기 위한 요청 정보 및 상태가 저장됩니다.
11
14
 
12
15
  ## Architecture for collecting data samples
13
- ![Architecture for data-samples](./assets/data-samples.jpg)
16
+
17
+ ![Architecture for data-samples](./assets/images/data-samples.jpg)
14
18
  data_samples, data_oocs, data_set_histories의 테이블 변경 사항은 Database CDC로 Kafka에 전송 및 저장되고 토픽별로 다음의 lambda 들이 트리거되어 S3로 저장합니다. 이 S3 데이터는 Glue Crawler, Glue Data Catalog를 거쳐 Athena에서 조회할 수 있습니다. hive 스타일의 S3 파티션 정보들을 업데이트 하는 작업이 스케줄링되어 작동하고, 파티션 정보가 업데이트 된 S3파일들이 Athena에서 조회되므로 실시간으로 데이터가 반영되지는 않습니다.
19
+
15
20
  - [func-data-samples-to-s3](https://github.com/operatochef/serverless/tree/main/func-data-samples-to-s3)
16
21
  - [func-data-oocs-to-s3](https://github.com/operatochef/serverless/tree/main/func-data-oocs-to-s3)
17
22
  - [func-data-set-histories-to-s3](https://github.com/operatochef/serverless/tree/main/func-data-set-histories-to-s3)
18
23
 
19
- 개발용으로는 reference-app을 사용하고 있으며, 여기서는 func-dev-* 로 시작하는 lambda들을 사용합니다.
24
+ 개발용으로는 reference-app을 사용하고 있으며, 여기서는 func-dev-\* 로 시작하는 lambda들을 사용합니다.
25
+
20
26
  ## data-report process
21
- ![data-report process](./assets/data-report.jpg)
27
+
28
+ ![data-report process](./assets/images/data-report.jpg)
22
29
 
23
30
  'shiny' uses the next lambda. But 'jasper' is not using this lambda now. Consider using the same data service.
31
+
24
32
  - [func-transform-data-samples](https://github.com/operatochef/serverless/tree/main/func-transform-data-samples)
25
33
 
26
34
  ## Partition Keys
35
+
27
36
  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'.
28
37
 
29
- Partition keys are related for S3 request limitations.
30
- > __3,500 PUT/COPY/POST/DELETE or 5,500 GET/HEAD requests per second per prefix in a bucket__
38
+ Partition keys are related for S3 request limitations.
39
+
40
+ > **3,500 PUT/COPY/POST/DELETE or 5,500 GET/HEAD requests per second per prefix in a bucket**
41
+
31
42
  - https://docs.aws.amazon.com/AmazonS3/latest/userguide/optimizing-performance.html
32
43
 
33
44
  ### :warning: This concept will be deprecated.
34
45
 
35
- Now partition keys are fixed
46
+ Now partition keys are fixed
47
+
36
48
  - domain
37
49
  - datasetid
38
50
  - date: local time date
@@ -40,19 +52,22 @@ Now partition keys are fixed
40
52
  - workshift
41
53
 
42
54
  ### Glue Catalog Table Indices
55
+
43
56
  Partitions can be indices. You can create new indices with combination of partitions.
44
57
  It affects query performance and finding partitions.
45
- ![partitions and indices](./assets/glue-table-indices.png)
58
+ ![partitions and indices](./assets/images/glue-table-indices-for-dataset.png)
46
59
 
47
60
  ## Timestamp of Data Samples
61
+
48
62
  sample data could have an own timestamp if it is from a sensor data.
49
63
  'collected_at' uses this timestamp.
50
64
  Manual type of data is used 'Date.now() and new Date()'
51
65
  Graphql might affect timezone of server os for Date type field.
52
66
  'TZ=UTC node' can help to solve this when server starts.
53
- Or use ``` process.env.TZ = 'UTC' ```.
67
+ Or use `process.env.TZ = 'UTC'`.
54
68
  Now applied in 'create-data-samples.ts'
55
69
 
56
70
  ## Data Archive
71
+
57
72
  제출용 데이터를 위해 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' 리소스를 참고바랍니다.
73
+ Glue Job을 이용한 처리를 진행해보았으나, 시간이 너무 오래걸리는 문제가 있었습니다. 해당 내용은 AWS ibex계정의 Glue Jobs - 'reference_app_samples_archive' 리소스를 참고바랍니다.
Binary file
Binary file
Binary file
@@ -1,3 +1,7 @@
1
+ import './components/data-collect-activity-view' /* refered by the activity template (activity-data-collect) on server */
2
+ import './components/ooc-review-activity-view' /* refered by the activity template (activity-ooc-review) on server */
3
+ import './components/ooc-resolve-activity-view' /* refered by the activity template (activity-ooc-resolve) on server */
4
+
1
5
  import '@operato/app/filter-renderer.js' /* register resource-object filter renderer */
2
6
 
3
7
  import { OxGristEditorCode } from '@operato/app/grist-editor/ox-grist-editor-code.js'
@@ -6,7 +10,7 @@ import {
6
10
  registerEditor as registerGristEditor,
7
11
  registerRenderer as registerGristRenderer
8
12
  } from '@operato/data-grist'
9
- import { OxGristEditorDataItemSpec } from '@operato/dataset/grist-editor'
13
+ import { OxGristEditorDataItemSpec } from '@operato/dataset/grist-editor/ox-grist-editor-data-item-spec.js'
10
14
  import { OxGristEditorPartitionKeys } from '@operato/grist-editor/ox-grist-editor-partition-keys.js'
11
15
 
12
16
  export default function bootstrap() {
@@ -0,0 +1,100 @@
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('data-collect-activity-view')
14
+ export class DataCollectActivityView extends localize(i18next)(LitElement) {
15
+ static styles = [
16
+ ScrollbarStyles,
17
+ css`
18
+ :host {
19
+ display: flex;
20
+ flex-direction: column;
21
+
22
+ background-color: #fff;
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() {
51
+ this.output = this.entryForm.value
52
+
53
+ this.dispatchEvent(
54
+ new CustomEvent('change', {
55
+ detail: this.output
56
+ })
57
+ )
58
+ }
59
+
60
+ updated(changes) {
61
+ if (changes.has('input')) {
62
+ this.fetchDataSet()
63
+ }
64
+ }
65
+
66
+ async fetchDataSet() {
67
+ const id = this.input.dataSetId
68
+
69
+ if (id) {
70
+ const response = await client.query({
71
+ query: gql`
72
+ query ($id: String!) {
73
+ dataSet(id: $id) {
74
+ id
75
+ name
76
+ description
77
+ useCase
78
+ dataItems {
79
+ name
80
+ description
81
+ active
82
+ tag
83
+ type
84
+ unit
85
+ options
86
+ quota
87
+ spec
88
+ }
89
+ }
90
+ }
91
+ `,
92
+ variables: {
93
+ id
94
+ }
95
+ })
96
+
97
+ this.dataSet = response.data.dataSet
98
+ }
99
+ }
100
+ }
@@ -2,47 +2,43 @@ import '@operato/dataset/ox-data-entry-form.js'
2
2
 
3
3
  import gql from 'graphql-tag'
4
4
  import { css, html, LitElement } from 'lit'
5
+ import { customElement, property, query, state } from 'lit/decorators.js'
5
6
 
6
7
  import { client } from '@operato/graphql'
7
8
  import { i18next, localize } from '@operato/i18n'
8
9
  import { ScrollbarStyles } from '@operato/styles'
10
+ import { OxDataEntryForm } from '@operato/dataset/ox-data-entry-form.js'
11
+ import { DataSet } from '@operato/dataset'
9
12
 
13
+ @customElement('data-entry-form')
10
14
  export class DataEntryForm extends localize(i18next)(LitElement) {
11
- static get properties() {
12
- return {
13
- dataSet: Object
14
- }
15
- }
15
+ static styles = [
16
+ ScrollbarStyles,
17
+ css`
18
+ :host {
19
+ display: flex;
20
+ flex-direction: column;
16
21
 
17
- static get styles() {
18
- return [
19
- ScrollbarStyles,
20
- css`
21
- :host {
22
- display: flex;
23
- flex-direction: column;
22
+ background-color: #fff;
23
+ }
24
24
 
25
- background-color: #fff;
26
- }
25
+ ox-data-entry-form {
26
+ flex: 1;
27
+ padding: 10px;
28
+ overflow: auto;
29
+ }
27
30
 
28
- ox-data-entry-form {
29
- flex: 1;
30
- padding: 10px;
31
- overflow: auto;
32
- }
31
+ .button-container {
32
+ display: flex;
33
+ margin-left: auto;
34
+ padding: var(--padding-default);
35
+ }
36
+ `
37
+ ]
33
38
 
34
- .button-container {
35
- display: flex;
36
- margin-left: auto;
37
- padding: var(--padding-default);
38
- }
39
- `
40
- ]
41
- }
39
+ @property({ type: Object }) dataSet?: DataSet & { id: string }
42
40
 
43
- get entryForm() {
44
- return this.renderRoot.querySelector('ox-data-entry-form')
45
- }
41
+ @query('ox-data-entry-form') entryForm!: OxDataEntryForm
46
42
 
47
43
  render() {
48
44
  return html`
@@ -54,10 +50,13 @@ export class DataEntryForm extends localize(i18next)(LitElement) {
54
50
  }
55
51
 
56
52
  async _updateDataItems() {
53
+ //@ts-ignore TODO replace with following line and confirm
57
54
  const data = this.entryForm.buildValue()
55
+ // const data = this.entryForm.value
56
+
58
57
  const dataSample = {
59
58
  dataSet: {
60
- id: this.dataSet.id
59
+ id: this.dataSet?.id
61
60
  },
62
61
  data
63
62
  }
@@ -83,5 +82,3 @@ export class DataEntryForm extends localize(i18next)(LitElement) {
83
82
  }
84
83
  }
85
84
  }
86
-
87
- window.customElements.define('data-entry-form', DataEntryForm)
@@ -0,0 +1,174 @@
1
+ import '@operato/dataset/ox-data-sample-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
+
11
+ @customElement('ooc-resolve-activity-view')
12
+ class OocResolveActivityView extends localize(i18next)(LitElement) {
13
+ static styles = [
14
+ ScrollbarStyles,
15
+ css`
16
+ :host {
17
+ display: flex;
18
+ flex-direction: column;
19
+
20
+ background-color: #fff;
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(--padding-wide);
34
+ overflow: auto;
35
+ }
36
+
37
+ div[instruction] {
38
+ display: flex;
39
+ flex-direction: column;
40
+
41
+ padding: var(--padding-wide);
42
+ }
43
+
44
+ div[instruction] div {
45
+ display: flex;
46
+ }
47
+
48
+ div[instruction] div[content] {
49
+ display: flex;
50
+ min-height: 50px;
51
+ }
52
+
53
+ label[action] {
54
+ display: flex;
55
+ flex-direction: column;
56
+
57
+ padding: var(--padding-wide);
58
+ }
59
+
60
+ label[action] div {
61
+ display: flex;
62
+ }
63
+
64
+ mwc-icon {
65
+ color: var(--status-danger-color);
66
+ }
67
+
68
+ textarea {
69
+ border: var(--input-field-border);
70
+ border-radius: var(--input-border-radius);
71
+ padding: var(--input-field-padding);
72
+ font: var(--input-field-font);
73
+ }
74
+
75
+ .button-container {
76
+ display: flex;
77
+ margin-left: auto;
78
+ padding: var(--padding-default);
79
+ }
80
+ `
81
+ ]
82
+
83
+ @property({ type: Object }) input?: any
84
+ @property({ type: Object }) output?: any
85
+
86
+ @state() dataOoc?: any
87
+
88
+ @query('textarea') actionTextArea!: HTMLTextAreaElement
89
+
90
+ render() {
91
+ const action = this.output?.action
92
+
93
+ return html`
94
+ <div content>
95
+ <ox-data-sample-view .dataSample=${this.dataOoc}></ox-data-sample-view>
96
+ </div>
97
+
98
+ <div instruction>
99
+ <div><mwc-icon>build_circle</mwc-icon> <span>corrective instruction</span></div>
100
+ <div content>${this.input?.instruction}</div>
101
+ </div>
102
+
103
+ <label action>
104
+ <div><mwc-icon>build_circle</mwc-icon> <span>corrective action</span></div>
105
+ <textarea
106
+ placeholder="시정 및 예방을 위한 조치 이행 사항을 입력해주세요."
107
+ .value=${action || ''}
108
+ @change=${this.onChangeAction}
109
+ ></textarea>
110
+ </label>
111
+ `
112
+ }
113
+
114
+ onChangeAction(e: Event) {
115
+ this.output ||= {}
116
+ this.output.action = (e.target as HTMLTextAreaElement).value
117
+
118
+ this.dispatchEvent(
119
+ new CustomEvent('change', {
120
+ detail: this.output
121
+ })
122
+ )
123
+ }
124
+
125
+ updated(changes) {
126
+ if (changes.has('input')) {
127
+ this.fetchDataOoc()
128
+ }
129
+ }
130
+
131
+ async fetchDataOoc() {
132
+ const id = this.input.dataOocId
133
+
134
+ if (id) {
135
+ const response = await client.query({
136
+ query: gql`
137
+ query ($id: String!) {
138
+ dataOoc(id: $id) {
139
+ id
140
+ name
141
+ description
142
+ ooc
143
+ oos
144
+ state
145
+ type
146
+ useCase
147
+ data
148
+ judgment
149
+ dataItems {
150
+ name
151
+ description
152
+ active
153
+ tag
154
+ type
155
+ unit
156
+ options
157
+ quota
158
+ spec
159
+ }
160
+ workDate
161
+ workShift
162
+ collectedAt
163
+ }
164
+ }
165
+ `,
166
+ variables: {
167
+ id
168
+ }
169
+ })
170
+
171
+ this.dataOoc = response.data.dataOoc
172
+ }
173
+ }
174
+ }
@@ -0,0 +1,153 @@
1
+ import '@operato/dataset/ox-data-sample-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
+
11
+ @customElement('ooc-review-activity-view')
12
+ class OocReviewActivityView extends localize(i18next)(LitElement) {
13
+ static styles = [
14
+ ScrollbarStyles,
15
+ css`
16
+ :host {
17
+ display: flex;
18
+ flex-direction: column;
19
+
20
+ background-color: #fff;
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(--padding-wide);
34
+ overflow: auto;
35
+ }
36
+
37
+ label[instruction] {
38
+ display: flex;
39
+ flex-direction: column;
40
+
41
+ padding: var(--padding-wide);
42
+ }
43
+
44
+ label[instruction] div {
45
+ display: flex;
46
+ }
47
+
48
+ mwc-icon {
49
+ color: var(--status-danger-color);
50
+ }
51
+
52
+ textarea {
53
+ border: var(--input-field-border);
54
+ border-radius: var(--input-border-radius);
55
+ padding: var(--input-field-padding);
56
+ font: var(--input-field-font);
57
+ }
58
+
59
+ .button-container {
60
+ display: flex;
61
+ margin-left: auto;
62
+ padding: var(--padding-default);
63
+ }
64
+ `
65
+ ]
66
+
67
+ @property({ type: Object }) input?: any
68
+ @property({ type: Object }) output?: any
69
+
70
+ @state() dataOoc?: any
71
+
72
+ @query('textarea') instructionTextArea!: HTMLTextAreaElement
73
+
74
+ render() {
75
+ const instruction = this.output?.instruction
76
+
77
+ return html`
78
+ <div content>
79
+ <ox-data-sample-view .dataSample=${this.dataOoc}></ox-data-sample-view>
80
+ </div>
81
+
82
+ <label instruction>
83
+ <div><mwc-icon>build_circle</mwc-icon> <span>corrective instruction</span></div>
84
+ <textarea
85
+ placeholder="시정 및 예방을 위한 조치 지시 사항을 입력해주세요."
86
+ .value=${instruction || ''}
87
+ @change=${this.onChangeInstruction}
88
+ ></textarea>
89
+ </label>
90
+ `
91
+ }
92
+
93
+ onChangeInstruction(e: Event) {
94
+ this.output ||= {}
95
+ this.output.instruction = (e.target as HTMLTextAreaElement).value
96
+
97
+ this.dispatchEvent(
98
+ new CustomEvent('change', {
99
+ detail: this.output
100
+ })
101
+ )
102
+ }
103
+
104
+ updated(changes) {
105
+ if (changes.has('input')) {
106
+ this.fetchDataOoc()
107
+ }
108
+ }
109
+
110
+ async fetchDataOoc() {
111
+ const id = this.input?.dataOocId
112
+
113
+ if (id) {
114
+ const response = await client.query({
115
+ query: gql`
116
+ query ($id: String!) {
117
+ dataOoc(id: $id) {
118
+ id
119
+ name
120
+ description
121
+ ooc
122
+ oos
123
+ state
124
+ type
125
+ useCase
126
+ data
127
+ judgment
128
+ dataItems {
129
+ name
130
+ description
131
+ active
132
+ tag
133
+ type
134
+ unit
135
+ options
136
+ quota
137
+ spec
138
+ }
139
+ workDate
140
+ workShift
141
+ collectedAt
142
+ }
143
+ }
144
+ `,
145
+ variables: {
146
+ id
147
+ }
148
+ })
149
+
150
+ this.dataOoc = response.data.dataOoc
151
+ }
152
+ }
153
+ }