blob: 52245e094654ab6b7502cd3bedd108a08560a204 [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
10export default class TwptWorkflowProgress extends LitElement {
11 static properties = {
12 workflow: {type: Object},
13 currentThread: {type: Number},
14 numThreads: {type: Number},
15 currentAction: {type: Number},
16 status: {type: String},
17 };
18
19 static styles = css`
20 .progressbar-container {
21 display: flex;
22 flex-direction: column;
23 align-items: center;
24 }
25 `;
26
27 renderThreadProgress() {
28 // @TODO: Improve this UI when the actions section is complete
29 return html`
30 <div class="progressbar-container">
31 <progress value=${this.currentThread + 1} max=${
32 this.numThreads}></progress>
33 <span>Thread ${this.currentThread + 1}/${this.numThreads}</span>
34 </div>
35 <p style="color: gray;">(Debug information) Status: ${this.status}</p>
36 `;
37 }
38
39 renderActions() {
40 const actions = this.workflow?.getActionsList?.() ?? [];
41 return map(actions, (action, i) => {
42 let status;
43 if (i > this.currentAction)
44 status = 'idle';
45 else if (i == this.currentAction && this.status == 'running')
46 status = 'running';
47 else if (i == this.currentAction && this.status == 'error')
48 status = 'error';
49 else
50 status = 'done';
51
52 return html`
53 <wf-action-editor
54 .action=${action}
55 readOnly
56 step=${i + 1}
57 status=${status}>
58 </wf-action-editor>
59 `;
60 });
61 }
62
63 render() {
64 return [
65 this.renderThreadProgress(),
66 this.renderActions(),
67 ];
68 }
69}
70window.customElements.define('twpt-workflow-progress', TwptWorkflowProgress);