@things-factory/board-ui 10.0.0-beta.28 → 10.0.0-beta.29
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.
- package/dist-client/board-provider.js +2 -0
- package/dist-client/board-provider.js.map +1 -1
- package/dist-client/pages/board-modeller-page.d.ts +1 -0
- package/dist-client/pages/board-modeller-page.js +12 -1
- package/dist-client/pages/board-modeller-page.js.map +1 -1
- package/dist-client/pages/board-viewer-page.d.ts +1 -0
- package/dist-client/pages/board-viewer-page.js +16 -10
- package/dist-client/pages/board-viewer-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -4,6 +4,7 @@ import { BoardDataStorage } from '@operato/board';
|
|
|
4
4
|
import { client, gqlContext, subscribe } from '@operato/graphql';
|
|
5
5
|
export function createBoardProvider() {
|
|
6
6
|
const _provider = new ReferenceMap(async (boardId, resolve, reject) => {
|
|
7
|
+
const startTime = performance.now();
|
|
7
8
|
try {
|
|
8
9
|
const response = await client.query({
|
|
9
10
|
query: gql `
|
|
@@ -33,6 +34,7 @@ export function createBoardProvider() {
|
|
|
33
34
|
mode: 0,
|
|
34
35
|
refProvider: provider,
|
|
35
36
|
dataStorage: new BoardDataStorage(boardId),
|
|
37
|
+
loading: { startTime },
|
|
36
38
|
dataSubscriptionProvider: {
|
|
37
39
|
subscribe: async (tag, component) => {
|
|
38
40
|
return await subscribe({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-provider.js","sourceRoot":"","sources":["../client/board-provider.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAS,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CA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E,CAAC;wCACT,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;oCACjC,CAAC;gCACH,CAAC;6BACF,CACF,CAAA;wBACH,CAAC;wBAED,OAAO,KAAI,CAAC;qBACb;iBACK,CAAC,CAAA;gBAET,6BAA6B;YAC/B,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,CAAA;QAChB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,KAAK,CAAC,CAAC,CAAC,CAAA;YACR,MAAM,CAAC,CAAC,CAAC,CAAA;QACX,CAAC;IACH,CAAC,EACD,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;QAChB,GAAG,CAAC,OAAO,EAAE,CAAA;IACf,CAAC,CACF,CAAA;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,mBAAmB,EAAE,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { create, error, ReferenceMap, Scene } from '@hatiolab/things-scene'\nimport { BoardDataStorage } from '@operato/board'\nimport { client, gqlContext, subscribe } from '@operato/graphql'\n\nexport function createBoardProvider() {\n const _provider = new ReferenceMap(\n async (boardId, resolve, reject): Promise<any> => {\n try {\n const response = await client.query({\n query: gql`\n query FetchBoardById($id: String!) {\n board(id: $id) {\n model\n }\n }\n `,\n variables: { id: boardId },\n context: gqlContext()\n })\n\n const board = response.data?.board\n\n if (!board) {\n reject(new Error('Failed to get the requested board.'))\n return\n }\n\n const model = JSON.parse(board.model)\n\n let scene: Scene\n\n try {\n scene = await provider.get(boardId)\n console.warn('Board fetched more than twice.', boardId)\n } catch (e) {\n scene = create({\n model,\n mode: 0,\n refProvider: provider as any,\n dataStorage: new BoardDataStorage(boardId),\n dataSubscriptionProvider: {\n subscribe: async (tag, component) => {\n return await subscribe(\n {\n query: gql`\n subscription {\n data(tag: \"${tag}\") {\n tag\n data\n }\n }\n `\n },\n {\n next: async ({ data }) => {\n if (data) {\n component.data = data.data.data\n }\n }\n }\n )\n },\n\n dispose() {}\n }\n } as any)\n\n // s.app.baseUrl = undefined;\n }\n\n resolve(scene)\n } catch (e) {\n error(e)\n reject(e)\n }\n },\n async (id, ref) => {\n ref.dispose()\n }\n )\n\n return _provider\n}\n\nexport const provider = createBoardProvider()\n"]}
|
|
1
|
+
{"version":3,"file":"board-provider.js","sourceRoot":"","sources":["../client/board-provider.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAS,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEhE,MAAM,UAAU,mBAAmB;IACjC,MAAM,SAAS,GAAG,IAAI,YAAY,CAChC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAgB,EAAE;QAC/C,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QACnC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAClC,KAAK,EAAE,GAAG,CAAA;;;;;;WAMT;gBACD,SAAS,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE;gBAC1B,OAAO,EAAE,UAAU,EAAE;aACtB,CAAC,CAAA;YAEF,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;YAElC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAA;gBACvD,OAAM;YACR,CAAC;YAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAErC,IAAI,KAAY,CAAA;YAEhB,IAAI,CAAC;gBACH,KAAK,GAAG,MA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/things-scene'\nimport { BoardDataStorage } from '@operato/board'\nimport { client, gqlContext, subscribe } from '@operato/graphql'\n\nexport function createBoardProvider() {\n const _provider = new ReferenceMap(\n async (boardId, resolve, reject): Promise<any> => {\n const startTime = performance.now()\n try {\n const response = await client.query({\n query: gql`\n query FetchBoardById($id: String!) {\n board(id: $id) {\n model\n }\n }\n `,\n variables: { id: boardId },\n context: gqlContext()\n })\n\n const board = response.data?.board\n\n if (!board) {\n reject(new Error('Failed to get the requested board.'))\n return\n }\n\n const model = JSON.parse(board.model)\n\n let scene: Scene\n\n try {\n scene = await provider.get(boardId)\n console.warn('Board fetched more than twice.', boardId)\n } catch (e) {\n scene = create({\n model,\n mode: 0,\n refProvider: provider as any,\n dataStorage: new BoardDataStorage(boardId),\n loading: { startTime },\n dataSubscriptionProvider: {\n subscribe: async (tag, component) => {\n return await subscribe(\n {\n query: gql`\n subscription {\n data(tag: \"${tag}\") {\n tag\n data\n }\n }\n `\n },\n {\n next: async ({ data }) => {\n if (data) {\n component.data = data.data.data\n }\n }\n }\n )\n },\n\n dispose() {}\n }\n } as any)\n\n // s.app.baseUrl = undefined;\n }\n\n resolve(scene)\n } catch (e) {\n error(e)\n reject(e)\n }\n },\n async (id, ref) => {\n ref.dispose()\n }\n )\n\n return _provider\n}\n\nexport const provider = createBoardProvider()\n"]}
|
|
@@ -6,6 +6,7 @@ import gql from 'graphql-tag';
|
|
|
6
6
|
import { css, html } from 'lit';
|
|
7
7
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
8
8
|
import { BoardModeller } from '@operato/board/ox-board-modeller.js';
|
|
9
|
+
import { LoadTracker } from '@hatiolab/things-scene';
|
|
9
10
|
import { OxPropertyEditor } from '@operato/property-editor';
|
|
10
11
|
import { PageView, FontController } from '@operato/shell';
|
|
11
12
|
import { hasPrivilege } from '@things-factory/auth-base/dist-client/index.js';
|
|
@@ -69,7 +70,7 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
69
70
|
]; }
|
|
70
71
|
get context() {
|
|
71
72
|
return {
|
|
72
|
-
title: this.board ? this.boardName : this.preparing ? 'Fetching board...' : '
|
|
73
|
+
title: this.board ? this.boardName : this.preparing ? 'Fetching board...' : '',
|
|
73
74
|
help: 'board-modeller/modeller',
|
|
74
75
|
widebleed: true
|
|
75
76
|
};
|
|
@@ -88,6 +89,11 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
91
|
try {
|
|
92
|
+
// 이전 보드 완전히 클리어
|
|
93
|
+
this.board = null;
|
|
94
|
+
this.model = null;
|
|
95
|
+
this._loadTracker = new LoadTracker();
|
|
96
|
+
this._loadTracker.setPhase('fetch');
|
|
91
97
|
this.preparing = true;
|
|
92
98
|
this.updateContext();
|
|
93
99
|
const response = await client.query({
|
|
@@ -103,6 +109,7 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
103
109
|
variables: { id: this.boardId },
|
|
104
110
|
context: gqlContext()
|
|
105
111
|
});
|
|
112
|
+
this._loadTracker?.setPhase('parse');
|
|
106
113
|
const board = response.data.board;
|
|
107
114
|
if (!board) {
|
|
108
115
|
this.board = null;
|
|
@@ -149,8 +156,11 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
149
156
|
}
|
|
150
157
|
else {
|
|
151
158
|
this.boardId = null;
|
|
159
|
+
this.board = null;
|
|
152
160
|
this.model = null;
|
|
161
|
+
this.preparing = false;
|
|
153
162
|
this.modeller?.close();
|
|
163
|
+
this.updateContext();
|
|
154
164
|
}
|
|
155
165
|
}
|
|
156
166
|
render() {
|
|
@@ -160,6 +170,7 @@ let BoardModellerPage = class BoardModellerPage extends PageView {
|
|
|
160
170
|
: html `
|
|
161
171
|
<ox-board-modeller
|
|
162
172
|
.mode=${this.mode}
|
|
173
|
+
.loadTracker=${this._loadTracker}
|
|
163
174
|
@mode-changed=${e => {
|
|
164
175
|
this.mode = e.detail.value;
|
|
165
176
|
}}
|
|
@@ -1 +1 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EAAE,CAAC;;gDAAkB;AAClB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;mDAAmB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CAAkB;AAChB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;uDAA+B;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAkB;AAClB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;6DAAkD;AACjD;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;yDAAoB;AACjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;oDAAoB;AAIpB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8BAAY,aAAa;mDAAA;AA/DzC,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;;GACxB,iBAAiB,CAiQ7B","sourcesContent":["import './things-scene-components.import'\nimport '@operato/board/ox-board-modeller.js'\nimport '@operato/oops'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { BoardModeller } from '@operato/board/ox-board-modeller.js'\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { PageView, FontController } from '@operato/shell'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client/index.js'\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\nimport { provider } from '../board-provider.js'\nimport components from './things-scene-components-with-tools.import'\n\nconst NOOP = () => {}\n\n@customElement('board-modeller-page')\nexport class BoardModellerPage extends PageView {\n constructor() {\n super()\n\n components.forEach(({ templates = [], groups = [] }) => {\n groups.forEach(group => BoardModeller.registerGroup(group))\n BoardModeller.registerTemplate(templates)\n })\n\n /* 컴포넌트에서 정의된 에디터들을 MODELLER_EDITORS에 등록 */\n const addedEditors = {}\n for (const component in components) {\n let { editors } = components[component]\n\n editors &&\n editors.forEach(editor => {\n let { type, element } = editor\n\n addedEditors[type] = element\n })\n }\n\n OxPropertyEditor.register(addedEditors)\n }\n\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n overflow: hidden;\n position: relative;\n }\n\n ox-board-modeller {\n flex: 1;\n }\n\n ox-oops-note {\n display: block;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n `\n ]\n\n @property({ type: String }) boardId?: string | null\n @property({ type: String }) boardName?: string = ''\n @property({ type: Object }) model: any = null\n @property({ type: Array }) selected: any = []\n @property({ type: Number }) mode?: number = 1\n @property({ type: Boolean }) hideProperty?: boolean = false\n @property({ type: String }) overlay?: string | null = null\n @property({ type: Object }) scene: any = null\n @property({ type: Array }) componentGroupList?: any[] = BoardModeller.groups\n @property({ type: Array }) propertyEditor: any\n @property({ type: Boolean }) preparing?: boolean\n\n private board: any = null\n private _fontCtrl = new FontController(this)\n @query('ox-board-modeller') modeller?: BoardModeller\n\n get context() {\n return {\n title: this.board ? this.boardName : this.preparing ? 'Fetching board...' : 'Board Not Found',\n help: 'board-modeller/modeller',\n widebleed: true\n }\n }\n\n get oopsNote() {\n return {\n icon: 'color_lens',\n title: 'EMPTY BOARD',\n description: 'There are no board to be designed'\n }\n }\n\n async refresh() {\n if (!this.boardId) {\n this.board = null\n this.model = null\n\n return\n }\n try {\n this.preparing = true\n this.updateContext()\n\n const response = await client.query({\n query: gql`\n query FetchBoardById($id: String!) {\n board(id: $id) {\n id\n name\n model\n }\n }\n `,\n variables: { id: this.boardId },\n context: gqlContext()\n })\n\n const board = response.data.board\n\n if (!board) {\n this.board = null\n throw new Error('board not found')\n }\n\n this.board = {\n ...board,\n model: JSON.parse(board.model)\n }\n\n this.boardName = this.board.name\n this.model = {\n ...this.board.model\n }\n } catch (ex) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: ex,\n ex\n }\n })\n )\n } finally {\n this.preparing = false\n this.updateContext()\n }\n }\n\n async updated(changes) {\n if (changes.has('boardId')) {\n if (await hasPrivilege({ privilege: 'mutation', category: 'board' })) {\n this.refresh()\n } else {\n this.boardId = null\n this.model = null\n this.modeller?.close()\n }\n }\n }\n\n pageUpdated(changes, lifecycle) {\n if (this.active) {\n this.boardId = lifecycle.resourceId\n } else {\n this.boardId = null\n this.model = null\n this.modeller?.close()\n }\n }\n\n render() {\n const oops = !this.preparing && !this.model && this.oopsNote\n\n return oops\n ? html` <ox-oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></ox-oops-note> `\n : html`\n <ox-board-modeller\n .mode=${this.mode}\n @mode-changed=${e => {\n this.mode = e.detail.value\n }}\n .model=${this.model}\n @model-changed=${e => {\n this.model = e.detail.value\n }}\n .scene=${this.scene}\n @scene-changed=${e => {\n this.scene = e.detail.value\n }}\n .selected=${this.selected}\n @selected-changed=${e => {\n this.selected = e.detail.value\n }}\n .provider=${provider}\n @save-model=${e => this.saveBoard()}\n .componentGroupList=${this.componentGroupList}\n .fonts=${this._fontCtrl.fonts}\n .hideProperty=${this.hideProperty}\n >\n </ox-board-modeller>\n `\n }\n\n async updateBoard() {\n try {\n this.preparing = true\n\n const { id, name, description, groupId } = this.board\n const model = JSON.stringify(this.scene.model)\n\n await client.mutate({\n mutation: gql`\n mutation UpdateBoard($id: String!, $patch: BoardPatch!) {\n updateBoard(id: $id, patch: $patch) {\n id\n }\n }\n `,\n variables: {\n id,\n patch: { name, description, model, groupId }\n },\n context: gqlContext()\n })\n\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'info',\n message: i18next.t('text.saved')\n }\n })\n )\n } catch (ex) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: ex,\n ex: ex\n }\n })\n )\n } finally {\n this.preparing = false\n }\n\n this.updateContext()\n }\n\n async saveBoard() {\n await this.updateBoard()\n this.modeller?.preserve()\n }\n\n async canDeactivate(): Promise<boolean> {\n if (this.modeller?.hasUnpreservedChanges()) {\n return await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('prompt.sure to navigate away?'),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n }\n\n return true\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"board-modeller-page.js","sourceRoot":"","sources":["../../client/pages/board-modeller-page.ts"],"names":[],"mappings":";AAAA,OAAO,kCAAkC,CAAA;AACzC,OAAO,qCAAqC,CAAA;AAC5C,OAAO,eAAe,CAAA;AAEtB,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,UAAU,MAAM,6CAA6C,CAAA;AAEpE,MAAM,IAAI,GAAG,GAAG,EA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EAAE,CAAC;;6DAAkD;AACjD;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;yDAAoB;AACjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;oDAAoB;AAKpB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8BAAY,aAAa;mDAAA;AAhEzC,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;;GACxB,iBAAiB,CA6Q7B","sourcesContent":["import './things-scene-components.import'\nimport '@operato/board/ox-board-modeller.js'\nimport '@operato/oops'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { BoardModeller } from '@operato/board/ox-board-modeller.js'\nimport { LoadTracker } from '@hatiolab/things-scene'\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { PageView, FontController } from '@operato/shell'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client/index.js'\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\nimport { provider } from '../board-provider.js'\nimport components from './things-scene-components-with-tools.import'\n\nconst NOOP = () => {}\n\n@customElement('board-modeller-page')\nexport class BoardModellerPage extends PageView {\n constructor() {\n super()\n\n components.forEach(({ templates = [], groups = [] }) => {\n groups.forEach(group => BoardModeller.registerGroup(group))\n BoardModeller.registerTemplate(templates)\n })\n\n /* 컴포넌트에서 정의된 에디터들을 MODELLER_EDITORS에 등록 */\n const addedEditors = {}\n for (const component in components) {\n let { editors } = components[component]\n\n editors &&\n editors.forEach(editor => {\n let { type, element } = editor\n\n addedEditors[type] = element\n })\n }\n\n OxPropertyEditor.register(addedEditors)\n }\n\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n overflow: hidden;\n position: relative;\n }\n\n ox-board-modeller {\n flex: 1;\n }\n\n ox-oops-note {\n display: block;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n `\n ]\n\n @property({ type: String }) boardId?: string | null\n @property({ type: String }) boardName?: string = ''\n @property({ type: Object }) model: any = null\n @property({ type: Array }) selected: any = []\n @property({ type: Number }) mode?: number = 1\n @property({ type: Boolean }) hideProperty?: boolean = false\n @property({ type: String }) overlay?: string | null = null\n @property({ type: Object }) scene: any = null\n @property({ type: Array }) componentGroupList?: any[] = BoardModeller.groups\n @property({ type: Array }) propertyEditor: any\n @property({ type: Boolean }) preparing?: boolean\n\n private board: any = null\n private _loadTracker?: LoadTracker\n private _fontCtrl = new FontController(this)\n @query('ox-board-modeller') modeller?: BoardModeller\n\n get context() {\n return {\n title: this.board ? this.boardName : this.preparing ? 'Fetching board...' : '',\n help: 'board-modeller/modeller',\n widebleed: true\n }\n }\n\n get oopsNote() {\n return {\n icon: 'color_lens',\n title: 'EMPTY BOARD',\n description: 'There are no board to be designed'\n }\n }\n\n async refresh() {\n if (!this.boardId) {\n this.board = null\n this.model = null\n\n return\n }\n try {\n // 이전 보드 완전히 클리어\n this.board = null\n this.model = null\n this._loadTracker = new LoadTracker()\n this._loadTracker.setPhase('fetch')\n this.preparing = true\n this.updateContext()\n\n const response = await client.query({\n query: gql`\n query FetchBoardById($id: String!) {\n board(id: $id) {\n id\n name\n model\n }\n }\n `,\n variables: { id: this.boardId },\n context: gqlContext()\n })\n\n this._loadTracker?.setPhase('parse')\n\n const board = response.data.board\n\n if (!board) {\n this.board = null\n throw new Error('board not found')\n }\n\n this.board = {\n ...board,\n model: JSON.parse(board.model)\n }\n\n this.boardName = this.board.name\n this.model = {\n ...this.board.model\n }\n } catch (ex) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: ex,\n ex\n }\n })\n )\n } finally {\n this.preparing = false\n this.updateContext()\n }\n }\n\n async updated(changes) {\n if (changes.has('boardId')) {\n if (await hasPrivilege({ privilege: 'mutation', category: 'board' })) {\n this.refresh()\n } else {\n this.boardId = null\n this.model = null\n this.modeller?.close()\n }\n }\n }\n\n pageUpdated(changes, lifecycle) {\n if (this.active) {\n this.boardId = lifecycle.resourceId\n } else {\n this.boardId = null\n this.board = null\n this.model = null\n this.preparing = false\n this.modeller?.close()\n this.updateContext()\n }\n }\n\n render() {\n const oops = !this.preparing && !this.model && this.oopsNote\n\n return oops\n ? html` <ox-oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></ox-oops-note> `\n : html`\n <ox-board-modeller\n .mode=${this.mode}\n .loadTracker=${this._loadTracker}\n @mode-changed=${e => {\n this.mode = e.detail.value\n }}\n .model=${this.model}\n @model-changed=${e => {\n this.model = e.detail.value\n }}\n .scene=${this.scene}\n @scene-changed=${e => {\n this.scene = e.detail.value\n }}\n .selected=${this.selected}\n @selected-changed=${e => {\n this.selected = e.detail.value\n }}\n .provider=${provider}\n @save-model=${e => this.saveBoard()}\n .componentGroupList=${this.componentGroupList}\n .fonts=${this._fontCtrl.fonts}\n .hideProperty=${this.hideProperty}\n >\n </ox-board-modeller>\n `\n }\n\n async updateBoard() {\n try {\n this.preparing = true\n\n const { id, name, description, groupId } = this.board\n const model = JSON.stringify(this.scene.model)\n\n await client.mutate({\n mutation: gql`\n mutation UpdateBoard($id: String!, $patch: BoardPatch!) {\n updateBoard(id: $id, patch: $patch) {\n id\n }\n }\n `,\n variables: {\n id,\n patch: { name, description, model, groupId }\n },\n context: gqlContext()\n })\n\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'info',\n message: i18next.t('text.saved')\n }\n })\n )\n } catch (ex) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: ex,\n ex: ex\n }\n })\n )\n } finally {\n this.preparing = false\n }\n\n this.updateContext()\n }\n\n async saveBoard() {\n await this.updateBoard()\n this.modeller?.preserve()\n }\n\n async canDeactivate(): Promise<boolean> {\n if (this.modeller?.hasUnpreservedChanges()) {\n return await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('prompt.sure to navigate away?'),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n }\n\n return true\n }\n}\n"]}
|
|
@@ -7,6 +7,7 @@ import { css, html } from 'lit';
|
|
|
7
7
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
8
8
|
import { buildLabelPrintCommand } from '@operato/barcode';
|
|
9
9
|
import { BoardViewer } from '@operato/board';
|
|
10
|
+
import { LoadTracker } from '@hatiolab/things-scene';
|
|
10
11
|
import { PageView } from '@operato/shell';
|
|
11
12
|
import { client, gqlContext, subscribe } from '@operato/graphql';
|
|
12
13
|
import { clientSettingStore } from '@operato/shell/object-store.js';
|
|
@@ -73,9 +74,8 @@ let BoardViewerPage = class BoardViewerPage extends PageView {
|
|
|
73
74
|
}
|
|
74
75
|
get context() {
|
|
75
76
|
return {
|
|
76
|
-
/* can set the page title with the 'title' parameter. */
|
|
77
77
|
title: this.lifecycle.params['title'] ||
|
|
78
|
-
(this._board ? this._board.name : this._showSpinner ? 'Fetching board...' : '
|
|
78
|
+
(this._board ? this._board.name : this._showSpinner ? 'Fetching board...' : ''),
|
|
79
79
|
help: this._help
|
|
80
80
|
};
|
|
81
81
|
}
|
|
@@ -90,6 +90,7 @@ let BoardViewerPage = class BoardViewerPage extends PageView {
|
|
|
90
90
|
?hide-fullscreen=${this._interactive}
|
|
91
91
|
?hide-navigation=${this._interactive}
|
|
92
92
|
.data=${this.data}
|
|
93
|
+
.loadTracker=${this._loadTracker}
|
|
93
94
|
history
|
|
94
95
|
></ox-board-viewer>
|
|
95
96
|
<ox-oops-spinner ?show=${this._showSpinner}></ox-oops-spinner>
|
|
@@ -108,17 +109,17 @@ let BoardViewerPage = class BoardViewerPage extends PageView {
|
|
|
108
109
|
this.data = parseQuery({ ...lifecycle.params });
|
|
109
110
|
}
|
|
110
111
|
else {
|
|
111
|
-
|
|
112
|
-
* 비활성화된 페이지에서 render update가 발생하지 않으므로, 강제로 scene을 close 한다.
|
|
113
|
-
* 화면이 inactive 될 때, 굳이 scene을 close하는 이유는,
|
|
114
|
-
* 새로운 board가 선택되어 뷰어가 열릴 때, 기존 보드 잔상이 보이지 않도록 하기위해서이다.
|
|
115
|
-
*/
|
|
112
|
+
// 비활성 — 철저히 클리어
|
|
116
113
|
this.stopSubscribing();
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
boardViewer
|
|
114
|
+
const boardViewer = this.boardViewer;
|
|
115
|
+
if (boardViewer) {
|
|
116
|
+
boardViewer.closeScene();
|
|
120
117
|
}
|
|
121
118
|
this._boardId = '';
|
|
119
|
+
this._board = null;
|
|
120
|
+
this._loadTracker = undefined;
|
|
121
|
+
this._showSpinner = false;
|
|
122
|
+
this.updateContext();
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
async fetch(id) {
|
|
@@ -145,9 +146,14 @@ let BoardViewerPage = class BoardViewerPage extends PageView {
|
|
|
145
146
|
return;
|
|
146
147
|
}
|
|
147
148
|
try {
|
|
149
|
+
// 이전 보드 완전히 클리어
|
|
150
|
+
this._board = null;
|
|
151
|
+
this._loadTracker = new LoadTracker();
|
|
152
|
+
this._loadTracker.setPhase('fetch');
|
|
148
153
|
this._showSpinner = true;
|
|
149
154
|
this.updateContext();
|
|
150
155
|
const { data, errors } = (await this.fetch(this._boardId)) || {};
|
|
156
|
+
this._loadTracker.setPhase('parse');
|
|
151
157
|
const board = data?.response;
|
|
152
158
|
if (!board) {
|
|
153
159
|
this._board = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-viewer-page.js","sourceRoot":"","sources":["../../client/pages/board-viewer-page.ts"],"names":[],"mappings":";AAAA,OAAO,kCAAkC,CAAA;AACzC,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AAEtB,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,E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ag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { buildLabelPrintCommand } from '@operato/barcode'\nimport { BoardViewer } from '@operato/board'\nimport { PageView } from '@operato/shell'\nimport { client, gqlContext, subscribe } from '@operato/graphql'\nimport { clientSettingStore } from '@operato/shell/object-store.js'\n\nimport { provider } from '../board-provider.js'\nimport { ApolloQueryResult } from '@apollo/client'\nconst NOOP = () => {}\n\nfunction parseQuery(query: any) {\n for (const key in query) {\n if (query.hasOwnProperty(key)) {\n try {\n query[key] = JSON.parse(query[key])\n } catch (error) {\n // do nothing\n }\n }\n }\n\n return query\n}\n\n@customElement('board-viewer-page')\nexport class BoardViewerPage extends PageView {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%; /* 전체화면보기를 위해서 필요함. */\n height: 100%;\n\n overflow: hidden;\n position: relative;\n }\n\n ox-board-viewer {\n flex: 1;\n }\n\n ox-oops-spinner {\n display: none;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n\n ox-oops-spinner[show] {\n display: block;\n }\n\n ox-oops-note {\n display: block;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n `\n ]\n\n @property({ type: Object }) _board: any\n @property({ type: String }) _boardId?: string\n @property({ type: String }) _help?: string\n @property({ type: Boolean }) _interactive?: boolean\n @property({ type: Boolean }) _showSpinner?: boolean\n\n @state() data: any\n\n subscriptionForAutoRefresh\n\n @query('ox-board-viewer') boardViewer!: BoardViewer\n\n get oopsNote() {\n return {\n icon: 'insert_chart_outlined',\n title: 'EMPTY BOARD',\n description: 'There are no board to be shown'\n }\n }\n\n get context() {\n return {\n /* can set the page title with the 'title' parameter. */\n title:\n this.lifecycle.params['title'] ||\n (this._board ? this._board.name : this._showSpinner ? 'Fetching board...' : 'Board Not Found'),\n help: this._help\n }\n }\n\n render() {\n const oops = !this._showSpinner && !this._board && this.oopsNote\n\n return oops\n ? html` <ox-oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></ox-oops-note> `\n : html`\n <ox-board-viewer\n .board=${this._board}\n .provider=${provider}\n ?hide-fullscreen=${this._interactive}\n ?hide-navigation=${this._interactive}\n .data=${this.data}\n history\n ></ox-board-viewer>\n <ox-oops-spinner ?show=${this._showSpinner}></ox-oops-spinner>\n `\n }\n\n updated(changes) {\n if (changes.has('_boardId')) {\n this.refresh()\n }\n }\n\n pageUpdated(changes, lifecycle) {\n if (this.active) {\n this._boardId = lifecycle.resourceId\n this._interactive = lifecycle.params['interactive'] === 'true'\n this._help = lifecycle.params['help']\n this.data = parseQuery({ ...lifecycle.params })\n } else {\n /*\n * 비활성화된 페이지에서 render update가 발생하지 않으므로, 강제로 scene을 close 한다.\n * 화면이 inactive 될 때, 굳이 scene을 close하는 이유는,\n * 새로운 board가 선택되어 뷰어가 열릴 때, 기존 보드 잔상이 보이지 않도록 하기위해서이다.\n */\n this.stopSubscribing()\n\n if (this._boardId) {\n let boardViewer = this.boardViewer\n boardViewer && boardViewer.closeScene()\n }\n\n this._boardId = ''\n }\n }\n\n async fetch(id: string): Promise<ApolloQueryResult<any> | undefined> {\n if (!id) {\n return\n }\n\n return await client.query({\n query: gql`\n query ($id: String!) {\n response: board(id: $id) {\n id\n name\n model\n }\n }\n `,\n variables: { id },\n context: gqlContext()\n })\n }\n\n async refresh() {\n if (!this._boardId) {\n this._board = null\n return\n }\n\n try {\n this._showSpinner = true\n this.updateContext()\n\n const { data, errors } = (await this.fetch(this._boardId)) || {}\n\n const board = data?.response\n\n if (!board) {\n this._board = null\n const message = errors?.map(error => error.message).join('\\n')\n throw message || 'board not found'\n }\n\n this._board = {\n ...board,\n model: JSON.parse(board.model)\n }\n } catch (ex) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: ex,\n ex\n }\n })\n )\n } finally {\n this._showSpinner = false\n this.updateContext()\n\n const { autoRefresh = true } = (await clientSettingStore.get('board-view'))?.value || {}\n autoRefresh && this.startSubscribingForAutoRefresh()\n }\n }\n\n async startSubscribingForAutoRefresh() {\n if (!this._board) {\n return\n }\n\n await this.stopSubscribing()\n\n this.subscriptionForAutoRefresh = await subscribe(\n {\n query: gql`\n subscription ($id: String!) {\n board(id: $id) {\n id\n }\n }\n `,\n variables: {\n id: this._board.id\n }\n },\n {\n next: async ({ data }) => {\n await this.stopSubscribing()\n\n if (data) {\n this.refresh()\n }\n }\n }\n )\n }\n\n async stopSubscribing() {\n await this.subscriptionForAutoRefresh?.unsubscribe()\n delete this.subscriptionForAutoRefresh\n }\n\n async getGrf() {\n const { labelRotation } = this._board.model\n\n const { width, height, data } = (await this.boardViewer.getSceneImageData()) || {}\n if (!width || !data) {\n throw new Error('Cannot get SceneImageData...')\n }\n\n return buildLabelPrintCommand(data as Uint8ClampedArray, width, height, labelRotation, false, false)\n }\n\n async printTrick(image) {\n await this.boardViewer.printTrick(image)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"board-viewer-page.js","sourceRoot":"","sources":["../../client/pages/board-viewer-page.ts"],"names":[],"mappings":";AAAA,OAAO,kCAAkC,CAAA;AACzC,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AAEtB,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,k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esContent":["import './things-scene-components.import'\nimport '@operato/board/ox-board-viewer.js'\nimport '@operato/oops'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { buildLabelPrintCommand } from '@operato/barcode'\nimport { BoardViewer } from '@operato/board'\nimport { LoadTracker } from '@hatiolab/things-scene'\nimport { PageView } from '@operato/shell'\nimport { client, gqlContext, subscribe } from '@operato/graphql'\nimport { clientSettingStore } from '@operato/shell/object-store.js'\n\nimport { provider } from '../board-provider.js'\nimport { ApolloQueryResult } from '@apollo/client'\nconst NOOP = () => {}\n\nfunction parseQuery(query: any) {\n for (const key in query) {\n if (query.hasOwnProperty(key)) {\n try {\n query[key] = JSON.parse(query[key])\n } catch (error) {\n // do nothing\n }\n }\n }\n\n return query\n}\n\n@customElement('board-viewer-page')\nexport class BoardViewerPage extends PageView {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%; /* 전체화면보기를 위해서 필요함. */\n height: 100%;\n\n overflow: hidden;\n position: relative;\n }\n\n ox-board-viewer {\n flex: 1;\n }\n\n ox-oops-spinner {\n display: none;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n\n ox-oops-spinner[show] {\n display: block;\n }\n\n ox-oops-note {\n display: block;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n `\n ]\n\n @property({ type: Object }) _board: any\n @property({ type: String }) _boardId?: string\n @property({ type: String }) _help?: string\n @property({ type: Boolean }) _interactive?: boolean\n @property({ type: Boolean }) _showSpinner?: boolean\n\n @state() data: any\n private _loadTracker?: LoadTracker\n\n subscriptionForAutoRefresh\n\n @query('ox-board-viewer') boardViewer!: BoardViewer\n\n get oopsNote() {\n return {\n icon: 'insert_chart_outlined',\n title: 'EMPTY BOARD',\n description: 'There are no board to be shown'\n }\n }\n\n get context() {\n return {\n title:\n this.lifecycle.params['title'] ||\n (this._board ? this._board.name : this._showSpinner ? 'Fetching board...' : ''),\n help: this._help\n }\n }\n\n render() {\n const oops = !this._showSpinner && !this._board && this.oopsNote\n\n return oops\n ? html` <ox-oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></ox-oops-note> `\n : html`\n <ox-board-viewer\n .board=${this._board}\n .provider=${provider}\n ?hide-fullscreen=${this._interactive}\n ?hide-navigation=${this._interactive}\n .data=${this.data}\n .loadTracker=${this._loadTracker}\n history\n ></ox-board-viewer>\n <ox-oops-spinner ?show=${this._showSpinner}></ox-oops-spinner>\n `\n }\n\n updated(changes) {\n if (changes.has('_boardId')) {\n this.refresh()\n }\n }\n\n pageUpdated(changes, lifecycle) {\n if (this.active) {\n this._boardId = lifecycle.resourceId\n this._interactive = lifecycle.params['interactive'] === 'true'\n this._help = lifecycle.params['help']\n this.data = parseQuery({ ...lifecycle.params })\n } else {\n // 비활성 — 철저히 클리어\n this.stopSubscribing()\n\n const boardViewer = this.boardViewer\n if (boardViewer) {\n boardViewer.closeScene()\n }\n\n this._boardId = ''\n this._board = null\n this._loadTracker = undefined\n this._showSpinner = false\n this.updateContext()\n }\n }\n\n async fetch(id: string): Promise<ApolloQueryResult<any> | undefined> {\n if (!id) {\n return\n }\n\n return await client.query({\n query: gql`\n query ($id: String!) {\n response: board(id: $id) {\n id\n name\n model\n }\n }\n `,\n variables: { id },\n context: gqlContext()\n })\n }\n\n async refresh() {\n if (!this._boardId) {\n this._board = null\n return\n }\n\n try {\n // 이전 보드 완전히 클리어\n this._board = null\n this._loadTracker = new LoadTracker()\n this._loadTracker.setPhase('fetch')\n this._showSpinner = true\n this.updateContext()\n\n const { data, errors } = (await this.fetch(this._boardId)) || {}\n\n this._loadTracker.setPhase('parse')\n\n const board = data?.response\n\n if (!board) {\n this._board = null\n const message = errors?.map(error => error.message).join('\\n')\n throw message || 'board not found'\n }\n\n this._board = {\n ...board,\n model: JSON.parse(board.model)\n }\n } catch (ex) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: ex,\n ex\n }\n })\n )\n } finally {\n this._showSpinner = false\n this.updateContext()\n\n const { autoRefresh = true } = (await clientSettingStore.get('board-view'))?.value || {}\n autoRefresh && this.startSubscribingForAutoRefresh()\n }\n }\n\n async startSubscribingForAutoRefresh() {\n if (!this._board) {\n return\n }\n\n await this.stopSubscribing()\n\n this.subscriptionForAutoRefresh = await subscribe(\n {\n query: gql`\n subscription ($id: String!) {\n board(id: $id) {\n id\n }\n }\n `,\n variables: {\n id: this._board.id\n }\n },\n {\n next: async ({ data }) => {\n await this.stopSubscribing()\n\n if (data) {\n this.refresh()\n }\n }\n }\n )\n }\n\n async stopSubscribing() {\n await this.subscriptionForAutoRefresh?.unsubscribe()\n delete this.subscriptionForAutoRefresh\n }\n\n async getGrf() {\n const { labelRotation } = this._board.model\n\n const { width, height, data } = (await this.boardViewer.getSceneImageData()) || {}\n if (!width || !data) {\n throw new Error('Cannot get SceneImageData...')\n }\n\n return buildLabelPrintCommand(data as Uint8ClampedArray, width, height, labelRotation, false, false)\n }\n\n async printTrick(image) {\n await this.boardViewer.printTrick(image)\n }\n}\n"]}
|