@things-factory/board-ui 6.4.8 → 6.4.11

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.
@@ -1,22 +1,26 @@
1
1
  import gql from 'graphql-tag'
2
2
 
3
3
  import { create, error, ReferenceMap, Scene } from '@hatiolab/things-scene'
4
- import { BoardDataStorage } from '@operato/board'
4
+ import { BoardDataStorage, BoardModelCache } from '@operato/board'
5
5
  import { client, gqlContext, subscribe } from '@operato/graphql'
6
6
 
7
7
  export function createBoardProvider() {
8
- var _provider = new ReferenceMap<Scene>(
8
+ const _provider = new ReferenceMap<Scene>(
9
9
  async (boardId, resolve, reject): Promise<any> => {
10
+ const startTime = performance.now()
10
11
  try {
12
+ const cached = await BoardModelCache.get(boardId)
13
+
11
14
  const response = await client.query({
12
15
  query: gql`
13
- query FetchBoardById($id: String!) {
14
- board(id: $id) {
16
+ query FetchBoardById($id: String!, $cachedUpdatedAt: String) {
17
+ board(id: $id, cachedUpdatedAt: $cachedUpdatedAt) {
15
18
  model
19
+ updatedAt
16
20
  }
17
21
  }
18
22
  `,
19
- variables: { id: boardId },
23
+ variables: { id: boardId, cachedUpdatedAt: cached?.updatedAt },
20
24
  context: gqlContext()
21
25
  })
22
26
 
@@ -27,7 +31,15 @@ export function createBoardProvider() {
27
31
  return
28
32
  }
29
33
 
30
- var model = JSON.parse(board.model)
34
+ let model: any
35
+ if (board.model === null && cached) {
36
+ // 캐시 유효
37
+ model = cached.model
38
+ } else {
39
+ // 새 모델
40
+ model = JSON.parse(board.model)
41
+ await BoardModelCache.put(boardId, '', board.model, board.updatedAt)
42
+ }
31
43
 
32
44
  var scene: Scene
33
45
 
@@ -7,6 +7,7 @@ import { customElement, property, query } from 'lit/decorators.js'
7
7
  import { connect } from 'pwa-helpers/connect-mixin.js'
8
8
 
9
9
  import { BoardModeller } from '@operato/board/ox-board-modeller.js'
10
+ import { BoardModelCache } from '@operato/board'
10
11
  import { OxPropertyEditor } from '@operato/property-editor'
11
12
  import { PageView, store } from '@operato/shell'
12
13
  import { hasPrivilege } from '@things-factory/auth-base/dist-client'
@@ -270,6 +271,11 @@ export class BoardModellerPage extends connect(store)(PageView) {
270
271
  async saveBoard() {
271
272
  await this.updateBoard()
272
273
  this.modeller?.preserve()
274
+
275
+ // 저장 시 캐시 무효화 — viewer가 다음에 최신 model을 가져옴
276
+ if (this.boardId) {
277
+ await BoardModelCache.remove(this.boardId)
278
+ }
273
279
  }
274
280
 
275
281
  async canDeactivate(): Promise<boolean> {
@@ -7,18 +7,22 @@ import { BoardViewerPage } from './board-viewer-page'
7
7
  @customElement('board-viewer-by-name-page')
8
8
  export class BoardViewerByNamePage extends BoardViewerPage {
9
9
  async fetch(name: string) {
10
- return await client.query({
11
- query: gql`
12
- query FetchBoardByName($name: String!) {
13
- response: boardByName(name: $name) {
14
- id
15
- name
16
- model
10
+ return {
11
+ cached: null,
12
+ ...(await client.query({
13
+ query: gql`
14
+ query FetchBoardByName($name: String!) {
15
+ response: boardByName(name: $name) {
16
+ id
17
+ name
18
+ model
19
+ updatedAt
20
+ }
17
21
  }
18
- }
19
- `,
20
- variables: { name },
21
- context: gqlContext()
22
- })
22
+ `,
23
+ variables: { name },
24
+ context: gqlContext()
25
+ }))
26
+ }
23
27
  }
24
28
  }
@@ -7,7 +7,7 @@ import { customElement, property, query, state } from 'lit/decorators.js'
7
7
  import { connect } from 'pwa-helpers/connect-mixin.js'
8
8
 
9
9
  import { buildLabelPrintCommand } from '@operato/barcode'
10
- import { BoardViewer } from '@operato/board'
10
+ import { BoardViewer, BoardModelCache } from '@operato/board'
11
11
  import { store, PageView } from '@operato/shell'
12
12
  import { client, gqlContext, subscribe } from '@operato/graphql'
13
13
  import { clientSettingStore } from '@operato/shell/object-store.js'
@@ -149,19 +149,25 @@ export class BoardViewerPage extends connect(store)(PageView) {
149
149
  }
150
150
 
151
151
  async fetch(id: string) {
152
- return await client.query({
153
- query: gql`
154
- query ($id: String!) {
155
- response: board(id: $id) {
156
- id
157
- name
158
- model
152
+ const cached = await BoardModelCache.get(id)
153
+
154
+ return {
155
+ cached,
156
+ ...(await client.query({
157
+ query: gql`
158
+ query ($id: String!, $cachedUpdatedAt: String) {
159
+ response: board(id: $id, cachedUpdatedAt: $cachedUpdatedAt) {
160
+ id
161
+ name
162
+ model
163
+ updatedAt
164
+ }
159
165
  }
160
- }
161
- `,
162
- variables: { id },
163
- context: gqlContext()
164
- })
166
+ `,
167
+ variables: { id, cachedUpdatedAt: cached?.updatedAt },
168
+ context: gqlContext()
169
+ }))
170
+ }
165
171
  }
166
172
 
167
173
  async refresh() {
@@ -174,7 +180,7 @@ export class BoardViewerPage extends connect(store)(PageView) {
174
180
  this._showSpinner = true
175
181
  this.updateContext()
176
182
 
177
- var { data, errors } = await this.fetch(this._boardId)
183
+ var { data, errors, cached } = await this.fetch(this._boardId)
178
184
 
179
185
  var board = data?.response
180
186
 
@@ -184,9 +190,17 @@ export class BoardViewerPage extends connect(store)(PageView) {
184
190
  throw message || 'board not found'
185
191
  }
186
192
 
193
+ let model: any
194
+ if (board.model === null && cached) {
195
+ model = cached.model
196
+ } else {
197
+ model = JSON.parse(board.model)
198
+ await BoardModelCache.put(this._boardId, board.name || '', board.model, board.updatedAt)
199
+ }
200
+
187
201
  this._board = {
188
202
  ...board,
189
- model: JSON.parse(board.model)
203
+ model
190
204
  }
191
205
  } catch (ex) {
192
206
  document.dispatchEvent(
@@ -1,20 +1,23 @@
1
1
  import gql from 'graphql-tag';
2
2
  import { create, error, ReferenceMap } from '@hatiolab/things-scene';
3
- import { BoardDataStorage } from '@operato/board';
3
+ import { BoardDataStorage, BoardModelCache } from '@operato/board';
4
4
  import { client, gqlContext, subscribe } from '@operato/graphql';
5
5
  export function createBoardProvider() {
6
- var _provider = new ReferenceMap(async (boardId, resolve, reject) => {
6
+ const _provider = new ReferenceMap(async (boardId, resolve, reject) => {
7
7
  var _a;
8
+ const startTime = performance.now();
8
9
  try {
10
+ const cached = await BoardModelCache.get(boardId);
9
11
  const response = await client.query({
10
12
  query: gql `
11
- query FetchBoardById($id: String!) {
12
- board(id: $id) {
13
+ query FetchBoardById($id: String!, $cachedUpdatedAt: String) {
14
+ board(id: $id, cachedUpdatedAt: $cachedUpdatedAt) {
13
15
  model
16
+ updatedAt
14
17
  }
15
18
  }
16
19
  `,
17
- variables: { id: boardId },
20
+ variables: { id: boardId, cachedUpdatedAt: cached === null || cached === void 0 ? void 0 : cached.updatedAt },
18
21
  context: gqlContext()
19
22
  });
20
23
  const board = (_a = response.data) === null || _a === void 0 ? void 0 : _a.board;
@@ -22,7 +25,16 @@ export function createBoardProvider() {
22
25
  reject(new Error('Failed to get the requested board.'));
23
26
  return;
24
27
  }
25
- var model = JSON.parse(board.model);
28
+ let model;
29
+ if (board.model === null && cached) {
30
+ // 캐시 유효
31
+ model = cached.model;
32
+ }
33
+ else {
34
+ // 새 모델
35
+ model = JSON.parse(board.model);
36
+ await BoardModelCache.put(boardId, '', board.model, board.updatedAt);
37
+ }
26
38
  var scene;
27
39
  try {
28
40
  scene = await provider.get(boardId);
@@ -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,CAAA;AAEhE,MAAM,UAAU,mBAAmB;IACjC,IAAI,SAAS,GAAG,IAAI,YAAY,CAC9B,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAgB,EAAE;;QAC/C,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAClC,KAAK,EAAE,GAAG,CAAA;;;;;;WAMT;gB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;YAEd,mBAAmB;YACnB,cAAc;YACd,UAAU;YACV,KAAK;QACP,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 var _provider = new ReferenceMap<Scene>(\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 var model = JSON.parse(board.model)\n\n var 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 })\n\n // s.app.baseUrl = undefined;\n }\n\n resolve(scene)\n\n // resolve(scene, {\n // ...board,\n // model\n // })\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,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAClE,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,MAAM,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YAEjD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAClC,KAAK,EAAE,GAAG,CAAA;;;;;;;WAOT;gBACD,SAAS,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAE;gBAC9D,OAAO,EAAE,UAAU,EAAE;aACtB,CAAC,CAAA;YAEF,MAAM,KAAK,GAAG,MAAA,QAAQ,CAAC,IAAI,0CAAE,KAAK,CAAA;YAElC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAA;gBACvD,OAAM;YACR,CAAC;YAED,IAAI,KAAU,CAAA;YACd,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnC,QAAQ;gBACR,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;YAC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AAM,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, BoardModelCache } from '@operato/board'\nimport { client, gqlContext, subscribe } from '@operato/graphql'\n\nexport function createBoardProvider() {\n const _provider = new ReferenceMap<Scene>(\n async (boardId, resolve, reject): Promise<any> => {\n const startTime = performance.now()\n try {\n const cached = await BoardModelCache.get(boardId)\n\n const response = await client.query({\n query: gql`\n query FetchBoardById($id: String!, $cachedUpdatedAt: String) {\n board(id: $id, cachedUpdatedAt: $cachedUpdatedAt) {\n model\n updatedAt\n }\n }\n `,\n variables: { id: boardId, cachedUpdatedAt: cached?.updatedAt },\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 let model: any\n if (board.model === null && cached) {\n // 캐시 유효\n model = cached.model\n } else {\n // 새 모델\n model = JSON.parse(board.model)\n await BoardModelCache.put(boardId, '', board.model, board.updatedAt)\n }\n\n var 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 })\n\n // s.app.baseUrl = undefined;\n }\n\n resolve(scene)\n\n // resolve(scene, {\n // ...board,\n // model\n // })\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 { css, html } from 'lit';
6
6
  import { customElement, property, query } from 'lit/decorators.js';
7
7
  import { connect } from 'pwa-helpers/connect-mixin.js';
8
8
  import { BoardModeller } from '@operato/board/ox-board-modeller.js';
9
+ import { BoardModelCache } from '@operato/board';
9
10
  import { OxPropertyEditor } from '@operato/property-editor';
10
11
  import { PageView, store } from '@operato/shell';
11
12
  import { hasPrivilege } from '@things-factory/auth-base/dist-client';
@@ -208,6 +209,10 @@ let BoardModellerPage = class BoardModellerPage extends connect(store)(PageView)
208
209
  var _a;
209
210
  await this.updateBoard();
210
211
  (_a = this.modeller) === null || _a === void 0 ? void 0 : _a.preserve();
212
+ // 저장 시 캐시 무효화 — viewer가 다음에 최신 model을 가져옴
213
+ if (this.boardId) {
214
+ await BoardModelCache.remove(this.boardId);
215
+ }
211
216
  }
212
217
  async canDeactivate() {
213
218
  var _a;
@@ -1 +1 @@
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;AAE5C,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,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CA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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;;gDAAgB;AACf;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;yDAAoB;AACjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;oDAAoB;AAGpB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8BAAY,aAAa;mDAAA;AAhEzC,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;;GACxB,iBAAiB,CAwQ7B","sourcesContent":["import './things-scene-components.import'\nimport '@operato/board/ox-board-modeller.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { BoardModeller } from '@operato/board/ox-board-modeller.js'\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { PageView, store } from '@operato/shell'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\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'\nimport components from './things-scene-components-with-tools.import'\n\nconst NOOP = () => {}\n\n@customElement('board-modeller-page')\nexport class BoardModellerPage extends connect(store)(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 var addedEditors = {}\n for (let 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 board-modeller {\n flex: 1;\n }\n\n 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: String }) baseUrl?: string = ''\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 }) fonts: any = []\n @property({ type: Array }) propertyEditor: any\n @property({ type: Boolean }) preparing?: boolean\n\n private board: any = null\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 var 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 var board = response.data.board\n\n if (!board) {\n this.board = null\n throw '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 stateChanged(state) {\n this.baseUrl = state.route.rootPath\n this.fonts = state.font\n }\n\n render() {\n var oops = !this.preparing && !this.model && this.oopsNote\n\n return oops\n ? html` <oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></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 .baseUrl=${this.baseUrl}\n .provider=${provider}\n @save-model=${e => this.saveBoard()}\n .componentGroupList=${this.componentGroupList}\n .fonts=${this.fonts}\n .hideProperty=${this.hideProperty}\n >\n </ox-board-modeller>\n `\n }\n\n async updateBoard() {\n try {\n this.preparing = true\n\n var { id, name, description, groupId } = this.board\n var 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;AAE5C,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,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAA;AACpE,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,mBAAmB,CAAA;AAC5C,OAAO,UAAU,MAAM,6CAA6C,CAAA;AAEpE,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAGd,IAAM,iBAAiB,GAAvB,MAAM,iB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AE,CAAC;;gDAAgB;AACf;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;yDAAoB;AACjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;oDAAoB;AAGpB;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'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { BoardModeller } from '@operato/board/ox-board-modeller.js'\nimport { BoardModelCache } from '@operato/board'\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { PageView, store } from '@operato/shell'\nimport { hasPrivilege } from '@things-factory/auth-base/dist-client'\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'\nimport components from './things-scene-components-with-tools.import'\n\nconst NOOP = () => {}\n\n@customElement('board-modeller-page')\nexport class BoardModellerPage extends connect(store)(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 var addedEditors = {}\n for (let 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 board-modeller {\n flex: 1;\n }\n\n 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: String }) baseUrl?: string = ''\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 }) fonts: any = []\n @property({ type: Array }) propertyEditor: any\n @property({ type: Boolean }) preparing?: boolean\n\n private board: any = null\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 var 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 var board = response.data.board\n\n if (!board) {\n this.board = null\n throw '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 stateChanged(state) {\n this.baseUrl = state.route.rootPath\n this.fonts = state.font\n }\n\n render() {\n var oops = !this.preparing && !this.model && this.oopsNote\n\n return oops\n ? html` <oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></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 .baseUrl=${this.baseUrl}\n .provider=${provider}\n @save-model=${e => this.saveBoard()}\n .componentGroupList=${this.componentGroupList}\n .fonts=${this.fonts}\n .hideProperty=${this.hideProperty}\n >\n </ox-board-modeller>\n `\n }\n\n async updateBoard() {\n try {\n this.preparing = true\n\n var { id, name, description, groupId } = this.board\n var 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 // 저장 시 캐시 무효화 — viewer가 다음에 최신 model을 가져옴\n if (this.boardId) {\n await BoardModelCache.remove(this.boardId)\n }\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,4 +1,12 @@
1
1
  import { BoardViewerPage } from './board-viewer-page';
2
2
  export declare class BoardViewerByNamePage extends BoardViewerPage {
3
- fetch(name: string): Promise<import("@apollo/client").InteropApolloQueryResult<any>>;
3
+ fetch(name: string): Promise<{
4
+ data: any;
5
+ errors?: ReadonlyArray<GraphQLFormattedError>;
6
+ error?: import("@apollo/client").ApolloError;
7
+ loading: boolean;
8
+ networkStatus: import("@apollo/client").NetworkStatus;
9
+ partial?: boolean;
10
+ cached: null;
11
+ }>;
4
12
  }
@@ -5,19 +5,20 @@ import { client, gqlContext } from '@operato/graphql';
5
5
  import { BoardViewerPage } from './board-viewer-page';
6
6
  let BoardViewerByNamePage = class BoardViewerByNamePage extends BoardViewerPage {
7
7
  async fetch(name) {
8
- return await client.query({
8
+ return Object.assign({ cached: null }, (await client.query({
9
9
  query: gql `
10
- query FetchBoardByName($name: String!) {
11
- response: boardByName(name: $name) {
12
- id
13
- name
14
- model
10
+ query FetchBoardByName($name: String!) {
11
+ response: boardByName(name: $name) {
12
+ id
13
+ name
14
+ model
15
+ updatedAt
16
+ }
15
17
  }
16
- }
17
- `,
18
+ `,
18
19
  variables: { name },
19
20
  context: gqlContext()
20
- });
21
+ })));
21
22
  }
22
23
  };
23
24
  BoardViewerByNamePage = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"board-viewer-by-name-page.js","sourceRoot":"","sources":["../../client/pages/board-viewer-by-name-page.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAG9C,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,eAAe;IACxD,KAAK,CAAC,KAAK,CAAC,IAAY;QACtB,OAAO,MAAM,MAAM,CAAC,KAAK,CAAC;YACxB,KAAK,EAAE,GAAG,CAAA;;;;;;;;OAQT;YACD,SAAS,EAAE,EAAE,IAAI,EAAE;YACnB,OAAO,EAAE,UAAU,EAAE;SACtB,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAhBY,qBAAqB;IADjC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,qBAAqB,CAgBjC","sourcesContent":["import gql from 'graphql-tag'\nimport { customElement } from 'lit/decorators.js'\nimport { client, gqlContext } from '@operato/graphql'\n\nimport { BoardViewerPage } from './board-viewer-page'\n\n@customElement('board-viewer-by-name-page')\nexport class BoardViewerByNamePage extends BoardViewerPage {\n async fetch(name: string) {\n return await client.query({\n query: gql`\n query FetchBoardByName($name: String!) {\n response: boardByName(name: $name) {\n id\n name\n model\n }\n }\n `,\n variables: { name },\n context: gqlContext()\n })\n }\n}\n"]}
1
+ {"version":3,"file":"board-viewer-by-name-page.js","sourceRoot":"","sources":["../../client/pages/board-viewer-by-name-page.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAG9C,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,eAAe;IACxD,KAAK,CAAC,KAAK,CAAC,IAAY;QACtB,uBACE,MAAM,EAAE,IAAI,IACT,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC;YACrB,KAAK,EAAE,GAAG,CAAA;;;;;;;;;SAST;YACD,SAAS,EAAE,EAAE,IAAI,EAAE;YACnB,OAAO,EAAE,UAAU,EAAE;SACtB,CAAC,CAAC,EACJ;IACH,CAAC;CACF,CAAA;AApBY,qBAAqB;IADjC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,qBAAqB,CAoBjC","sourcesContent":["import gql from 'graphql-tag'\nimport { customElement } from 'lit/decorators.js'\nimport { client, gqlContext } from '@operato/graphql'\n\nimport { BoardViewerPage } from './board-viewer-page'\n\n@customElement('board-viewer-by-name-page')\nexport class BoardViewerByNamePage extends BoardViewerPage {\n async fetch(name: string) {\n return {\n cached: null,\n ...(await client.query({\n query: gql`\n query FetchBoardByName($name: String!) {\n response: boardByName(name: $name) {\n id\n name\n model\n updatedAt\n }\n }\n `,\n variables: { name },\n context: gqlContext()\n }))\n }\n }\n}\n"]}
@@ -31,7 +31,15 @@ export declare class BoardViewerPage extends BoardViewerPage_base {
31
31
  updated(changes: any): void;
32
32
  pageUpdated(changes: any, lifecycle: any): void;
33
33
  stateChanged(state: any): void;
34
- fetch(id: string): Promise<import("@apollo/client").InteropApolloQueryResult<any>>;
34
+ fetch(id: string): Promise<{
35
+ data: any;
36
+ errors?: ReadonlyArray<GraphQLFormattedError>;
37
+ error?: import("@apollo/client").ApolloError;
38
+ loading: boolean;
39
+ networkStatus: import("@apollo/client").NetworkStatus;
40
+ partial?: boolean;
41
+ cached: import("@operato/board").CachedBoard | null;
42
+ }>;
35
43
  refresh(): Promise<void>;
36
44
  startSubscribingForAutoRefresh(): Promise<void>;
37
45
  stopSubscribing(): Promise<void>;
@@ -6,7 +6,7 @@ import { css, html } from 'lit';
6
6
  import { customElement, property, query, state } from 'lit/decorators.js';
7
7
  import { connect } from 'pwa-helpers/connect-mixin.js';
8
8
  import { buildLabelPrintCommand } from '@operato/barcode';
9
- import { BoardViewer } from '@operato/board';
9
+ import { BoardViewer, BoardModelCache } from '@operato/board';
10
10
  import { store, PageView } from '@operato/shell';
11
11
  import { client, gqlContext, subscribe } from '@operato/graphql';
12
12
  import { clientSettingStore } from '@operato/shell/object-store.js';
@@ -84,19 +84,21 @@ let BoardViewerPage = class BoardViewerPage extends connect(store)(PageView) {
84
84
  this._baseUrl = state.app.baseUrl;
85
85
  }
86
86
  async fetch(id) {
87
- return await client.query({
87
+ const cached = await BoardModelCache.get(id);
88
+ return Object.assign({ cached }, (await client.query({
88
89
  query: gql `
89
- query ($id: String!) {
90
- response: board(id: $id) {
91
- id
92
- name
93
- model
90
+ query ($id: String!, $cachedUpdatedAt: String) {
91
+ response: board(id: $id, cachedUpdatedAt: $cachedUpdatedAt) {
92
+ id
93
+ name
94
+ model
95
+ updatedAt
96
+ }
94
97
  }
95
- }
96
- `,
97
- variables: { id },
98
+ `,
99
+ variables: { id, cachedUpdatedAt: cached === null || cached === void 0 ? void 0 : cached.updatedAt },
98
100
  context: gqlContext()
99
- });
101
+ })));
100
102
  }
101
103
  async refresh() {
102
104
  var _a;
@@ -107,14 +109,22 @@ let BoardViewerPage = class BoardViewerPage extends connect(store)(PageView) {
107
109
  try {
108
110
  this._showSpinner = true;
109
111
  this.updateContext();
110
- var { data, errors } = await this.fetch(this._boardId);
112
+ var { data, errors, cached } = await this.fetch(this._boardId);
111
113
  var board = data === null || data === void 0 ? void 0 : data.response;
112
114
  if (!board) {
113
115
  this._board = null;
114
116
  const message = errors === null || errors === void 0 ? void 0 : errors.map(error => error.message).join('\n');
115
117
  throw message || 'board not found';
116
118
  }
117
- this._board = Object.assign(Object.assign({}, board), { model: JSON.parse(board.model) });
119
+ let model;
120
+ if (board.model === null && cached) {
121
+ model = cached.model;
122
+ }
123
+ else {
124
+ model = JSON.parse(board.model);
125
+ await BoardModelCache.put(this._boardId, board.name || '', board.model, board.updatedAt);
126
+ }
127
+ this._board = Object.assign(Object.assign({}, board), { model });
118
128
  }
119
129
  catch (ex) {
120
130
  document.dispatchEvent(new CustomEvent('notify', {
@@ -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;AAE1C,OAAO,GA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WAAW;oDAAA;AAlDxC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAmO3B","sourcesContent":["import './things-scene-components.import'\nimport '@operato/board/ox-board-viewer.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { buildLabelPrintCommand } from '@operato/barcode'\nimport { BoardViewer } from '@operato/board'\nimport { store, 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'\n\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 connect(store)(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 oops-spinner {\n display: none;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n\n oops-spinner[show] {\n display: block;\n }\n\n 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 }) _baseUrl?: 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: this.lifecycle.params['title'] || (this._board ? this._board.name : this._showSpinner ? 'Fetching board...' : 'Board Not Found')\n }\n }\n\n render() {\n var oops = !this._showSpinner && !this._board && this.oopsNote\n\n return oops\n ? html` <oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></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 <oops-spinner ?show=${this._showSpinner}></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.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 stateChanged(state) {\n this._baseUrl = state.app.baseUrl\n }\n\n async fetch(id: string) {\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 var { data, errors } = await this.fetch(this._boardId)\n\n var 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 var { labelRotation } = this._board.model\n\n var { width, height, data } = (await this.boardViewer.getSceneImageData()) || {}\n if (!width || !data) {\n throw '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;AAE1C,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,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA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,EAAE,OAAO,EAAE,CAAC;;qDAAuB;AAE1C;IAAR,KAAK,EAAE;;6CAAU;AAIQ;IAAzB,KAAK,CAAC,iBAAiB,CAAC;8BAAe,WAAW;oDAAA;AAlDxC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAiP3B","sourcesContent":["import './things-scene-components.import'\nimport '@operato/board/ox-board-viewer.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { buildLabelPrintCommand } from '@operato/barcode'\nimport { BoardViewer, BoardModelCache } from '@operato/board'\nimport { store, 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'\n\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 connect(store)(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 oops-spinner {\n display: none;\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n }\n\n oops-spinner[show] {\n display: block;\n }\n\n 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 }) _baseUrl?: 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: this.lifecycle.params['title'] || (this._board ? this._board.name : this._showSpinner ? 'Fetching board...' : 'Board Not Found')\n }\n }\n\n render() {\n var oops = !this._showSpinner && !this._board && this.oopsNote\n\n return oops\n ? html` <oops-note icon=${oops.icon} title=${oops.title} description=${oops.description}></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 <oops-spinner ?show=${this._showSpinner}></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.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 stateChanged(state) {\n this._baseUrl = state.app.baseUrl\n }\n\n async fetch(id: string) {\n const cached = await BoardModelCache.get(id)\n\n return {\n cached,\n ...(await client.query({\n query: gql`\n query ($id: String!, $cachedUpdatedAt: String) {\n response: board(id: $id, cachedUpdatedAt: $cachedUpdatedAt) {\n id\n name\n model\n updatedAt\n }\n }\n `,\n variables: { id, cachedUpdatedAt: cached?.updatedAt },\n context: gqlContext()\n }))\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 var { data, errors, cached } = await this.fetch(this._boardId)\n\n var 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 let model: any\n if (board.model === null && cached) {\n model = cached.model\n } else {\n model = JSON.parse(board.model)\n await BoardModelCache.put(this._boardId, board.name || '', board.model, board.updatedAt)\n }\n\n this._board = {\n ...board,\n 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 var { labelRotation } = this._board.model\n\n var { width, height, data } = (await this.boardViewer.getSceneImageData()) || {}\n if (!width || !data) {\n throw '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,5 +1,5 @@
1
1
  export declare function buildThemeValueRecordConfig(): {
2
2
  editor: (value: any, column: any, record: any, rowIndex: any, field: any) => import("@operato/data-grist").OxGristEditor;
3
- renderer: (value: any, column: any, record: any, rowIndex: any, field: any) => string | void | import("lit-html").TemplateResult | import("@operato/data-grist").OxGristRenderer;
3
+ renderer: (value: any, column: any, record: any, rowIndex: any, field: any) => string | void | import("@operato/data-grist").OxGristRenderer | import("lit-html").TemplateResult;
4
4
  editable: boolean;
5
5
  };