@things-factory/board-ui 4.0.3 → 4.0.4

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,15 +1,12 @@
1
- import { LitElement, html, css } from 'lit-element'
2
-
3
1
  import '@material/mwc-fab'
4
-
2
+ import '@operato/board' // ox-board-viewer
5
3
  import '@polymer/paper-dialog/paper-dialog'
6
- import '../board-viewer/board-viewer'
7
-
8
4
  import './scene-viewer/things-scene-viewer'
9
-
10
5
  import './component-toolbar/component-toolbar'
11
6
  import './property-sidebar/property-sidebar'
12
7
 
8
+ import { LitElement, css, html } from 'lit-element'
9
+
13
10
  export class BoardModeller extends LitElement {
14
11
  constructor() {
15
12
  super()
@@ -192,7 +189,7 @@ export class BoardModeller extends LitElement {
192
189
  * https://github.com/PolymerElements/paper-dialog/issues/152
193
190
  **/
194
191
 
195
- var preview = document.createElement('board-viewer')
192
+ var preview = document.createElement('ox-board-viewer')
196
193
 
197
194
  preview.style.width = '100%'
198
195
  preview.style.height = '100%'
package/client/index.js CHANGED
@@ -2,8 +2,6 @@ export * from './actions/board'
2
2
 
3
3
  export * from './board-modeller/board-modeller'
4
4
  export * from './board-modeller/edit-toolbar'
5
- export * from './board-player/board-player'
6
- export * from './board-viewer/board-viewer'
7
5
  export * from './board-provider'
8
6
  export * from './viewparts/board-selector'
9
7
  export * from './viewparts/board-creation-card'
@@ -1,11 +1,12 @@
1
- import '../board-player/board-player'
2
1
  import './things-scene-components.import'
2
+ import '@operato/board' // ox-board-player
3
3
 
4
- import gql from 'graphql-tag'
4
+ import { PageView, client, store } from '@things-factory/shell'
5
5
  import { css, html } from 'lit-element'
6
- import { connect } from 'pwa-helpers/connect-mixin.js'
7
6
 
8
- import { client, PageView, store } from '@things-factory/shell'
7
+ import { connect } from 'pwa-helpers/connect-mixin.js'
8
+ import { createBoardProvider } from '../board-provider'
9
+ import gql from 'graphql-tag'
9
10
 
10
11
  const NOOP = () => {}
11
12
 
@@ -33,7 +34,7 @@ export class BoardPlayerPage extends connect(store)(PageView) {
33
34
  position: relative;
34
35
  }
35
36
 
36
- board-player {
37
+ ox-board-player {
37
38
  flex: 1;
38
39
  }
39
40
 
@@ -60,6 +61,19 @@ export class BoardPlayerPage extends connect(store)(PageView) {
60
61
  ]
61
62
  }
62
63
 
64
+ connectedCallback() {
65
+ super.connectedCallback()
66
+
67
+ this.provider = createBoardProvider()
68
+ }
69
+
70
+ disconnectedCallback() {
71
+ super.disconnectedCallback()
72
+
73
+ this.provider.despose()
74
+ delete this.provider
75
+ }
76
+
63
77
  async refresh() {
64
78
  if (!this._playGroupId) {
65
79
  return
@@ -126,7 +140,7 @@ export class BoardPlayerPage extends connect(store)(PageView) {
126
140
 
127
141
  updated(changes) {
128
142
  if (changes.has('_playGroupId')) {
129
- this.shadowRoot.querySelector('board-player').stop()
143
+ this.shadowRoot.querySelector('ox-board-player').stop()
130
144
  this.refresh()
131
145
  }
132
146
  }
@@ -166,7 +180,7 @@ export class BoardPlayerPage extends connect(store)(PageView) {
166
180
  ></oops-note>
167
181
  `
168
182
  : html`
169
- <board-player .boards=${this._boards}></board-player>
183
+ <ox-board-player .boards=${this._boards} .provider=${this.provider}></ox-board-player>
170
184
  <oops-spinner ?show=${this._showSpinner}></oops-spinner>
171
185
  `
172
186
  }
@@ -178,7 +192,7 @@ export class BoardPlayerPage extends connect(store)(PageView) {
178
192
  this.refresh()
179
193
  } else {
180
194
  this._playGroupId = null
181
- this.shadowRoot.querySelector('board-player').stop()
195
+ this.shadowRoot.querySelector('ox-board-player').stop()
182
196
  }
183
197
  }
184
198
  }
@@ -1,11 +1,13 @@
1
- import { buildLabelPrintCommand } from '@things-factory/barcode-base'
2
- import { client, PageView, store, gqlContext } from '@things-factory/shell'
3
- import gql from 'graphql-tag'
1
+ import './things-scene-components.import'
2
+ import '@operato/board' // ox-board-viewer
3
+
4
+ import { PageView, client, gqlContext, store } from '@things-factory/shell'
4
5
  import { css, html } from 'lit-element'
6
+
7
+ import { buildLabelPrintCommand } from '@things-factory/barcode-base'
5
8
  import { connect } from 'pwa-helpers/connect-mixin.js'
9
+ import gql from 'graphql-tag'
6
10
  import { provider } from '../board-provider'
7
- import '../board-viewer/board-viewer'
8
- import './things-scene-components.import'
9
11
 
10
12
  const NOOP = () => {}
11
13
 
@@ -33,7 +35,7 @@ export class BoardViewerPage extends connect(store)(PageView) {
33
35
  position: relative;
34
36
  }
35
37
 
36
- board-viewer {
38
+ ox-board-viewer {
37
39
  flex: 1;
38
40
  }
39
41
 
@@ -90,15 +92,13 @@ export class BoardViewerPage extends connect(store)(PageView) {
90
92
  ></oops-note>
91
93
  `
92
94
  : html`
93
- <board-viewer .board=${this._board} .provider=${provider}></board-viewer>
95
+ <ox-board-viewer .board=${this._board} .provider=${provider}></ox-board-viewer>
94
96
  <oops-spinner ?show=${this._showSpinner}></oops-spinner>
95
97
  `
96
98
  }
97
99
 
98
100
  updated(changes) {
99
101
  if (changes.has('_boardId')) {
100
- var boardViewerElement = this.shadowRoot.querySelector('board-viewer')
101
- boardViewerElement && boardViewerElement.closeScene()
102
102
  this.refresh()
103
103
  }
104
104
  }
@@ -107,9 +107,17 @@ export class BoardViewerPage extends connect(store)(PageView) {
107
107
  if (this.active) {
108
108
  this._boardId = lifecycle.resourceId
109
109
  } else {
110
- this._boardId = null
111
- let boardViewer = this.shadowRoot.querySelector('board-viewer')
112
- boardViewer && boardViewer.closeScene()
110
+ /*
111
+ * 비활성화된 페이지에서 render update가 발생하지 않으므로, 강제로 scene을 close 한다.
112
+ * 화면이 inactive 될 때, 굳이 scene을 close하는 이유는,
113
+ * 새로운 board가 선택되어 뷰어가 열릴 때, 기존 보드 잔상이 보이지 않도록 하기위해서이다.
114
+ */
115
+ if (this._boardId) {
116
+ let boardViewer = this.shadowRoot.querySelector('ox-board-viewer')
117
+ boardViewer && boardViewer.closeScene()
118
+ }
119
+
120
+ this._boardId = ''
113
121
  }
114
122
  }
115
123
 
@@ -119,6 +127,7 @@ export class BoardViewerPage extends connect(store)(PageView) {
119
127
 
120
128
  async refresh() {
121
129
  if (!this._boardId) {
130
+ this._board = null
122
131
  return
123
132
  }
124
133
 
@@ -170,7 +179,7 @@ export class BoardViewerPage extends connect(store)(PageView) {
170
179
  async getGrf() {
171
180
  var { labelRotation } = this._board.model
172
181
 
173
- var { width, height, data } = (await this.shadowRoot.querySelector('board-viewer').getSceneImageData()) || {}
182
+ var { width, height, data } = (await this.shadowRoot.querySelector('ox-board-viewer').getSceneImageData()) || {}
174
183
  if (!width) {
175
184
  throw 'Cannot get SceneImageData...'
176
185
  }
@@ -179,7 +188,7 @@ export class BoardViewerPage extends connect(store)(PageView) {
179
188
  }
180
189
 
181
190
  async printTrick(image) {
182
- await this.renderRoot.querySelector('board-viewer').printTrick(image)
191
+ await this.renderRoot.querySelector('ox-board-viewer').printTrick(image)
183
192
  }
184
193
  }
185
194
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/board-ui",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -26,6 +26,7 @@
26
26
  "dependencies": {
27
27
  "@material/mwc-list": "^0.22.1",
28
28
  "@material/mwc-select": "^0.22.1",
29
+ "@operato/board": "^0.2.18",
29
30
  "@polymer/iron-icon": "^3.0.1",
30
31
  "@polymer/iron-icons": "^3.0.1",
31
32
  "@polymer/paper-button": "^3.0.1",
@@ -37,13 +38,13 @@
37
38
  "@polymer/paper-listbox": "^3.0.1",
38
39
  "@polymer/paper-menu-button": "^3.0.1",
39
40
  "@polymer/paper-slider": "^3.0.1",
40
- "@things-factory/barcode-base": "^4.0.1",
41
+ "@things-factory/barcode-base": "^4.0.4",
41
42
  "@things-factory/grist-ui": "^4.0.1",
42
- "@things-factory/help": "^4.0.1",
43
- "@things-factory/i18n-base": "^4.0.1",
44
- "@things-factory/modeller-ui": "^4.0.1",
43
+ "@things-factory/help": "^4.0.4",
44
+ "@things-factory/i18n-base": "^4.0.4",
45
+ "@things-factory/modeller-ui": "^4.0.4",
45
46
  "file-saver": "^2.0.2",
46
47
  "sortablejs": "^1.10.2"
47
48
  },
48
- "gitHead": "8a4a002853361ce3668e56830cd0258be758ea01"
49
+ "gitHead": "292d7c4e2675d228d6be474ea6a0525d26ac1657"
49
50
  }
@@ -1,199 +0,0 @@
1
- import { css } from 'lit-element'
2
-
3
- export const style = css`
4
- :host {
5
- display: flex;
6
- position: relative;
7
- flex-direction: column;
8
- width: 100%;
9
- height: 100%;
10
- overflow: hidden;
11
- justify-content: center;
12
- align-items: center;
13
- }
14
-
15
- :slotted(*) {
16
- border: none;
17
- }
18
-
19
- ::slotted > * {
20
- flex: 1;
21
- }
22
-
23
- board-wrapper {
24
- width: 100%;
25
- height: 100%;
26
- position: relative;
27
- }
28
-
29
- board-wrapper[front] {
30
- background: black;
31
- }
32
-
33
- board-wrapper[back] {
34
- background: black;
35
- }
36
-
37
- #control {
38
- position: absolute;
39
- bottom: 1vh;
40
- width: 100vw;
41
- max-width: 435px;
42
- display: grid;
43
- grid-template-columns: 42px 42px 1fr;
44
- color: white;
45
- justify-content: center;
46
- align-items: center;
47
- grid-auto-flow: dense;
48
- padding: 5px;
49
- box-sizing: border-box;
50
- grid-template-rows: 12px 60px 12px;
51
- }
52
-
53
- #control[hidden] {
54
- display: none;
55
- }
56
-
57
- #control > div > * {
58
- cursor: pointer;
59
- }
60
-
61
- #joystick {
62
- position: relative;
63
- box-sizing: border-box;
64
- border: 2px solid tomato;
65
- background-color: #c34827;
66
- box-shadow: 0 0 5px #000;
67
- width: 100%;
68
- height: 100%;
69
- grid-column: 1 / span 2;
70
- border-radius: 50%;
71
- z-index: 2;
72
- grid-row: 1 / span 3;
73
- }
74
-
75
- #joystick mwc-icon {
76
- position: absolute;
77
- display: block;
78
- width: 20px;
79
- height: 20px;
80
- font-size: 25px;
81
- line-height: 0.7;
82
- }
83
-
84
- mwc-icon#up {
85
- left: 29px;
86
- }
87
-
88
- mwc-icon#left {
89
- top: 32px;
90
- left: -2px;
91
- }
92
-
93
- mwc-icon#play,
94
- mwc-icon#pause {
95
- left: 20px;
96
- top: 20px;
97
- width: 40px;
98
- height: 40px;
99
- border: 1px solid rgba(0, 0, 0, 0.15);
100
- border-radius: 50%;
101
- background-color: rgba(0, 0, 0, 0.15);
102
- font-size: 45px;
103
- line-height: 0.9;
104
- }
105
-
106
- mwc-icon#right {
107
- top: 31px;
108
- left: 60px;
109
- }
110
-
111
- mwc-icon#down {
112
- left: 29px;
113
- top: 63px;
114
- }
115
-
116
- mwc-icon#pause {
117
- text-indent: -2px;
118
- }
119
-
120
- #setting-container {
121
- grid-column: 2 / span 2;
122
- grid-row: 2;
123
- gap: 0 10px;
124
- border-radius: 12px;
125
- background: rgba(0, 0, 0, 0.7);
126
- height: 100%;
127
- box-shadow: rgb(0, 0, 0) 0px 0px 5px;
128
- display: grid;
129
- grid-template-columns: 1fr 60px;
130
- align-items: center;
131
- padding-left: 60px;
132
- padding-right: 5px;
133
- }
134
-
135
- #setting {
136
- display: grid;
137
- grid-template-columns: 1fr 1fr;
138
- grid-gap: 0 10px;
139
- }
140
-
141
- #setting mwc-icon {
142
- font-size: 22px;
143
- color: rgba(255, 174, 53, 0.8);
144
- }
145
-
146
- #setting input {
147
- width: 50px;
148
- margin-right: 5px;
149
- font-size: 14px;
150
- background-color: transparent;
151
- border: none;
152
- border-bottom: 1px solid #fff;
153
- color: #fff;
154
- text-align: right;
155
- }
156
-
157
- #setting select {
158
- border: none;
159
- font-size: 14px;
160
- }
161
-
162
- #setting input:focus {
163
- outline: none;
164
- }
165
-
166
- #schedule-container {
167
- display: flex;
168
- align-items: center;
169
- justify-content: space-between;
170
- }
171
-
172
- #grid-setting-container {
173
- display: flex;
174
- align-items: center;
175
- justify-content: space-between;
176
- }
177
-
178
- #etc {
179
- display: grid;
180
- grid-template-columns: 1fr 1fr;
181
- align-items: center;
182
- justify-items: center;
183
- }
184
-
185
- #etc mwc-icon {
186
- font-size: 30px;
187
- }
188
-
189
- #control [hidden] {
190
- display: none;
191
- }
192
-
193
- @media screen and (max-width: 460px) {
194
- #setting {
195
- grid-template-columns: 1fr;
196
- grid-template-rows: 1fr 1fr;
197
- }
198
- }
199
- `
@@ -1,279 +0,0 @@
1
- import { LitElement, html, css } from 'lit-element'
2
-
3
- import '@material/mwc-fab/mwc-fab'
4
- import '@material/mwc-icon/mwc-icon'
5
- import SwipeListener from 'swipe-listener'
6
-
7
- import './board-wrapper'
8
-
9
- import './player/board-player-carousel'
10
-
11
- import { togglefullscreen, exitfullscreen } from '@things-factory/utils'
12
-
13
- import { style } from './board-player-style'
14
-
15
- export class BoardPlayer extends LitElement {
16
- constructor() {
17
- super()
18
-
19
- this.boards = []
20
-
21
- this.playtime = 30
22
- this.columns = 1
23
- this.rows = 1
24
- this.started = false
25
- this.fullscreened = false
26
- }
27
-
28
- static get properties() {
29
- return {
30
- boards: Array,
31
-
32
- playtime: Number,
33
- columns: Number,
34
- rows: Number,
35
- started: Boolean,
36
- playing: Boolean,
37
- fullscreened: Boolean
38
- }
39
- }
40
-
41
- static get styles() {
42
- return [style]
43
- }
44
-
45
- render() {
46
- return html`
47
- <slot @mousemove=${e => this.onMousemove(e)} @transform=${e => this.onTransform(e)} tabindex="-1">
48
- ${
49
- this.started
50
- ? html`
51
- <board-player-carousel axis="y" .rows=${this.rows} .columns=${this.columns} player>
52
- ${this.boards.map(
53
- item => html`
54
- <board-wrapper page .sceneId=${item.id}> </board-wrapper>
55
- `
56
- )}
57
- </board-player-carousel>
58
- `
59
- : html``
60
- }
61
- </slot>
62
-
63
- <div id="control" @mouseover=${e => this.onMouseoverControl(e)} hidden>
64
- <div id="joystick">
65
- <mwc-icon id="up" @click=${e => this.onTapUp(e)}>keyboard_arrow_up</mwc-icon>
66
- <mwc-icon id="left" @click=${e => this.onTapLeft(e)}>keyboard_arrow_left</mwc-icon>
67
- <mwc-icon id="play" @click=${e => this.onTapPlay(e)} ?hidden=${this.playing}>play_arrow</mwc-icon>
68
- <mwc-icon id="pause" @click=${e => this.onTapPause(e)} ?hidden=${!this.playing}>pause</mwc-icon>
69
- <mwc-icon id="right" @click=${e => this.onTapRight(e)}>keyboard_arrow_right</mwc-icon>
70
- <mwc-icon id="down" @click=${e => this.onTapDown(e)}>keyboard_arrow_down</mwc-icon>
71
- </div>
72
-
73
- <div id="setting-container">
74
- <div id="setting">
75
- <div id="schedule-container">
76
- <mwc-icon id="schedule">schedule</mwc-icon>
77
- <input .value=${this.playtime} @change=${e => (this.playtime = e.target.value)}></input>
78
- sec.
79
- </div>
80
- <div id="grid-setting-container">
81
- <mwc-icon id="view_module">view_module</mwc-icon>
82
- <select .value=${this.rows} @change=${e => (this.rows = e.target.value)}>
83
- ${[1, 2, 3, 4, 5].map(
84
- row => html`
85
- <option>${row}</option>
86
- `
87
- )}
88
- </select>
89
- x
90
- <select .value=${this.columns} @change=${e => (this.columns = e.target.value)}>
91
- ${[1, 2, 3, 4, 5].map(
92
- column => html`
93
- <option>${column}</option>
94
- `
95
- )}
96
- </select>
97
- </div>
98
- </div>
99
-
100
- <div id="etc">
101
- <mwc-icon id="fullscreen" @click=${e => this.onTapFullscreen(e)} ?hidden=${this.fullscreened}
102
- >fullscreen</mwc-icon>
103
- <mwc-icon id="fullscreen-exit" @click=${e => this.onTapFullscreen(e)} ?hidden=${!this.fullscreened}
104
- >fullscreen_exit</mwc-icon>
105
- <mwc-icon id="close" @click=${e => this.onTapClose(e)}>close</mwc-icon>
106
- </div>
107
- </div>
108
- </div>
109
- `
110
- }
111
-
112
- firstUpdated() {
113
- SwipeListener(this)
114
-
115
- this.addEventListener('swipe', e => {
116
- var directions = e.detail.directions
117
-
118
- if (directions.left) {
119
- this.onTapRight()
120
- } else if (directions.right) {
121
- this.onTapLeft()
122
- } else if (directions.top) {
123
- this.onTapDown()
124
- } else if (directions.bottom) {
125
- this.onTapUp()
126
- }
127
- })
128
- }
129
-
130
- updated(changes) {
131
- if (changes.has('boards') || changes.has('columns') || changes.has('rows')) {
132
- this.boards && this.boards.length > 0 ? this.restart() : this.stop()
133
- } else if (changes.has('playtime') && this.playing) {
134
- this._resetTransformTimer()
135
- }
136
- }
137
-
138
- get control() {
139
- return this.shadowRoot.getElementById('control')
140
- }
141
-
142
- get fullscreen() {
143
- return this.shadowRoot.getElementById('fullscreen')
144
- }
145
-
146
- async _resetFadeTimer(stop) {
147
- if (!this._control_animation) {
148
- this._control_animation = this.control.animate(
149
- [
150
- {
151
- opacity: 1,
152
- easing: 'ease-in'
153
- },
154
- { opacity: 0 }
155
- ],
156
- { delay: 1000, duration: 2000 }
157
- )
158
- }
159
-
160
- this.control.hidden = false
161
-
162
- this._control_animation.cancel()
163
- if (stop) return
164
-
165
- try {
166
- this._control_animation.play()
167
- await this._control_animation.finished
168
- this.control.hidden = true
169
- } catch (e) {
170
- /* cancelled */
171
- }
172
- }
173
-
174
- _resetTransformTimer() {
175
- clearTimeout(this._transfer_timer)
176
-
177
- this.playing = true
178
-
179
- if (this.currentPlayer) {
180
- this._transfer_timer = setTimeout(() => {
181
- if (this._transfer_timer) this.currentPlayer.next()
182
- }, this.playtime * 1000)
183
- }
184
- }
185
-
186
- onMousemove() {
187
- this._resetFadeTimer()
188
- }
189
-
190
- onMouseoverControl() {
191
- this._resetFadeTimer(true)
192
- }
193
-
194
- onTapFullscreen() {
195
- togglefullscreen(
196
- this,
197
- () => {
198
- this.fullscreened = true
199
- this.focus()
200
- },
201
- () => {
202
- this.fullscreened = false
203
- this.focus()
204
- }
205
- )
206
- }
207
-
208
- onTransform() {
209
- requestAnimationFrame(() => this.started && this.playing && this._resetTransformTimer())
210
- }
211
-
212
- onTapPlay(e) {
213
- this._resetTransformTimer()
214
- }
215
-
216
- onTapPause(e) {
217
- clearTimeout(this._transfer_timer)
218
- this.playing = false
219
- }
220
-
221
- onTapLeft(e) {
222
- this.currentPlayer.axis = 'y'
223
- this.currentPlayer.previous()
224
- }
225
-
226
- onTapRight(e) {
227
- this.currentPlayer.axis = 'y'
228
- this.currentPlayer.next()
229
- }
230
-
231
- onTapUp(e) {
232
- this.currentPlayer.axis = 'x'
233
- this.currentPlayer.next()
234
- }
235
-
236
- onTapDown(e) {
237
- this.currentPlayer.axis = 'x'
238
- this.currentPlayer.previous()
239
- }
240
-
241
- onTapClose(e) {
242
- if (this.fullscreened) {
243
- exitfullscreen()
244
- }
245
-
246
- window.history.back()
247
- }
248
-
249
- async restart() {
250
- await this.stop()
251
- await this.start()
252
- }
253
-
254
- async start() {
255
- if (!this.boards || this.boards.length == 0) return
256
-
257
- this.started = true
258
- this.playing = true
259
-
260
- await this.renderComplete
261
- this.currentPlayer = this.shadowRoot.querySelector(':not([style*="display: none"])[player]')
262
-
263
- this._resetTransformTimer()
264
- this._resetFadeTimer()
265
-
266
- this.focus()
267
- }
268
-
269
- async stop() {
270
- clearTimeout(this._transfer_timer)
271
-
272
- this.currentPlayer && this.currentPlayer.stop()
273
-
274
- await this.renderComplete
275
- this.started = false
276
- }
277
- }
278
-
279
- customElements.define('board-player', BoardPlayer)