@things-factory/worklist 5.0.0-zeta.7 → 5.0.0

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 (208) hide show
  1. package/README.md +13 -0
  2. package/client/bootstrap.js +12 -1
  3. package/client/components/activity-/bowner-view.js +108 -0
  4. package/client/components/activity-instance-preview.js +206 -0
  5. package/client/components/activity-intro-view.js +108 -0
  6. package/client/components/activity-reporter-view.js +108 -0
  7. package/client/components/activity-starter-form.js +330 -0
  8. package/client/index.js +1 -0
  9. package/client/pages/activity/activity-list-page.js +153 -37
  10. package/client/pages/activity/activity-model-item-list.js +301 -0
  11. package/client/pages/activity/activity-page.js +433 -0
  12. package/client/pages/{todo → activity}/starter-list-page.js +42 -56
  13. package/client/pages/activity-instance/activity-instance-list-page.js +31 -2
  14. package/client/pages/activity-instance/activity-instance-page.js +421 -0
  15. package/client/pages/activity-store/activity-store-page.js +233 -0
  16. package/client/pages/activity-supervisor/reporter-list-page.js +225 -0
  17. package/client/pages/activity-template/activity-template-importer.js +107 -0
  18. package/client/pages/activity-template/activity-template-list-page.js +439 -0
  19. package/client/pages/activity-template/activity-template-model-item-list.js +43 -0
  20. package/client/pages/activity-thread/activity-thread-importer.js +107 -0
  21. package/client/pages/activity-thread/activity-thread-list-page.js +327 -0
  22. package/client/pages/activity-thread/activity-thread-page.js +398 -0
  23. package/client/pages/dashboard/dashboard-home.js +20 -0
  24. package/client/pages/todo/assigned-list-page.js +27 -13
  25. package/client/pages/todo/draft-list-page.js +327 -0
  26. package/client/pages/todo/pickable-list-page.js +276 -0
  27. package/client/pages/todo/todo-list-page.js +149 -38
  28. package/client/pages/worklist-home.js +1 -1
  29. package/client/route.js +41 -1
  30. package/client/types.js +39 -0
  31. package/dist-server/controllers/activity-extension-controller.js +11 -0
  32. package/dist-server/controllers/activity-extension-controller.js.map +1 -0
  33. package/dist-server/controllers/activity-instance/abort.js +22 -0
  34. package/dist-server/controllers/activity-instance/abort.js.map +1 -0
  35. package/dist-server/controllers/activity-instance/adjust.js +14 -0
  36. package/dist-server/controllers/activity-instance/adjust.js.map +1 -0
  37. package/dist-server/controllers/activity-instance/assign.js +46 -0
  38. package/dist-server/controllers/activity-instance/assign.js.map +1 -0
  39. package/dist-server/controllers/activity-instance/common.js +30 -0
  40. package/dist-server/controllers/activity-instance/common.js.map +1 -0
  41. package/dist-server/controllers/activity-instance/create.js +103 -0
  42. package/dist-server/controllers/activity-instance/create.js.map +1 -0
  43. package/dist-server/controllers/activity-instance/delegate.js +26 -0
  44. package/dist-server/controllers/activity-instance/delegate.js.map +1 -0
  45. package/dist-server/controllers/activity-instance/draft.js +32 -0
  46. package/dist-server/controllers/activity-instance/draft.js.map +1 -0
  47. package/dist-server/controllers/activity-instance/end.js +23 -0
  48. package/dist-server/controllers/activity-instance/end.js.map +1 -0
  49. package/dist-server/controllers/activity-instance/index.js +27 -0
  50. package/dist-server/controllers/activity-instance/index.js.map +1 -0
  51. package/dist-server/controllers/activity-instance/pick.js +22 -0
  52. package/dist-server/controllers/activity-instance/pick.js.map +1 -0
  53. package/dist-server/controllers/activity-instance/post.js +21 -0
  54. package/dist-server/controllers/activity-instance/post.js.map +1 -0
  55. package/dist-server/controllers/activity-instance/save.js +14 -0
  56. package/dist-server/controllers/activity-instance/save.js.map +1 -0
  57. package/dist-server/controllers/activity-instance/start.js +14 -0
  58. package/dist-server/controllers/activity-instance/start.js.map +1 -0
  59. package/dist-server/controllers/activity-instance/take.js +46 -0
  60. package/dist-server/controllers/activity-instance/take.js.map +1 -0
  61. package/dist-server/controllers/activity-instance/terminate.js +23 -0
  62. package/dist-server/controllers/activity-instance/terminate.js.map +1 -0
  63. package/dist-server/controllers/activity-thread/abort.js +21 -0
  64. package/dist-server/controllers/activity-thread/abort.js.map +1 -0
  65. package/dist-server/controllers/activity-thread/adjust.js +13 -0
  66. package/dist-server/controllers/activity-thread/adjust.js.map +1 -0
  67. package/dist-server/controllers/activity-thread/delegate.js +25 -0
  68. package/dist-server/controllers/activity-thread/delegate.js.map +1 -0
  69. package/dist-server/controllers/activity-thread/end.js +22 -0
  70. package/dist-server/controllers/activity-thread/end.js.map +1 -0
  71. package/dist-server/controllers/activity-thread/index.js +24 -0
  72. package/dist-server/controllers/activity-thread/index.js.map +1 -0
  73. package/dist-server/controllers/activity-thread/save.js +13 -0
  74. package/dist-server/controllers/activity-thread/save.js.map +1 -0
  75. package/dist-server/controllers/activity-thread/start.js +23 -0
  76. package/dist-server/controllers/activity-thread/start.js.map +1 -0
  77. package/dist-server/controllers/activity-thread/terminate.js +22 -0
  78. package/dist-server/controllers/activity-thread/terminate.js.map +1 -0
  79. package/dist-server/controllers/common.js +65 -0
  80. package/dist-server/controllers/common.js.map +1 -0
  81. package/dist-server/service/activity/activity-history.js +202 -0
  82. package/dist-server/service/activity/activity-history.js.map +1 -0
  83. package/dist-server/service/activity/activity-model-type.js +147 -0
  84. package/dist-server/service/activity/activity-model-type.js.map +1 -0
  85. package/dist-server/service/activity/activity-mutation.js +41 -2
  86. package/dist-server/service/activity/activity-mutation.js.map +1 -1
  87. package/dist-server/service/activity/activity-query.js +83 -8
  88. package/dist-server/service/activity/activity-query.js.map +1 -1
  89. package/dist-server/service/activity/activity-type.js +63 -3
  90. package/dist-server/service/activity/activity-type.js.map +1 -1
  91. package/dist-server/service/activity/activity.js +66 -10
  92. package/dist-server/service/activity/activity.js.map +1 -1
  93. package/dist-server/service/activity/event-subscriber.js +26 -0
  94. package/dist-server/service/activity/event-subscriber.js.map +1 -0
  95. package/dist-server/service/activity/index.js +6 -3
  96. package/dist-server/service/activity/index.js.map +1 -1
  97. package/dist-server/service/activity-instance/activity-instance-history.js +249 -0
  98. package/dist-server/service/activity-instance/activity-instance-history.js.map +1 -0
  99. package/dist-server/service/activity-instance/activity-instance-mutation.js +79 -122
  100. package/dist-server/service/activity-instance/activity-instance-mutation.js.map +1 -1
  101. package/dist-server/service/activity-instance/activity-instance-query.js +119 -10
  102. package/dist-server/service/activity-instance/activity-instance-query.js.map +1 -1
  103. package/dist-server/service/activity-instance/activity-instance-subscription.js +68 -0
  104. package/dist-server/service/activity-instance/activity-instance-subscription.js.map +1 -0
  105. package/dist-server/service/activity-instance/activity-instance-type.js +148 -6
  106. package/dist-server/service/activity-instance/activity-instance-type.js.map +1 -1
  107. package/dist-server/service/activity-instance/activity-instance.js +125 -11
  108. package/dist-server/service/activity-instance/activity-instance.js.map +1 -1
  109. package/dist-server/service/activity-instance/event-subscriber.js +53 -0
  110. package/dist-server/service/activity-instance/event-subscriber.js.map +1 -0
  111. package/dist-server/service/activity-instance/index.js +8 -4
  112. package/dist-server/service/activity-instance/index.js.map +1 -1
  113. package/dist-server/service/activity-template/activity-template-history.js +167 -0
  114. package/dist-server/service/activity-template/activity-template-history.js.map +1 -0
  115. package/dist-server/service/activity-template/activity-template-mutation.js +177 -0
  116. package/dist-server/service/activity-template/activity-template-mutation.js.map +1 -0
  117. package/dist-server/service/activity-template/activity-template-query.js +109 -0
  118. package/dist-server/service/activity-template/activity-template-query.js.map +1 -0
  119. package/dist-server/service/activity-template/activity-template-type.js +159 -0
  120. package/dist-server/service/activity-template/activity-template-type.js.map +1 -0
  121. package/dist-server/service/activity-template/activity-template.js +157 -0
  122. package/dist-server/service/activity-template/activity-template.js.map +1 -0
  123. package/dist-server/service/activity-template/event-subscriber.js +26 -0
  124. package/dist-server/service/activity-template/event-subscriber.js.map +1 -0
  125. package/dist-server/service/activity-template/index.js +12 -0
  126. package/dist-server/service/activity-template/index.js.map +1 -0
  127. package/dist-server/service/activity-thread/activity-thread-mutation.js +211 -0
  128. package/dist-server/service/activity-thread/activity-thread-mutation.js.map +1 -0
  129. package/dist-server/service/activity-thread/activity-thread-query.js +142 -0
  130. package/dist-server/service/activity-thread/activity-thread-query.js.map +1 -0
  131. package/dist-server/service/activity-thread/activity-thread-subscription.js +58 -0
  132. package/dist-server/service/activity-thread/activity-thread-subscription.js.map +1 -0
  133. package/dist-server/service/activity-thread/activity-thread-type.js +81 -0
  134. package/dist-server/service/activity-thread/activity-thread-type.js.map +1 -0
  135. package/dist-server/service/activity-thread/activity-thread.js +174 -0
  136. package/dist-server/service/activity-thread/activity-thread.js.map +1 -0
  137. package/dist-server/service/activity-thread/event-subscriber.js +43 -0
  138. package/dist-server/service/activity-thread/event-subscriber.js.map +1 -0
  139. package/dist-server/service/activity-thread/index.js +12 -0
  140. package/dist-server/service/activity-thread/index.js.map +1 -0
  141. package/dist-server/service/index.js +20 -6
  142. package/dist-server/service/index.js.map +1 -1
  143. package/package.json +8 -6
  144. package/scenarios/scenario-001-issuer-assignee.txt +19 -0
  145. package/scenarios/scenario-001.png +0 -0
  146. package/scenarios/scenario-002-scenario-engine-issuer.txt +22 -0
  147. package/scenarios/scenario-002.png +0 -0
  148. package/scenarios/scenario-003-scheduled-scenario-issuer.txt +27 -0
  149. package/scenarios/scenario-003.png +0 -0
  150. package/scenarios/scenario-004-scheduled-dataset-issuer.txt +23 -0
  151. package/scenarios/scenario-004.png +0 -0
  152. package/server/controllers/activity-extension-controller.ts +12 -0
  153. package/server/controllers/activity-instance/abort.ts +37 -0
  154. package/server/controllers/activity-instance/adjust.ts +22 -0
  155. package/server/controllers/activity-instance/assign.ts +72 -0
  156. package/server/controllers/activity-instance/delegate.ts +51 -0
  157. package/server/controllers/activity-instance/draft.ts +58 -0
  158. package/server/controllers/activity-instance/end.ts +38 -0
  159. package/server/controllers/activity-instance/index.ts +10 -0
  160. package/server/controllers/activity-instance/pick.ts +27 -0
  161. package/server/controllers/activity-instance/post.ts +36 -0
  162. package/server/controllers/activity-instance/start.ts +17 -0
  163. package/server/controllers/activity-instance/terminate.ts +38 -0
  164. package/server/controllers/activity-thread/abort.ts +37 -0
  165. package/server/controllers/activity-thread/adjust.ts +21 -0
  166. package/server/controllers/activity-thread/delegate.ts +51 -0
  167. package/server/controllers/activity-thread/end.ts +37 -0
  168. package/server/controllers/activity-thread/index.ts +7 -0
  169. package/server/controllers/activity-thread/save.ts +21 -0
  170. package/server/controllers/activity-thread/start.ts +38 -0
  171. package/server/controllers/activity-thread/terminate.ts +38 -0
  172. package/server/controllers/common.ts +84 -0
  173. package/server/service/activity/activity-history.ts +165 -0
  174. package/server/service/activity/activity-model-type.ts +106 -0
  175. package/server/service/activity/activity-mutation.ts +71 -9
  176. package/server/service/activity/activity-query.ts +72 -8
  177. package/server/service/activity/activity-type.ts +47 -2
  178. package/server/service/activity/activity.ts +53 -9
  179. package/server/service/activity/event-subscriber.ts +17 -0
  180. package/server/service/activity/index.ts +5 -2
  181. package/server/service/activity-instance/activity-instance-history.ts +206 -0
  182. package/server/service/activity-instance/activity-instance-mutation.ts +58 -160
  183. package/server/service/activity-instance/activity-instance-query.ts +107 -10
  184. package/server/service/activity-instance/activity-instance-subscription.ts +57 -0
  185. package/server/service/activity-instance/activity-instance-type.ts +108 -4
  186. package/server/service/activity-instance/activity-instance.ts +104 -10
  187. package/server/service/activity-instance/event-subscriber.ts +51 -0
  188. package/server/service/activity-instance/index.ts +7 -3
  189. package/server/service/activity-template/activity-template-history.ts +140 -0
  190. package/server/service/activity-template/activity-template-mutation.ts +196 -0
  191. package/server/service/activity-template/activity-template-query.ts +64 -0
  192. package/server/service/activity-template/activity-template-type.ts +108 -0
  193. package/server/service/activity-template/activity-template.ts +130 -0
  194. package/server/service/activity-template/event-subscriber.ts +20 -0
  195. package/server/service/activity-template/index.ts +9 -0
  196. package/server/service/activity-thread/activity-thread-mutation.ts +191 -0
  197. package/server/service/activity-thread/activity-thread-query.ts +88 -0
  198. package/server/service/activity-thread/activity-thread-subscription.ts +45 -0
  199. package/server/service/activity-thread/activity-thread-type.ts +47 -0
  200. package/server/service/activity-thread/activity-thread.ts +156 -0
  201. package/server/service/activity-thread/event-subscriber.ts +43 -0
  202. package/server/service/activity-thread/index.ts +9 -0
  203. package/server/service/index.ts +37 -11
  204. package/things-factory.config.js +16 -1
  205. package/translations/en.json +30 -2
  206. package/translations/ko.json +29 -1
  207. package/translations/ms.json +29 -1
  208. package/translations/zh.json +29 -1
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Worklist
2
+
3
+ - Activity can be defined.
4
+ - An Activity Instance can be posted by an Issuer.
5
+ - Activity instance can be performed by assignee.
6
+ - Manages the life cycle of Activity Instance.
7
+
8
+ ## Sequence
9
+
10
+ ![Scenario 1](./scenarios/scenario-001.png)
11
+ ![Scenario 2](./scenarios/scenario-002.png)
12
+ ![Scenario 3](./scenarios/scenario-003.png)
13
+ ![Scenario 4](./scenarios/scenario-004.png)
@@ -1 +1,12 @@
1
- export default function bootstrap() {}
1
+ import { registerEditor as registerGristEditor, registerRenderer as registerGristRenderer } from '@operato/data-grist'
2
+ import { OxGristEditorDuration } from '@operato/grist-editor/ox-grist-editor-duration.js'
3
+ import { OxGristEditorQuantifier } from '@operato/grist-editor/ox-grist-editor-quantifier.js'
4
+ import { OxGristRendererDuration } from '@operato/grist-editor/ox-grist-renderer-duration.js'
5
+ import { OxGristRendererQuantifier } from '@operato/grist-editor/ox-grist-renderer-quantifier.js'
6
+
7
+ export default function bootstrap() {
8
+ registerGristEditor('duration', OxGristEditorDuration)
9
+ registerGristRenderer('duration', OxGristRendererDuration)
10
+ registerGristEditor('quantifier', OxGristEditorQuantifier)
11
+ registerGristRenderer('quantifier', OxGristRendererQuantifier)
12
+ }
@@ -0,0 +1,108 @@
1
+ import '@material/mwc-button'
2
+ import '@operato/property-editor/ox-properties-dynamic-view.js'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html, LitElement } from 'lit'
6
+
7
+ import { client } from '@operato/graphql'
8
+ import { i18next, localize } from '@operato/i18n'
9
+ import { ScrollbarStyles } from '@operato/styles'
10
+
11
+ class ActivityOwnerView extends localize(i18next)(LitElement) {
12
+ static get properties() {
13
+ return {
14
+ activityId: String,
15
+ activity: Object,
16
+ activityInstance: Object
17
+ }
18
+ }
19
+
20
+ static get styles() {
21
+ return [
22
+ ScrollbarStyles,
23
+ css`
24
+ :host {
25
+ display: flex;
26
+ flex-direction: column;
27
+
28
+ background-color: #fff;
29
+ }
30
+
31
+ content {
32
+ flex: 1;
33
+ display: flex;
34
+ flex-direction: column;
35
+ padding: var(--padding-default);
36
+ overflow: auto;
37
+ }
38
+
39
+ section {
40
+ display: flex;
41
+ flex-direction: column;
42
+ }
43
+ `
44
+ ]
45
+ }
46
+
47
+ constructor() {
48
+ super()
49
+
50
+ this.activityInstance = {}
51
+ }
52
+
53
+ render() {
54
+ const { name, description, thumbnail } = this.activity || {}
55
+
56
+ return html`
57
+ <content>
58
+ <section>
59
+ <div>name: ${name}</div>
60
+ <div>description: ${description}</div>
61
+ </section>
62
+
63
+ <section>
64
+ <img src=${thumbnail} />
65
+ </section>
66
+ </content>
67
+ `
68
+ }
69
+
70
+ firstUpdated() {
71
+ this.fetchActivity(this.activityId)
72
+ }
73
+
74
+ async fetchActivity(id) {
75
+ const response = await client.query({
76
+ query: gql`
77
+ query activity($id: String!) {
78
+ activity(id: $id) {
79
+ id
80
+ name
81
+ description
82
+ state
83
+ thumbnail
84
+ model {
85
+ name
86
+ description
87
+ active
88
+ tag
89
+ inout
90
+ type
91
+ unit
92
+ options
93
+ quantifier
94
+ spec
95
+ }
96
+ }
97
+ }
98
+ `,
99
+ variables: {
100
+ id
101
+ }
102
+ })
103
+
104
+ this.activity = response.data.activity
105
+ }
106
+ }
107
+
108
+ window.customElements.define('activity-owner-view', ActivityOwnerView)
@@ -0,0 +1,206 @@
1
+ import '@material/mwc-button'
2
+ import '@operato/property-editor/ox-properties-dynamic-view.js'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html, LitElement } from 'lit'
6
+
7
+ import { client } from '@operato/graphql'
8
+ import { i18next, localize } from '@operato/i18n'
9
+ import { notify } from '@operato/layout'
10
+ import { ScrollbarStyles } from '@operato/styles'
11
+
12
+ class ActivityInstancePreview extends localize(i18next)(LitElement) {
13
+ static get properties() {
14
+ return {
15
+ activityInstanceId: String,
16
+ activityInstance: Object,
17
+ activityThreads: Array
18
+ }
19
+ }
20
+
21
+ static get styles() {
22
+ return [
23
+ ScrollbarStyles,
24
+ css`
25
+ :host {
26
+ display: flex;
27
+ flex-direction: column;
28
+
29
+ background-color: #fff;
30
+ }
31
+
32
+ content {
33
+ flex: 1;
34
+ display: flex;
35
+ flex-direction: column;
36
+ padding: var(--padding-default);
37
+ overflow: auto;
38
+ }
39
+
40
+ section {
41
+ display: flex;
42
+ flex-direction: column;
43
+ }
44
+
45
+ #description {
46
+ height: 60px;
47
+ }
48
+
49
+ .button-container {
50
+ display: flex;
51
+ margin-left: auto;
52
+ padding: var(--padding-default);
53
+ }
54
+
55
+ mwc-button {
56
+ margin-left: var(--margin-default);
57
+ }
58
+ `
59
+ ]
60
+ }
61
+
62
+ constructor() {
63
+ super()
64
+
65
+ this.activityInstance = {}
66
+ }
67
+
68
+ render() {
69
+ const {
70
+ id,
71
+ name,
72
+ description,
73
+ input,
74
+ state,
75
+ threadsMin = 0,
76
+ threadsMax = 0,
77
+ activity
78
+ } = this.activityInstance || {}
79
+ const { model, thumbnail } = activity || {}
80
+
81
+ const inputSpec = (model || [])
82
+ .filter(item => item.inout === 'in' || item.inout === 'inout')
83
+ .map(item => {
84
+ return {
85
+ ...item,
86
+ label: item.name
87
+ }
88
+ })
89
+
90
+ const pickable = !(this.activityThreads?.length > 0)
91
+
92
+ return html`
93
+ <content>
94
+ <section>
95
+ <div>title: ${name}</div>
96
+ <div>${description}</div>
97
+ <div>min-max: ${threadsMin} - ${threadsMax}</div>
98
+ <img src=${thumbnail} />
99
+ </section>
100
+
101
+ <label>Input</label>
102
+ ${!model
103
+ ? html``
104
+ : html`
105
+ <ox-properties-dynamic-view
106
+ .props=${inputSpec}
107
+ .value=${input}
108
+ @change=${e => {
109
+ /* TODO remove this comment, after solving the problem of sometimes not saving. */
110
+ this.activityInstance.input = e.currentTarget.value
111
+ console.log('activity-instance', this.activityInstance.input)
112
+ }}
113
+ ></ox-properties-dynamic-view>
114
+ `}
115
+ </content>
116
+
117
+ <div class="button-container">
118
+ <mwc-button raised @click=${e => history.back()}>${i18next.t('button.close')}</mwc-button>
119
+ ${pickable
120
+ ? html`<mwc-button raised @click=${this.pickActivityInstance.bind(this)}
121
+ >${i18next.t('button.pick')}</mwc-button
122
+ >`
123
+ : html``}
124
+ </div>
125
+ `
126
+ }
127
+
128
+ updated(changes) {
129
+ if (changes.has('activityInstanceId')) {
130
+ this.fetchAll(this.activityInstanceId)
131
+ }
132
+ }
133
+
134
+ async fetchAll(id) {
135
+ const response = await client.query({
136
+ query: gql`
137
+ {
138
+ activityInstance(id: "${id}") {
139
+ id
140
+ name
141
+ description
142
+ input
143
+ state
144
+ threadsMin
145
+ threadsMax
146
+ activity {
147
+ id
148
+ name
149
+ description
150
+ state
151
+ thumbnail
152
+ model {
153
+ name
154
+ description
155
+ active
156
+ tag
157
+ inout
158
+ type
159
+ unit
160
+ options
161
+ quantifier
162
+ spec
163
+ }
164
+ }
165
+ }
166
+
167
+ activityThreads(filters: [{ name: "activityInstanceId", operator: "eq", value: "${id}"}]) {
168
+ items {
169
+ id
170
+ }
171
+ total
172
+ }
173
+ }
174
+ `
175
+ })
176
+
177
+ this.activityInstance = response.data.activityInstance
178
+ this.activityThreads = response.data.activityThreads.items
179
+ }
180
+
181
+ async pickActivityInstance() {
182
+ const response = await client.mutate({
183
+ mutation: gql`
184
+ mutation ($id: String!) {
185
+ pickActivityInstance(id: $id) {
186
+ id
187
+ }
188
+ }
189
+ `,
190
+ variables: {
191
+ id: this.activityInstanceId
192
+ }
193
+ })
194
+
195
+ if (!response.errors) {
196
+ this.activityThreads = [response.data.pickActivityInstance]
197
+ notify({
198
+ message: i18next.t('text.info_x_successfully', {
199
+ x: `${i18next.t('label.activity-instance')} ${i18next.t('text.pick')}`
200
+ })
201
+ })
202
+ }
203
+ }
204
+ }
205
+
206
+ window.customElements.define('activity-instance-preview', ActivityInstancePreview)
@@ -0,0 +1,108 @@
1
+ import '@material/mwc-button'
2
+ import '@operato/property-editor/ox-properties-dynamic-view.js'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html, LitElement } from 'lit'
6
+
7
+ import { client } from '@operato/graphql'
8
+ import { i18next, localize } from '@operato/i18n'
9
+ import { ScrollbarStyles } from '@operato/styles'
10
+
11
+ class ActivityIntroView extends localize(i18next)(LitElement) {
12
+ static get properties() {
13
+ return {
14
+ activityTemplateId: String,
15
+ activityTemplate: Object,
16
+ activityInstance: Object
17
+ }
18
+ }
19
+
20
+ static get styles() {
21
+ return [
22
+ ScrollbarStyles,
23
+ css`
24
+ :host {
25
+ display: flex;
26
+ flex-direction: column;
27
+
28
+ background-color: #fff;
29
+ }
30
+
31
+ content {
32
+ flex: 1;
33
+ display: flex;
34
+ flex-direction: column;
35
+ padding: var(--padding-default);
36
+ overflow: auto;
37
+ }
38
+
39
+ section {
40
+ display: flex;
41
+ flex-direction: column;
42
+ }
43
+ `
44
+ ]
45
+ }
46
+
47
+ constructor() {
48
+ super()
49
+
50
+ this.activityInstance = {}
51
+ }
52
+
53
+ render() {
54
+ const { name, description, thumbnail } = this.activityTemplate || {}
55
+
56
+ return html`
57
+ <content>
58
+ <section>
59
+ <div>name: ${name}</div>
60
+ <div>description: ${description}</div>
61
+ </section>
62
+
63
+ <section>
64
+ <img src=${thumbnail} />
65
+ </section>
66
+ </content>
67
+ `
68
+ }
69
+
70
+ firstUpdated() {
71
+ this.fetchActivity(this.activityTemplateId)
72
+ }
73
+
74
+ async fetchActivity(id) {
75
+ const response = await client.query({
76
+ query: gql`
77
+ query activityTemplate($id: String!) {
78
+ activityTemplate(id: $id) {
79
+ id
80
+ name
81
+ description
82
+ state
83
+ thumbnail
84
+ model {
85
+ name
86
+ description
87
+ active
88
+ tag
89
+ inout
90
+ type
91
+ unit
92
+ options
93
+ quantifier
94
+ spec
95
+ }
96
+ }
97
+ }
98
+ `,
99
+ variables: {
100
+ id
101
+ }
102
+ })
103
+
104
+ this.activityTemplate = response.data.activityTemplate
105
+ }
106
+ }
107
+
108
+ window.customElements.define('activity-intro-view', ActivityIntroView)
@@ -0,0 +1,108 @@
1
+ import '@material/mwc-button'
2
+ import '@operato/property-editor/ox-properties-dynamic-view.js'
3
+
4
+ import gql from 'graphql-tag'
5
+ import { css, html, LitElement } from 'lit'
6
+
7
+ import { client } from '@operato/graphql'
8
+ import { i18next, localize } from '@operato/i18n'
9
+ import { ScrollbarStyles } from '@operato/styles'
10
+
11
+ class ActivityReporterView extends localize(i18next)(LitElement) {
12
+ static get properties() {
13
+ return {
14
+ activityId: String,
15
+ activity: Object,
16
+ activityInstance: Object
17
+ }
18
+ }
19
+
20
+ static get styles() {
21
+ return [
22
+ ScrollbarStyles,
23
+ css`
24
+ :host {
25
+ display: flex;
26
+ flex-direction: column;
27
+
28
+ background-color: #fff;
29
+ }
30
+
31
+ content {
32
+ flex: 1;
33
+ display: flex;
34
+ flex-direction: column;
35
+ padding: var(--padding-default);
36
+ overflow: auto;
37
+ }
38
+
39
+ section {
40
+ display: flex;
41
+ flex-direction: column;
42
+ }
43
+ `
44
+ ]
45
+ }
46
+
47
+ constructor() {
48
+ super()
49
+
50
+ this.activityInstance = {}
51
+ }
52
+
53
+ render() {
54
+ const { name, description, thumbnail } = this.activity || {}
55
+
56
+ return html`
57
+ <content>
58
+ <section>
59
+ <div>name: ${name}</div>
60
+ <div>description: ${description}</div>
61
+ </section>
62
+
63
+ <section>
64
+ <img src=${thumbnail} />
65
+ </section>
66
+ </content>
67
+ `
68
+ }
69
+
70
+ firstUpdated() {
71
+ this.fetchActivity(this.activityId)
72
+ }
73
+
74
+ async fetchActivity(id) {
75
+ const response = await client.query({
76
+ query: gql`
77
+ query activity($id: String!) {
78
+ activity(id: $id) {
79
+ id
80
+ name
81
+ description
82
+ state
83
+ thumbnail
84
+ model {
85
+ name
86
+ description
87
+ active
88
+ tag
89
+ inout
90
+ type
91
+ unit
92
+ options
93
+ quantifier
94
+ spec
95
+ }
96
+ }
97
+ }
98
+ `,
99
+ variables: {
100
+ id
101
+ }
102
+ })
103
+
104
+ this.activity = response.data.activity
105
+ }
106
+ }
107
+
108
+ window.customElements.define('activity-reporter-view', ActivityReporterView)