blob: 54e8c63e5b4bda4a4882f5908f9f632ff01599f9 [file] [log] [blame]
Adrià Vilanova Martínez54964a52022-10-26 23:53:29 +02001import '@material/mwc-dialog/mwc-dialog.js';
2import '@material/web/button/filled-button.js';
3import '@material/web/button/text-button.js';
4
5import '../../../../workflows/manager/components/ActionEditor.js';
6
7import {css, html, LitElement} from 'lit';
8import {map} from 'lit/directives/map.js';
9
Adrià Vilanova Martínez6f62c7d2022-11-05 20:48:52 +010010import {SHARED_MD3_STYLES} from '../../../../common/styles/md3.js';
11
Adrià Vilanova Martínez54964a52022-10-26 23:53:29 +020012export default class TwptWorkflowProgress extends LitElement {
13 static properties = {
14 workflow: {type: Object},
15 currentThread: {type: Number},
16 numThreads: {type: Number},
17 currentAction: {type: Number},
18 status: {type: String},
19 };
20
Adrià Vilanova Martínez6f62c7d2022-11-05 20:48:52 +010021 static styles = [
22 SHARED_MD3_STYLES,
23 css`
24 .progressbar-container {
25 display: flex;
26 flex-direction: column;
27 align-items: center;
28 }
29 `,
30 ];
Adrià Vilanova Martínez54964a52022-10-26 23:53:29 +020031
32 renderThreadProgress() {
33 // @TODO: Improve this UI when the actions section is complete
34 return html`
35 <div class="progressbar-container">
36 <progress value=${this.currentThread + 1} max=${
37 this.numThreads}></progress>
38 <span>Thread ${this.currentThread + 1}/${this.numThreads}</span>
39 </div>
40 <p style="color: gray;">(Debug information) Status: ${this.status}</p>
41 `;
42 }
43
44 renderActions() {
45 const actions = this.workflow?.getActionsList?.() ?? [];
46 return map(actions, (action, i) => {
47 let status;
48 if (i > this.currentAction)
49 status = 'idle';
50 else if (i == this.currentAction && this.status == 'running')
51 status = 'running';
52 else if (i == this.currentAction && this.status == 'error')
53 status = 'error';
54 else
55 status = 'done';
56
57 return html`
58 <wf-action-editor
59 .action=${action}
60 readOnly
61 step=${i + 1}
62 status=${status}>
63 </wf-action-editor>
64 `;
65 });
66 }
67
68 render() {
69 return [
70 this.renderThreadProgress(),
71 this.renderActions(),
72 ];
73 }
74}
75window.customElements.define('twpt-workflow-progress', TwptWorkflowProgress);