@things-factory/board-ui 8.0.0 → 9.0.0-beta.3

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 (59) hide show
  1. package/dist-client/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +19 -19
  3. package/translations/en.json +31 -29
  4. package/translations/ja.json +33 -31
  5. package/translations/ko.json +33 -31
  6. package/translations/ms.json +28 -25
  7. package/translations/zh.json +31 -29
  8. package/client/apptools/favorite-tool.ts +0 -124
  9. package/client/board-list/board-tile-list.ts +0 -272
  10. package/client/board-list/group-bar-styles.ts +0 -63
  11. package/client/board-list/group-bar.ts +0 -99
  12. package/client/board-list/play-group-bar.ts +0 -88
  13. package/client/board-provider.ts +0 -92
  14. package/client/bootstrap.ts +0 -39
  15. package/client/data-grist/board-editor.ts +0 -113
  16. package/client/data-grist/board-renderer.ts +0 -134
  17. package/client/data-grist/color-map-editor.ts +0 -17
  18. package/client/data-grist/color-ranges-editor.ts +0 -17
  19. package/client/graphql/board-template.ts +0 -141
  20. package/client/graphql/board.ts +0 -273
  21. package/client/graphql/favorite-board.ts +0 -25
  22. package/client/graphql/group.ts +0 -138
  23. package/client/graphql/index.ts +0 -6
  24. package/client/graphql/my-board.ts +0 -25
  25. package/client/graphql/play-group.ts +0 -189
  26. package/client/index.ts +0 -10
  27. package/client/pages/attachment-list-page.ts +0 -142
  28. package/client/pages/board-list-page.ts +0 -603
  29. package/client/pages/board-modeller-page.ts +0 -288
  30. package/client/pages/board-player-by-name-page.ts +0 -29
  31. package/client/pages/board-player-page.ts +0 -241
  32. package/client/pages/board-template/board-template-list-page.ts +0 -248
  33. package/client/pages/board-viewer-by-name-page.ts +0 -24
  34. package/client/pages/board-viewer-page.ts +0 -271
  35. package/client/pages/font-list-page.ts +0 -31
  36. package/client/pages/play-list-page.ts +0 -400
  37. package/client/pages/printable-board-viewer-page.ts +0 -54
  38. package/client/pages/theme/theme-editors.ts +0 -56
  39. package/client/pages/theme/theme-list-page.ts +0 -313
  40. package/client/pages/things-scene-components-with-tools.import +0 -0
  41. package/client/pages/things-scene-components.import +0 -0
  42. package/client/route.ts +0 -51
  43. package/client/setting-let/board-view-setting-let.ts +0 -68
  44. package/client/themes/board-theme.css +0 -77
  45. package/client/things-scene-import.d.ts +0 -4
  46. package/client/viewparts/board-basic-info.ts +0 -646
  47. package/client/viewparts/board-info-link.ts +0 -56
  48. package/client/viewparts/board-info.ts +0 -85
  49. package/client/viewparts/board-template-builder.ts +0 -134
  50. package/client/viewparts/board-versions.ts +0 -172
  51. package/client/viewparts/group-info-basic.ts +0 -267
  52. package/client/viewparts/group-info-import.ts +0 -132
  53. package/client/viewparts/group-info.ts +0 -87
  54. package/client/viewparts/index.ts +0 -3
  55. package/client/viewparts/link-builder.ts +0 -210
  56. package/client/viewparts/play-group-info-basic.ts +0 -268
  57. package/client/viewparts/play-group-info-link.ts +0 -46
  58. package/client/viewparts/play-group-info.ts +0 -81
  59. package/server/index.ts +0 -0
