@operato/scene-integration 1.0.0-alpha.35 → 1.0.0-alpha.38
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 +28 -0
- package/assets/favicon.ico +0 -0
- package/assets/images/spinner.png +0 -0
- package/dist/client-api.js +2 -2
- package/dist/client-api.js.map +1 -1
- package/dist/connection-control.d.ts +0 -5
- package/dist/connection-control.js +2 -27
- package/dist/connection-control.js.map +1 -1
- package/dist/connection-state-subscription.js +2 -2
- package/dist/connection-state-subscription.js.map +1 -1
- package/dist/data-subscription.js +1 -1
- package/dist/data-subscription.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/scenario-control.d.ts +0 -4
- package/dist/scenario-control.js +11 -32
- package/dist/scenario-control.js.map +1 -1
- package/dist/scenario-instance-subscription.js +1 -1
- package/dist/scenario-instance-subscription.js.map +1 -1
- package/dist/scenario-queue-subscription.js +1 -1
- package/dist/scenario-queue-subscription.js.map +1 -1
- package/dist/scenario-run.d.ts +0 -4
- package/dist/scenario-run.js +6 -26
- package/dist/scenario-run.js.map +1 -1
- package/dist/scenario-start.d.ts +0 -5
- package/dist/scenario-start.js +1 -27
- package/dist/scenario-start.js.map +1 -1
- package/dist/scenario-stop.d.ts +0 -5
- package/dist/scenario-stop.js +1 -27
- package/dist/scenario-stop.js.map +1 -1
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +20 -0
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +20 -0
- package/logs/application-2022-07-17-17.log +13 -0
- package/logs/application-2022-07-17-18.log +8 -0
- package/logs/connections-2022-07-17-17.log +105 -0
- package/logs/connections-2022-07-17-18.log +70 -0
- package/package.json +6 -7
- package/src/client-api.ts +2 -2
- package/src/connection-control.ts +2 -34
- package/src/connection-state-subscription.ts +2 -3
- package/src/data-subscription.ts +1 -2
- package/src/scenario-control.ts +13 -36
- package/src/scenario-instance-subscription.ts +1 -1
- package/src/scenario-queue-subscription.ts +1 -2
- package/src/scenario-run.ts +7 -30
- package/src/scenario-start.ts +1 -33
- package/src/scenario-stop.ts +1 -33
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/origin-client.d.ts +0 -5
- package/dist/origin-client.js +0 -110
- package/dist/origin-client.js.map +0 -1
- package/src/origin-client.ts +0 -133
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.0-alpha.38](https://github.com/things-scene/operato-scene/compare/v1.0.0-alpha.37...v1.0.0-alpha.38) (2022-07-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* latest dependencies ([668aed1](https://github.com/things-scene/operato-scene/commit/668aed12552b08366230dbfab77ac2cbf4785c95))
|
|
12
|
+
* latest dependencies ([8a4cf6b](https://github.com/things-scene/operato-scene/commit/8a4cf6bfc9eed2bdb991eb77df9dba4b42de45e7))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [1.0.0-alpha.37](https://github.com/things-scene/operato-scene/compare/v1.0.0-alpha.36...v1.0.0-alpha.37) (2022-07-17)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### :bug: Bug Fix
|
|
20
|
+
|
|
21
|
+
* latest dependencies ([cb2e928](https://github.com/things-scene/operato-scene/commit/cb2e92871da17a11ac9c68b3c4ead5df59429973))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [1.0.0-alpha.36](https://github.com/things-scene/operato-scene/compare/v1.0.0-alpha.35...v1.0.0-alpha.36) (2022-07-17)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### :bug: Bug Fix
|
|
29
|
+
|
|
30
|
+
* integration use @operato/graphql client and subscribe ([d184eb3](https://github.com/things-scene/operato-scene/commit/d184eb35c9447ef1ecb6f5abe88ee1677345f487))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
## [1.0.0-alpha.35](https://github.com/things-scene/operato-scene/compare/v1.0.0-alpha.34...v1.0.0-alpha.35) (2022-07-15)
|
|
7
35
|
|
|
8
36
|
|
|
Binary file
|
|
Binary file
|
package/dist/client-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
|
-
import {
|
|
2
|
+
import { client } from '@operato/graphql';
|
|
3
3
|
export const scenarios = async () => {
|
|
4
|
-
var response = await
|
|
4
|
+
var response = await client.query({
|
|
5
5
|
query: gql `
|
|
6
6
|
query {
|
|
7
7
|
scenarios {
|
package/dist/client-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-api.js","sourceRoot":"","sources":["../src/client-api.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client-api.js","sourceRoot":"","sources":["../src/client-api.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAClC,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;QAChC,KAAK,EAAE,GAAG,CAAA;;;;;;;;KAQT;KACF,CAAC,CAAA;IACF,IAAI,QAAQ,CAAC,MAAM,EAAE;QACnB,OAAO,CAAC,EAAE,CAAC,CAAA;KACZ;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAE3B,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { client } from '@operato/graphql'\n\nexport const scenarios = async () => {\n var response = await client.query({\n query: gql`\n query {\n scenarios {\n items {\n name\n }\n }\n }\n `\n })\n if (response.errors) {\n return ['']\n }\n\n const items = response.data.scenarios.items.map((item: any) => item.name)\n const sorted = items.sort()\n\n return [''].concat(sorted)\n}\n"]}
|
|
@@ -3,13 +3,8 @@ declare const ConnectionControl_base: typeof Shape;
|
|
|
3
3
|
export default class ConnectionControl extends ConnectionControl_base {
|
|
4
4
|
static _image: HTMLImageElement;
|
|
5
5
|
static get image(): HTMLImageElement;
|
|
6
|
-
private _client;
|
|
7
6
|
render(context: CanvasRenderingContext2D): void;
|
|
8
|
-
ready(): void;
|
|
9
|
-
_init(): void;
|
|
10
|
-
dispose(): void;
|
|
11
7
|
get nature(): ComponentNature;
|
|
12
|
-
get client(): any;
|
|
13
8
|
get controlType(): string;
|
|
14
9
|
set controlType(controlType: string);
|
|
15
10
|
controlConnect(): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { Component, RectPath, Shape } from '@hatiolab/things-scene';
|
|
3
|
-
import {
|
|
3
|
+
import { client } from '@operato/graphql';
|
|
4
4
|
const NATURE = {
|
|
5
5
|
mutable: false,
|
|
6
6
|
resizable: true,
|
|
@@ -12,7 +12,7 @@ const NATURE = {
|
|
|
12
12
|
name: 'connectionName',
|
|
13
13
|
property: {
|
|
14
14
|
options: async () => {
|
|
15
|
-
var response = await
|
|
15
|
+
var response = await client.query({
|
|
16
16
|
query: gql `
|
|
17
17
|
query {
|
|
18
18
|
connections {
|
|
@@ -68,33 +68,9 @@ export default class ConnectionControl extends RectPath(Shape) {
|
|
|
68
68
|
context.beginPath();
|
|
69
69
|
this.drawImage(context, ConnectionControl.image, left, top, width, height);
|
|
70
70
|
}
|
|
71
|
-
ready() {
|
|
72
|
-
super.ready();
|
|
73
|
-
this._init();
|
|
74
|
-
}
|
|
75
|
-
_init() {
|
|
76
|
-
if (!this.app.isViewMode)
|
|
77
|
-
return;
|
|
78
|
-
this._client = getClient();
|
|
79
|
-
}
|
|
80
|
-
dispose() {
|
|
81
|
-
super.dispose();
|
|
82
|
-
try {
|
|
83
|
-
if (this._client) {
|
|
84
|
-
this._client.stop();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch (e) {
|
|
88
|
-
console.error(e);
|
|
89
|
-
}
|
|
90
|
-
delete this._client;
|
|
91
|
-
}
|
|
92
71
|
get nature() {
|
|
93
72
|
return NATURE;
|
|
94
73
|
}
|
|
95
|
-
get client() {
|
|
96
|
-
return this._client;
|
|
97
|
-
}
|
|
98
74
|
get controlType() {
|
|
99
75
|
return this.getState('controlType');
|
|
100
76
|
}
|
|
@@ -115,7 +91,6 @@ export default class ConnectionControl extends RectPath(Shape) {
|
|
|
115
91
|
default:
|
|
116
92
|
controlType = 'disconnect';
|
|
117
93
|
}
|
|
118
|
-
var client = this._client;
|
|
119
94
|
var query = '';
|
|
120
95
|
query = `mutation{
|
|
121
96
|
${controlType}Connection(name: "${connectionName}") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-control.js","sourceRoot":"","sources":["../src/connection-control.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"connection-control.js","sourceRoot":"","sources":["../src/connection-control.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACpF,OAAO,EAAE,MAAM,EAAE,MA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AM,EAAE;YACV,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAChC,KAAK,EAAE,GAAG,CAAA;YACN,KAAK;SACR;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;SACrB;IACH,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'\nimport { client } from '@operato/graphql'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'connection-name',\n name: 'connectionName',\n property: {\n options: async () => {\n var response = await client.query({\n query: gql`\n query {\n connections {\n items {\n name\n }\n }\n }\n `\n })\n if (response.errors) {\n return ['']\n }\n\n return [''].concat(response.data.connections.items.map((item: any) => item.name))\n }\n }\n },\n {\n type: 'select',\n label: 'control-type',\n name: 'controlType',\n property: {\n options: [\n {\n display: '',\n value: ''\n },\n {\n display: 'connect',\n value: 'connect'\n },\n {\n display: 'disconnect',\n value: 'disconnect'\n }\n ]\n }\n }\n ],\n 'value-property': 'controlType',\n help: 'scene/component/connection-control'\n}\n\nexport default class ConnectionControl extends RectPath(Shape) {\n static _image: HTMLImageElement\n\n static get image() {\n if (!ConnectionControl._image) {\n ConnectionControl._image = new Image()\n ConnectionControl._image.src = new URL('../icons/symbol-connection-control.png', import.meta.url).href\n }\n return ConnectionControl._image\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n context.beginPath()\n this.drawImage(context, ConnectionControl.image, left, top, width, height)\n }\n\n get nature() {\n return NATURE\n }\n\n get controlType() {\n return this.getState('controlType')\n }\n\n set controlType(controlType: string) {\n this.setState('controlType', controlType)\n this.controlConnect()\n }\n\n async controlConnect() {\n let { controlType, connectionName } = this.state\n\n if (!connectionName || !this.app.isViewMode) return\n\n switch (controlType) {\n case 'connect':\n case true:\n case 1:\n controlType = 'connect'\n break\n default:\n controlType = 'disconnect'\n }\n\n var query = ''\n\n query = `mutation{\n ${controlType}Connection(name: \"${connectionName}\") {\n status\n }\n }`\n\n if (client) {\n var response = await client.query({\n query: gql`\n ${query}\n `\n })\n\n this.data = response\n }\n }\n}\n\nComponent.register('connection-control', ConnectionControl)\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { Component, DataSource, RectPath, Shape } from '@hatiolab/things-scene';
|
|
3
|
-
import {
|
|
3
|
+
import { client, subscribe } from '@operato/graphql';
|
|
4
4
|
const NATURE = {
|
|
5
5
|
mutable: false,
|
|
6
6
|
resizable: true,
|
|
@@ -12,7 +12,7 @@ const NATURE = {
|
|
|
12
12
|
name: 'connectionName',
|
|
13
13
|
property: {
|
|
14
14
|
options: async () => {
|
|
15
|
-
var response = await
|
|
15
|
+
var response = await client.query({
|
|
16
16
|
query: gql `
|
|
17
17
|
query {
|
|
18
18
|
connections {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-state-subscription.js","sourceRoot":"","sources":["../src/connection-state-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"connection-state-subscription.js","sourceRoot":"","sources":["../src/connection-state-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAChG,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEpD,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI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EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAE9C,OAAO,CAAC,SAAS,EAAE,CAAA;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,2BAA2B,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IACtF,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU;YAAE,OAAM;QAChC,IAAI,CAAC,gCAAgC,EAAE,CAAA;IACzC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;IAED,gCAAgC;QAC9B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU;YAAE,OAAM;QAChC,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,IAAI,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAEnC,IAAI,CAAC,YAAY,GAAG,MAAM,SAAS,CACjC;YACE,KAAK,EAAE,GAAG,CAAA;mCACiB,cAAc;;;;;UAKvC;SACH,EACD;YACE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAiB,EAAE,EAAE;gBACtC,IAAI,IAAI,EAAE;oBACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAA;iBACjC;YACH,CAAC;SACF,CACF,CAAA;IACH,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,+BAA+B,EAAE,2BAA2B,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, DataSource, RectPath, Shape } from '@hatiolab/things-scene'\nimport { client, subscribe } from '@operato/graphql'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'connection-name',\n name: 'connectionName',\n property: {\n options: async () => {\n var response = await client.query({\n query: gql`\n query {\n connections {\n items {\n name\n }\n }\n }\n `\n })\n if (response.errors) {\n return ['']\n }\n\n return [''].concat(response.data.connections.items.map((item: any) => item.name))\n }\n }\n }\n ],\n help: 'scene/component/connection-state-subscription'\n}\n\nexport default class ConnectionStateSubscription extends DataSource(RectPath(Shape)) {\n static _image: HTMLImageElement\n static get image() {\n if (!ConnectionStateSubscription._image) {\n ConnectionStateSubscription._image = new Image()\n ConnectionStateSubscription._image.src = new URL(\n '../icons/symbol-connection-state-subscription.png',\n import.meta.url\n ).href\n }\n\n return ConnectionStateSubscription._image\n }\n\n private subscription?: {\n unsubscribe(): void\n }\n\n dispose() {\n super.dispose()\n\n this.subscription?.unsubscribe()\n delete this.subscription\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n this.drawImage(context, ConnectionStateSubscription.image, left, top, width, height)\n }\n\n ready() {\n if (!this.app.isViewMode) return\n this._initConnectionStateSubscription()\n }\n\n get nature() {\n return NATURE\n }\n\n _initConnectionStateSubscription() {\n if (!this.app.isViewMode) return\n this.startSubscribe()\n }\n\n async startSubscribe() {\n var { connectionName } = this.state\n\n this.subscription = await subscribe(\n {\n query: gql`subscription {\n connectionState(name: \"${connectionName}\") {\n name\n state\n timestamp\n }\n }`\n },\n {\n next: async ({ data }: { data: any }) => {\n if (data) {\n this.data = data.connectionState\n }\n }\n }\n )\n }\n}\n\nComponent.register('connection-state-subscription', ConnectionStateSubscription)\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-subscription.js","sourceRoot":"","sources":["../src/data-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"data-subscription.js","sourceRoot":"","sources":["../src/data-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAA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AM,CAAC,CAAA;IAC3E,CAAC;IAED,KAAK;QACH,IAAI,CAAC,qBAAqB,EAAE,CAAA;IAC9B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA;IACvB,CAAC;IAED,IAAI,GAAG,CAAC,GAAG;QACT,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED,qBAAqB;QACnB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU;YAAE,OAAM;QAEhC,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAExB,IAAI,CAAC,YAAY,GAAG,MAAM,SAAS,CACjC;YACE,KAAK,EAAE,GAAG,CAAA;;yBAEO,GAAG;;;;;SAKnB;SACF,EACD;YACE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAiB,EAAE,EAAE;gBACtC,IAAI,IAAI,EAAE;oBACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;iBAC3B;YACH,CAAC;SACF,CACF,CAAA;IACH,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, DataSource, RectPath, Shape } from '@hatiolab/things-scene'\nimport { subscribe } from '@operato/graphql'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'string',\n label: 'tag',\n name: 'tag'\n }\n ],\n 'value-property': 'tag',\n help: 'scene/component/data-subscription'\n}\n\nexport default class DataSubscription extends DataSource(RectPath(Shape)) {\n static _image: HTMLImageElement\n static get image() {\n if (!DataSubscription._image) {\n DataSubscription._image = new Image()\n DataSubscription._image.src = new URL('../icons/symbol-data-subscription.png', import.meta.url).href\n }\n\n return DataSubscription._image\n }\n\n private subscription?: {\n unsubscribe(): void\n }\n\n dispose() {\n this.subscription?.unsubscribe()\n delete this.subscription\n\n super.dispose()\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n this.drawImage(context, DataSubscription.image, left, top, width, height)\n }\n\n ready() {\n this._initDataSubscription()\n }\n\n get nature() {\n return NATURE\n }\n\n get tag() {\n return this.state.tag\n }\n\n set tag(tag) {\n this.setState('tag', tag)\n }\n\n _initDataSubscription() {\n if (!this.app.isViewMode) return\n\n this.startSubscribe()\n }\n\n async startSubscribe() {\n var { tag } = this.state\n\n this.subscription = await subscribe(\n {\n query: gql`\n subscription {\n data(tag: \"${tag}\") {\n tag\n data\n }\n }\n `\n },\n {\n next: async ({ data }: { data: any }) => {\n if (data) {\n this.data = data.data.data\n }\n }\n }\n )\n }\n}\n\nComponent.register('data-subscription', DataSubscription)\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import DataSubscription from './data-subscription';
|
|
2
2
|
import ScenarioControl from './scenario-control';
|
|
3
3
|
import ScenarioRun from './scenario-run';
|
|
4
|
-
import ScenarioStart from './scenario-start';
|
|
5
4
|
import ScenarioStop from './scenario-stop';
|
|
6
5
|
import ScenarioInstanceSubscription from './scenario-instance-subscription';
|
|
7
6
|
import ScenarioQueueSubscription from './scenario-queue-subscription';
|
|
8
7
|
import ConnectionStateSubscription from './connection-state-subscription';
|
|
9
8
|
import ConnectionControl from './connection-control';
|
|
10
|
-
declare const _default: (typeof ConnectionControl | typeof ConnectionStateSubscription | typeof DataSubscription | typeof ScenarioControl | typeof ScenarioRun | typeof
|
|
9
|
+
declare const _default: (typeof ConnectionControl | typeof ConnectionStateSubscription | typeof DataSubscription | typeof ScenarioControl | typeof ScenarioRun | typeof ScenarioStop | typeof ScenarioInstanceSubscription | typeof ScenarioQueueSubscription)[];
|
|
11
10
|
export default _default;
|
|
@@ -6,14 +6,10 @@ declare const ScenarioControl_base: (new (...args: any[]) => {
|
|
|
6
6
|
export default class ScenarioControl extends ScenarioControl_base {
|
|
7
7
|
static _image: HTMLImageElement;
|
|
8
8
|
static get image(): HTMLImageElement;
|
|
9
|
-
private _client;
|
|
10
9
|
render(context: CanvasRenderingContext2D): void;
|
|
11
10
|
ready(): void;
|
|
12
|
-
_initScenario(): void;
|
|
13
|
-
dispose(): void;
|
|
14
11
|
get nature(): ComponentNature;
|
|
15
12
|
onchange(after: Properties): void;
|
|
16
|
-
get client(): any;
|
|
17
13
|
get controlType(): any;
|
|
18
14
|
set controlType(controlType: any);
|
|
19
15
|
requestData(): Promise<void>;
|
package/dist/scenario-control.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { Component, DataSource, RectPath, Shape } from '@hatiolab/things-scene';
|
|
3
|
+
import { client } from '@operato/graphql';
|
|
3
4
|
import { scenarios } from './client-api';
|
|
4
|
-
import { getClient } from './origin-client';
|
|
5
5
|
const NATURE = {
|
|
6
6
|
mutable: false,
|
|
7
7
|
resizable: true,
|
|
@@ -55,25 +55,9 @@ export default class ScenarioControl extends DataSource(RectPath(Shape)) {
|
|
|
55
55
|
}
|
|
56
56
|
ready() {
|
|
57
57
|
super.ready();
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
_initScenario() {
|
|
61
|
-
if (!this.app.isViewMode)
|
|
62
|
-
return;
|
|
63
|
-
this._client = getClient();
|
|
64
|
-
this.requestData();
|
|
65
|
-
}
|
|
66
|
-
dispose() {
|
|
67
|
-
super.dispose();
|
|
68
|
-
try {
|
|
69
|
-
if (this._client) {
|
|
70
|
-
this._client.stop();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
console.error(e);
|
|
58
|
+
if (this.app.isViewMode) {
|
|
59
|
+
this.requestData();
|
|
75
60
|
}
|
|
76
|
-
delete this._client;
|
|
77
61
|
}
|
|
78
62
|
get nature() {
|
|
79
63
|
return NATURE;
|
|
@@ -83,9 +67,6 @@ export default class ScenarioControl extends DataSource(RectPath(Shape)) {
|
|
|
83
67
|
this.requestData();
|
|
84
68
|
}
|
|
85
69
|
}
|
|
86
|
-
get client() {
|
|
87
|
-
return this._client;
|
|
88
|
-
}
|
|
89
70
|
get controlType() {
|
|
90
71
|
return this.getState('controlType');
|
|
91
72
|
}
|
|
@@ -94,9 +75,9 @@ export default class ScenarioControl extends DataSource(RectPath(Shape)) {
|
|
|
94
75
|
}
|
|
95
76
|
async requestData() {
|
|
96
77
|
let { controlType, scenarioName } = this.state;
|
|
97
|
-
if (!controlType || !scenarioName || !this.app.isViewMode)
|
|
78
|
+
if (!controlType || !scenarioName || !this.app.isViewMode) {
|
|
98
79
|
return;
|
|
99
|
-
|
|
80
|
+
}
|
|
100
81
|
var query = '';
|
|
101
82
|
if (controlType == 'start') {
|
|
102
83
|
query = `mutation{
|
|
@@ -112,14 +93,12 @@ export default class ScenarioControl extends DataSource(RectPath(Shape)) {
|
|
|
112
93
|
}
|
|
113
94
|
}`;
|
|
114
95
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.data = response;
|
|
122
|
-
}
|
|
96
|
+
var response = await client.query({
|
|
97
|
+
query: gql `
|
|
98
|
+
${query}
|
|
99
|
+
`
|
|
100
|
+
});
|
|
101
|
+
this.data = response;
|
|
123
102
|
}
|
|
124
103
|
}
|
|
125
104
|
Component.register('scenario-control', ScenarioControl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenario-control.js","sourceRoot":"","sources":["../src/scenario-control.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAc,QAAQ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AAY,qBAAqB,YAAY;;;QAGrF,CAAA;SACH;aAAM;YACL,KAAK,GAAG;UACJ,WAAW,2BAA2B,YAAY;;;QAGpD,CAAA;SACH;QAED,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;YAChC,KAAK,EAAE,GAAG,CAAA;UACN,KAAK;OACR;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;IACtB,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, DataSource, Properties, RectPath, Shape } from '@hatiolab/things-scene'\nimport { client } from '@operato/graphql'\n\nimport { scenarios } from './client-api'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'scenario-name',\n name: 'scenarioName',\n property: {\n options: scenarios\n }\n },\n {\n type: 'select',\n label: 'control-type',\n name: 'controlType',\n property: {\n options: [\n {\n display: '',\n value: ''\n },\n {\n display: 'start',\n value: 'start'\n },\n {\n display: 'stop',\n value: 'stop'\n }\n ]\n }\n }\n ],\n 'value-property': 'controlType',\n help: 'scene/component/scenario-control'\n}\n\nexport default class ScenarioControl extends DataSource(RectPath(Shape)) {\n static _image: HTMLImageElement\n\n static get image() {\n if (!ScenarioControl._image) {\n ScenarioControl._image = new Image()\n ScenarioControl._image.src = new URL('../icons/symbol-scenario-control.png', import.meta.url).href\n }\n return ScenarioControl._image\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n context.beginPath()\n this.drawImage(context, ScenarioControl.image, left, top, width, height)\n }\n\n ready() {\n super.ready()\n\n if (this.app.isViewMode) {\n this.requestData()\n }\n }\n\n get nature() {\n return NATURE\n }\n\n onchange(after: Properties) {\n if ('controlType' in after) {\n this.requestData()\n }\n }\n\n get controlType() {\n return this.getState('controlType')\n }\n\n set controlType(controlType) {\n this.setState('controlType', controlType)\n }\n\n async requestData() {\n let { controlType, scenarioName } = this.state\n if (!controlType || !scenarioName || !this.app.isViewMode) {\n return\n }\n\n var query = ''\n if (controlType == 'start') {\n query = `mutation{\n ${controlType}Scenario(instanceName: \"${scenarioName}\", scenarioName: \"${scenarioName}\", variables: {}) {\n state\n }\n }`\n } else {\n query = `mutation{\n ${controlType}Scenario(instanceName: \"${scenarioName}\") {\n state\n }\n }`\n }\n\n var response = await client.query({\n query: gql`\n ${query}\n `\n })\n\n this.data = response\n }\n}\n\nComponent.register('scenario-control', ScenarioControl)\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { Component, DataSource, RectPath, Shape } from '@hatiolab/things-scene';
|
|
3
|
+
import { subscribe } from '@operato/graphql';
|
|
3
4
|
import { scenarios } from './client-api';
|
|
4
|
-
import { subscribe } from './origin-client';
|
|
5
5
|
const NATURE = {
|
|
6
6
|
mutable: false,
|
|
7
7
|
resizable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenario-instance-subscription.js","sourceRoot":"","sources":["../src/scenario-instance-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"scenario-instance-subscription.js","sourceRoot":"","sources":["../src/scenario-instance-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,MAAM,GAAoB;IAC9B,OAAO,E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AAE,OAAM;QAChC,IAAI,CAAC,iCAAiC,EAAE,CAAA;IAC1C,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;IAED,iCAAiC;QAC/B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU;YAAE,OAAM;QAChC,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,IAAI,EAAE,YAAY,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAEpD,YAAY,GAAG,YAAY,IAAI,YAAY,CAAA;QAE3C,IAAI,CAAC,YAAY,GAAG,MAAM,SAAS,CACjC;YACE,KAAK,EAAE,GAAG,CAAA;;iDAE+B,YAAY,qBAAqB,YAAY;;;;;;;;;;;;;;;;OAgBvF;SACA,EACD;YACE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAiB,EAAE,EAAE;gBACtC,IAAI,IAAI,EAAE;oBACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,qBAAqB,CAAA;iBACvC;YACH,CAAC;SACF,CACF,CAAA;IACH,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,gCAAgC,EAAE,4BAA4B,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, DataSource, RectPath, Shape } from '@hatiolab/things-scene'\nimport { subscribe } from '@operato/graphql'\n\nimport { scenarios } from './client-api'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'scenario-name',\n name: 'scenarioName',\n property: {\n options: scenarios\n }\n },\n {\n type: 'string',\n label: 'instance-name',\n name: 'instanceName'\n }\n ],\n help: 'scene/component/scenario-instance-subscription'\n}\n\nexport default class ScenarioInstanceSubscription extends DataSource(RectPath(Shape)) {\n static _image: HTMLImageElement\n\n static get image() {\n if (!ScenarioInstanceSubscription._image) {\n ScenarioInstanceSubscription._image = new Image()\n ScenarioInstanceSubscription._image.src = new URL(\n '../icons/symbol-scenario-instance-subscription.png',\n import.meta.url\n ).href\n }\n\n return ScenarioInstanceSubscription._image\n }\n\n private subscription?: {\n unsubscribe(): void\n }\n\n dispose() {\n super.dispose()\n\n this.subscription?.unsubscribe()\n delete this.subscription\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n this.drawImage(context, ScenarioInstanceSubscription.image, left, top, width, height)\n }\n\n ready() {\n if (!this.app.isViewMode) return\n this._initScenarioInstanceSubscription()\n }\n\n get nature() {\n return NATURE\n }\n\n _initScenarioInstanceSubscription() {\n if (!this.app.isViewMode) return\n this.startSubscribe()\n }\n\n async startSubscribe() {\n var { instanceName, scenarioName = '' } = this.state\n\n instanceName = instanceName || scenarioName\n\n this.subscription = await subscribe(\n {\n query: gql`\n subscription {\n scenarioInstanceState(instanceName: \"${instanceName}\", scenarioName: \"${scenarioName}\") {\n instanceName\n scenarioName\n state\n variables\n progress{\n rounds\n rate\n steps\n step\n }\n data\n message\n timestamp\n }\n }\n `\n },\n {\n next: async ({ data }: { data: any }) => {\n if (data) {\n this.data = data.scenarioInstanceState\n }\n }\n }\n )\n }\n}\n\nComponent.register('scenario-instance-subscription', ScenarioInstanceSubscription)\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenario-queue-subscription.js","sourceRoot":"","sources":["../src/scenario-queue-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"scenario-queue-subscription.js","sourceRoot":"","sources":["../src/scenario-queue-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAE,QAAQ,EA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OAAO,MAAM,CAAA;IACf,CAAC;IAED,8BAA8B;QAC5B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU;YAAE,OAAM;QAChC,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,IAAI,CAAC,YAAY,GAAG,MAAM,SAAS,CACjC;YACE,KAAK,EAAE,GAAG,CAAA;;;;;;;;;;;SAWT;SACF,EACD;YACE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAiB,EAAE,EAAE;gBACtC,IAAI,IAAI,EAAE;oBACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAA;iBACpC;YACH,CAAC;SACF,CACF,CAAA;IACH,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,6BAA6B,EAAE,yBAAyB,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, DataSource, RectPath, Shape } from '@hatiolab/things-scene'\nimport { subscribe } from '@operato/graphql'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [],\n help: 'scene/component/scenario-queue-subscription'\n}\n\nexport default class ScenarioQueueSubscription extends DataSource(RectPath(Shape)) {\n static _image: HTMLImageElement\n\n static get image() {\n if (!ScenarioQueueSubscription._image) {\n ScenarioQueueSubscription._image = new Image()\n ScenarioQueueSubscription._image.src = new URL(\n '../icons/symbol-scenario-queue-subscription.png',\n import.meta.url\n ).href\n }\n\n return ScenarioQueueSubscription._image\n }\n\n private subscription?: {\n unsubscribe(): void\n }\n\n dispose() {\n super.dispose()\n\n this.subscription?.unsubscribe()\n delete this.subscription\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n context.beginPath()\n this.drawImage(context, ScenarioQueueSubscription.image, left, top, width, height)\n }\n\n ready() {\n if (!this.app.isViewMode) return\n this._initScenarioQueueSubscription()\n }\n\n get nature() {\n return NATURE\n }\n\n _initScenarioQueueSubscription() {\n if (!this.app.isViewMode) return\n this.startSubscribe()\n }\n\n async startSubscribe() {\n this.subscription = await subscribe(\n {\n query: gql`\n subscription {\n scenarioQueueState {\n queue {\n stuff\n due\n priority\n tag\n }\n }\n }\n `\n },\n {\n next: async ({ data }: { data: any }) => {\n if (data) {\n this.data = data.scenarioQueueState\n }\n }\n }\n )\n }\n}\n\nComponent.register('scenario-queue-subscription', ScenarioQueueSubscription)\n"]}
|
package/dist/scenario-run.d.ts
CHANGED
|
@@ -6,16 +6,12 @@ declare const ScenarioRun_base: (new (...args: any[]) => {
|
|
|
6
6
|
export default class ScenarioRun extends ScenarioRun_base {
|
|
7
7
|
static _image: HTMLImageElement;
|
|
8
8
|
static get image(): HTMLImageElement;
|
|
9
|
-
private _client;
|
|
10
9
|
render(context: CanvasRenderingContext2D): void;
|
|
11
10
|
ready(): void;
|
|
12
|
-
_initScenario(): void;
|
|
13
|
-
dispose(): void;
|
|
14
11
|
get nature(): ComponentNature;
|
|
15
12
|
onchange(after: Properties): void;
|
|
16
13
|
get variables(): any;
|
|
17
14
|
set variables(variables: any);
|
|
18
|
-
get client(): any;
|
|
19
15
|
requestData(): Promise<void>;
|
|
20
16
|
}
|
|
21
17
|
export {};
|
package/dist/scenario-run.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { Component, DataSource, RectPath, Shape } from '@hatiolab/things-scene';
|
|
3
|
+
import { client } from '@operato/graphql';
|
|
3
4
|
import { scenarios } from './client-api';
|
|
4
|
-
import { getClient } from './origin-client';
|
|
5
5
|
const NATURE = {
|
|
6
6
|
mutable: false,
|
|
7
7
|
resizable: true,
|
|
@@ -44,28 +44,11 @@ export default class ScenarioRun extends DataSource(RectPath(Shape)) {
|
|
|
44
44
|
}
|
|
45
45
|
ready() {
|
|
46
46
|
super.ready();
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (!this.app.isViewMode) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
this._client = getClient();
|
|
54
|
-
if (this.state.runOnStart) {
|
|
55
|
-
this.requestData();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
dispose() {
|
|
59
|
-
super.dispose();
|
|
60
|
-
try {
|
|
61
|
-
if (this._client) {
|
|
62
|
-
this._client.stop();
|
|
47
|
+
if (this.app.isViewMode) {
|
|
48
|
+
if (this.state.runOnStart) {
|
|
49
|
+
this.requestData();
|
|
63
50
|
}
|
|
64
51
|
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
console.error(e);
|
|
67
|
-
}
|
|
68
|
-
delete this._client;
|
|
69
52
|
}
|
|
70
53
|
get nature() {
|
|
71
54
|
return NATURE;
|
|
@@ -81,15 +64,12 @@ export default class ScenarioRun extends DataSource(RectPath(Shape)) {
|
|
|
81
64
|
set variables(variables) {
|
|
82
65
|
this.setState('variables', variables);
|
|
83
66
|
}
|
|
84
|
-
get client() {
|
|
85
|
-
return this._client;
|
|
86
|
-
}
|
|
87
67
|
async requestData() {
|
|
88
68
|
var _a, _b;
|
|
89
69
|
let { scenarioName, variables } = this.state;
|
|
90
|
-
if (!scenarioName || !this.app.isViewMode)
|
|
70
|
+
if (!scenarioName || !this.app.isViewMode) {
|
|
91
71
|
return;
|
|
92
|
-
|
|
72
|
+
}
|
|
93
73
|
try {
|
|
94
74
|
variables = typeof variables == 'string' ? JSON.parse(variables) : variables;
|
|
95
75
|
}
|
package/dist/scenario-run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scenario-run.js","sourceRoot":"","sources":["../src/scenario-run.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,SAAS,EAAmB,UAAU,EAAc,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"scenario-run.js","sourceRoot":"","sources":["../src/scenario-run.ts"],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;;;;SAQT;gBACD,SAAS,EAAE;oBACT,YAAY,EAAE,YAAY;oBAC1B,SAAS;iBACV;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,IAAI,GAAG,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,WAAW,0CAAE,IAAI,CAAA;SAC9C;IACH,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, DataSource, Properties, RectPath, Shape } from '@hatiolab/things-scene'\nimport { client } from '@operato/graphql'\n\nimport { scenarios } from './client-api'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'scenario-name',\n name: 'scenarioName',\n property: {\n options: scenarios\n }\n },\n {\n type: 'data',\n label: 'variables',\n name: 'variables'\n },\n {\n type: 'checkbox',\n label: 'run-on-start',\n name: 'runOnStart'\n }\n ],\n 'value-property': 'variables',\n help: 'scene/component/scenario-run'\n}\n\nexport default class ScenarioRun extends DataSource(RectPath(Shape)) {\n static _image: HTMLImageElement\n\n static get image() {\n if (!ScenarioRun._image) {\n ScenarioRun._image = new Image()\n ScenarioRun._image.src = new URL('../icons/symbol-scenario-run.png', import.meta.url).href\n }\n return ScenarioRun._image\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n context.beginPath()\n this.drawImage(context, ScenarioRun.image, left, top, width, height)\n }\n\n ready() {\n super.ready()\n\n if (this.app.isViewMode) {\n if (this.state.runOnStart) {\n this.requestData()\n }\n }\n }\n\n get nature() {\n return NATURE\n }\n\n onchange(after: Properties) {\n if ('variables' in after) {\n this.requestData()\n }\n }\n\n get variables() {\n return this.state.variables\n }\n\n set variables(variables) {\n this.setState('variables', variables)\n }\n\n async requestData() {\n let { scenarioName, variables } = this.state\n if (!scenarioName || !this.app.isViewMode) {\n return\n }\n\n try {\n variables = typeof variables == 'string' ? JSON.parse(variables) : variables\n } catch (e) {\n console.warn('runScenario mutation variable is not an object')\n }\n\n if (client) {\n var response = await client.query({\n query: gql`\n mutation ($scenarioName: String!, $variables: Object) {\n runScenario(scenarioName: $scenarioName, variables: $variables) {\n state\n message\n data\n }\n }\n `,\n variables: {\n scenarioName: scenarioName,\n variables\n }\n })\n\n this.data = response?.data?.runScenario?.data\n }\n }\n}\n\nComponent.register('scenario-run', ScenarioRun)\n"]}
|
package/dist/scenario-start.d.ts
CHANGED
|
@@ -6,16 +6,11 @@ declare const ScenarioStart_base: (new (...args: any[]) => {
|
|
|
6
6
|
export default class ScenarioStart extends ScenarioStart_base {
|
|
7
7
|
static _image: HTMLImageElement;
|
|
8
8
|
static get image(): HTMLImageElement;
|
|
9
|
-
private _client;
|
|
10
9
|
render(context: CanvasRenderingContext2D): void;
|
|
11
|
-
ready(): void;
|
|
12
|
-
_initScenario(): void;
|
|
13
|
-
dispose(): void;
|
|
14
10
|
get nature(): ComponentNature;
|
|
15
11
|
onchange(after: Properties): Promise<void>;
|
|
16
12
|
get variables(): any;
|
|
17
13
|
set variables(variables: any);
|
|
18
|
-
get client(): any;
|
|
19
14
|
requestData(): Promise<void>;
|
|
20
15
|
}
|
|
21
16
|
export {};
|
package/dist/scenario-start.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
2
|
import { Component, DataSource, RectPath, Shape } from '@hatiolab/things-scene';
|
|
3
|
+
import { client } from '@operato/graphql';
|
|
3
4
|
import { scenarios } from './client-api';
|
|
4
|
-
import { getClient } from './origin-client';
|
|
5
5
|
const NATURE = {
|
|
6
6
|
mutable: false,
|
|
7
7
|
resizable: true,
|
|
@@ -42,28 +42,6 @@ export default class ScenarioStart extends DataSource(RectPath(Shape)) {
|
|
|
42
42
|
context.beginPath();
|
|
43
43
|
this.drawImage(context, ScenarioStart.image, left, top, width, height);
|
|
44
44
|
}
|
|
45
|
-
ready() {
|
|
46
|
-
super.ready();
|
|
47
|
-
this._initScenario();
|
|
48
|
-
}
|
|
49
|
-
_initScenario() {
|
|
50
|
-
if (!this.app.isViewMode) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
this._client = getClient();
|
|
54
|
-
}
|
|
55
|
-
dispose() {
|
|
56
|
-
super.dispose();
|
|
57
|
-
try {
|
|
58
|
-
if (this._client) {
|
|
59
|
-
this._client.stop();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
console.error(e);
|
|
64
|
-
}
|
|
65
|
-
delete this._client;
|
|
66
|
-
}
|
|
67
45
|
get nature() {
|
|
68
46
|
return NATURE;
|
|
69
47
|
}
|
|
@@ -78,15 +56,11 @@ export default class ScenarioStart extends DataSource(RectPath(Shape)) {
|
|
|
78
56
|
set variables(variables) {
|
|
79
57
|
this.setState('variables', variables);
|
|
80
58
|
}
|
|
81
|
-
get client() {
|
|
82
|
-
return this._client;
|
|
83
|
-
}
|
|
84
59
|
async requestData() {
|
|
85
60
|
var _a, _b;
|
|
86
61
|
let { instanceName, scenarioName, variables } = this.state;
|
|
87
62
|
if (!scenarioName || !this.app.isViewMode)
|
|
88
63
|
return;
|
|
89
|
-
var client = this._client;
|
|
90
64
|
try {
|
|
91
65
|
variables = typeof variables == 'string' ? JSON.parse(variables) : variables;
|
|
92
66
|
}
|