From e82913869b470be18dd8df4e47b9b8b49aae9ac9 Mon Sep 17 00:00:00 2001 From: Roy Kakkenberg Date: Sun, 2 Feb 2025 18:26:53 +0100 Subject: [PATCH] feat(effects): add reset controller button --- .../effects/EffectControllerButtonDialog.vue | 10 ++++++ .../effects/button/ButtonDialogReset.vue | 36 +++++++++++++++++++ src/stores/effects-controller.store.ts | 25 ++++++++++--- 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 src/components/lights/effects/button/ButtonDialogReset.vue diff --git a/src/components/lights/effects/EffectControllerButtonDialog.vue b/src/components/lights/effects/EffectControllerButtonDialog.vue index 61816ed..ef038ce 100644 --- a/src/components/lights/effects/EffectControllerButtonDialog.vue +++ b/src/components/lights/effects/EffectControllerButtonDialog.vue @@ -54,6 +54,14 @@ @input-valid="(v) => (propertiesValid = v)" @update:model-value="(p) => (properties = p)" /> + + + + + + diff --git a/src/stores/effects-controller.store.ts b/src/stores/effects-controller.store.ts index 2f0575e..1095f71 100644 --- a/src/stores/effects-controller.store.ts +++ b/src/stores/effects-controller.store.ts @@ -125,9 +125,14 @@ export const useEffectsControllerStore = defineStore('effectsController', { }), ); }, - async disableLightsColors() { + /** + * Remove all color effects from the given fixtures. + * Uses "selectedLightsGroupIds if none given" + */ + async disableLightsColors(lightGroupIds?: number[]) { + const ids = lightGroupIds ?? this.selectedLightsGroupIds; await Promise.all( - this.selectedLightsGroupIds.map((id) => { + ids.map((id) => { return applyLightsEffectColor({ body: [], path: { id }, @@ -135,9 +140,14 @@ export const useEffectsControllerStore = defineStore('effectsController', { }), ); }, - async disableLightsMovement() { + /** + * Remove all movement effects from the given fixtures. + * Uses "selectedLightsGroupIds if none given" + */ + async disableLightsMovement(lightGroupIds?: number[]) { + const ids = lightGroupIds ?? this.selectedLightsGroupIds; await Promise.all( - this.selectedLightsGroupIds.map((id) => { + ids.map((id) => { return applyLightsEffectMovement({ body: [], path: { id }, @@ -241,6 +251,13 @@ export const useEffectsControllerStore = defineStore('effectsController', { this.setMovementEffect(button.properties.effectProps, button.properties.lightsGroupIds); return; } + case 'LightsButtonReset': { + await Promise.all([ + this.disableLightsColors(button.properties.lightsGroupIds), + this.disableLightsMovement(button.properties.lightsGroupIds), + ]); + return; + } case 'LightsButtonStrobe': { await this.enableStrobe(button.properties.lightsGroupIds); return;