@operato/board 7.0.8 → 7.0.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.
- package/CHANGELOG.md +18 -0
- package/dist/src/modeller/property-sidebar/effects/property-event-tap.js +1 -0
- package/dist/src/modeller/property-sidebar/effects/property-event-tap.js.map +1 -1
- package/dist/src/ox-board-component-info.d.ts +1 -0
- package/dist/src/ox-board-component-info.js +32 -3
- package/dist/src/ox-board-component-info.js.map +1 -1
- package/dist/src/ox-board-viewer.d.ts +1 -0
- package/dist/src/ox-board-viewer.js +30 -0
- package/dist/src/ox-board-viewer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/icons/icon-excel-export.png +0 -0
- package/package.json +2 -2
- package/src/modeller/property-sidebar/effects/property-event-tap.ts +1 -0
- package/src/ox-board-component-info.ts +35 -3
- package/src/ox-board-viewer.ts +38 -0
Binary file
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@operato/board",
|
3
|
-
"version": "7.0.
|
3
|
+
"version": "7.0.11",
|
4
4
|
"description": "Webcomponent for board following open-wc recommendations",
|
5
5
|
"author": "heartyoh",
|
6
6
|
"main": "dist/src/index.js",
|
@@ -155,5 +155,5 @@
|
|
155
155
|
"prettier --write"
|
156
156
|
]
|
157
157
|
},
|
158
|
-
"gitHead": "
|
158
|
+
"gitHead": "cbcfab84994b3bd1c2c3993703894249d9210c59"
|
159
159
|
}
|
@@ -77,6 +77,7 @@ export class PropertyEventTap extends LitElement {
|
|
77
77
|
<option value="start-scenario">start the given scenario</option>
|
78
78
|
<option value="run-scenario">run the given scenario</option>
|
79
79
|
<option value="export-data">export data</option>
|
80
|
+
<option value="import-data">import data</option>
|
80
81
|
</select>
|
81
82
|
|
82
83
|
<label> <ox-i18n msgid="label.target">target</ox-i18n> </label>
|
@@ -2,12 +2,15 @@ import '@material/web/icon/icon.js'
|
|
2
2
|
import '@operato/property-editor/ox-properties-dynamic-view.js'
|
3
3
|
import '@operato/markdown'
|
4
4
|
|
5
|
-
import { css, html, LitElement } from 'lit'
|
5
|
+
import { css, html, LitElement, nothing } from 'lit'
|
6
6
|
import { customElement, property } from 'lit/decorators.js'
|
7
|
+
import * as XLSX from 'xlsx'
|
7
8
|
|
8
9
|
import { ScrollbarStyles } from '@operato/styles'
|
9
10
|
import { i18next } from '@operato/i18n'
|
10
11
|
|
12
|
+
const ICON_EXCEL_EXPORT = new URL('../../icons/icon-excel-export.png', import.meta.url).href
|
13
|
+
|
11
14
|
@customElement('ox-board-component-info')
|
12
15
|
export class BoardComponentInfo extends LitElement {
|
13
16
|
static styles = [
|
@@ -49,6 +52,7 @@ export class BoardComponentInfo extends LitElement {
|
|
49
52
|
background-color: var(--md-sys-color-surface);
|
50
53
|
width: 100%;
|
51
54
|
margin: auto;
|
55
|
+
table-layout: fixed;
|
52
56
|
}
|
53
57
|
|
54
58
|
tr {
|
@@ -64,11 +68,20 @@ export class BoardComponentInfo extends LitElement {
|
|
64
68
|
[subTh] {
|
65
69
|
text-align: center !important;
|
66
70
|
font-weight: bold;
|
67
|
-
|
71
|
+
width: 40px;
|
68
72
|
text-transform: capitalize;
|
69
73
|
background-color: rgba(0, 0, 0, 0.05);
|
70
74
|
}
|
71
75
|
|
76
|
+
span.export {
|
77
|
+
position: absolute;
|
78
|
+
width: 20px;
|
79
|
+
height: 20px;
|
80
|
+
top: 4px;
|
81
|
+
right: 4px;
|
82
|
+
background: var(--url-icon-excel-export) no-repeat;
|
83
|
+
}
|
84
|
+
|
72
85
|
a {
|
73
86
|
text-decoration: none;
|
74
87
|
}
|
@@ -83,6 +96,8 @@ export class BoardComponentInfo extends LitElement {
|
|
83
96
|
connectedCallback(): void {
|
84
97
|
super.connectedCallback()
|
85
98
|
|
99
|
+
this.style.setProperty('--url-icon-excel-export', `url(${ICON_EXCEL_EXPORT})`)
|
100
|
+
|
86
101
|
document.addEventListener('mouseup', this.dragEndHandler)
|
87
102
|
document.addEventListener('mousemove', this.dragMoveHandler)
|
88
103
|
}
|
@@ -129,8 +144,11 @@ export class BoardComponentInfo extends LitElement {
|
|
129
144
|
</tr>
|
130
145
|
|
131
146
|
<tr>
|
132
|
-
<td colspan="2">
|
147
|
+
<td colspan="2" style="position: relative;">
|
133
148
|
<pre>${JSON.stringify(data, null, 2)}</pre>
|
149
|
+
${data && Array.isArray(data)
|
150
|
+
? html`<span class="export" @tap=${() => this.exportData()}></span>`
|
151
|
+
: nothing}
|
134
152
|
</td>
|
135
153
|
</tr>
|
136
154
|
</table>
|
@@ -201,4 +219,18 @@ export class BoardComponentInfo extends LitElement {
|
|
201
219
|
delete this.dragStart
|
202
220
|
}
|
203
221
|
}
|
222
|
+
|
223
|
+
async exportData() {
|
224
|
+
try {
|
225
|
+
const { id = 'board-component', data } = this.component || {}
|
226
|
+
const filename = `${id}.xlsx`
|
227
|
+
|
228
|
+
const worksheet = XLSX.utils.json_to_sheet(data)
|
229
|
+
const workbook = XLSX.utils.book_new()
|
230
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')
|
231
|
+
XLSX.writeFile(workbook, filename)
|
232
|
+
} catch (e) {
|
233
|
+
console.error(e)
|
234
|
+
}
|
235
|
+
}
|
204
236
|
}
|
package/src/ox-board-viewer.ts
CHANGED
@@ -392,6 +392,7 @@ export class BoardViewer extends LitElement {
|
|
392
392
|
this._scene.on('start-scenario', this.onStartScenario, this)
|
393
393
|
this._scene.on('run-scenario', this.onRunScenario, this)
|
394
394
|
this._scene.on('export-data', this.onExportData, this)
|
395
|
+
this._scene.on('import-data', this.onImportData, this)
|
395
396
|
this._scene.on('click', this.onClickEvent, this)
|
396
397
|
}
|
397
398
|
|
@@ -405,6 +406,7 @@ export class BoardViewer extends LitElement {
|
|
405
406
|
scene.off('start-scenario', this.onStartScenario, this)
|
406
407
|
scene.off('run-scenario', this.onRunScenario, this)
|
407
408
|
scene.off('export-data', this.onExportData, this)
|
409
|
+
scene.off('import-data', this.onImportData, this)
|
408
410
|
scene.off('click', this.onClickEvent, this)
|
409
411
|
}
|
410
412
|
|
@@ -572,6 +574,42 @@ export class BoardViewer extends LitElement {
|
|
572
574
|
}
|
573
575
|
}
|
574
576
|
|
577
|
+
async onImportData(_: string, value: string | number | object, component: Component) {
|
578
|
+
const fileInput = document.createElement('input')
|
579
|
+
fileInput.type = 'file'
|
580
|
+
fileInput.accept = '.xlsx, .xls'
|
581
|
+
fileInput.style.display = 'none'
|
582
|
+
|
583
|
+
fileInput.addEventListener(
|
584
|
+
'change',
|
585
|
+
(event: Event) => {
|
586
|
+
const input = event.target as HTMLInputElement
|
587
|
+
const file = input.files?.[0]
|
588
|
+
if (!file) {
|
589
|
+
return
|
590
|
+
}
|
591
|
+
|
592
|
+
const reader = new FileReader()
|
593
|
+
reader.onload = function (event) {
|
594
|
+
const data = new Uint8Array(event.target?.result as ArrayBuffer)
|
595
|
+
const workbook = XLSX.read(data, { type: 'array' })
|
596
|
+
|
597
|
+
// 첫 번째 시트의 데이타만 가져온다.
|
598
|
+
const firstSheetName = workbook.SheetNames[0]
|
599
|
+
const worksheet = workbook.Sheets[firstSheetName]
|
600
|
+
component.data = XLSX.utils.sheet_to_json(worksheet)
|
601
|
+
|
602
|
+
input.remove()
|
603
|
+
}
|
604
|
+
reader.readAsArrayBuffer(file)
|
605
|
+
},
|
606
|
+
false
|
607
|
+
)
|
608
|
+
|
609
|
+
document.body.appendChild(fileInput)
|
610
|
+
fileInput.click()
|
611
|
+
}
|
612
|
+
|
575
613
|
onClickEvent(e: MouseEvent, hint: any) {
|
576
614
|
const component = hint.origin
|
577
615
|
|