@@ -1,288 +0,0 @@
1
- import './things-scene-components.import'
2
- import '@operato/board/ox-board-modeller.js'
3
- import '@operato/oops'
4
-
5
- import gql from 'graphql-tag'
6
- import { css, html } from 'lit'
7
- import { customElement, property, query } from 'lit/decorators.js'
8
- import { connect } from 'pwa-helpers/connect-mixin.js'
9
-
10
- import { BoardModeller } from '@operato/board/ox-board-modeller.js'
11
- import { OxPropertyEditor } from '@operato/property-editor'
12
- import { PageView, store } from '@operato/shell'
13
- import { hasPrivilege } from '@things-factory/auth-base/dist-client'
14
- import { client, gqlContext } from '@operato/graphql'
15
- import { i18next } from '@operato/i18n'
16
- import { OxPrompt } from '@operato/popup/ox-prompt.js'
17
-
18
- import { provider } from '../board-provider'
19
- import components from './things-scene-components-with-tools.import'
20
-
21
- const NOOP = () => {}
22
-
23
- @customElement('board-modeller-page')
24
- export class BoardModellerPage extends connect(store)(PageView) {
25
- constructor() {
26
- super()
27
-
28
- components.forEach(({ templates = [], groups = [] }) => {
29
- groups.forEach(group => BoardModeller.registerGroup(group))
30
- BoardModeller.registerTemplate(templates)
31
- })
32
-
33
- /* 컴포넌트에서 정의된 에디터들을 MODELLER_EDITORS에 등록 */
34
- var addedEditors = {}
35
- for (let component in components) {
36
- let { editors } = components[component]
37
-
38
- editors &&
39
- editors.forEach(editor => {
40
- let { type, element } = editor
41
-
42
- addedEditors[type] = element
43
- })
44
- }
45
-
46
- OxPropertyEditor.register(addedEditors)
47
- }
48
-
49
- static styles = [
50
- css`
51
- :host {
52
- display: flex;
53
- flex-direction: column;
54
-
55
- overflow: hidden;
56
- position: relative;
57
- }
58
-
59
- ox-board-modeller {
60
- flex: 1;
61
- }
62
-
63
- ox-oops-note {
64
- display: block;
65
- position: absolute;
66
- left: 50%;
67
- top: 50%;
68
- transform: translate(-50%, -50%);
69
- }
70
- `
71
- ]
72
-
73
- @property({ type: String }) boardId?: string | null
74
- @property({ type: String }) boardName?: string = ''
75
- @property({ type: Object }) model: any = null
76
- @property({ type: String }) baseUrl?: string = ''
77
- @property({ type: Array }) selected: any = []
78
- @property({ type: Number }) mode?: number = 1
79
- @property({ type: Boolean }) hideProperty?: boolean = false
80
- @property({ type: String }) overlay?: string | null = null
81
- @property({ type: Object }) scene: any = null
82
- @property({ type: Array }) componentGroupList?: any[] = BoardModeller.groups
83
- @property({ type: Array }) fonts: any = []
84
- @property({ type: Array }) propertyEditor: any
85
- @property({ type: Boolean }) preparing?: boolean
86
-
87
- private board: any = null
88
- @query('ox-board-modeller') modeller?: BoardModeller
89
-
90
- get context() {
91
- return {
92
- title: this.board ? this.boardName : this.preparing ? 'Fetching board...' : 'Board Not Found',
93
- help: 'board-modeller/modeller',
94
- widebleed: true
95
- }
96
- }
97
-
98
- get oopsNote() {
99
- return {
100
- icon: 'color_lens',
101
- title: 'EMPTY BOARD',
102
- description: 'There are no board to be designed'
103
- }
104
- }
105
-
106
- async refresh() {
107
- if (!this.boardId) {
108
- this.board = null
109
- this.model = null
110
-
111
- return
112
- }
113
- try {
114
- this.preparing = true
115
- this.updateContext()
116
-
117
- var response = await client.query({
118
- query: gql`
119
- query FetchBoardById($id: String!) {
120
- board(id: $id) {
121
- id
122
- name
123
- model
124
- }
125
- }
126
- `,
127
- variables: { id: this.boardId },
128
- context: gqlContext()
129
- })
130
-
131
- var board = response.data.board
132
-
133
- if (!board) {
134
- this.board = null
135
- throw 'board not found'
136
- }
137
-
138
- this.board = {
139
- ...board,
140
- model: JSON.parse(board.model)
141
- }
142
-
143
- this.boardName = this.board.name
144
- this.model = {
145
- ...this.board.model
146
- }
147
- } catch (ex) {
148
- document.dispatchEvent(
149
- new CustomEvent('notify', {
150
- detail: {
151
- level: 'error',
152
- message: ex,
153
- ex
154
- }
155
- })
156
- )
157
- } finally {
158
- this.preparing = false
159
- this.updateContext()
160
- }
161
- }
162
-
163
- async updated(changes) {
164
- if (changes.has('boardId')) {
165
- if (await hasPrivilege({ privilege: 'mutation', category: 'board' })) {
166
- this.refresh()
167
- } else {
168
- this.boardId = null
169
- this.model = null
170
- this.modeller?.close()
171
- }
172
- }
173
- }
174
-
175
- pageUpdated(changes, lifecycle) {
176
- if (this.active) {
177
- this.boardId = lifecycle.resourceId
178
- } else {
179
- this.boardId = null
180
- this.model = null
181
- this.modeller?.close()
182
- }
183
- }
184
-
185
- stateChanged(state) {
186
- this.baseUrl = state.route.rootPath
187
- this.fonts = state.font
188
- }
189
-
190
- render() {
191
- var oops = !this.preparing && !this.model && this.oopsNote
192
-
193
- return oops
194
- ? html` <ox-oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></ox-oops-note> `
195
- : html`
196
- <ox-board-modeller
197
- .mode=${this.mode}
198
- @mode-changed=${e => {
199
- this.mode = e.detail.value
200
- }}
201
- .model=${this.model}
202
- @model-changed=${e => {
203
- this.model = e.detail.value
204
- }}
205
- .scene=${this.scene}
206
- @scene-changed=${e => {
207
- this.scene = e.detail.value
208
- }}
209
- .selected=${this.selected}
210
- @selected-changed=${e => {
211
- this.selected = e.detail.value
212
- }}
213
- .baseUrl=${this.baseUrl}
214
- .provider=${provider}
215
- @save-model=${e => this.saveBoard()}
216
- .componentGroupList=${this.componentGroupList}
217
- .fonts=${this.fonts}
218
- .hideProperty=${this.hideProperty}
219
- >
220
- </ox-board-modeller>
221
- `
222
- }
223
-
224
- async updateBoard() {
225
- try {
226
- this.preparing = true
227
-
228
- var { id, name, description, groupId } = this.board
229
- var model = JSON.stringify(this.scene.model)
230
-
231
- await client.mutate({
232
- mutation: gql`
233
- mutation UpdateBoard($id: String!, $patch: BoardPatch!) {
234
- updateBoard(id: $id, patch: $patch) {
235
- id
236
- }
237
- }
238
- `,
239
- variables: {
240
- id,
241
- patch: { name, description, model, groupId }
242
- },
243
- context: gqlContext()
244
- })
245
-
246
- document.dispatchEvent(
247
- new CustomEvent('notify', {
248
- detail: {
249
- level: 'info',
250
- message: i18next.t('text.saved')
251
- }
252
- })
253
- )
254
- } catch (ex) {
255
- document.dispatchEvent(
256
- new CustomEvent('notify', {
257
- detail: {
258
- level: 'error',
259
- message: ex,
260
- ex: ex
261
- }
262
- })
263
- )
264
- } finally {
265
- this.preparing = false
266
- }
267
-
268
- this.updateContext()
269
- }
270
-
271
- async saveBoard() {
272
- await this.updateBoard()
273
- this.modeller?.preserve()
274
- }
275
-
276
- async canDeactivate(): Promise<boolean> {
277
- if (this.modeller?.hasUnpreservedChanges()) {
278
- return await OxPrompt.open({
279
- title: i18next.t('text.are_you_sure'),
280
- text: i18next.t('prompt.sure to navigate away?'),
281
- confirmButton: { text: i18next.t('button.confirm') },
282
- cancelButton: { text: i18next.t('button.cancel') }
283
- })
284
- }
285
-
286
- return true
287
- }
288
- }
@@ -1,29 +0,0 @@
1
- import gql from 'graphql-tag'
2
- import { customElement } from 'lit/decorators.js'
3
- import { client, gqlContext } from '@operato/graphql'
4
-
5
- import { BoardPlayerPage } from './board-player-page'
6
-
7
- @customElement('board-player-by-name-page')
8
- export class BoardPlayerByNamePage extends BoardPlayerPage {
9
- async fetch(name: string) {
10
- return await client.query({
11
- query: gql`
12
- query ($name: String!) {
13
- response: playGroupByName(name: $name) {
14
- id
15
- name
16
- description
17
- boards {
18
- id
19
- model
20
- }
21
- }
22
- }
23
- `,
24
- variables: {
25
- name
26
- }
27
- })
28
- }
29
- }
@@ -1,241 +0,0 @@
1
- import './things-scene-components.import'
2
- import '@operato/board/ox-board-player.js'
3
- import '@operato/oops'
4
-
5
- import gql from 'graphql-tag'
6
- import { css, html } from 'lit'
7
- import { customElement, state, query } from 'lit/decorators.js'
8
- import { connect } from 'pwa-helpers/connect-mixin.js'
9
-
10
- import { createBoardProvider } from '../board-provider'
11
- import { store, PageView } from '@operato/shell'
12
- import { clientSettingStore } from '@operato/shell/object-store.js'
13
- import { client, subscribe } from '@operato/graphql'
14
- import { ReferenceMap } from '@hatiolab/things-scene'
15
- import { BoardPlayer } from '@operato/board/ox-board-player.js'
16
-
17
- function parseQuery(query: any) {
18
- for (const key in query) {
19
- if (query.hasOwnProperty(key)) {
20
- try {
21
- query[key] = JSON.parse(query[key])
22
- } catch (error) {
23
- // do nothing
24
- }
25
- }
26
- }
27
-
28
- return query
29
- }
30
-
31
- @customElement('board-player-page')
32
- export class BoardPlayerPage extends connect(store)(PageView) {
33
- static styles = [
34
- css`
35
- :host {
36
- display: flex;
37
- flex-direction: column;
38
- width: 100%;
39
- height: 100%;
40
-
41
- overflow: hidden;
42
- position: relative;
43
- }
44
-
45
- ox-board-player {
46
- flex: 1;
47
- }
48
-
49
- ox-oops-spinner {
50
- display: none;
51
- position: absolute;
52
- left: 50%;
53
- top: 50%;
54
- transform: translate(-50%, -50%);
55
- }
56
-
57
- ox-oops-spinner[show] {
58
- display: block;
59
- }
60
-
61
- ox-oops-note {
62
- display: block;
63
- position: absolute;
64
- left: 50%;
65
- top: 50%;
66
- transform: translate(-50%, -50%);
67
- }
68
- `
69
- ]
70
-
71
- @state() data: any
72
- @state() playGroup: any
73
- @state() playGroupId?: string | null
74
- @state() boards: any
75
- @state() baseUrl?: string
76
- @state() showSpinner?: boolean
77
-
78
- private provider?: ReferenceMap<unknown> & { dispose?: () => void }
79
- private subscriptionForAutoRefresh
80
-
81
- @query('ox-board-player') boardPlayer?: BoardPlayer
82
-
83
- connectedCallback() {
84
- super.connectedCallback()
85
-
86
- this.provider = createBoardProvider()
87
- }
88
-
89
- disconnectedCallback() {
90
- super.disconnectedCallback()
91
-
92
- this.provider!.dispose!()
93
- delete this.provider
94
- }
95
-
96
- async fetch(id: string) {
97
- return await client.query({
98
- query: gql`
99
- query ($id: String!) {
100
- response: playGroup(id: $id) {
101
- id
102
- name
103
- description
104
- boards {
105
- id
106
- model
107
- }
108
- }
109
- }
110
- `,
111
- variables: {
112
- id
113
- }
114
- })
115
- }
116
-
117
- async refresh() {
118
- if (!this.playGroupId) {
119
- return
120
- }
121
-
122
- try {
123
- this.showSpinner = true
124
- this.updateContext()
125
-
126
- const response = await this.fetch(this.playGroupId)
127
-
128
- this.playGroup = response.data.response
129
-
130
- if (!this.playGroup) {
131
- throw 'playgroup not found'
132
- }
133
-
134
- this.boards = this.playGroup.boards
135
- } catch (ex) {
136
- document.dispatchEvent(
137
- new CustomEvent('notify', {
138
- detail: {
139
- level: 'error',
140
- message: ex,
141
- ex
142
- }
143
- })
144
- )
145
- } finally {
146
- this.showSpinner = false
147
- this.updateContext()
148
-
149
- const { autoRefresh = true } = (await clientSettingStore.get('board-view'))?.value || {}
150
- autoRefresh && this.startSubscribingForAutoRefresh()
151
- }
152
- }
153
-
154
- updated(changes) {
155
- if (changes.has('playGroupId')) {
156
- this.boardPlayer!.stop()
157
- this.refresh()
158
- }
159
- }
160
-
161
- stateChanged(state) {
162
- this.baseUrl = state.app.baseUrl
163
- }
164
-
165
- get oopsNote() {
166
- return {
167
- icon: 'style',
168
- title: 'EMPTY PLAYGROUP',
169
- description: 'There are no board to be shown'
170
- }
171
- }
172
-
173
- get context() {
174
- return {
175
- title: this.playGroup ? this.playGroup.name : this.showSpinner ? 'Fetching playgroup...' : 'Playgroup Not Found'
176
- }
177
- }
178
-
179
- render() {
180
- var oops = !this.showSpinner && !this.playGroup && this.oopsNote
181
-
182
- return oops
183
- ? html` <ox-oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></ox-oops-note> `
184
- : html`
185
- <ox-board-player .boards=${this.boards} .data=${this.data} .provider=${this.provider}></ox-board-player>
186
- <ox-oops-spinner ?show=${this.showSpinner}></ox-oops-spinner>
187
- `
188
- }
189
-
190
- pageUpdated(changes, lifecycle) {
191
- if (this.active) {
192
- this.playGroupId = lifecycle.resourceId
193
- this.data = parseQuery({ ...lifecycle.params })
194
-
195
- this.refresh()
196
- } else {
197
- this.stopSubscribing()
198
-
199
- this.playGroupId = null
200
- this.boardPlayer!.stop()
201
- }
202
- }
203
-
204
- async startSubscribingForAutoRefresh() {
205
- if (!this.playGroup) {
206
- return
207
- }
208
-
209
- await this.stopSubscribing()
210
-
211
- this.subscriptionForAutoRefresh = await subscribe(
212
- {
213
- query: gql`
214
- subscription ($id: String!) {
215
- playGroup(id: $id) {
216
- id
217
- }
218
- }
219
- `,
220
- variables: {
221
- id: this.playGroup.id
222
- }
223
- },
224
- {
225
- next: async ({ data }) => {
226
- await this.stopSubscribing()
227
-
228
- // location.reload()
229
- if (data) {
230
- this.refresh()
231
- }
232
- }
233
- }
234
- )
235
- }
236
-
237
- async stopSubscribing() {
238
- await this.subscriptionForAutoRefresh?.unsubscribe()
239
- delete this.subscriptionForAutoRefresh
240
- }
241
- }