@operato/scene-integration 8.0.0-beta.0 → 8.0.0-beta.2
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 +5 -5
- package/CHANGELOG.md +0 -932
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -15
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -15
- package/logs/application-2024-08-11-22.log +0 -105
- package/logs/connections-2024-08-11-22.log +0 -50
- package/logs/system/.ce832741a58883a058e9af6fb7483de16a838e2c-audit.json +0 -20
- package/logs/system/scenario-NOW-2024-08-11-22.log +0 -66
- package/logs/system/scenario-NOW-2024-08-11-23.log +0 -1826
- package/schema.graphql +0 -4369
- package/src/client-api.ts +0 -25
- package/src/connection-control.ts +0 -127
- package/src/connection-state-subscription.ts +0 -110
- package/src/data-subscription.ts +0 -41
- package/src/editors/index.ts +0 -1
- package/src/index.ts +0 -21
- package/src/scenario-control.ts +0 -121
- package/src/scenario-instance-subscription.ts +0 -115
- package/src/scenario-queue-subscription.ts +0 -88
- package/src/scenario-run.ts +0 -219
- package/src/scenario-start.ts +0 -102
- package/src/scenario-stop.ts +0 -90
- package/src/templates/connection-control.ts +0 -17
- package/src/templates/connection-state-subscription.ts +0 -17
- package/src/templates/data-subscription.ts +0 -17
- package/src/templates/index.ts +0 -21
- package/src/templates/scenario-control.ts +0 -18
- package/src/templates/scenario-instance-subscription.ts +0 -17
- package/src/templates/scenario-queue-subscription.ts +0 -17
- package/src/templates/scenario-run.ts +0 -17
- package/src/templates/scenario-start.ts +0 -17
- package/src/templates/scenario-stop.ts +0 -17
- package/tsconfig.json +0 -23
- package/tsconfig.tsbuildinfo +0 -1
package/src/client-api.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { client } from '@operato/graphql'
|
|
4
|
-
|
|
5
|
-
export const scenarios = async () => {
|
|
6
|
-
var response = await client.query({
|
|
7
|
-
query: gql`
|
|
8
|
-
query {
|
|
9
|
-
scenarios {
|
|
10
|
-
items {
|
|
11
|
-
name
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`
|
|
16
|
-
})
|
|
17
|
-
if (response.errors) {
|
|
18
|
-
return ['']
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const items = response.data.scenarios.items.map((item: any) => item.name)
|
|
22
|
-
const sorted = items.sort()
|
|
23
|
-
|
|
24
|
-
return [''].concat(sorted)
|
|
25
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'
|
|
4
|
-
import { client } from '@operato/graphql'
|
|
5
|
-
|
|
6
|
-
const NATURE: ComponentNature = {
|
|
7
|
-
mutable: false,
|
|
8
|
-
resizable: true,
|
|
9
|
-
rotatable: true,
|
|
10
|
-
properties: [
|
|
11
|
-
{
|
|
12
|
-
type: 'select',
|
|
13
|
-
label: 'connection-name',
|
|
14
|
-
name: 'connectionName',
|
|
15
|
-
property: {
|
|
16
|
-
options: async () => {
|
|
17
|
-
var response = await client.query({
|
|
18
|
-
query: gql`
|
|
19
|
-
query {
|
|
20
|
-
connections {
|
|
21
|
-
items {
|
|
22
|
-
name
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
`
|
|
27
|
-
})
|
|
28
|
-
if (response.errors) {
|
|
29
|
-
return ['']
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return [''].concat(response.data.connections.items.map((item: any) => item.name))
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: 'select',
|
|
38
|
-
label: 'control-type',
|
|
39
|
-
name: 'controlType',
|
|
40
|
-
property: {
|
|
41
|
-
options: [
|
|
42
|
-
{
|
|
43
|
-
display: '',
|
|
44
|
-
value: ''
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
display: 'connect',
|
|
48
|
-
value: 'connect'
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
display: 'disconnect',
|
|
52
|
-
value: 'disconnect'
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
'value-property': 'controlType',
|
|
59
|
-
help: 'scene/component/connection-control'
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default class ConnectionControl extends RectPath(Shape) {
|
|
63
|
-
static _image: HTMLImageElement
|
|
64
|
-
|
|
65
|
-
static get image() {
|
|
66
|
-
if (!ConnectionControl._image) {
|
|
67
|
-
ConnectionControl._image = new Image()
|
|
68
|
-
ConnectionControl._image.src = new URL('../icons/symbol-connection-control.png', import.meta.url).href
|
|
69
|
-
}
|
|
70
|
-
return ConnectionControl._image
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
render(context: CanvasRenderingContext2D) {
|
|
74
|
-
var { left, top, width, height } = this.bounds
|
|
75
|
-
context.beginPath()
|
|
76
|
-
this.drawImage(context, ConnectionControl.image, left, top, width, height)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
get nature() {
|
|
80
|
-
return NATURE
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get controlType() {
|
|
84
|
-
return this.getState('controlType')
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
set controlType(controlType: string) {
|
|
88
|
-
this.setState('controlType', controlType)
|
|
89
|
-
this.controlConnect()
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async controlConnect() {
|
|
93
|
-
let { controlType, connectionName } = this.state
|
|
94
|
-
|
|
95
|
-
if (!connectionName || !this.app.isViewMode) return
|
|
96
|
-
|
|
97
|
-
switch (controlType) {
|
|
98
|
-
case 'connect':
|
|
99
|
-
case true:
|
|
100
|
-
case 1:
|
|
101
|
-
controlType = 'connect'
|
|
102
|
-
break
|
|
103
|
-
default:
|
|
104
|
-
controlType = 'disconnect'
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
var query = ''
|
|
108
|
-
|
|
109
|
-
query = `mutation{
|
|
110
|
-
${controlType}Connection(name: "${connectionName}") {
|
|
111
|
-
status
|
|
112
|
-
}
|
|
113
|
-
}`
|
|
114
|
-
|
|
115
|
-
if (client) {
|
|
116
|
-
var response = await client.query({
|
|
117
|
-
query: gql`
|
|
118
|
-
${query}
|
|
119
|
-
`
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
this.data = response
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
Component.register('connection-control', ConnectionControl)
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { Component, ComponentNature, DataSource, RectPath, Shape } from '@hatiolab/things-scene'
|
|
4
|
-
import { client, subscribe } from '@operato/graphql'
|
|
5
|
-
|
|
6
|
-
const NATURE: ComponentNature = {
|
|
7
|
-
mutable: false,
|
|
8
|
-
resizable: true,
|
|
9
|
-
rotatable: true,
|
|
10
|
-
properties: [
|
|
11
|
-
{
|
|
12
|
-
type: 'select',
|
|
13
|
-
label: 'connection-name',
|
|
14
|
-
name: 'connectionName',
|
|
15
|
-
property: {
|
|
16
|
-
options: async () => {
|
|
17
|
-
var response = await client.query({
|
|
18
|
-
query: gql`
|
|
19
|
-
query {
|
|
20
|
-
connections {
|
|
21
|
-
items {
|
|
22
|
-
name
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
`
|
|
27
|
-
})
|
|
28
|
-
if (response.errors) {
|
|
29
|
-
return ['']
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return [''].concat(response.data.connections.items.map((item: any) => item.name))
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
help: 'scene/component/connection-state-subscription'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default class ConnectionStateSubscription extends DataSource(RectPath(Shape)) {
|
|
41
|
-
static _image: HTMLImageElement
|
|
42
|
-
static get image() {
|
|
43
|
-
if (!ConnectionStateSubscription._image) {
|
|
44
|
-
ConnectionStateSubscription._image = new Image()
|
|
45
|
-
ConnectionStateSubscription._image.src = new URL(
|
|
46
|
-
'../icons/symbol-connection-state-subscription.png',
|
|
47
|
-
import.meta.url
|
|
48
|
-
).href
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return ConnectionStateSubscription._image
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private subscription?: {
|
|
55
|
-
unsubscribe(): void
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
dispose() {
|
|
59
|
-
super.dispose()
|
|
60
|
-
|
|
61
|
-
this.subscription?.unsubscribe()
|
|
62
|
-
delete this.subscription
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
render(context: CanvasRenderingContext2D) {
|
|
66
|
-
var { left, top, width, height } = this.bounds
|
|
67
|
-
|
|
68
|
-
context.beginPath()
|
|
69
|
-
this.drawImage(context, ConnectionStateSubscription.image, left, top, width, height)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
ready() {
|
|
73
|
-
if (!this.app.isViewMode) return
|
|
74
|
-
this._initConnectionStateSubscription()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get nature() {
|
|
78
|
-
return NATURE
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
_initConnectionStateSubscription() {
|
|
82
|
-
if (!this.app.isViewMode) return
|
|
83
|
-
this.startSubscribe()
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async startSubscribe() {
|
|
87
|
-
var { connectionName } = this.state
|
|
88
|
-
|
|
89
|
-
this.subscription = await subscribe(
|
|
90
|
-
{
|
|
91
|
-
query: gql`subscription {
|
|
92
|
-
connectionState(name: "${connectionName}") {
|
|
93
|
-
name
|
|
94
|
-
state
|
|
95
|
-
timestamp
|
|
96
|
-
}
|
|
97
|
-
}`
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
next: async ({ data }: { data: any }) => {
|
|
101
|
-
if (data) {
|
|
102
|
-
this.data = data.connectionState
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
Component.register('connection-state-subscription', ConnectionStateSubscription)
|
package/src/data-subscription.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Component, ComponentNature, DataSource, RectPath, Shape } from '@hatiolab/things-scene'
|
|
2
|
-
|
|
3
|
-
const NATURE: ComponentNature = {
|
|
4
|
-
mutable: false,
|
|
5
|
-
resizable: true,
|
|
6
|
-
rotatable: true,
|
|
7
|
-
properties: [
|
|
8
|
-
{
|
|
9
|
-
type: 'string',
|
|
10
|
-
label: 'tag',
|
|
11
|
-
name: 'tag'
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
'value-property': 'tag',
|
|
15
|
-
help: 'scene/component/data-subscription'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default class DataSubscription extends DataSource(RectPath(Shape)) {
|
|
19
|
-
static _image: HTMLImageElement
|
|
20
|
-
static get image() {
|
|
21
|
-
if (!DataSubscription._image) {
|
|
22
|
-
DataSubscription._image = new Image()
|
|
23
|
-
DataSubscription._image.src = new URL('../icons/symbol-data-subscription.png', import.meta.url).href
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return DataSubscription._image
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
render(context: CanvasRenderingContext2D) {
|
|
30
|
-
var { left, top, width, height } = this.bounds
|
|
31
|
-
|
|
32
|
-
context.beginPath()
|
|
33
|
-
this.drawImage(context, DataSubscription.image, left, top, width, height)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get nature() {
|
|
37
|
-
return NATURE
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
Component.register('data-subscription', DataSubscription)
|
package/src/editors/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default []
|
package/src/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import DataSubscription from './data-subscription'
|
|
2
|
-
import ScenarioControl from './scenario-control'
|
|
3
|
-
import ScenarioRun from './scenario-run'
|
|
4
|
-
import ScenarioStart from './scenario-start'
|
|
5
|
-
import ScenarioStop from './scenario-stop'
|
|
6
|
-
import ScenarioInstanceSubscription from './scenario-instance-subscription'
|
|
7
|
-
import ScenarioQueueSubscription from './scenario-queue-subscription'
|
|
8
|
-
import ConnectionStateSubscription from './connection-state-subscription'
|
|
9
|
-
import ConnectionControl from './connection-control'
|
|
10
|
-
|
|
11
|
-
export default [
|
|
12
|
-
DataSubscription,
|
|
13
|
-
ScenarioControl,
|
|
14
|
-
ScenarioRun,
|
|
15
|
-
ScenarioStart,
|
|
16
|
-
ScenarioStop,
|
|
17
|
-
ScenarioInstanceSubscription,
|
|
18
|
-
ScenarioQueueSubscription,
|
|
19
|
-
ConnectionStateSubscription,
|
|
20
|
-
ConnectionControl
|
|
21
|
-
]
|
package/src/scenario-control.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { Component, ComponentNature, DataSource, Properties, RectPath, Shape } from '@hatiolab/things-scene'
|
|
4
|
-
import { client } from '@operato/graphql'
|
|
5
|
-
|
|
6
|
-
import { scenarios } from './client-api'
|
|
7
|
-
|
|
8
|
-
const NATURE: ComponentNature = {
|
|
9
|
-
mutable: false,
|
|
10
|
-
resizable: true,
|
|
11
|
-
rotatable: true,
|
|
12
|
-
properties: [
|
|
13
|
-
{
|
|
14
|
-
type: 'select',
|
|
15
|
-
label: 'scenario-name',
|
|
16
|
-
name: 'scenarioName',
|
|
17
|
-
property: {
|
|
18
|
-
options: scenarios
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
type: 'select',
|
|
23
|
-
label: 'control-type',
|
|
24
|
-
name: 'controlType',
|
|
25
|
-
property: {
|
|
26
|
-
options: [
|
|
27
|
-
{
|
|
28
|
-
display: '',
|
|
29
|
-
value: ''
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
display: 'start',
|
|
33
|
-
value: 'start'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
display: 'stop',
|
|
37
|
-
value: 'stop'
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
'value-property': 'controlType',
|
|
44
|
-
help: 'scene/component/scenario-control'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default class ScenarioControl extends DataSource(RectPath(Shape)) {
|
|
48
|
-
static _image: HTMLImageElement
|
|
49
|
-
|
|
50
|
-
static get image() {
|
|
51
|
-
if (!ScenarioControl._image) {
|
|
52
|
-
ScenarioControl._image = new Image()
|
|
53
|
-
ScenarioControl._image.src = new URL('../icons/symbol-scenario-control.png', import.meta.url).href
|
|
54
|
-
}
|
|
55
|
-
return ScenarioControl._image
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
render(context: CanvasRenderingContext2D) {
|
|
59
|
-
var { left, top, width, height } = this.bounds
|
|
60
|
-
context.beginPath()
|
|
61
|
-
this.drawImage(context, ScenarioControl.image, left, top, width, height)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
ready() {
|
|
65
|
-
super.ready()
|
|
66
|
-
|
|
67
|
-
if (this.app.isViewMode) {
|
|
68
|
-
this.requestData()
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get nature() {
|
|
73
|
-
return NATURE
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
onchange(after: Properties) {
|
|
77
|
-
if ('controlType' in after) {
|
|
78
|
-
this.requestData()
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
get controlType() {
|
|
83
|
-
return this.getState('controlType')
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
set controlType(controlType) {
|
|
87
|
-
this.setState('controlType', controlType)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async requestData() {
|
|
91
|
-
let { controlType, scenarioName } = this.state
|
|
92
|
-
if (!controlType || !scenarioName || !this.app.isViewMode) {
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
var query = ''
|
|
97
|
-
if (controlType == 'start') {
|
|
98
|
-
query = `mutation{
|
|
99
|
-
${controlType}Scenario(instanceName: "${scenarioName}", scenarioName: "${scenarioName}", variables: {}) {
|
|
100
|
-
state
|
|
101
|
-
}
|
|
102
|
-
}`
|
|
103
|
-
} else {
|
|
104
|
-
query = `mutation{
|
|
105
|
-
${controlType}Scenario(instanceName: "${scenarioName}") {
|
|
106
|
-
state
|
|
107
|
-
}
|
|
108
|
-
}`
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
var response = await client.query({
|
|
112
|
-
query: gql`
|
|
113
|
-
${query}
|
|
114
|
-
`
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
this.data = response
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
Component.register('scenario-control', ScenarioControl)
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { Component, ComponentNature, DataSource, RectPath, Shape } from '@hatiolab/things-scene'
|
|
4
|
-
import { subscribe } from '@operato/graphql'
|
|
5
|
-
|
|
6
|
-
import { scenarios } from './client-api'
|
|
7
|
-
|
|
8
|
-
const NATURE: ComponentNature = {
|
|
9
|
-
mutable: false,
|
|
10
|
-
resizable: true,
|
|
11
|
-
rotatable: true,
|
|
12
|
-
properties: [
|
|
13
|
-
{
|
|
14
|
-
type: 'select',
|
|
15
|
-
label: 'scenario-name',
|
|
16
|
-
name: 'scenarioName',
|
|
17
|
-
property: {
|
|
18
|
-
options: scenarios
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
type: 'string',
|
|
23
|
-
label: 'instance-name',
|
|
24
|
-
name: 'instanceName'
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
help: 'scene/component/scenario-instance-subscription'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default class ScenarioInstanceSubscription extends DataSource(RectPath(Shape)) {
|
|
31
|
-
static _image: HTMLImageElement
|
|
32
|
-
|
|
33
|
-
static get image() {
|
|
34
|
-
if (!ScenarioInstanceSubscription._image) {
|
|
35
|
-
ScenarioInstanceSubscription._image = new Image()
|
|
36
|
-
ScenarioInstanceSubscription._image.src = new URL(
|
|
37
|
-
'../icons/symbol-scenario-instance-subscription.png',
|
|
38
|
-
import.meta.url
|
|
39
|
-
).href
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return ScenarioInstanceSubscription._image
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private subscription?: {
|
|
46
|
-
unsubscribe(): void
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
dispose() {
|
|
50
|
-
super.dispose()
|
|
51
|
-
|
|
52
|
-
this.subscription?.unsubscribe()
|
|
53
|
-
delete this.subscription
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
render(context: CanvasRenderingContext2D) {
|
|
57
|
-
var { left, top, width, height } = this.bounds
|
|
58
|
-
|
|
59
|
-
context.beginPath()
|
|
60
|
-
this.drawImage(context, ScenarioInstanceSubscription.image, left, top, width, height)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
ready() {
|
|
64
|
-
if (!this.app.isViewMode) return
|
|
65
|
-
this._initScenarioInstanceSubscription()
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
get nature() {
|
|
69
|
-
return NATURE
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
_initScenarioInstanceSubscription() {
|
|
73
|
-
if (!this.app.isViewMode) return
|
|
74
|
-
this.startSubscribe()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async startSubscribe() {
|
|
78
|
-
var { instanceName, scenarioName = '' } = this.state
|
|
79
|
-
|
|
80
|
-
instanceName = instanceName || scenarioName
|
|
81
|
-
|
|
82
|
-
this.subscription = await subscribe(
|
|
83
|
-
{
|
|
84
|
-
query: gql`
|
|
85
|
-
subscription {
|
|
86
|
-
scenarioInstanceState(instanceName: "${instanceName}", scenarioName: "${scenarioName}") {
|
|
87
|
-
instanceName
|
|
88
|
-
scenarioName
|
|
89
|
-
state
|
|
90
|
-
variables
|
|
91
|
-
progress{
|
|
92
|
-
rounds
|
|
93
|
-
rate
|
|
94
|
-
steps
|
|
95
|
-
step
|
|
96
|
-
}
|
|
97
|
-
data
|
|
98
|
-
message
|
|
99
|
-
timestamp
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
`
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
next: async ({ data }: { data: any }) => {
|
|
106
|
-
if (data) {
|
|
107
|
-
this.data = data.scenarioInstanceState
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
Component.register('scenario-instance-subscription', ScenarioInstanceSubscription)
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { Component, ComponentNature, DataSource, RectPath, Shape } from '@hatiolab/things-scene'
|
|
4
|
-
import { subscribe } from '@operato/graphql'
|
|
5
|
-
|
|
6
|
-
const NATURE: ComponentNature = {
|
|
7
|
-
mutable: false,
|
|
8
|
-
resizable: true,
|
|
9
|
-
rotatable: true,
|
|
10
|
-
properties: [],
|
|
11
|
-
help: 'scene/component/scenario-queue-subscription'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default class ScenarioQueueSubscription extends DataSource(RectPath(Shape)) {
|
|
15
|
-
static _image: HTMLImageElement
|
|
16
|
-
|
|
17
|
-
static get image() {
|
|
18
|
-
if (!ScenarioQueueSubscription._image) {
|
|
19
|
-
ScenarioQueueSubscription._image = new Image()
|
|
20
|
-
ScenarioQueueSubscription._image.src = new URL(
|
|
21
|
-
'../icons/symbol-scenario-queue-subscription.png',
|
|
22
|
-
import.meta.url
|
|
23
|
-
).href
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return ScenarioQueueSubscription._image
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private subscription?: {
|
|
30
|
-
unsubscribe(): void
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
dispose() {
|
|
34
|
-
super.dispose()
|
|
35
|
-
|
|
36
|
-
this.subscription?.unsubscribe()
|
|
37
|
-
delete this.subscription
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
render(context: CanvasRenderingContext2D) {
|
|
41
|
-
var { left, top, width, height } = this.bounds
|
|
42
|
-
|
|
43
|
-
context.beginPath()
|
|
44
|
-
this.drawImage(context, ScenarioQueueSubscription.image, left, top, width, height)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
ready() {
|
|
48
|
-
if (!this.app.isViewMode) return
|
|
49
|
-
this._initScenarioQueueSubscription()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get nature() {
|
|
53
|
-
return NATURE
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
_initScenarioQueueSubscription() {
|
|
57
|
-
if (!this.app.isViewMode) return
|
|
58
|
-
this.startSubscribe()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async startSubscribe() {
|
|
62
|
-
this.subscription = await subscribe(
|
|
63
|
-
{
|
|
64
|
-
query: gql`
|
|
65
|
-
subscription {
|
|
66
|
-
scenarioQueueState {
|
|
67
|
-
queue {
|
|
68
|
-
stuff
|
|
69
|
-
due
|
|
70
|
-
priority
|
|
71
|
-
tag
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
`
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
next: async ({ data }: { data: any }) => {
|
|
79
|
-
if (data) {
|
|
80
|
-
this.data = data.scenarioQueueState
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
Component.register('scenario-queue-subscription', ScenarioQueueSubscription)
|