-
- ${stateObj.state === "on"
- ? html`
- ${stateObj.attributes.mode !== "single" &&
- (stateObj.attributes.current || 0) > 0
- ? this.hass.localize("ui.card.script.cancel_multiple", {
- number: stateObj.attributes.current,
- })
- : this.hass.localize("ui.card.script.cancel")}
- `
- : nothing}
- ${stateObj.state === "off" || stateObj.attributes.max
- ? html`
- ${this.hass!.localize("ui.card.script.run")}
- `
- : nothing}
+
0
+ ? isParallel && current > 1
+ ? this.hass.localize("ui.card.script.running_parallel", {
+ active: current,
+ })
+ : this.hass.localize("ui.card.script.running_single")
+ : this.hass.localize("ui.card.script.idle")}
+ .changedOverride=${this.stateObj.attributes.last_triggered || 0}
+ >
+
+
+ ${hasQueue
+ ? html`
+ ${this.hass.localize("ui.card.script.running_queued", {
+ queued: current - 1,
+ })}
+ `
+ : ""}
${hasFields
? html`
-
+
+
+ ${this.hass.localize("ui.card.script.run_script")}
+
+
+
`
: nothing}
-
-
-
- ${this.hass.localize(
- "ui.dialogs.more_info_control.script.last_triggered"
- )}:
-
- ${this.stateObj.attributes.last_triggered
- ? html`
-
- `
- : this.hass.localize("ui.components.relative_time.never")}
-
+
+
+
+ ${(isQueued || isParallel) && current > 1
+ ? this.hass.localize("ui.card.script.cancel_all")
+ : this.hass.localize("ui.card.script.cancel")}
+
+
+
+ ${this.hass!.localize("ui.card.script.run")}
+
+
`;
}
@@ -139,17 +176,41 @@ class MoreInfoScript extends LitElement {
this._scriptData = { ...this._scriptData, ...ev.detail.value };
}
+ private _canRun() {
+ if (
+ canRun(this.stateObj!) ||
+ // Restart can also always runs. Just cancels other run.
+ this.stateObj!.attributes.mode === "restart"
+ ) {
+ return true;
+ }
+ return false;
+ }
+
static get styles(): CSSResultGroup {
return css`
- .flex {
- display: flex;
- justify-content: space-between;
+ .queue {
+ visibility: hidden;
+ color: var(--secondary-text-color);
+ text-align: center;
+ margin-bottom: 16px;
+ height: 21px;
+ }
+ .queue.has-queue {
+ visibility: visible;
+ }
+ .fields {
+ padding: 16px;
+ border: 1px solid var(--divider-color);
+ border-radius: 8px;
margin-bottom: 16px;
}
- hr {
- border-color: var(--divider-color);
- border-bottom: none;
- margin: 16px 0;
+ .fields .title {
+ font-weight: bold;
+ }
+ ha-control-button ha-svg-icon {
+ z-index: -1;
+ margin-right: 4px;
}
ha-service-control {
--service-control-padding: 0;
diff --git a/src/translations/en.json b/src/translations/en.json
index 5c385a9e32..24f63e86a3 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -218,8 +218,14 @@
},
"script": {
"run": "[%key:ui::card::service::run%]",
+ "running_single": "Running…",
+ "running_queued": "{queued} queued",
+ "running_parallel": "{active} Running…",
"cancel": "Cancel",
- "cancel_multiple": "Cancel {number}"
+ "cancel_multiple": "Cancel {number}",
+ "cancel_all": "Cancel all",
+ "idle": "Idle",
+ "run_script": "Run script"
},
"service": {
"run": "Run"