@things-factory/board-ui 8.0.0-beta.9 → 8.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 (55) hide show
  1. package/client/apptools/favorite-tool.ts +124 -0
  2. package/client/board-list/board-tile-list.ts +272 -0
  3. package/client/board-list/group-bar-styles.ts +63 -0
  4. package/client/board-list/group-bar.ts +99 -0
  5. package/client/board-list/play-group-bar.ts +88 -0
  6. package/client/board-provider.ts +92 -0
  7. package/client/bootstrap.ts +39 -0
  8. package/client/data-grist/board-editor.ts +113 -0
  9. package/client/data-grist/board-renderer.ts +134 -0
  10. package/client/data-grist/color-map-editor.ts +17 -0
  11. package/client/data-grist/color-ranges-editor.ts +17 -0
  12. package/client/graphql/board-template.ts +141 -0
  13. package/client/graphql/board.ts +273 -0
  14. package/client/graphql/favorite-board.ts +25 -0
  15. package/client/graphql/group.ts +138 -0
  16. package/client/graphql/index.ts +6 -0
  17. package/client/graphql/my-board.ts +25 -0
  18. package/client/graphql/play-group.ts +189 -0
  19. package/client/index.ts +10 -0
  20. package/client/pages/attachment-list-page.ts +142 -0
  21. package/client/pages/board-list-page.ts +603 -0
  22. package/client/pages/board-modeller-page.ts +288 -0
  23. package/client/pages/board-player-by-name-page.ts +29 -0
  24. package/client/pages/board-player-page.ts +241 -0
  25. package/client/pages/board-template/board-template-list-page.ts +248 -0
  26. package/client/pages/board-viewer-by-name-page.ts +24 -0
  27. package/client/pages/board-viewer-page.ts +271 -0
  28. package/client/pages/font-list-page.ts +31 -0
  29. package/client/pages/play-list-page.ts +400 -0
  30. package/client/pages/printable-board-viewer-page.ts +54 -0
  31. package/client/pages/theme/theme-editors.ts +56 -0
  32. package/client/pages/theme/theme-list-page.ts +313 -0
  33. package/client/pages/things-scene-components-with-tools.import +0 -0
  34. package/client/pages/things-scene-components.import +0 -0
  35. package/client/route.ts +51 -0
  36. package/client/setting-let/board-view-setting-let.ts +68 -0
  37. package/client/themes/board-theme.css +77 -0
  38. package/client/things-scene-import.d.ts +4 -0
  39. package/client/viewparts/board-basic-info.ts +646 -0
  40. package/client/viewparts/board-info-link.ts +56 -0
  41. package/client/viewparts/board-info.ts +85 -0
  42. package/client/viewparts/board-template-builder.ts +134 -0
  43. package/client/viewparts/board-versions.ts +172 -0
  44. package/client/viewparts/group-info-basic.ts +267 -0
  45. package/client/viewparts/group-info-import.ts +132 -0
  46. package/client/viewparts/group-info.ts +87 -0
  47. package/client/viewparts/index.ts +3 -0
  48. package/client/viewparts/link-builder.ts +210 -0
  49. package/client/viewparts/play-group-info-basic.ts +268 -0
  50. package/client/viewparts/play-group-info-link.ts +46 -0
  51. package/client/viewparts/play-group-info.ts +81 -0
  52. package/dist-client/tsconfig.tsbuildinfo +1 -1
  53. package/dist-server/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +19 -19
  55. package/server/index.ts +0 -0
@@ -0,0 +1,142 @@
1
+ import '@operato/attachment/ox-attachment-list.js'
2
+
3
+ import { css, html } from 'lit'
4
+ import { customElement, query } from 'lit/decorators.js'
5
+ import gql from 'graphql-tag'
6
+
7
+ import { i18next, localize } from '@operato/i18n'
8
+ import { PageView } from '@operato/shell'
9
+ import { OxAttachmentList } from '@operato/attachment/ox-attachment-list.js'
10
+ import { client } from '@operato/graphql'
11
+
12
+ async function fetchDataFromURL(fileURL: string) {
13
+ try {
14
+ const response = await fetch(fileURL)
15
+
16
+ if (!response.ok) {
17
+ throw new Error('Network response was not ok')
18
+ }
19
+
20
+ const blob = await response.blob() // 파일 데이터를 Blob으로 변환
21
+
22
+ if (blob.size === 0) {
23
+ throw new Error('Content is empty') // Content가 비어 있으면 예외
24
+ }
25
+
26
+ return new Promise((resolve, reject) => {
27
+ const reader = new FileReader()
28
+
29
+ reader.onload = (event: any) => {
30
+ const dataURL = event.target.result
31
+ resolve(dataURL)
32
+ }
33
+
34
+ reader.onerror = (event: any) => {
35
+ reject(event.error)
36
+ }
37
+
38
+ reader.readAsDataURL(blob) // Blob을 Data URL로 읽기
39
+ })
40
+ } catch (error) {
41
+ throw error
42
+ }
43
+ }
44
+
45
+ @customElement('attachment-list-page')
46
+ export class AttachmentListPage extends localize(i18next)(PageView) {
47
+ static styles = [
48
+ css`
49
+ :host {
50
+ display: flex;
51
+ }
52
+ `
53
+ ]
54
+
55
+ @query('ox-attachment-list') attachmentList!: OxAttachmentList
56
+
57
+ get context() {
58
+ return {
59
+ title: i18next.t('title.attachment list'),
60
+ search: {
61
+ handler: search => {
62
+ this.grist.searchText = search
63
+ },
64
+ value: this.grist?.searchText || ''
65
+ },
66
+ board_topmenu: true,
67
+ exportable: {
68
+ name: i18next.t('title.attachment list'),
69
+ data: this.exportHandler.bind(this)
70
+ },
71
+ importable: {
72
+ handler: this.importHandler.bind(this)
73
+ }
74
+ }
75
+ }
76
+
77
+ render() {
78
+ return html` <ox-attachment-list .creatable=${true} without-search></ox-attachment-list> `
79
+ }
80
+
81
+ get grist() {
82
+ return this.attachmentList.grist
83
+ }
84
+
85
+ languageUpdated(i18next) {
86
+ this.attachmentList.requestUpdate()
87
+ }
88
+
89
+ async pageInitialized() {
90
+ await this.updateComplete
91
+
92
+ this.attachmentList.refreshAttachments()
93
+ }
94
+
95
+ async exportHandler() {
96
+ const records = this.grist.data.records
97
+ const data = {} as any
98
+
99
+ for (const record of records) {
100
+ const { id, name, mimetype, encoding, category, fullpath } = record
101
+
102
+ try {
103
+ const dataURL = await fetchDataFromURL(fullpath)
104
+
105
+ id &&
106
+ (data[id!] = {
107
+ id,
108
+ name,
109
+ mimetype,
110
+ encoding,
111
+ category,
112
+ contents: dataURL
113
+ })
114
+ } catch (err) {
115
+ console.log(name, err)
116
+ }
117
+ }
118
+
119
+ return data
120
+ }
121
+
122
+ async importHandler(data, file) {
123
+ await client.mutate({
124
+ mutation: gql`
125
+ mutation importAttachments($file: Upload!) {
126
+ importAttachments(file: $file) {
127
+ id
128
+ name
129
+ description
130
+ path
131
+ }
132
+ }
133
+ `,
134
+ variables: {
135
+ file
136
+ },
137
+ context: { hasUpload: true }
138
+ })
139
+
140
+ this.grist.fetch()
141
+ }
142
+ }