@things-factory/board-ui 6.1.160 → 6.1.166

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.
@@ -97,20 +97,7 @@ export class BoardPlayerPage extends connect(store)(PageView) {
97
97
  description
98
98
  boards {
99
99
  id
100
- name
101
- description
102
100
  model
103
- thumbnail
104
- createdAt
105
- creator {
106
- id
107
- name
108
- }
109
- updatedAt
110
- updater {
111
- id
112
- name
113
- }
114
101
  }
115
102
  }
116
103
  }
@@ -219,6 +206,7 @@ export class BoardPlayerPage extends connect(store)(PageView) {
219
206
  next: async ({ data }) => {
220
207
  await this.stopSubscribing()
221
208
 
209
+ // location.reload()
222
210
  if (data) {
223
211
  this.refresh()
224
212
  }
@@ -37,20 +37,7 @@ let BoardPlayerPage = class BoardPlayerPage extends connect(store)(PageView) {
37
37
  description
38
38
  boards {
39
39
  id
40
- name
41
- description
42
40
  model
43
- thumbnail
44
- createdAt
45
- creator {
46
- id
47
- name
48
- }
49
- updatedAt
50
- updater {
51
- id
52
- name
53
- }
54
41
  }
55
42
  }
56
43
  }
@@ -141,6 +128,7 @@ let BoardPlayerPage = class BoardPlayerPage extends connect(store)(PageView) {
141
128
  }, {
142
129
  next: async ({ data }) => {
143
130
  await this.stopSubscribing();
131
+ // location.reload()
144
132
  if (data) {
145
133
  this.refresh();
146
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"board-player-page.js","sourceRoot":"","sources":["../../client/pages/board-player-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,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EA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AAO,IAAI,CAAC,0BAA0B,CAAA;IACxC,CAAC;;AAvNM,sBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkCF;CACF,CAAA;AAED;IAAC,KAAK,EAAE;;6CAAU;AAClB;IAAC,KAAK,EAAE;;kDAAe;AACvB;IAAC,KAAK,EAAE;;oDAA4B;AACpC;IAAC,KAAK,EAAE;;+CAAY;AACpB;IAAC,KAAK,EAAE;;gDAAiB;AACzB;IAAC,KAAK,EAAE;;oDAAsB;AAK9B;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAAe,WAAW;oDAAA;AAjDxC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAyN3B;SAzNY,eAAe","sourcesContent":["import './things-scene-components.import'\nimport '@operato/board/ox-board-player.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, state, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { createBoardProvider } from '../board-provider'\nimport { store, PageView } from '@operato/shell'\nimport { clientSettingStore } from '@operato/shell/object-store.js'\nimport { client, subscribe } from '@operato/graphql'\nimport { ReferenceMap } from '@hatiolab/things-scene'\nimport { BoardPlayer } from '@operato/board/ox-board-player.js'\n\n@customElement('board-player-page')\nexport class BoardPlayerPage extends connect(store)(PageView) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n\n overflow: hidden;\n position: relative;\n }\n\n ox-board-player {\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 @state() data: any\n @state() playGroup: any\n @state() playGroupId?: string | null\n @state() boards: any\n @state() baseUrl?: string\n @state() showSpinner?: boolean\n\n private provider?: ReferenceMap<unknown> & { dispose?: () => void }\n private subscriptionForAutoRefresh\n\n @query('ox-board-player') boardPlayer?: BoardPlayer\n\n connectedCallback() {\n super.connectedCallback()\n\n this.provider = createBoardProvider()\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n\n this.provider!.dispose!()\n delete this.provider\n }\n\n async refresh() {\n if (!this.playGroupId) {\n return\n }\n\n try {\n this.showSpinner = true\n this.updateContext()\n\n this.playGroup = (\n await client.query({\n query: gql`\n query FetchPlayGroup($id: String!) {\n playGroup(id: $id) {\n id\n name\n description\n boards {\n id\n name\n description\n model\n thumbnail\n createdAt\n creator {\n id\n name\n }\n updatedAt\n updater {\n id\n name\n }\n }\n }\n }\n `,\n variables: {\n id: this.playGroupId\n }\n })\n ).data.playGroup\n\n if (!this.playGroup) {\n throw 'playgroup not found'\n }\n\n this.boards = this.playGroup.boards\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 = false } = (await clientSettingStore.get('board-view'))?.value || {}\n autoRefresh && this.startSubscribingForAutoRefresh()\n }\n }\n\n updated(changes) {\n if (changes.has('playGroupId')) {\n this.boardPlayer!.stop()\n this.refresh()\n }\n }\n\n stateChanged(state) {\n this.baseUrl = state.app.baseUrl\n }\n\n get oopsNote() {\n return {\n icon: 'style',\n title: 'EMPTY PLAYGROUP',\n description: 'There are no board to be shown'\n }\n }\n\n get context() {\n return {\n title: this.playGroup ? this.playGroup.name : this.showSpinner ? 'Fetching playgroup...' : 'Playgroup Not Found'\n }\n }\n\n render() {\n var oops = !this.showSpinner && !this.playGroup && 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-player .boards=${this.boards} .data=${this.data} .provider=${this.provider}></ox-board-player>\n <oops-spinner ?show=${this.showSpinner}></oops-spinner>\n `\n }\n\n pageUpdated(changes, lifecycle) {\n if (this.active) {\n this.playGroupId = lifecycle.resourceId\n this.data = lifecycle.params\n\n this.refresh()\n } else {\n this.stopSubscribing()\n\n this.playGroupId = null\n this.boardPlayer!.stop()\n }\n }\n\n async startSubscribingForAutoRefresh() {\n if (!this.playGroupId) {\n return\n }\n\n await this.stopSubscribing()\n\n this.subscriptionForAutoRefresh = await subscribe(\n {\n query: gql`\n subscription ($id: String!) {\n playGroup(id: $id) {\n id\n }\n }\n `,\n variables: {\n id: this.playGroupId\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"]}
1
+ {"version":3,"file":"board-player-page.js","sourceRoot":"","sources":["../../client/pages/board-player-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,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAGxD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAA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AAC,iBAAiB,CAAC;8BAAe,WAAW;oDAAA;AAjDxC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA6M3B;SA7MY,eAAe","sourcesContent":["import './things-scene-components.import'\nimport '@operato/board/ox-board-player.js'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, state, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin.js'\n\nimport { createBoardProvider } from '../board-provider'\nimport { store, PageView } from '@operato/shell'\nimport { clientSettingStore } from '@operato/shell/object-store.js'\nimport { client, subscribe } from '@operato/graphql'\nimport { ReferenceMap } from '@hatiolab/things-scene'\nimport { BoardPlayer } from '@operato/board/ox-board-player.js'\n\n@customElement('board-player-page')\nexport class BoardPlayerPage extends connect(store)(PageView) {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n\n overflow: hidden;\n position: relative;\n }\n\n ox-board-player {\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 @state() data: any\n @state() playGroup: any\n @state() playGroupId?: string | null\n @state() boards: any\n @state() baseUrl?: string\n @state() showSpinner?: boolean\n\n private provider?: ReferenceMap<unknown> & { dispose?: () => void }\n private subscriptionForAutoRefresh\n\n @query('ox-board-player') boardPlayer?: BoardPlayer\n\n connectedCallback() {\n super.connectedCallback()\n\n this.provider = createBoardProvider()\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n\n this.provider!.dispose!()\n delete this.provider\n }\n\n async refresh() {\n if (!this.playGroupId) {\n return\n }\n\n try {\n this.showSpinner = true\n this.updateContext()\n\n this.playGroup = (\n await client.query({\n query: gql`\n query FetchPlayGroup($id: String!) {\n playGroup(id: $id) {\n id\n name\n description\n boards {\n id\n model\n }\n }\n }\n `,\n variables: {\n id: this.playGroupId\n }\n })\n ).data.playGroup\n\n if (!this.playGroup) {\n throw 'playgroup not found'\n }\n\n this.boards = this.playGroup.boards\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 = false } = (await clientSettingStore.get('board-view'))?.value || {}\n autoRefresh && this.startSubscribingForAutoRefresh()\n }\n }\n\n updated(changes) {\n if (changes.has('playGroupId')) {\n this.boardPlayer!.stop()\n this.refresh()\n }\n }\n\n stateChanged(state) {\n this.baseUrl = state.app.baseUrl\n }\n\n get oopsNote() {\n return {\n icon: 'style',\n title: 'EMPTY PLAYGROUP',\n description: 'There are no board to be shown'\n }\n }\n\n get context() {\n return {\n title: this.playGroup ? this.playGroup.name : this.showSpinner ? 'Fetching playgroup...' : 'Playgroup Not Found'\n }\n }\n\n render() {\n var oops = !this.showSpinner && !this.playGroup && 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-player .boards=${this.boards} .data=${this.data} .provider=${this.provider}></ox-board-player>\n <oops-spinner ?show=${this.showSpinner}></oops-spinner>\n `\n }\n\n pageUpdated(changes, lifecycle) {\n if (this.active) {\n this.playGroupId = lifecycle.resourceId\n this.data = lifecycle.params\n\n this.refresh()\n } else {\n this.stopSubscribing()\n\n this.playGroupId = null\n this.boardPlayer!.stop()\n }\n }\n\n async startSubscribingForAutoRefresh() {\n if (!this.playGroupId) {\n return\n }\n\n await this.stopSubscribing()\n\n this.subscriptionForAutoRefresh = await subscribe(\n {\n query: gql`\n subscription ($id: String!) {\n playGroup(id: $id) {\n id\n }\n }\n `,\n variables: {\n id: this.playGroupId\n }\n },\n {\n next: async ({ data }) => {\n await this.stopSubscribing()\n\n // location.reload()\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"]}