@things-factory/integration-ui 6.1.66 → 6.1.71
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/client/editors/{entity-editor.js → entity-editor.ts} +2 -2
- package/client/editors/{entity-selector.js → entity-selector.ts} +45 -57
- package/client/editors/{property-editor.js → property-editor.ts} +1 -0
- package/client/editors/{things-editor-entity-selector.js → things-editor-entity-selector.ts} +27 -31
- package/client/editors/{things-editor-http-body.js → things-editor-http-body.ts} +43 -48
- package/client/editors/{things-editor-http-headers.js → things-editor-http-headers.ts} +48 -58
- package/client/editors/{things-editor-http-parameters.js → things-editor-http-parameters.ts} +48 -58
- package/client/grist/{connection-selector.js → connection-selector.ts} +2 -2
- package/client/grist/{connector-selector.js → connector-selector.ts} +2 -2
- package/client/grist/{dynamic-selector.js → dynamic-selector.ts} +9 -7
- package/client/grist/{task-type-selector.js → task-type-selector.ts} +4 -2
- package/client/index.ts +2 -0
- package/client/pages/{connection.js → connection.ts} +39 -45
- package/client/pages/{integration-monitor.js → integration-monitor.ts} +54 -56
- package/client/pages/{scenario-detail.js → scenario-detail.ts} +41 -47
- package/client/pages/scenario-importer.ts +107 -0
- package/client/pages/{scenario.js → scenario.ts} +15 -21
- package/client/viewparts/{connections-monitor.js → connections-monitor.ts} +76 -82
- package/client/viewparts/{monitoring-summary.js → monitoring-summary.ts} +55 -61
- package/client/viewparts/{pending-q-monitor.js → pending-q-monitor.ts} +110 -114
- package/client/viewparts/{scenario-instance-log-view.js → scenario-instance-log-view.ts} +31 -35
- package/client/viewparts/{scenario-instance-monitor.js → scenario-instance-monitor.ts} +67 -73
- package/client/viewparts/{scenario-instance-view.js → scenario-instance-view.ts} +100 -104
- package/client/viewparts/{scenario-monitor.js → scenario-monitor.ts} +143 -149
- package/client/viewparts/scenarios-monitor.ts +147 -0
- package/dist-client/bootstrap.d.ts +4 -0
- package/dist-client/bootstrap.js +29 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/editors/entity-editor.d.ts +10 -0
- package/dist-client/editors/entity-editor.js +47 -0
- package/dist-client/editors/entity-editor.js.map +1 -0
- package/dist-client/editors/entity-selector.d.ts +34 -0
- package/dist-client/editors/entity-selector.js +305 -0
- package/dist-client/editors/entity-selector.js.map +1 -0
- package/dist-client/editors/property-editor.d.ts +20 -0
- package/dist-client/editors/property-editor.js +61 -0
- package/dist-client/editors/property-editor.js.map +1 -0
- package/dist-client/editors/things-editor-entity-selector.d.ts +15 -0
- package/dist-client/editors/things-editor-entity-selector.js +87 -0
- package/dist-client/editors/things-editor-entity-selector.js.map +1 -0
- package/dist-client/editors/things-editor-http-body.d.ts +22 -0
- package/dist-client/editors/things-editor-http-body.js +130 -0
- package/dist-client/editors/things-editor-http-body.js.map +1 -0
- package/dist-client/editors/things-editor-http-headers.d.ts +29 -0
- package/dist-client/editors/things-editor-http-headers.js +160 -0
- package/dist-client/editors/things-editor-http-headers.js.map +1 -0
- package/dist-client/editors/things-editor-http-parameters.d.ts +29 -0
- package/dist-client/editors/things-editor-http-parameters.js +160 -0
- package/dist-client/editors/things-editor-http-parameters.js.map +1 -0
- package/dist-client/grist/connection-selector.d.ts +5 -0
- package/dist-client/grist/connection-selector.js +31 -0
- package/dist-client/grist/connection-selector.js.map +1 -0
- package/dist-client/grist/connector-selector.d.ts +5 -0
- package/dist-client/grist/connector-selector.js +31 -0
- package/dist-client/grist/connector-selector.js.map +1 -0
- package/dist-client/grist/dynamic-selector.d.ts +8 -0
- package/dist-client/grist/dynamic-selector.js +33 -0
- package/dist-client/grist/dynamic-selector.js.map +1 -0
- package/dist-client/grist/task-type-selector.d.ts +7 -0
- package/dist-client/grist/task-type-selector.js +58 -0
- package/dist-client/grist/task-type-selector.js.map +1 -0
- package/dist-client/index.d.ts +2 -0
- package/dist-client/index.js +3 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/connection.d.ts +53 -0
- package/dist-client/pages/connection.js +429 -0
- package/dist-client/pages/connection.js.map +1 -0
- package/dist-client/pages/integration-monitor.d.ts +28 -0
- package/dist-client/pages/integration-monitor.js +340 -0
- package/dist-client/pages/integration-monitor.js.map +1 -0
- package/dist-client/pages/scenario-detail.d.ts +1 -0
- package/dist-client/pages/scenario-detail.js +303 -0
- package/dist-client/pages/scenario-detail.js.map +1 -0
- package/dist-client/pages/scenario-importer.d.ts +9 -0
- package/dist-client/pages/scenario-importer.js +116 -0
- package/dist-client/pages/scenario-importer.js.map +1 -0
- package/dist-client/pages/scenario.d.ts +68 -0
- package/dist-client/pages/scenario.js +582 -0
- package/dist-client/pages/scenario.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +14 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-client/viewparts/connections-monitor.d.ts +10 -0
- package/dist-client/viewparts/connections-monitor.js +169 -0
- package/dist-client/viewparts/connections-monitor.js.map +1 -0
- package/dist-client/viewparts/monitoring-summary.d.ts +12 -0
- package/dist-client/viewparts/monitoring-summary.js +135 -0
- package/dist-client/viewparts/monitoring-summary.js.map +1 -0
- package/dist-client/viewparts/pending-q-monitor.d.ts +17 -0
- package/dist-client/viewparts/pending-q-monitor.js +247 -0
- package/dist-client/viewparts/pending-q-monitor.js.map +1 -0
- package/dist-client/viewparts/scenario-instance-log-view.d.ts +21 -0
- package/dist-client/viewparts/scenario-instance-log-view.js +105 -0
- package/dist-client/viewparts/scenario-instance-log-view.js.map +1 -0
- package/dist-client/viewparts/scenario-instance-monitor.d.ts +15 -0
- package/dist-client/viewparts/scenario-instance-monitor.js +171 -0
- package/dist-client/viewparts/scenario-instance-monitor.js.map +1 -0
- package/dist-client/viewparts/scenario-instance-view.d.ts +29 -0
- package/dist-client/viewparts/scenario-instance-view.js +263 -0
- package/dist-client/viewparts/scenario-instance-view.js.map +1 -0
- package/dist-client/viewparts/scenario-monitor.d.ts +16 -0
- package/dist-client/viewparts/scenario-monitor.js +288 -0
- package/dist-client/viewparts/scenario-monitor.js.map +1 -0
- package/dist-client/viewparts/scenarios-monitor.d.ts +16 -0
- package/dist-client/viewparts/scenarios-monitor.js +167 -0
- package/dist-client/viewparts/scenarios-monitor.js.map +1 -0
- package/package.json +10 -7
- package/client/index.js +0 -0
- package/client/pages/scenario-importer.js +0 -118
- package/client/viewparts/scenarios-monitor.js +0 -153
- /package/client/{bootstrap.js → bootstrap.ts} +0 -0
- /package/client/{route.js → route.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitoring-summary.js","sourceRoot":"","sources":["../../client/viewparts/monitoring-summary.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAG1C,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC;IAkE7E,MAAM;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;QACpC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAA;QACtC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAA;QAE1C,MAAM,KAAK,GAAG;YACZ;gBACE,KAAK,EAAE,mBAAmB;gBAC1B,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,QAAQ,CAAC,MAAM;aACvB;YACD;gBACE,KAAK,EAAE,mBAAmB;gBAC1B,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,IAAI,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwDF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;8DAAc;AACxC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;+DAAe;AACzC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;iEAAiB;AAhEhC,4BAA4B;IADxC,aAAa,CAAC,qBAAqB,CAAC;GACxB,4BAA4B,CA0HxC;SA1HY,4BAA4B","sourcesContent":["import '@operato/data-grist'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { i18next, localize } from '@operato/i18n'\nimport { ScrollbarStyles } from '@operato/styles'\n\n@customElement('integration-summary')\nexport class IntegrationMonitoringSummary extends localize(i18next)(LitElement) {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: row;\n\n overflow: hidden;\n background-color: var(--paper-grey-800);\n border-radius: var(--border-radius);\n color: var(--opacity-light-color);\n }\n\n [card] {\n flex: 1;\n margin: var(--margin-default);\n padding: var(--padding-narrow) var(--padding-default);\n border-right: var(--border-light-color);\n }\n :host :last-child {\n border-right: none;\n }\n strong {\n font-size: 36px;\n line-height: 30px;\n color: var(--theme-white-color);\n }\n span {\n display: block;\n margin-bottom: var(--margin-narrow);\n font-size: var(--fontsize-small);\n text-transform: capitalize;\n }\n @media screen and (max-width: 480px) {\n :host {\n font-size: 0.8em;\n }\n [card] {\n margin: var(--margin-narrow);\n padding: var(--padding-narrow);\n }\n [card]:nth-child(5),\n [card]:nth-child(6) {\n display: none;\n }\n [card]:nth-child(4) {\n border-right: none;\n }\n mwc-icon {\n font-size: var(--fontsize-large);\n }\n span {\n line-height: 1;\n }\n strong {\n font-size: 24px;\n }\n }\n `\n ]\n\n @property({ type: Array }) pendings: any\n @property({ type: Array }) scenarios: any\n @property({ type: Array }) connections: any\n\n render() {\n const now = Date.now()\n const pendings = this.pendings || []\n const scenarios = this.scenarios || []\n const connections = this.connections || []\n\n const cards = [\n {\n title: 'pending instances',\n icon: 'update',\n value: pendings.length\n },\n {\n title: 'due out instances',\n icon: 'update_disabled',\n value: Math.max(\n 0,\n pendings.concat({ due: now + 1 }).findIndex(pending => Number(pending.due) > now)\n )\n },\n {\n title: 'total scenarios',\n icon: 'format_list_numbered',\n value: scenarios.length\n },\n {\n title: 'scenario instances',\n icon: 'list_alt',\n value: scenarios.reduce((total, scenario) => {\n return total + scenario.instances.length\n }, 0)\n },\n {\n title: 'connections',\n icon: 'device_hub',\n value: connections.length\n },\n {\n title: 'active connections',\n icon: 'fact_check',\n value: connections.filter(connection => connection.state == 'CONNECTED').length\n }\n ]\n\n return cards.map(({ title, icon, value }) => this.renderCard(title, icon, value))\n }\n\n renderCard(title, icon, value) {\n return html`\n <div card>\n <span>${title}</span>\n <mwc-icon>${icon}</mwc-icon>\n <strong> ${value}</strong>\n </div>\n `\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class PendingQMonitor extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult[];
|
|
4
|
+
pendings: any;
|
|
5
|
+
filteredPendings: any;
|
|
6
|
+
colorIndex: any;
|
|
7
|
+
running?: boolean;
|
|
8
|
+
tags: any;
|
|
9
|
+
tag?: string;
|
|
10
|
+
scales: any;
|
|
11
|
+
filterPendings: any;
|
|
12
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
13
|
+
queue(): AsyncGenerator<import("lit-html").TemplateResult<1>[], void, unknown>;
|
|
14
|
+
countdown(due: any, now: any): string;
|
|
15
|
+
buildFilterPendings(): void;
|
|
16
|
+
updated(changes: any): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { __asyncGenerator, __await, __decorate, __metadata } from "tslib";
|
|
2
|
+
import { css, html, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { asyncReplace } from 'lit/directives/async-replace.js';
|
|
5
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
6
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
7
|
+
import { sleep } from '@operato/utils';
|
|
8
|
+
let PendingQMonitor = class PendingQMonitor extends LitElement {
|
|
9
|
+
render() {
|
|
10
|
+
const tag = this.tag === undefined ? '(*)' : this.tag;
|
|
11
|
+
const scales = this.scales || [];
|
|
12
|
+
return html `
|
|
13
|
+
<div tags>
|
|
14
|
+
<mwc-icon>bookmark_border</mwc-icon>
|
|
15
|
+
<select @change=${e => (this.tag = e.target.value)} .value=${tag}>
|
|
16
|
+
<option value="(*)">*</option>
|
|
17
|
+
${Object.keys(this.tags || {})
|
|
18
|
+
.sort()
|
|
19
|
+
.map(tag => html `<option value=${tag}>${tag}</option>`)}
|
|
20
|
+
</select>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div pendings>
|
|
24
|
+
<div timeline>
|
|
25
|
+
<table>
|
|
26
|
+
${unsafeHTML(scales.map(time => `
|
|
27
|
+
<tr>
|
|
28
|
+
<th><span>${time}</span></th>
|
|
29
|
+
<td></td>
|
|
30
|
+
</tr>
|
|
31
|
+
`).join(`
|
|
32
|
+
<tr>
|
|
33
|
+
<th></th>
|
|
34
|
+
<td></td>
|
|
35
|
+
</tr>
|
|
36
|
+
<tr>
|
|
37
|
+
<th></th>
|
|
38
|
+
<td></td>
|
|
39
|
+
</tr>
|
|
40
|
+
`))}
|
|
41
|
+
</table>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div pending-wrap>${asyncReplace(this.queue())}</div>
|
|
45
|
+
</div>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
queue() {
|
|
49
|
+
return __asyncGenerator(this, arguments, function* queue_1() {
|
|
50
|
+
while (this.running) {
|
|
51
|
+
var now = Date.now();
|
|
52
|
+
var pendingsByTags = Object.values(this.filterPendings || {});
|
|
53
|
+
yield yield __await(pendingsByTags.map(pendings => html `
|
|
54
|
+
<div pendings-by-tag>
|
|
55
|
+
${pendings.map((pending, index) => {
|
|
56
|
+
var due = Number(pending.due);
|
|
57
|
+
var top = Math.max(Math.floor((due - now) / 1000) * 3, 0); /* 3px per second */
|
|
58
|
+
return html `
|
|
59
|
+
<div pending .style="top:${top}px;background-color:${this.colorIndex[pending.stuff.scenario]};">
|
|
60
|
+
${index == 0 ? html ` <div>${this.countdown(pending.due, now)}</div> ` : html ``}
|
|
61
|
+
</div>
|
|
62
|
+
`;
|
|
63
|
+
})}
|
|
64
|
+
</div>
|
|
65
|
+
`));
|
|
66
|
+
yield __await(sleep(1000));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
countdown(due, now) {
|
|
71
|
+
const MIN = 60;
|
|
72
|
+
var remain = (Number(due) - now) / 1000;
|
|
73
|
+
var normailzed = Math.floor(Math.abs(remain));
|
|
74
|
+
const mins = Math.floor(normailzed / MIN);
|
|
75
|
+
const secs = normailzed - mins * MIN;
|
|
76
|
+
return `${remain > 0 ? '' : '-'}${mins ? mins + 'm ' : ''}${secs}s`;
|
|
77
|
+
}
|
|
78
|
+
buildFilterPendings() {
|
|
79
|
+
var _a;
|
|
80
|
+
var filtered;
|
|
81
|
+
if (this.tag === undefined || this.tag == '(*)') {
|
|
82
|
+
filtered = this.pendings || [];
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
filtered = (this.pendings || []).filter(pending => pending.tag == this.tag);
|
|
86
|
+
}
|
|
87
|
+
const now = Date.now();
|
|
88
|
+
const lastdue = ((_a = filtered[filtered.length - 1]) === null || _a === void 0 ? void 0 : _a.due) || now;
|
|
89
|
+
const length = Math.max(5, Math.ceil((lastdue - now) / (1000 * 30 * 2) + 1));
|
|
90
|
+
this.scales = new Array(length)
|
|
91
|
+
.fill(0)
|
|
92
|
+
.map((_, index) => [`${String(index).padStart(2, '0')}:00`, `${String(index).padStart(2, '0')}:30`])
|
|
93
|
+
.flat();
|
|
94
|
+
this.filterPendings = filtered.reduce((sum, pending) => {
|
|
95
|
+
if (sum[pending.tag]) {
|
|
96
|
+
sum[pending.tag].push(pending);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
sum[pending.tag] = [pending];
|
|
100
|
+
}
|
|
101
|
+
return sum;
|
|
102
|
+
}, {});
|
|
103
|
+
}
|
|
104
|
+
updated(changes) {
|
|
105
|
+
if (changes.has('pendings')) {
|
|
106
|
+
this.buildFilterPendings();
|
|
107
|
+
this.tags = (this.pendings || []).reduce((tags, pending) => {
|
|
108
|
+
tags[pending.tag] = (tags[pending.tag] || 0) + 1;
|
|
109
|
+
return tags;
|
|
110
|
+
}, {});
|
|
111
|
+
}
|
|
112
|
+
if (changes.has('tag')) {
|
|
113
|
+
this.buildFilterPendings();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
PendingQMonitor.styles = [
|
|
118
|
+
ScrollbarStyles,
|
|
119
|
+
css `
|
|
120
|
+
:host {
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
background-color: rgba(var(--primary-color-rgb), 0.1);
|
|
124
|
+
border-radius: var(--border-radius);
|
|
125
|
+
padding: var(--padding-narrow);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
div[tags] {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
}
|
|
132
|
+
[tags] mwc-icon {
|
|
133
|
+
margin: 0 var(--margin-narrow) 0 0;
|
|
134
|
+
font-size: var(--fontsize-large);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
select {
|
|
138
|
+
flex: 1;
|
|
139
|
+
display: inline-block;
|
|
140
|
+
border: none;
|
|
141
|
+
border-radius: var(--border-radius);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
select:focus {
|
|
145
|
+
outline: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
[pendings] {
|
|
149
|
+
display: flex;
|
|
150
|
+
|
|
151
|
+
flex: 1;
|
|
152
|
+
position: relative;
|
|
153
|
+
overflow: auto;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
[pending-wrap] {
|
|
157
|
+
flex: 1;
|
|
158
|
+
margin-top: var(--margin-default);
|
|
159
|
+
padding-left: 30px;
|
|
160
|
+
padding-right: 4px;
|
|
161
|
+
font-size: 8px;
|
|
162
|
+
line-height: 16px;
|
|
163
|
+
|
|
164
|
+
display: flex;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
[pendings-by-tag] {
|
|
168
|
+
flex: 1;
|
|
169
|
+
position: relative;
|
|
170
|
+
margin: 0 1px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
[pending] {
|
|
174
|
+
display: block;
|
|
175
|
+
height: 2px;
|
|
176
|
+
width: 100%;
|
|
177
|
+
white-space: nowrap;
|
|
178
|
+
position: absolute;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
[timeline] {
|
|
182
|
+
position: absolute;
|
|
183
|
+
width: 100%;
|
|
184
|
+
}
|
|
185
|
+
[timeline] table {
|
|
186
|
+
border-collapse: collapse;
|
|
187
|
+
margin-top: var(--margin-default);
|
|
188
|
+
width: 100%;
|
|
189
|
+
}
|
|
190
|
+
[timeline] th {
|
|
191
|
+
opacity: 0.5;
|
|
192
|
+
width: 25px;
|
|
193
|
+
border: 0;
|
|
194
|
+
font-weight: normal;
|
|
195
|
+
font-size: 9px;
|
|
196
|
+
}
|
|
197
|
+
[timeline] th span {
|
|
198
|
+
display: block;
|
|
199
|
+
position: absolute;
|
|
200
|
+
margin-top: -22px;
|
|
201
|
+
}
|
|
202
|
+
[timeline] td {
|
|
203
|
+
border: 0;
|
|
204
|
+
border-top: var(--border-dark-color);
|
|
205
|
+
height: 30px;
|
|
206
|
+
box-sizing: border-box;
|
|
207
|
+
}
|
|
208
|
+
[timeline] tr:nth-child(3n + 1) td {
|
|
209
|
+
border: 0;
|
|
210
|
+
border-top: 1px solid rgba(0, 0, 0, 0.4);
|
|
211
|
+
box-sizing: border-box;
|
|
212
|
+
}
|
|
213
|
+
`
|
|
214
|
+
];
|
|
215
|
+
__decorate([
|
|
216
|
+
property({ type: Array }),
|
|
217
|
+
__metadata("design:type", Object)
|
|
218
|
+
], PendingQMonitor.prototype, "pendings", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
property({ type: Array }),
|
|
221
|
+
__metadata("design:type", Object)
|
|
222
|
+
], PendingQMonitor.prototype, "filteredPendings", void 0);
|
|
223
|
+
__decorate([
|
|
224
|
+
property({ type: Object }),
|
|
225
|
+
__metadata("design:type", Object)
|
|
226
|
+
], PendingQMonitor.prototype, "colorIndex", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
property({ type: Boolean }),
|
|
229
|
+
__metadata("design:type", Boolean)
|
|
230
|
+
], PendingQMonitor.prototype, "running", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ type: Object }),
|
|
233
|
+
__metadata("design:type", Object)
|
|
234
|
+
], PendingQMonitor.prototype, "tags", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
property({ type: String }),
|
|
237
|
+
__metadata("design:type", String)
|
|
238
|
+
], PendingQMonitor.prototype, "tag", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
property({ type: Array }),
|
|
241
|
+
__metadata("design:type", Object)
|
|
242
|
+
], PendingQMonitor.prototype, "scales", void 0);
|
|
243
|
+
PendingQMonitor = __decorate([
|
|
244
|
+
customElement('pending-q-monitor')
|
|
245
|
+
], PendingQMonitor);
|
|
246
|
+
export { PendingQMonitor };
|
|
247
|
+
//# sourceMappingURL=pending-q-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-q-monitor.js","sourceRoot":"","sources":["../../client/viewparts/pending-q-monitor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EA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iDAAc;AACxC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;yDAAsB;AAChD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAgB;AAC3C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;gDAAkB;AAC9C;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAAU;AACrC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CAAa;AACxC;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;+CAAY;AA1G3B,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAwO3B;SAxOY,eAAe","sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { asyncReplace } from 'lit/directives/async-replace.js'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\nimport { sleep } from '@operato/utils'\n\n@customElement('pending-q-monitor')\nexport class PendingQMonitor extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: rgba(var(--primary-color-rgb), 0.1);\n border-radius: var(--border-radius);\n padding: var(--padding-narrow);\n }\n\n div[tags] {\n display: flex;\n align-items: center;\n }\n [tags] mwc-icon {\n margin: 0 var(--margin-narrow) 0 0;\n font-size: var(--fontsize-large);\n }\n\n select {\n flex: 1;\n display: inline-block;\n border: none;\n border-radius: var(--border-radius);\n }\n\n select:focus {\n outline: 0;\n }\n\n [pendings] {\n display: flex;\n\n flex: 1;\n position: relative;\n overflow: auto;\n }\n\n [pending-wrap] {\n flex: 1;\n margin-top: var(--margin-default);\n padding-left: 30px;\n padding-right: 4px;\n font-size: 8px;\n line-height: 16px;\n\n display: flex;\n }\n\n [pendings-by-tag] {\n flex: 1;\n position: relative;\n margin: 0 1px;\n }\n\n [pending] {\n display: block;\n height: 2px;\n width: 100%;\n white-space: nowrap;\n position: absolute;\n }\n\n [timeline] {\n position: absolute;\n width: 100%;\n }\n [timeline] table {\n border-collapse: collapse;\n margin-top: var(--margin-default);\n width: 100%;\n }\n [timeline] th {\n opacity: 0.5;\n width: 25px;\n border: 0;\n font-weight: normal;\n font-size: 9px;\n }\n [timeline] th span {\n display: block;\n position: absolute;\n margin-top: -22px;\n }\n [timeline] td {\n border: 0;\n border-top: var(--border-dark-color);\n height: 30px;\n box-sizing: border-box;\n }\n [timeline] tr:nth-child(3n + 1) td {\n border: 0;\n border-top: 1px solid rgba(0, 0, 0, 0.4);\n box-sizing: border-box;\n }\n `\n ]\n\n @property({ type: Array }) pendings: any\n @property({ type: Array }) filteredPendings: any\n @property({ type: Object }) colorIndex: any\n @property({ type: Boolean }) running?: boolean\n @property({ type: Object }) tags: any\n @property({ type: String }) tag?: string\n @property({ type: Array }) scales: any\n\n filterPendings: any\n\n render() {\n const tag = this.tag === undefined ? '(*)' : this.tag\n const scales = this.scales || []\n\n return html`\n <div tags>\n <mwc-icon>bookmark_border</mwc-icon>\n <select @change=${e => (this.tag = e.target.value)} .value=${tag}>\n <option value=\"(*)\">*</option>\n ${Object.keys(this.tags || {})\n .sort()\n .map(tag => html`<option value=${tag}>${tag}</option>`)}\n </select>\n </div>\n\n <div pendings>\n <div timeline>\n <table>\n ${unsafeHTML(\n scales.map(\n time => `\n <tr>\n <th><span>${time}</span></th>\n <td></td>\n </tr>\n `\n ).join(`\n <tr>\n <th></th>\n <td></td>\n </tr>\n <tr>\n <th></th>\n <td></td>\n </tr>\n `)\n )}\n </table>\n </div>\n\n <div pending-wrap>${asyncReplace(this.queue())}</div>\n </div>\n `\n }\n\n async *queue() {\n while (this.running) {\n var now = Date.now()\n var pendingsByTags = Object.values(this.filterPendings || {})\n\n yield pendingsByTags.map(\n pendings => html`\n <div pendings-by-tag>\n ${(pendings as any).map((pending, index) => {\n var due = Number(pending.due)\n var top = Math.max(Math.floor((due - now) / 1000) * 3, 0) /* 3px per second */\n\n return html`\n <div pending .style=\"top:${top}px;background-color:${this.colorIndex[pending.stuff.scenario]};\">\n ${index == 0 ? html` <div>${this.countdown(pending.due, now)}</div> ` : html``}\n </div>\n `\n })}\n </div>\n `\n )\n\n await sleep(1000)\n }\n }\n\n countdown(due, now) {\n const MIN = 60\n\n var remain = (Number(due) - now) / 1000\n var normailzed = Math.floor(Math.abs(remain))\n const mins = Math.floor(normailzed / MIN)\n const secs = normailzed - mins * MIN\n\n return `${remain > 0 ? '' : '-'}${mins ? mins + 'm ' : ''}${secs}s`\n }\n\n buildFilterPendings() {\n var filtered\n if (this.tag === undefined || this.tag == '(*)') {\n filtered = this.pendings || []\n } else {\n filtered = (this.pendings || []).filter(pending => pending.tag == this.tag)\n }\n\n const now = Date.now()\n const lastdue = filtered[filtered.length - 1]?.due || now\n const length = Math.max(5, Math.ceil((lastdue - now) / (1000 * 30 * 2) + 1))\n this.scales = new Array(length)\n .fill(0)\n .map((_, index) => [`${String(index).padStart(2, '0')}:00`, `${String(index).padStart(2, '0')}:30`])\n .flat()\n\n this.filterPendings = filtered.reduce((sum, pending) => {\n if (sum[pending.tag]) {\n sum[pending.tag].push(pending)\n } else {\n sum[pending.tag] = [pending]\n }\n return sum\n }, {})\n }\n\n updated(changes) {\n if (changes.has('pendings')) {\n this.buildFilterPendings()\n\n this.tags = (this.pendings || []).reduce((tags, pending) => {\n tags[pending.tag] = (tags[pending.tag] || 0) + 1\n return tags\n }, {})\n }\n\n if (changes.has('tag')) {\n this.buildFilterPendings()\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const ScenarioInstanceLogView_base: (new (...args: any[]) => {
|
|
3
|
+
_storeUnsubscribe: import("redux").Unsubscribe;
|
|
4
|
+
connectedCallback(): void;
|
|
5
|
+
disconnectedCallback(): void;
|
|
6
|
+
stateChanged(_state: unknown): void;
|
|
7
|
+
readonly isConnected: boolean;
|
|
8
|
+
}) & typeof LitElement;
|
|
9
|
+
export declare class ScenarioInstanceLogView extends ScenarioInstanceLogView_base {
|
|
10
|
+
static styles: import("lit").CSSResult[];
|
|
11
|
+
scenarioName?: string;
|
|
12
|
+
instanceName?: string;
|
|
13
|
+
logs: any;
|
|
14
|
+
subscription: any;
|
|
15
|
+
firstUpdated(): void;
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
18
|
+
startSubscribe(): Promise<void>;
|
|
19
|
+
stopSubscribe(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import gql from 'graphql-tag';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import { connect } from 'pwa-helpers/connect-mixin';
|
|
6
|
+
import { subscribe } from '@operato/graphql';
|
|
7
|
+
import { store } from '@operato/shell';
|
|
8
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
9
|
+
let ScenarioInstanceLogView = class ScenarioInstanceLogView extends connect(store)(LitElement) {
|
|
10
|
+
firstUpdated() {
|
|
11
|
+
this.logs = [];
|
|
12
|
+
this.startSubscribe();
|
|
13
|
+
}
|
|
14
|
+
disconnectedCallback() {
|
|
15
|
+
super.disconnectedCallback();
|
|
16
|
+
this.stopSubscribe();
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const logs = this.logs || [];
|
|
20
|
+
return html `
|
|
21
|
+
<div options></div>
|
|
22
|
+
<div content>
|
|
23
|
+
${logs.map(({ timestamp, message, level }) => html ` <div><span>${new Date(timestamp).toLocaleString()}</span> <strong>${level}</strong> ${message}</div> `)}
|
|
24
|
+
</div>
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
async startSubscribe() {
|
|
28
|
+
this.subscription = await subscribe({
|
|
29
|
+
query: gql `
|
|
30
|
+
subscription ($instanceName: String, $scenarioName: String, $level: String) {
|
|
31
|
+
log: scenarioInstanceLog(instanceName: $instanceName, scenarioName: $scenarioName, level: $level) {
|
|
32
|
+
level
|
|
33
|
+
message
|
|
34
|
+
timestamp
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
variables: {
|
|
39
|
+
instanceName: this.instanceName,
|
|
40
|
+
scenarioName: this.scenarioName
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
next: async ({ data }) => {
|
|
44
|
+
var wasBottom = this.scrollHeight - this.scrollTop === this.clientHeight;
|
|
45
|
+
this.logs.push(data.log);
|
|
46
|
+
this.logs.length > 100 && this.logs.shift();
|
|
47
|
+
this.requestUpdate();
|
|
48
|
+
if (wasBottom) {
|
|
49
|
+
/* this is not proved yet - to keep bottom scroll position */
|
|
50
|
+
await this.updateComplete;
|
|
51
|
+
this.scrollTop = this.scrollHeight - this.clientHeight;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async stopSubscribe() {
|
|
57
|
+
var _a;
|
|
58
|
+
await ((_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe());
|
|
59
|
+
delete this.subscription;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
ScenarioInstanceLogView.styles = [
|
|
63
|
+
ScrollbarStyles,
|
|
64
|
+
css `
|
|
65
|
+
:host {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
background-color: var(--theme-white-color);
|
|
69
|
+
padding: var(--padding-wide);
|
|
70
|
+
}
|
|
71
|
+
:host([active]) {
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[content] {
|
|
76
|
+
flex: 1;
|
|
77
|
+
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
overflow: auto;
|
|
81
|
+
|
|
82
|
+
font-size: var(--fontsize-small);
|
|
83
|
+
}
|
|
84
|
+
span {
|
|
85
|
+
color: var(--secondary-text-color);
|
|
86
|
+
}
|
|
87
|
+
`
|
|
88
|
+
];
|
|
89
|
+
__decorate([
|
|
90
|
+
property({ type: String }),
|
|
91
|
+
__metadata("design:type", String)
|
|
92
|
+
], ScenarioInstanceLogView.prototype, "scenarioName", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
property({ type: String }),
|
|
95
|
+
__metadata("design:type", String)
|
|
96
|
+
], ScenarioInstanceLogView.prototype, "instanceName", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
property({ type: Array }),
|
|
99
|
+
__metadata("design:type", Object)
|
|
100
|
+
], ScenarioInstanceLogView.prototype, "logs", void 0);
|
|
101
|
+
ScenarioInstanceLogView = __decorate([
|
|
102
|
+
customElement('scenario-instance-log-view')
|
|
103
|
+
], ScenarioInstanceLogView);
|
|
104
|
+
export { ScenarioInstanceLogView };
|
|
105
|
+
//# sourceMappingURL=scenario-instance-log-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenario-instance-log-view.js","sourceRoot":"","sources":["../../client/viewparts/scenario-instance-log-view.ts"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAG1C,IAAM,uBAAuB,GAA7B,MAAM,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I,CAAC,cAAc,CAAA;oBACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAA;iBACvD;YACH,CAAC;SACF,CACF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,aAAa;;QACjB,MAAM,CAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,WAAW,EAAE,CAAA,CAAA;QACtC,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;;AAhGM,8BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;KAuBF;CACF,CAAA;AAED;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6DAAsB;AACjD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6DAAsB;AACjD;IAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;qDAAU;AA/BzB,uBAAuB;IADnC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,uBAAuB,CAkGnC;SAlGY,uBAAuB","sourcesContent":["import gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin'\n\nimport { subscribe } from '@operato/graphql'\nimport { store } from '@operato/shell'\nimport { ScrollbarStyles } from '@operato/styles'\n\n@customElement('scenario-instance-log-view')\nexport class ScenarioInstanceLogView extends connect(store)(LitElement) {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--theme-white-color);\n padding: var(--padding-wide);\n }\n :host([active]) {\n padding: 0;\n }\n\n [content] {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n overflow: auto;\n\n font-size: var(--fontsize-small);\n }\n span {\n color: var(--secondary-text-color);\n }\n `\n ]\n\n @property({ type: String }) scenarioName?: string\n @property({ type: String }) instanceName?: string\n @property({ type: Array }) logs: any\n\n subscription: any\n\n firstUpdated() {\n this.logs = []\n this.startSubscribe()\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this.stopSubscribe()\n }\n\n render() {\n const logs = this.logs || []\n\n return html`\n <div options></div>\n <div content>\n ${logs.map(\n ({ timestamp, message, level }) =>\n html` <div><span>${new Date(timestamp).toLocaleString()}</span> <strong>${level}</strong> ${message}</div> `\n )}\n </div>\n `\n }\n\n async startSubscribe() {\n this.subscription = await subscribe(\n {\n query: gql`\n subscription ($instanceName: String, $scenarioName: String, $level: String) {\n log: scenarioInstanceLog(instanceName: $instanceName, scenarioName: $scenarioName, level: $level) {\n level\n message\n timestamp\n }\n }\n `,\n variables: {\n instanceName: this.instanceName,\n scenarioName: this.scenarioName\n }\n },\n {\n next: async ({ data }) => {\n var wasBottom = this.scrollHeight - this.scrollTop === this.clientHeight\n\n this.logs.push(data.log)\n this.logs.length > 100 && this.logs.shift()\n this.requestUpdate()\n\n if (wasBottom) {\n /* this is not proved yet - to keep bottom scroll position */\n await this.updateComplete\n this.scrollTop = this.scrollHeight - this.clientHeight\n }\n }\n }\n )\n }\n\n async stopSubscribe() {\n await this.subscription?.unsubscribe()\n delete this.subscription\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '@operato/data-grist';
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import './scenario-instance-view';
|
|
4
|
+
import { LitElement } from 'lit';
|
|
5
|
+
declare const ScenarioInstanceMonitor_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
6
|
+
export declare class ScenarioInstanceMonitor extends ScenarioInstanceMonitor_base {
|
|
7
|
+
static styles: import("lit").CSSResult[];
|
|
8
|
+
instance: any;
|
|
9
|
+
color?: string;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
startScenario(instance: any): Promise<void>;
|
|
12
|
+
stopScenario(instance: any): Promise<void>;
|
|
13
|
+
showInstanceDetail(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@operato/data-grist';
|
|
3
|
+
import '@material/mwc-icon';
|
|
4
|
+
import './scenario-instance-view';
|
|
5
|
+
import gql from 'graphql-tag';
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
8
|
+
import { client } from '@operato/graphql';
|
|
9
|
+
import { i18next, localize } from '@operato/i18n';
|
|
10
|
+
import { notify, openPopup } from '@operato/layout';
|
|
11
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
12
|
+
function IS_SCENARIO_RUNNING(state) {
|
|
13
|
+
return state && state !== 'UNLOADED';
|
|
14
|
+
}
|
|
15
|
+
let ScenarioInstanceMonitor = class ScenarioInstanceMonitor extends localize(i18next)(LitElement) {
|
|
16
|
+
render() {
|
|
17
|
+
var instance = this.instance;
|
|
18
|
+
const { instanceName, progress, message, state } = instance;
|
|
19
|
+
const { rate = 0, steps = 0, step = 0, rounds = 0 } = progress || {};
|
|
20
|
+
const running = IS_SCENARIO_RUNNING(state);
|
|
21
|
+
return html `
|
|
22
|
+
<div name>${instanceName}</div>
|
|
23
|
+
<div progress-wrap>
|
|
24
|
+
<div progress>
|
|
25
|
+
<div id="progressbar" .style="width:${rate}%;background-color:${this.color};"></div>
|
|
26
|
+
</div>
|
|
27
|
+
<div steps>${step}/${steps}</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div buttons>
|
|
30
|
+
<span><strong>${rounds}</strong> round</span>
|
|
31
|
+
<mwc-icon-button @click=${e => this.showInstanceDetail()} icon="wysiwyg"></mwc-icon-button>
|
|
32
|
+
<mwc-icon-button
|
|
33
|
+
@click=${e => (running ? this.stopScenario(instance) : this.startScenario(instance))}
|
|
34
|
+
icon=${running ? 'pause' : 'play_arrow'}
|
|
35
|
+
></mwc-icon-button>
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
async startScenario(instance) {
|
|
40
|
+
var response = await client.mutate({
|
|
41
|
+
mutation: gql `
|
|
42
|
+
mutation ($scenarioName: String!, $instanceName: String) {
|
|
43
|
+
startScenario(scenarioName: $scenarioName, instanceName: $instanceName) {
|
|
44
|
+
state
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
variables: {
|
|
49
|
+
scenarioName: instance.scenarioName,
|
|
50
|
+
instanceName: instance.instanceName
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
notify({
|
|
54
|
+
level: 'info',
|
|
55
|
+
message: `${IS_SCENARIO_RUNNING(response.data.startScenario.state) ? 'success' : 'fail'} to start scenario : ${instance.scenarioName}`
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async stopScenario(instance) {
|
|
59
|
+
var response = await client.mutate({
|
|
60
|
+
mutation: gql `
|
|
61
|
+
mutation ($instanceName: String!) {
|
|
62
|
+
stopScenario(instanceName: $instanceName) {
|
|
63
|
+
state
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`,
|
|
67
|
+
variables: {
|
|
68
|
+
instanceName: instance.instanceName
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
notify({
|
|
72
|
+
level: 'info',
|
|
73
|
+
message: `${IS_SCENARIO_RUNNING(response.data.stopScenario.state) ? 'fail' : 'success'} to stop instance : ${instance.instanceName}`
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async showInstanceDetail() {
|
|
77
|
+
const { instanceName, scenarioName } = this.instance;
|
|
78
|
+
openPopup(html `
|
|
79
|
+
<scenario-instance-view .instanceName=${instanceName} .scenarioName=${scenarioName}></scenario-instance-view>
|
|
80
|
+
`, {
|
|
81
|
+
size: 'large',
|
|
82
|
+
title: `${i18next.t('title.scenario-instance')}`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
ScenarioInstanceMonitor.styles = [
|
|
87
|
+
ScrollbarStyles,
|
|
88
|
+
css `
|
|
89
|
+
:host {
|
|
90
|
+
display: block;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
position: relative;
|
|
93
|
+
padding: var(--padding-narrow);
|
|
94
|
+
color: var(--secondary-color);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[running] {
|
|
98
|
+
background-color: lightgreen;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[name] {
|
|
102
|
+
font-size: var(--fontsize-default);
|
|
103
|
+
font-weight: bold;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[progress] {
|
|
107
|
+
display: block;
|
|
108
|
+
position: relative;
|
|
109
|
+
|
|
110
|
+
width: 100%;
|
|
111
|
+
margin: 2px;
|
|
112
|
+
padding: 2px;
|
|
113
|
+
box-sizing: border-box;
|
|
114
|
+
|
|
115
|
+
border: var(--border-dark-color);
|
|
116
|
+
border-radius: 10px;
|
|
117
|
+
background-color: var(--theme-white-color);
|
|
118
|
+
}
|
|
119
|
+
[progress-wrap] {
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: row;
|
|
122
|
+
margin: 4px 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
[running] [progress] {
|
|
126
|
+
background-color: var(--theme-white-color);
|
|
127
|
+
}
|
|
128
|
+
[steps] {
|
|
129
|
+
padding: 0 0 0 var(--padding-narrow);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
#progressbar {
|
|
133
|
+
height: 100%;
|
|
134
|
+
text-align: left;
|
|
135
|
+
border-radius: 5px;
|
|
136
|
+
animation: width 1s linear ease-out;
|
|
137
|
+
}
|
|
138
|
+
[buttons] {
|
|
139
|
+
--mdc-icon-button-size: 18px;
|
|
140
|
+
--mdc-icon-size: 18px;
|
|
141
|
+
border-top: var(--border-dark-color);
|
|
142
|
+
padding: var(--padding-narrow) 0 0 0;
|
|
143
|
+
text-align: right;
|
|
144
|
+
}
|
|
145
|
+
[buttons] mwc-icon-button {
|
|
146
|
+
color: var(--primary-color);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@keyframes width {
|
|
150
|
+
0% {
|
|
151
|
+
width: 0;
|
|
152
|
+
}
|
|
153
|
+
100% {
|
|
154
|
+
width: auto;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
`
|
|
158
|
+
];
|
|
159
|
+
__decorate([
|
|
160
|
+
property({ type: Object }),
|
|
161
|
+
__metadata("design:type", Object)
|
|
162
|
+
], ScenarioInstanceMonitor.prototype, "instance", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
property({ type: String }),
|
|
165
|
+
__metadata("design:type", String)
|
|
166
|
+
], ScenarioInstanceMonitor.prototype, "color", void 0);
|
|
167
|
+
ScenarioInstanceMonitor = __decorate([
|
|
168
|
+
customElement('scenario-instance-monitor')
|
|
169
|
+
], ScenarioInstanceMonitor);
|
|
170
|
+
export { ScenarioInstanceMonitor };
|
|
171
|
+
//# sourceMappingURL=scenario-instance-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenario-instance-monitor.js","sourceRoot":"","sources":["../../client/viewparts/scenario-instance-monitor.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,oBAAoB,CAAA;AAC3B,OAAO,0BAA0B,CAAA;AAEjC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD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CAAC;;sDAAe;AA5E/B,uBAAuB;IADnC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,uBAAuB,CAiKnC;SAjKY,uBAAuB","sourcesContent":["import '@operato/data-grist'\nimport '@material/mwc-icon'\nimport './scenario-instance-view'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { ScrollbarStyles } from '@operato/styles'\n\nfunction IS_SCENARIO_RUNNING(state) {\n return state && state !== 'UNLOADED'\n}\n\n@customElement('scenario-instance-monitor')\nexport class ScenarioInstanceMonitor extends localize(i18next)(LitElement) {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: block;\n overflow: hidden;\n position: relative;\n padding: var(--padding-narrow);\n color: var(--secondary-color);\n }\n\n [running] {\n background-color: lightgreen;\n }\n\n [name] {\n font-size: var(--fontsize-default);\n font-weight: bold;\n }\n\n [progress] {\n display: block;\n position: relative;\n\n width: 100%;\n margin: 2px;\n padding: 2px;\n box-sizing: border-box;\n\n border: var(--border-dark-color);\n border-radius: 10px;\n background-color: var(--theme-white-color);\n }\n [progress-wrap] {\n display: flex;\n flex-direction: row;\n margin: 4px 0;\n }\n\n [running] [progress] {\n background-color: var(--theme-white-color);\n }\n [steps] {\n padding: 0 0 0 var(--padding-narrow);\n }\n\n #progressbar {\n height: 100%;\n text-align: left;\n border-radius: 5px;\n animation: width 1s linear ease-out;\n }\n [buttons] {\n --mdc-icon-button-size: 18px;\n --mdc-icon-size: 18px;\n border-top: var(--border-dark-color);\n padding: var(--padding-narrow) 0 0 0;\n text-align: right;\n }\n [buttons] mwc-icon-button {\n color: var(--primary-color);\n }\n\n @keyframes width {\n 0% {\n width: 0;\n }\n 100% {\n width: auto;\n }\n }\n `\n ]\n\n @property({ type: Object }) instance: any\n @property({ type: String }) color?: string\n\n render() {\n var instance = this.instance\n const { instanceName, progress, message, state } = instance\n const { rate = 0, steps = 0, step = 0, rounds = 0 } = progress || {}\n\n const running = IS_SCENARIO_RUNNING(state)\n\n return html`\n <div name>${instanceName}</div>\n <div progress-wrap>\n <div progress>\n <div id=\"progressbar\" .style=\"width:${rate}%;background-color:${this.color};\"></div>\n </div>\n <div steps>${step}/${steps}</div>\n </div>\n <div buttons>\n <span><strong>${rounds}</strong> round</span>\n <mwc-icon-button @click=${e => this.showInstanceDetail()} icon=\"wysiwyg\"></mwc-icon-button>\n <mwc-icon-button\n @click=${e => (running ? this.stopScenario(instance) : this.startScenario(instance))}\n icon=${running ? 'pause' : 'play_arrow'}\n ></mwc-icon-button>\n </div>\n `\n }\n\n async startScenario(instance) {\n var response = await client.mutate({\n mutation: gql`\n mutation ($scenarioName: String!, $instanceName: String) {\n startScenario(scenarioName: $scenarioName, instanceName: $instanceName) {\n state\n }\n }\n `,\n variables: {\n scenarioName: instance.scenarioName,\n instanceName: instance.instanceName\n }\n })\n\n notify({\n level: 'info',\n message: `${IS_SCENARIO_RUNNING(response.data.startScenario.state) ? 'success' : 'fail'} to start scenario : ${\n instance.scenarioName\n }`\n })\n }\n\n async stopScenario(instance) {\n var response = await client.mutate({\n mutation: gql`\n mutation ($instanceName: String!) {\n stopScenario(instanceName: $instanceName) {\n state\n }\n }\n `,\n variables: {\n instanceName: instance.instanceName\n }\n })\n\n notify({\n level: 'info',\n message: `${IS_SCENARIO_RUNNING(response.data.stopScenario.state) ? 'fail' : 'success'} to stop instance : ${\n instance.instanceName\n }`\n })\n }\n\n async showInstanceDetail() {\n const { instanceName, scenarioName } = this.instance\n openPopup(\n html`\n <scenario-instance-view .instanceName=${instanceName} .scenarioName=${scenarioName}></scenario-instance-view>\n `,\n {\n size: 'large',\n title: `${i18next.t('title.scenario-instance')}`\n }\n )\n }\n}\n"]}
|