Update action button to allow ID to be forced and to check tasks via mixin
This commit is contained in:
parent
84b96809ad
commit
b4d6436bf3
2 changed files with 47 additions and 19 deletions
|
|
@ -126,6 +126,20 @@ export default {
|
|||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Find and ongoing Action and return its task response.
|
||||
*
|
||||
* Returns null if there is no ongoing action
|
||||
*/
|
||||
async getOngingAction(thing, action) {
|
||||
let response = await this.findOngoingActions(thing, action);
|
||||
// Exit if response is null, due to an error.
|
||||
if (response == null) return null;
|
||||
// Check for a task that is ongoing.
|
||||
// We can't handle multiple tasks ongoing, so this picks the first.
|
||||
// ?? Is the "Nullish Coalescing-Operator" to turn undefined into null.
|
||||
return response.data.find((t) => ["pending", "running"].includes(t.status)) ?? null;
|
||||
},
|
||||
thingActionUrl(thing, action, allowUndefined = false) {
|
||||
let url = this.$store.getters["wot/thingActionUrl"](
|
||||
thing,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue