@operato/board 1.4.62 → 1.4.64

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/board",
3
- "version": "1.4.62",
3
+ "version": "1.4.64",
4
4
  "description": "Webcomponent for board following open-wc recommendations",
5
5
  "author": "heartyoh",
6
6
  "main": "dist/src/index.js",
@@ -88,18 +88,18 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "@open-wc/scoped-elements": "^2.0.0-next.6",
91
- "@operato/app": "^1.4.62",
92
- "@operato/data-grist": "^1.4.39",
93
- "@operato/font": "^1.4.62",
94
- "@operato/graphql": "^1.4.20",
95
- "@operato/i18n": "^1.4.36",
96
- "@operato/input": "^1.4.39",
97
- "@operato/layout": "^1.4.32",
98
- "@operato/markdown": "^1.4.61",
99
- "@operato/popup": "^1.4.32",
100
- "@operato/property-editor": "^1.4.62",
101
- "@operato/styles": "^1.4.11",
102
- "@operato/utils": "^1.4.28",
91
+ "@operato/app": "^1.4.64",
92
+ "@operato/data-grist": "^1.4.64",
93
+ "@operato/font": "^1.4.64",
94
+ "@operato/graphql": "^1.4.64",
95
+ "@operato/i18n": "^1.4.64",
96
+ "@operato/input": "^1.4.64",
97
+ "@operato/layout": "^1.4.64",
98
+ "@operato/markdown": "^1.4.64",
99
+ "@operato/popup": "^1.4.64",
100
+ "@operato/property-editor": "^1.4.64",
101
+ "@operato/styles": "^1.4.64",
102
+ "@operato/utils": "^1.4.64",
103
103
  "@polymer/paper-dropdown-menu": "^3.2.0",
104
104
  "@types/file-saver": "^2.0.4",
105
105
  "@types/sortablejs": "^1.10.7",
@@ -148,5 +148,5 @@
148
148
  "prettier --write"
149
149
  ]
150
150
  },
151
- "gitHead": "889a8429b0cc8fb4579c2090d4586f1feebf4dae"
151
+ "gitHead": "47382eb5b652aeb12fc530a9508921824e19aca0"
152
152
  }
@@ -4,12 +4,14 @@ import { Component, PersistentDataStorage } from '@hatiolab/things-scene'
4
4
 
