@things-factory/integration-ui 7.0.0-alpha.7 → 7.0.0-alpha.9

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.
@@ -1,5 +1,8 @@
1
+ import '@material/mwc-fab'
2
+
1
3
  import gql from 'graphql-tag'
2
- import { css, html, LitElement } from 'lit'
4
+
5
+ import { css, html, LitElement, nothing } from 'lit'
3
6
  import { customElement, property, query } from 'lit/decorators.js'
4
7
  import { connect } from 'pwa-helpers/connect-mixin'
5
8
 
@@ -44,12 +47,20 @@ export class ScenarioInstanceLogView extends connect(store)(LitElement) {
44
47
  span {
45
48
  color: var(--secondary-text-color);
46
49
  }
50
+
51
+ #start {
52
+ position: absolute;
53
+ bottom: 15px;
54
+ right: 16px;
55
+ text-decoration: auto;
56
+ }
47
57
  `
48
58
  ]
49
59
 
50
60
  @property({ type: String }) scenarioName?: string
51
61
  @property({ type: String }) instanceName?: string
52
62
  @property({ type: Array }) logs: any
63
+ @property({ type: Boolean }) startable: boolean = false
53
64
 
54
65
  subscription: any
55
66
 
@@ -70,14 +81,10 @@ export class ScenarioInstanceLogView extends connect(store)(LitElement) {
70
81
  <div options></div>
71
82
  <div content>
72
83
  ${logs.map(
73
- ({ timestamp, message, level }) =>
74
- html`
75
- <div class="${level}">
76
- <span>${new Date(timestamp).toLocaleString()}</span> <strong>${level}</strong> ${message}
77
- </div>
78
- `
84
+ ({ timestamp, message, level }) => html` <div class="${level}"><span>${new Date(timestamp).toLocaleString()}</span> <strong>${level}</strong> ${message}</div> `
79
85
  )}
80
86
  </div>
87
+ ${this.startable ? html`<mwc-fab id="start" icon="play_arrow" title="start" @click=${() => this.dispatchEvent(new CustomEvent('start'))}> </mwc-fab>` : nothing}
81
88
  `
82
89
  }
83
90
 
@@ -112,10 +112,7 @@ export class ScenarioInstanceMonitor extends localize(i18next)(LitElement) {
112
112
  <div buttons>
113
113
  <span><strong>${rounds}</strong> round</span>
114
114
  <mwc-icon-button @click=${e => this.showInstanceDetail()} icon="wysiwyg"></mwc-icon-button>
115
- <mwc-icon-button
116
- @click=${e => (running ? this.stopScenario(instance) : this.startScenario(instance))}
117
- icon=${running ? 'pause' : 'play_arrow'}
118
- ></mwc-icon-button>
115
+ <mwc-icon-button @click=${e => (running ? this.stopScenario(instance) : this.startScenario(instance))} icon=${running ? 'pause' : 'play_arrow'}></mwc-icon-button>
119
116
  </div>
120
117
  `
121
118
  }
@@ -137,9 +134,7 @@ export class ScenarioInstanceMonitor extends localize(i18next)(LitElement) {
137
134
 
138
135
  notify({
139
136
  level: 'info',
140
- message: `${IS_SCENARIO_RUNNING(response.data.startScenario.state) ? 'success' : 'fail'} to start scenario : ${
141
- instance.scenarioName
142
- }`
137
+ message: `${IS_SCENARIO_RUNNING(response.data.startScenario.state) ? 'success' : 'fail'} to start scenario : ${instance.scenarioName}`
143
138
  })
144
139
  }
145
140
 
@@ -159,22 +154,15 @@ export class ScenarioInstanceMonitor extends localize(i18next)(LitElement) {
159
154
 
160
155
  notify({
161
156
  level: 'info',
162
- message: `${IS_SCENARIO_RUNNING(response.data.stopScenario.state) ? 'fail' : 'success'} to stop instance : ${
163
- instance.instanceName
164
- }`
157
+ message: `${IS_SCENARIO_RUNNING(response.data.stopScenario.state) ? 'fail' : 'success'} to stop instance : ${instance.instanceName}`
165
158
  })
166
159
  }
167
160
 
168
161
  async showInstanceDetail() {
169
162
  const { instanceName, scenarioName } = this.instance
170
- openPopup(
171
- html`
172
- <scenario-instance-view .instanceName=${instanceName} .scenarioName=${scenarioName}></scenario-instance-view>
173
- `,
174
- {
175
- size: 'large',
176
- title: `${i18next.t('title.scenario-instance')}`
177
- }
178
- )
163
+ openPopup(html` <scenario-instance-view .instanceName=${instanceName} .scenarioName=${scenarioName}></scenario-instance-view> `, {
164
+ size: 'large',
165
+ title: `${i18next.t('title.scenario-instance')}`
166
+ })
179
167
  }
180
168
  }
@@ -4,7 +4,7 @@ import './scenario-instance-monitor'
4
4
 
5
5
  import gql from 'graphql-tag'
6
6
  import { css, html, LitElement } from 'lit'
7
- import { customElement, property, query } from 'lit/decorators.js'
7
+ import { customElement, property, query, state } from 'lit/decorators.js'
8
8
 
9
9
  import { client } from '@operato/graphql'
10
10
  import { i18next, localize } from '@operato/i18n'
@@ -220,7 +220,7 @@ export class ScenarioMonitor extends localize(i18next)(LitElement) {
220
220
 
221
221
  renderButtons(scenario) {
222
222
  const instances = scenario.instances || []
223
- const scenarioInstance = instances.find(instance => instance.instanceName == scenario.name)
223
+ const scenarioInstance = instances.find(instance => instance.instanceName == scenario.name) || null
224
224
 
225
225
  return html`
226
226
  <div buttons ?detail=${this.mode == 'detail'}>
@@ -233,10 +233,13 @@ export class ScenarioMonitor extends localize(i18next)(LitElement) {
233
233
  }
234
234
 
235
235
  async popupLogView(scenario) {
236
- openPopup(html` <scenario-instance-log-view .scenarioName=${scenario.name}></scenario-instance-log-view> `, {
237
- size: 'large',
238
- title: `${i18next.t('title.scenario-log')} (${scenario.name})`
239
- })
236
+ const popup = openPopup(
237
+ html` <scenario-instance-log-view .scenarioName=${scenario.name} @start=${() => this.startScenario(scenario)} startable></scenario-instance-log-view> `,
238
+ {
239
+ size: 'large',
240
+ title: `${i18next.t('title.scenario-log')} (${scenario.name})`
241
+ }
242
+ )
240
243
  }
241
244
 
242
245
  async startScenario(scenario) {