Add clicked status (hourglass)

To give visual feedback of the action, until
the new status comes back via the event stream.
This commit is contained in:
Stéphane Bidoul 2022-01-30 14:09:09 +01:00
parent 4a249ed9ca
commit b7906786bb
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92

View file

@ -76,24 +76,32 @@ class RunboatBuildElement extends LitElement {
} }
</p> </p>
<p> <p>
<button @click="${this.startHandler}" ?disabled="${this.build.status != "stopped"}">start</button> <button @click="${this.startHandler}" ?disabled="${this.build.status != "stopped" || this.build.status == RunboatBuildElement.clickedStatus}">start</button>
<button @click="${this.stopHandler}" ?disabled="${this.build.status != "started"}">stop</button> <button @click="${this.stopHandler}" ?disabled="${this.build.status != "started" || this.build.status == RunboatBuildElement.clickedStatus}">stop</button>
<button @click="${this.resetHandler}">reset</button> <button @click="${this.resetHandler}" ?disabled="${this.build.status == RunboatBuildElement.clickedStatus}">reset</button>
</p> </p>
</div> </div>
`; `;
} }
startHandler(e) { startHandler(e) {
fetch(`/api/v1/builds/${this.build.name}/start`, {method: 'POST'}); this.actionHandler("start");
} }
stopHandler(e) { stopHandler(e) {
fetch(`/api/v1/builds/${this.build.name}/stop`, {method: 'POST'}); this.actionHandler("stop");
} }
resetHandler(e) { resetHandler(e) {
fetch(`/api/v1/builds/${this.build.name}/reset`, {method: 'POST'}); this.actionHandler("reset");
}
static clickedStatus = "⏳";
actionHandler(action) {
this.build.status = RunboatBuildElement.clickedStatus;
this.requestUpdate();
fetch(`/api/v1/builds/${this.build.name}/${action}`, {method: 'POST'});
} }
} }