5
5
  class BoardDatabase extends Dexie {
6
6
  board_data!: Dexie.Table<IBoardData, number> // number = type of the primkey
7
+ playlist_data!: Dexie.Table<IPlayListData, number> // number = type of the primkey
7
8
  //...other tables goes here...
8
9
 
9
10
  constructor() {
10
11
  super('operato-board-database')
11
12
  this.version(1).stores({
12
- board_data: '[board+refid]'
13
+ board_data: '[board+refid]',
14
+ playlist_data: '[playlist]'
13
15
  //...other tables goes here...
14
16
  })
15
17
  }
@@ -23,9 +25,20 @@ interface IBoardData {
23
25
  timestamp: number
24
26
  }
25
27
 
28
+ interface IPlayListData {
29
+ id?: number
30
+ playlist: string
31
+ setting: {
32
+ playtime: number
33
+ columns: number
34
+ rows: number
35
+ }
36
+ timestamp: number
37
+ }
38
+
26
39
  const db = new BoardDatabase()
27
40
 
28
- export class DataStorage implements PersistentDataStorage {
41
+ export class BoardDataStorage implements PersistentDataStorage {
29
42
  private id: string
30
43
 
31
44
  constructor(id: string) {
@@ -45,3 +58,18 @@ export class DataStorage implements PersistentDataStorage {
45
58
  await db.board_data.where({ board: this.id, refid: key.state.refid }).delete()
46
59
  }
47
60
  }
61
+
62
+ export class PlaylistStorage implements PersistentDataStorage {
63
+ public async load(key: String): Promise<any> {
64
+ const saved = await db.playlist_data.where({ playlist: key }).first()
65
+ return saved?.setting
66
+ }
67
+
68
+ public async save(key: String, value: any): Promise<void> {
69
+ await db.playlist_data.put({ playlist: key.toString(), setting: value, timestamp: Date.now() })
70
+ }
71
+
72
+ public async clear(key: String): Promise<void> {
73
+ await db.playlist_data.where({ playlist: key }).delete()
74
+ }
75
+ }
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from './types.js'
2
2
 
3
3
  export { registerDefaultGroups } from './component/register-default-groups.js'
4
- export { DataStorage } from './data-storage/data-storage.js'
4
+ export { BoardDataStorage, PlaylistStorage } from './data-storage/data-storage.js'
5
5
 
6
6
  export * from './ox-board-viewer.js'
7
7
  export * from './ox-board-player.js'
@@ -8,8 +8,11 @@ import { customElement, property, query, state } from 'lit/decorators.js'
8
8
 
9
9
  import { exitfullscreen, SwipeListener, togglefullscreen } from '@operato/utils'
10
10
 
11
+ import { PlaylistStorage } from './data-storage/data-storage.js'
11
12
  import { style } from './ox-board-player-style'
12
13
 
14
+ const DEFAULT_PLAYLIST = String('__default__')
15
+
13
16
  @customElement('ox-board-player')
14
17
  export class BoardPlayer extends LitElement {
15
18
  static styles = style
@@ -29,6 +32,8 @@ export class BoardPlayer extends LitElement {
29
32
 
30
33
  @query('#control') _control!: HTMLElement
31
34
 
35
+ private playlistStorage: PlaylistStorage = new PlaylistStorage()
36
+
32
37
  render() {
33
38
  return html`
34
39
  <slot @mousemove=${() => this.onMousemove()} @transform=${() => this.onTransform()} tabindex="-1">
@@ -59,23 +64,44 @@ export class BoardPlayer extends LitElement {
59
64
  <label id="schedule-container">
60
65
  <mwc-icon id="schedule">schedule</mwc-icon>
61
66
  <input
62
- .value=${this.playtime}
63
- @change=${(e: Event) => (this.playtime = Number((e.target as HTMLInputElement).value))}
67
+ .value=${String(this.playtime)}
68
+ @change=${(e: Event) => {
69
+ this.playtime = Number((e.target as HTMLInputElement).value)
70
+ this.playlistStorage.save(DEFAULT_PLAYLIST, {
71
+ playtime: this.playtime,
72
+ columns: this.columns,
73
+ rows: this.rows
74
+ })
75
+ }}
64
76
  />
65
77
  sec.
66
78
  </label>
67
79
  <div id="grid-setting-container">
68
80
  <mwc-icon id="view_module">view_module</mwc-icon>
69
81
  <select
70
- .value=${this.rows}
71
- @change=${(e: Event) => (this.rows = Number((e.target as HTMLInputElement).value))}
82
+ .value=${String(this.rows)}
83
+ @change=${(e: Event) => {
84
+ this.rows = Number((e.target as HTMLInputElement).value)
85
+ this.playlistStorage.save(DEFAULT_PLAYLIST, {
86
+ playtime: this.playtime,
87
+ columns: this.columns,
88
+ rows: this.rows
89
+ })
90
+ }}
72
91
  >
73
92
  ${[1, 2, 3, 4, 5].map(row => html` <option>${row}</option> `)}
74
93
  </select>
75
94
  x
76
95
  <select
77
- .value=${this.columns}
78
- @change=${(e: Event) => (this.columns = Number((e.target as HTMLInputElement).value))}
96
+ .value=${String(this.columns)}
97
+ @change=${(e: Event) => {
98
+ this.columns = Number((e.target as HTMLInputElement).value)
99
+ this.playlistStorage.save(DEFAULT_PLAYLIST, {
100
+ playtime: this.playtime,
101
+ columns: this.columns,
102
+ rows: this.rows
103
+ })
104
+ }}
79
105
  >
80
106
  ${[1, 2, 3, 4, 5].map(column => html` <option>${column}</option> `)}
81
107
  </select>
@@ -96,7 +122,17 @@ export class BoardPlayer extends LitElement {
96
122
  `
97
123
  }
98
124
 
99
- firstUpdated() {
125
+ async firstUpdated() {
126
+ const setting = await this.playlistStorage.load('DEFAULT_PLAYLIST')
127
+
128
+ if (setting) {
129
+ const { playtime = 30, columns = 1, rows = 1 } = setting || {}
130
+
131
+ this.playtime = playtime
132
+ this.columns = columns
133
+ this.rows = rows
134
+ }
135
+
100
136
  SwipeListener(this)
101
137
 
102
138
  this.addEventListener('swipe', (e: Event) => {
@@ -9,7 +9,7 @@ import { Component, create, ReferenceProvider, SCENE_MODE } from '@hatiolab/thin
9
9
  import { isIOS, togglefullscreen } from '@operato/utils'
10
10
  import { ScrollbarStyles } from '@operato/styles'
11
11
 
12
- import { DataStorage } from './data-storage/data-storage.js'
12
+ import { BoardDataStorage } from './data-storage/data-storage.js'
13
13
  import { DataSubscriptionProviderImpl } from './graphql/data-subscription.js'
14
14
  import { runScenario, startScenario } from './graphql/scenario.js'
15
15
 
@@ -243,7 +243,7 @@ export class BoardViewer extends LitElement {
243
243
  },
244
244
  mode: SCENE_MODE.VIEW,
245
245
  refProvider: this.provider!,
246
- dataStorage: this.board.id !== 'preview' ? new DataStorage(this.board.id) : undefined,
246
+ dataStorage: this.board.id !== 'preview' ? new BoardDataStorage(this.board.id) : undefined,
247
247
  dataSubscriptionProvider: new DataSubscriptionProviderImpl()
248
248
  })
249
249