@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,603 +0,0 @@
1
- import '../viewparts/board-info'
2
- import '../viewparts/group-info'
3
- import '../board-list/board-tile-list'
4
- import '../board-list/group-bar'
5
-
6
- import gql from 'graphql-tag'
7
- import { css, html } from 'lit'
8
- import { customElement, property, query, queryAll, state } from 'lit/decorators.js'
9
- import { connect } from 'pwa-helpers/connect-mixin.js'
10
-
11
- import { client } from '@operato/graphql'
12
- import { i18next, localize } from '@operato/i18n'
13
- import { openOverlay } from '@operato/layout'
14
- import { pulltorefresh } from '@operato/pull-to-refresh'
15
- import { navigate, PageView, store } from '@operato/shell'
16
- import { ScrollbarStyles } from '@operato/styles'
17
- import InfiniteScrollable from '@operato/utils/mixins/infinite-scrollable.js'
18
- import { UPDATE_FAVORITES } from '@things-factory/fav-base/client'
19
- import { swipe } from '@things-factory/utils/src/index.js'
20
-
21
- import {
22
- cloneBoard,
23
- releaseBoard,
24
- revertBoardVersion,
25
- createBoard,
26
- createGroup,
27
- deleteBoard,
28
- deleteGroup,
29
- fetchBoardList,
30
- fetchFavoriteBoardList,
31
- fetchMyBoardList,
32
- fetchGroupList,
33
- updateBoard,
34
- updateGroup,
35
- importBoards
36
- } from '../graphql'
37
-
38
- @customElement('board-list-page')
39
- export class BoardListPage extends localize(i18next)(connect(store)(InfiniteScrollable(PageView))) {
40
- static styles = [
41
- ScrollbarStyles,
42
- css`
43
- :host {
44
- display: flex;
45
- flex-direction: column;
46
- position: relative;
47
-
48
- overflow: hidden;
49
- }
50
-
51
- board-tile-list {
52
- flex: 1;
53
- overflow-y: auto;
54
- }
55
-
56
- #create {
57
- position: absolute;
58
- bottom: 15px;
59
- right: 16px;
60
- }
61
- `
62
- ]
63
-
64
- @property({ type: String }) groupId?: string
65
- @property({ type: Array }) groups: any[] = []
66
- @property({ type: Array }) boards: any[] = []
67
- @property({ type: Array }) favorites: any[] = []
68
-
69
- @state() searchText: string = ''
70
-
71
- @query('board-tile-list') scrollTargetEl!: HTMLElement
72
-
73
- private _page: number = 1
74
- private _total: number = 0 /* required for infinite-scrolling */
75
-
76
- private page?: string
77
-
78
- get context() {
79
- var groupId = this.groupId
80
- var group = this.groups && this.groups.find(group => group.id === groupId)
81
-
82
- return {
83
- title: {
84
- icon: 'dashboard',
85
- text: group
86
- ? 'Group ' + group.name
87
- : groupId == 'favor'
88
- ? 'Favorite'
89
- : groupId == 'mywork'
90
- ? 'My works'
91
- : 'Board List'
92
- },
93
- search: {
94
- handler: search => {
95
- this.searchText = search
96
- this.refreshBoards()
97
- },
98
- value: this.searchText || ''
99
- },
100
- board_topmenu: true
101
- }
102
- }
103
-
104
- constructor() {
105
- super()
106
-
107
- this._infiniteScrollOptions.limit = 50
108
- }
109
-
110
- render() {
111
- return html`
112
- <group-bar
113
- .groups=${this.groups}
114
- .groupId=${this.groupId}
115
- targetPage="board-list"
116
- @info-group=${e => this.onInfoGroup(e.detail)}
117
- ></group-bar>
118
-
119
- <board-tile-list
120
- id="list"
121
- .boards=${this.boards}
122
- .favorites=${this.favorites}
123
- .groups=${this.groups}
124
- .group=${this.groupId}
125
- search-text=${this.searchText}
126
- @info-board=${e => this.onInfoBoard(e.detail)}
127
- @scroll=${e => {
128
- this.onScroll(e)
129
- }}
130
- @create-board=${e => this.onCreateBoard(e.detail)}
131
- @refresh-favorites=${e => this.refreshFavorites()}
132
- creatable
133
- ></board-tile-list>
134
- `
135
- }
136
-
137
- async refresh() {
138
- this.groups = (await fetchGroupList()).groups.items
139
-
140
- if (this.groups) {
141
- await this.refreshBoards()
142
- }
143
- }
144
-
145
- async getBoards({ page = 1, limit = this._infiniteScrollOptions.limit } = {}) {
146
- if (this.groupId && this.groupId == 'favor') {
147
- return await this.getFavoriteBoards({
148
- page,
149
- limit
150
- })
151
- } else if (this.groupId && this.groupId == 'mywork') {
152
- return await this.getMyBoards({
153
- page,
154
- limit
155
- })
156
- }
157
-
158
- const filters = [] as any[]
159
-
160
- if (this.groupId) {
161
- filters.push({
162
- name: 'groupId',
163
- operator: 'eq',
164
- value: this.groupId
165
- })
166
- }
167
-
168
- if (this.searchText) {
169
- filters.push({
170
- name: 'name',
171
- operator: 'search',
172
- value: '%' + this.searchText + '%'
173
- })
174
- }
175
-
176
- var listParam = {
177
- filters,
178
- sortings: [
179
- {
180
- name: 'name',
181
- desc: false
182
- }
183
- ],
184
- pagination: {
185
- page,
186
- limit
187
- }
188
- }
189
-
190
- return (await fetchBoardList(listParam)).boards
191
- }
192
-
193
- async getFavoriteBoards({ page = 1, limit = this._infiniteScrollOptions.limit } = {}) {
194
- const filters = [] as any[]
195
-
196
- if (this.searchText) {
197
- filters.push({
198
- name: 'name',
199
- operator: 'search',
200
- value: '%' + this.searchText + '%'
201
- })
202
- }
203
-
204
- var listParam = {
205
- filters,
206
- pagination: {
207
- page,
208
- limit
209
- }
210
- }
211
-
212
- return (await fetchFavoriteBoardList(listParam)).favoriteBoards
213
- }
214
-
215
- async getMyBoards({ page = 1, limit = this._infiniteScrollOptions.limit } = {}) {
216
- const filters = [] as any[]
217
-
218
- if (this.searchText) {
219
- filters.push({
220
- name: 'name',
221
- operator: 'search',
222
- value: '%' + this.searchText + '%'
223
- })
224
- }
225
-
226
- var listParam = {
227
- filters,
228
- pagination: {
229
- page,
230
- limit
231
- }
232
- }
233
-
234
- return (await fetchMyBoardList(listParam)).boardsCreatedByMe
235
- }
236
-
237
- async refreshBoards() {
238
- if (!this.groups) {
239
- await this.refresh()
240
- return
241
- }
242
-
243
- var { items: boards, total } = await this.getBoards()
244
- this.boards = boards
245
- this._page = 1
246
- this._total = total
247
-
248
- this.updateContext()
249
-
250
- this.scrollTargetEl.style.transition = ''
251
- this.scrollTargetEl.style.transform = `translate3d(0, 0, 0)`
252
- }
253
-
254
- async appendBoards() {
255
- if (!this.groups) {
256
- await this.refresh()
257
- return
258
- }
259
-
260
- var { items: boards, total } = await this.getBoards({ page: this._page + 1 })
261
- this.boards = [...this.boards, ...boards]
262
- this._page = this._page + 1
263
- this._total = total
264
- }
265
-
266
- async scrollAction() {
267
- return this.appendBoards()
268
- }
269
-
270
- async pageInitialized() {
271
- this.refresh()
272
- }
273
-
274
- async pageUpdated(changes, lifecycle) {
275
- if (this.active) {
276
- this.page = lifecycle.page
277
- this.groupId = lifecycle.resourceId
278
- this.searchText = lifecycle.params?.search || ''
279
-
280
- await this.updateComplete
281
-
282
- this.refreshBoards()
283
- }
284
- }
285
-
286
- stateChanged(state) {
287
- this.favorites = state.favorite.favorites
288
- }
289
-
290
- firstUpdated() {
291
- const list = this.scrollTargetEl
292
-
293
- pulltorefresh({
294
- container: this.renderRoot,
295
- scrollable: list,
296
- refresh: () => {
297
- return this.refresh()
298
- }
299
- })
300
-
301
- swipe({
302
- container: list,
303
- animates: {
304
- dragging: async (d, opts) => {
305
- var groups = [{ id: '' }, { id: 'favor' }, ...this.groups]
306
- var currentIndex = groups.findIndex(group => group.id == this.groupId)
307
-
308
- if ((d > 0 && currentIndex <= 0) || (d < 0 && currentIndex >= groups.length - 1)) {
309
- /* TODO blocked gesture */
310
- return false
311
- }
312
-
313
- list.style.transform = `translate3d(${d}px, 0, 0)`
314
- },
315
- aborting: async opts => {
316
- list.style.transition = 'transform 0.3s'
317
- list.style.transform = `translate3d(0, 0, 0)`
318
-
319
- setTimeout(() => {
320
- list.style.transition = ''
321
- })
322
- },
323
- swiping: async (d, opts) => {
324
- var groups = [{ id: '' }, { id: 'favor' }, ...this.groups]
325
- var currentIndex = groups.findIndex(group => group.id == this.groupId)
326
-
327
- if ((d > 0 && currentIndex <= 0) || (d < 0 && currentIndex >= groups.length - 1)) {
328
- list.style.transition = ''
329
- list.style.transform = `translate3d(0, 0, 0)`
330
- } else {
331
- list.style.transition = 'transform 0.3s'
332
- list.style.transform = `translate3d(${d < 0 ? '-100%' : '100%'}, 0, 0)`
333
-
334
- navigate(
335
- `${this.page}/${groups[currentIndex + (d < 0 ? 1 : -1)].id}${this.searchText ? '?search=' + this.searchText : ''}`
336
- )
337
- }
338
- }
339
- }
340
- })
341
- }
342
-
343
- async onInfoBoard(board) {
344
- openOverlay('viewpart-info', {
345
- template: html`
346
- <board-info
347
- .board=${board}
348
- .groupId=${this.groupId}
349
- @clone-board=${e => this.onCloneBoard(e.detail)}
350
- @release-board=${e => this.onReleaseBoard(e.detail)}
351
- @revert-board-version=${e => this.onRevertBoardVersion(e.detail)}
352
- @update-board=${e => this.onUpdateBoard(e.detail)}
353
- @delete-board=${e => this.onDeleteBoard(e.detail)}
354
- @join-playgroup=${e => this.onJoinPlayGroup(e.detail)}
355
- @leave-playgroup=${e => this.onLeavePlayGroup(e.detail)}
356
- @register-template=${e => this.onRegisterTemplate(e.detail)}
357
- ></board-info>
358
- `
359
- })
360
- }
361
-
362
- async onInfoGroup(groupId) {
363
- openOverlay('viewpart-info', {
364
- template: html`
365
- <group-info
366
- .groupId=${groupId}
367
- @update-group=${e => this.onUpdateGroup(e.detail)}
368
- @delete-group=${e => this.onDeleteGroup(e.detail)}
369
- @create-group=${e => this.onCreateGroup(e.detail)}
370
- @import-boards=${e => this.onImportBoards(e.detail)}
371
- ></group-info>
372
- `
373
- })
374
- }
375
-
376
- async onCreateGroup(group) {
377
- try {
378
- const data = await createGroup(group)
379
- data && this._notify('info', i18next.t('text.group created', { group: group.name }))
380
- } catch (ex) {
381
- this._notify('error', ex, ex)
382
- }
383
-
384
- this.refresh()
385
- }
386
-
387
- async onUpdateGroup(group) {
388
- try {
389
- const data = await updateGroup(group)
390
- data && this._notify('info', i18next.t('text.group updated', { group: group.name }))
391
- } catch (ex) {
392
- this._notify('error', ex, ex)
393
- }
394
-
395
- this.refresh()
396
- }
397
-
398
- async onDeleteGroup(group) {
399
- try {
400
- const data = await deleteGroup(group.id)
401
- data && this._notify('info', i18next.t('text.group deleted', { group: group.name }))
402
- } catch (ex) {
403
- this._notify('error', ex, ex)
404
- }
405
-
406
- this.refresh()
407
- }
408
-
409
- async onImportBoards({ group, files, overwrite }) {
410
- try {
411
- const data = await importBoards({ groupId: group.id, files, overwrite })
412
- data && this._notify('info', i18next.t('text.boards imported', { count: files.length, group: group.name }))
413
- } catch (ex) {
414
- this._notify('error', ex, ex)
415
- }
416
-
417
- this.refresh()
418
- }
419
-
420
- async onCreateBoard(board) {
421
- try {
422
- if (!board.model) {
423
- board.model = {
424
- width: 800,
425
- height: 600
426
- }
427
- }
428
-
429
- const data = await createBoard(board)
430
-
431
- data && this._notify('info', i18next.t('text.board created', { board: board.name }))
432
- } catch (ex) {
433
- this._notify('error', ex, ex)
434
- }
435
-
436
- this.refreshBoards()
437
- }
438
-
439
- async onCloneBoard({ id, name, description, targetSubdomain, targetGroupId }) {
440
- try {
441
- const data = await cloneBoard({
442
- id,
443
- name,
444
- description,
445
- targetSubdomain,
446
- targetGroupId
447
- })
448
- data && this._notify('info', i18next.t('text.board cloned', { board: name }))
449
- } catch (ex) {
450
- this._notify('error', ex, ex)
451
- }
452
-
453
- this.refreshBoards()
454
- }
455
-
456
- async onReleaseBoard(board) {
457
- try {
458
- const data = await releaseBoard(board)
459
- data && this._notify('info', i18next.t('text.board released', { board: board.name }))
460
- } catch (ex) {
461
- this._notify('error', ex, ex)
462
- }
463
-
464
- this.refreshBoards()
465
- }
466
-
467
- async onRevertBoardVersion({ id, version }) {
468
- try {
469
- const board = await revertBoardVersion(id, version)
470
- board && this._notify('info', i18next.t('text.board reverted', { board: board.name, version }))
471
- } catch (ex) {
472
- this._notify('error', ex, ex)
473
- }
474
-
475
- this.refreshBoards()
476
- }
477
-
478
- async onUpdateBoard(board) {
479
- try {
480
- const data = await updateBoard(board)
481
- data && this._notify('info', i18next.t('text.board updated', { board: board.name }))
482
- } catch (ex) {
483
- this._notify('error', ex, ex)
484
- }
485
-
486
- this.refreshBoards()
487
- }
488
-
489
- async onDeleteBoard(board) {
490
- try {
491
- const data = await deleteBoard(board.id)
492
- data && this._notify('info', i18next.t('text.board deleted', { board: board.name }))
493
- } catch (ex) {
494
- this._notify('error', ex, ex)
495
- }
496
-
497
- this.refreshBoards()
498
- }
499
-
500
- async onJoinPlayGroup({ board, playGroup }) {
501
- try {
502
- const { data } = await client.mutate({
503
- mutation: gql`
504
- mutation JoinPlayGroup($id: String!, $boardIds: [String!]!) {
505
- joinPlayGroup(id: $id, boardIds: $boardIds) {
506
- id
507
- }
508
- }
509
- `,
510
- variables: {
511
- id: playGroup.id,
512
- boardIds: [board.id]
513
- }
514
- })
515
-
516
- data &&
517
- this._notify('info', i18next.t('text.joined into play-group', { board: board.name, playGroup: playGroup.name }))
518
- } catch (ex) {
519
- this._notify('error', ex, ex)
520
- }
521
- }
522
-
523
- async onLeavePlayGroup({ board, playGroup }) {
524
- try {
525
- const { data } = await client.mutate({
526
- mutation: gql`
527
- mutation ($id: String!, $boardIds: [String!]!) {
528
- leavePlayGroup(id: $id, boardIds: $boardIds) {
529
- id
530
- }
531
- }
532
- `,
533
- variables: {
534
- id: playGroup.id,
535
- boardIds: [board.id]
536
- }
537
- })
538
-
539
- data &&
540
- this._notify('info', i18next.t('text.leaved from play-group', { board: board.name, playGroup: playGroup.name }))
541
- } catch (ex) {
542
- this._notify('error', ex, ex)
543
- }
544
- }
545
-
546
- async onRegisterTemplate({ id, name, description, visibility }) {
547
- try {
548
- const { data } = await client.mutate({
549
- mutation: gql`
550
- mutation ($id: String!, $name: String!, $description: String!, $visibility: String!) {
551
- registerBoardAsTemplate(id: $id, name: $name, description: $description, visibility: $visibility) {
552
- id
553
- }
554
- }
555
- `,
556
- variables: {
557
- id,
558
- name,
559
- description,
560
- visibility
561
- }
562
- })
563
-
564
- data &&
565
- this._notify('info', i18next.t('text.info_x_successfully', { x: i18next.t('text.register-template') }), {
566
- name
567
- })
568
- } catch (ex) {
569
- this._notify('error', ex, ex)
570
- }
571
- }
572
-
573
- async refreshFavorites() {
574
- const { data } = await client.query({
575
- query: gql`
576
- query {
577
- myFavorites {
578
- id
579
- routing
580
- }
581
- }
582
- `
583
- })
584
-
585
- data &&
586
- store.dispatch({
587
- type: UPDATE_FAVORITES,
588
- favorites: data.myFavorites.map(favorite => favorite.routing)
589
- })
590
- }
591
-
592
- _notify(level: 'info' | 'error' | 'warn', message: any, ex?: any) {
593
- document.dispatchEvent(
594
- new CustomEvent('notify', {
595
- detail: {
596
- level,
597
- message,
598
- ex
599
- }
600
- })
601
- )
602
- }
603
- }