@operato/board 7.0.5 → 7.0.7

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": "7.0.5",
3
+ "version": "7.0.7",
4
4
  "description": "Webcomponent for board following open-wc recommendations",
5
5
  "author": "heartyoh",
6
6
  "main": "dist/src/index.js",
@@ -114,7 +114,8 @@
114
114
  "file-saver": "^2.0.5",
115
115
  "lit": "^3.1.2",
116
116
  "lodash-es": "^4.17.21",
117
- "sortablejs": "^1.15.2"
117
+ "sortablejs": "^1.15.2",
118
+ "xlsx": "^0.18.5"
118
119
  },
119
120
  "devDependencies": {
120
121
  "@custom-elements-manifest/analyzer": "^0.9.2",
@@ -154,5 +155,5 @@
154
155
  "prettier --write"
155
156
  ]
156
157
  },
157
- "gitHead": "78f3be8a64bb2be76cba1d244f55c120ea5cea46"
158
+ "gitHead": "6f41df0039b072b17fa4c9af28869a3f5469750d"
158
159
  }
@@ -76,6 +76,7 @@ export class PropertyEventTap extends LitElement {
76
76
  <option value="partial-value-set">set partial value to target component value</option>
77
77
  <option value="start-scenario">start the given scenario</option>
78
78
  <option value="run-scenario">run the given scenario</option>
79
+ <option value="export-data">export data</option>
79
80
  </select>
80
81
 
81
82
  <label> <ox-i18n msgid="label.target">target</ox-i18n> </label>
@@ -129,11 +130,11 @@ export class PropertyEventTap extends LitElement {
129
130
  }
130
131
  `
131
132
  : SETS_ACTION.indexOf(action) != -1
132
- ? html`
133
- <label> <ox-i18n msgid="label.value">value</ox-i18n> </label>
134
- <ox-input-data value-key="value" .value=${value} custom-editor fullwidth></ox-input-data>
135
- `
136
- : html``}
133
+ ? html`
134
+ <label> <ox-i18n msgid="label.value">value</ox-i18n> </label>
135
+ <ox-input-data value-key="value" .value=${value} custom-editor fullwidth></ox-input-data>
136
+ `
137
+ : html``}
137
138
  `
138
139
  }
139
140
 
@@ -142,6 +143,8 @@ export class PropertyEventTap extends LitElement {
142
143
  case 'link-open':
143
144
  case 'link-move':
144
145
  return 'http://www.hatiolab.com/'
146
+ case 'export-data':
147
+ return 'abc.xlsx'
145
148
  default:
146
149
  return ''
147
150
  }
@@ -184,6 +187,7 @@ export class PropertyEventTap extends LitElement {
184
187
  return this.scenarios
185
188
  case 'goto-playlist':
186
189
  return this.playlists
190
+ case 'export-data':
187
191
  default:
188
192
  return []
189
193
  }
@@ -4,6 +4,7 @@ import './ox-board-component-info.js'
4
4
 
5
5
  import { css, html, LitElement, PropertyValues } from 'lit'
6
6
  import { customElement, property, query, state } from 'lit/decorators.js'
7
+ import * as XLSX from 'xlsx'
7
8
 
8
9
  import { Component, create, ReferenceProvider, SCENE_MODE } from '@hatiolab/things-scene'
9
10
  import { isIOS, togglefullscreen } from '@operato/utils'
@@ -390,6 +391,7 @@ export class BoardViewer extends LitElement {
390
391
  this._scene.on('route-page', this.onRoutePage, this)
391
392
  this._scene.on('start-scenario', this.onStartScenario, this)
392
393
  this._scene.on('run-scenario', this.onRunScenario, this)
394
+ this._scene.on('export-data', this.onExportData, this)
393
395
  this._scene.on('click', this.onClickEvent, this)
394
396
  }
395
397
 
@@ -402,6 +404,7 @@ export class BoardViewer extends LitElement {
402
404
  scene.off('route-page', this.onRoutePage, this)
403
405
  scene.off('start-scenario', this.onStartScenario, this)
404
406
  scene.off('run-scenario', this.onRunScenario, this)
407
+ scene.off('export-data', this.onExportData, this)
405
408
  scene.off('click', this.onClickEvent, this)
406
409
  }
407
410
 
@@ -556,6 +559,19 @@ export class BoardViewer extends LitElement {
556
559
  }
557
560
  }
558
561
 
562
+ async onExportData(filename: string, value: string | number | object, component: Component) {
563
+ try {
564
+ const data = component.data
565
+
566
+ const worksheet = XLSX.utils.json_to_sheet(data)
567
+ const workbook = XLSX.utils.book_new()
568
+ XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')
569
+ XLSX.writeFile(workbook, filename || 'export-data.xlsx')
570
+ } catch (e) {
571
+ console.error(e)
572
+ }
573
+ }
574
+
559
575
  onClickEvent(e: MouseEvent, hint: any) {
560
576
  const component = hint.origin
561
577