@operato/board 1.3.16 → 1.4.0
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 +22 -0
- package/dist/src/modeller/scene-viewer/ox-scene-viewer.js +1 -0
- package/dist/src/modeller/scene-viewer/ox-scene-viewer.js.map +1 -1
- package/dist/src/ox-board-component-info.d.ts +18 -0
- package/dist/src/ox-board-component-info.js +160 -0
- package/dist/src/ox-board-component-info.js.map +1 -0
- package/dist/src/ox-board-viewer.d.ts +4 -0
- package/dist/src/ox-board-viewer.js +37 -0
- package/dist/src/ox-board-viewer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/modeller/scene-viewer/ox-scene-viewer.ts +2 -0
- package/src/ox-board-component-info.ts +178 -0
- package/src/ox-board-viewer.ts +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/board",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Webcomponent for board following open-wc recommendations",
|
|
5
5
|
"author": "heartyoh",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -88,16 +88,16 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@open-wc/scoped-elements": "^2.0.0-next.6",
|
|
91
|
-
"@operato/app": "^1.3.
|
|
92
|
-
"@operato/data-grist": "^1.3.
|
|
93
|
-
"@operato/font": "^1.3.
|
|
91
|
+
"@operato/app": "^1.3.17",
|
|
92
|
+
"@operato/data-grist": "^1.3.17",
|
|
93
|
+
"@operato/font": "^1.3.17",
|
|
94
94
|
"@operato/graphql": "^1.3.13",
|
|
95
95
|
"@operato/i18n": "^1.3.13",
|
|
96
|
-
"@operato/input": "^1.3.
|
|
96
|
+
"@operato/input": "^1.3.17",
|
|
97
97
|
"@operato/layout": "^1.3.14",
|
|
98
98
|
"@operato/markdown": "^1.3.13",
|
|
99
99
|
"@operato/popup": "^1.3.13",
|
|
100
|
-
"@operato/property-editor": "^1.3.
|
|
100
|
+
"@operato/property-editor": "^1.3.17",
|
|
101
101
|
"@operato/styles": "^1.3.13",
|
|
102
102
|
"@operato/utils": "^1.3.13",
|
|
103
103
|
"@polymer/paper-dropdown-menu": "^3.2.0",
|
|
@@ -148,5 +148,5 @@
|
|
|
148
148
|
"prettier --write"
|
|
149
149
|
]
|
|
150
150
|
},
|
|
151
|
-
"gitHead": "
|
|
151
|
+
"gitHead": "c632a7afef494d7c33cef6a0c0b9210e810181dc"
|
|
152
152
|
}
|
|
@@ -182,6 +182,8 @@ export default class OxSceneViewer extends LitElement {
|
|
|
182
182
|
this._onModeChanged(this.mode)
|
|
183
183
|
this._onDisplayChanged(this.screenSize)
|
|
184
184
|
this._onBaseUrlChanged(this.baseUrl)
|
|
185
|
+
|
|
186
|
+
this.focus()
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
_onDisplayChanged(screenSize: string | number) {
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import '@material/mwc-icon'
|
|
2
|
+
import '@material/mwc-button'
|
|
3
|
+
import '@operato/property-editor/ox-properties-dynamic-view.js'
|
|
4
|
+
import '@operato/markdown'
|
|
5
|
+
|
|
6
|
+
import { css, html, LitElement } from 'lit'
|
|
7
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
8
|
+
|
|
9
|
+
import { ScrollbarStyles } from '@operato/styles'
|
|
10
|
+
import { i18next } from '@operato/i18n'
|
|
11
|
+
|
|
12
|
+
@customElement('ox-board-component-info')
|
|
13
|
+
export class BoardComponentInfo extends LitElement {
|
|
14
|
+
static styles = [
|
|
15
|
+
ScrollbarStyles,
|
|
16
|
+
css`
|
|
17
|
+
:host {
|
|
18
|
+
background-color: white;
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
border: 2px solid var(--primary-color);
|
|
24
|
+
border-radius: 3px;
|
|
25
|
+
|
|
26
|
+
--mdc-icon-size: 12px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[header] {
|
|
30
|
+
background-color: var(--primary-color);
|
|
31
|
+
user-select: none;
|
|
32
|
+
align-items: center;
|
|
33
|
+
color: #eee;
|
|
34
|
+
padding: 0 2px;
|
|
35
|
+
|
|
36
|
+
display: flex;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[header] mwc-icon {
|
|
40
|
+
margin-left: auto;
|
|
41
|
+
align-self: center;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[content] {
|
|
45
|
+
overflow: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
table {
|
|
49
|
+
border-collapse: collapse;
|
|
50
|
+
background-color: #fff;
|
|
51
|
+
width: 100%;
|
|
52
|
+
margin: auto;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
tr {
|
|
56
|
+
border-bottom: var(--border-dark-color);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
td {
|
|
60
|
+
padding: var(--padding-narrow);
|
|
61
|
+
border-right: var(--border-dark-color);
|
|
62
|
+
font-size: 0.8em;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[subTh] {
|
|
66
|
+
text-align: center !important;
|
|
67
|
+
font-weight: bold;
|
|
68
|
+
min-width: 60px;
|
|
69
|
+
text-transform: capitalize;
|
|
70
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
71
|
+
}
|
|
72
|
+
`
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
@property({ type: Object }) component?: any
|
|
76
|
+
|
|
77
|
+
private dragEndHandler = this.onDragEnd.bind(this) as EventListener
|
|
78
|
+
private dragMoveHandler = this.onDragMove.bind(this) as EventListener
|
|
79
|
+
|
|
80
|
+
connectedCallback(): void {
|
|
81
|
+
super.connectedCallback()
|
|
82
|
+
|
|
83
|
+
document.addEventListener('mouseup', this.dragEndHandler)
|
|
84
|
+
document.addEventListener('mousemove', this.dragMoveHandler)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
disconnectedCallback(): void {
|
|
88
|
+
super.disconnectedCallback()
|
|
89
|
+
|
|
90
|
+
document.removeEventListener('mouseup', this.dragEndHandler)
|
|
91
|
+
document.removeEventListener('mousemove', this.dragMoveHandler)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
render() {
|
|
95
|
+
const { state, data, value } = this.component || {}
|
|
96
|
+
const { id, type } = state || {}
|
|
97
|
+
|
|
98
|
+
return html`
|
|
99
|
+
<div header @mousedown=${this.onDragStart.bind(this)} draggable="false">
|
|
100
|
+
Component Inspection<mwc-icon @click=${(e: MouseEvent) => this.dispatchEvent(new CustomEvent('close'))}
|
|
101
|
+
>close</mwc-icon
|
|
102
|
+
>
|
|
103
|
+
</div>
|
|
104
|
+
<div content>
|
|
105
|
+
<table>
|
|
106
|
+
<tr>
|
|
107
|
+
<td subTh>${i18next.t('label.id')}</td>
|
|
108
|
+
<td>${id}</td>
|
|
109
|
+
</tr>
|
|
110
|
+
<tr>
|
|
111
|
+
<td subTh>${i18next.t('label.type')}</td>
|
|
112
|
+
<td>${type}</td>
|
|
113
|
+
</tr>
|
|
114
|
+
<tr>
|
|
115
|
+
<td subTh>${i18next.t('label.value')}</td>
|
|
116
|
+
<td>${value === data ? 'equal to data' : html`<pre>${JSON.stringify(value, null, 2)}</pre>`}</td>
|
|
117
|
+
</tr>
|
|
118
|
+
|
|
119
|
+
<tr>
|
|
120
|
+
<td colspan="2">
|
|
121
|
+
<pre>${JSON.stringify(data, null, 2)}</pre>
|
|
122
|
+
</td>
|
|
123
|
+
</tr>
|
|
124
|
+
</table>
|
|
125
|
+
</div>
|
|
126
|
+
`
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private dragStart?: { x: number; y: number }
|
|
130
|
+
|
|
131
|
+
onDragStart(e: MouseEvent) {
|
|
132
|
+
e.stopPropagation()
|
|
133
|
+
|
|
134
|
+
if (e.button == 0) {
|
|
135
|
+
this.dragStart = {
|
|
136
|
+
x: e.clientX,
|
|
137
|
+
y: e.clientY
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return false
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
onDragMove(e: Event) {
|
|
145
|
+
if (!this.dragStart) {
|
|
146
|
+
return false
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
e.stopPropagation()
|
|
150
|
+
e.preventDefault()
|
|
151
|
+
|
|
152
|
+
var x = (e as MouseEvent).clientX,
|
|
153
|
+
y = (e as MouseEvent).clientY
|
|
154
|
+
|
|
155
|
+
const dragStart = { x, y }
|
|
156
|
+
|
|
157
|
+
x -= this.dragStart.x
|
|
158
|
+
y -= this.dragStart.y
|
|
159
|
+
|
|
160
|
+
this.dragStart = dragStart
|
|
161
|
+
|
|
162
|
+
this.style.left =
|
|
163
|
+
Math.min(this.parentElement!.offsetWidth - this.offsetWidth, Math.max(0, this.offsetLeft + x)) + 'px'
|
|
164
|
+
this.style.top =
|
|
165
|
+
Math.min(this.parentElement!.offsetHeight - this.offsetHeight, Math.max(0, this.offsetTop + y)) + 'px'
|
|
166
|
+
|
|
167
|
+
return false
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
onDragEnd(e: Event) {
|
|
171
|
+
if (this.dragStart) {
|
|
172
|
+
e.stopPropagation()
|
|
173
|
+
e.preventDefault()
|
|
174
|
+
|
|
175
|
+
delete this.dragStart
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
package/src/ox-board-viewer.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '@material/mwc-fab'
|
|
2
2
|
import '@material/mwc-icon'
|
|
3
|
+
import './ox-board-component-info.js'
|
|
3
4
|
|
|
4
5
|
import { css, html, LitElement, PropertyValues } from 'lit'
|
|
5
6
|
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
@@ -12,6 +13,8 @@ import { DataStorage } from './data-storage/data-storage.js'
|
|
|
12
13
|
import { DataSubscriptionProviderImpl } from './graphql/data-subscription.js'
|
|
13
14
|
import { runScenario, startScenario } from './graphql/scenario.js'
|
|
14
15
|
|
|
16
|
+
import { BoardComponentInfo } from './ox-board-component-info.js'
|
|
17
|
+
|
|
15
18
|
@customElement('ox-board-viewer')
|
|
16
19
|
export class BoardViewer extends LitElement {
|
|
17
20
|
static styles = [
|
|
@@ -36,6 +39,17 @@ export class BoardViewer extends LitElement {
|
|
|
36
39
|
outline: 0;
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
::slotted(ox-board-component-info) {
|
|
43
|
+
position: absolute;
|
|
44
|
+
right: 10px;
|
|
45
|
+
top: 10px;
|
|
46
|
+
width: 240px;
|
|
47
|
+
opacity: 0.9;
|
|
48
|
+
box-shadow: 2px 2px 4px gray;
|
|
49
|
+
max-height: 600px;
|
|
50
|
+
overflow: auto;
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
/* navigation buttons */
|
|
40
54
|
mwc-icon {
|
|
41
55
|
z-index: 10;
|
|
@@ -105,6 +119,7 @@ export class BoardViewer extends LitElement {
|
|
|
105
119
|
@state() _fade_animations?: Array<Animation>
|
|
106
120
|
|
|
107
121
|
public currentBoardId?: string = this.board?.id
|
|
122
|
+
private popup?: BoardComponentInfo
|
|
108
123
|
|
|
109
124
|
@query('#target') _target!: HTMLElement
|
|
110
125
|
@query('#prev') _prev!: HTMLElement
|
|
@@ -161,6 +176,7 @@ export class BoardViewer extends LitElement {
|
|
|
161
176
|
@mousemove=${(e: Event) => this.transientShowButtons()}
|
|
162
177
|
></div>
|
|
163
178
|
|
|
179
|
+
<slot></slot>
|
|
164
180
|
${next} ${fullscreen}
|
|
165
181
|
`
|
|
166
182
|
}
|
|
@@ -190,6 +206,7 @@ export class BoardViewer extends LitElement {
|
|
|
190
206
|
|
|
191
207
|
updated(changes: PropertyValues<this>) {
|
|
192
208
|
if (changes.has('board')) {
|
|
209
|
+
this.hidePopup()
|
|
193
210
|
this.closeScene()
|
|
194
211
|
|
|
195
212
|
if (this.board && this.board.id) {
|
|
@@ -335,6 +352,7 @@ export class BoardViewer extends LitElement {
|
|
|
335
352
|
this._scene.on('route-page', this.onRoutePage, this)
|
|
336
353
|
this._scene.on('start-scenario', this.onStartScenario, this)
|
|
337
354
|
this._scene.on('run-scenario', this.onRunScenario, this)
|
|
355
|
+
this._scene.on('click', this.onClickEvent, this)
|
|
338
356
|
}
|
|
339
357
|
|
|
340
358
|
unbindSceneEvents(scene: any) {
|
|
@@ -345,6 +363,7 @@ export class BoardViewer extends LitElement {
|
|
|
345
363
|
scene.off('route-page', this.onRoutePage, this)
|
|
346
364
|
scene.off('start-scenario', this.onStartScenario, this)
|
|
347
365
|
scene.off('run-scenario', this.onRunScenario, this)
|
|
366
|
+
scene.off('click', this.onClickEvent, this)
|
|
348
367
|
}
|
|
349
368
|
|
|
350
369
|
transientShowButtons(stop?: boolean) {
|
|
@@ -490,6 +509,32 @@ export class BoardViewer extends LitElement {
|
|
|
490
509
|
}
|
|
491
510
|
}
|
|
492
511
|
|
|
512
|
+
onClickEvent(e: MouseEvent, hint: any) {
|
|
513
|
+
const component = hint.origin
|
|
514
|
+
|
|
515
|
+
if (!this.popup && e.altKey) {
|
|
516
|
+
const popup = document.createElement('ox-board-component-info') as BoardComponentInfo
|
|
517
|
+
popup.addEventListener('close', e => {
|
|
518
|
+
e.stopPropagation()
|
|
519
|
+
this.hidePopup()
|
|
520
|
+
})
|
|
521
|
+
|
|
522
|
+
this.appendChild(popup)
|
|
523
|
+
this.popup = popup
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (this.popup) {
|
|
527
|
+
this.popup.component = component
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
hidePopup() {
|
|
532
|
+
if (this.popup) {
|
|
533
|
+
this.removeChild(this.popup)
|
|
534
|
+
delete this.popup
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
493
538
|
getSceneData() {
|
|
494
539
|
return this._scene?.data
|
|
495
540
|
}
|