|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="text-xs-center">
|
|
|
<v-dialog
|
|
|
- v-model="dialog"
|
|
|
+ v-model="showDialog"
|
|
|
width="600"
|
|
|
:fullscreen="$vuetify.breakpoint.smAndDown"
|
|
|
>
|
|
@@ -19,47 +19,105 @@
|
|
|
|
|
|
<v-divider />
|
|
|
|
|
|
- <v-card-actions v-if="$vuetify.breakpoint.smAndDown">
|
|
|
- <v-flex xs12 text-xs-center>
|
|
|
- <div>
|
|
|
- <v-btn color="primary" block flat @click="reset({ hostConfig: true })">Reset configuration</v-btn>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <v-btn color="primary" block flat @click="reset({ hostConfig: true, scenesList: true })">Reset everything</v-btn>
|
|
|
- </div>
|
|
|
|
|
|
- <div class="mt-4">
|
|
|
- <v-btn color="secondary" block flat @click="dialog = false">Cancel</v-btn>
|
|
|
- </div>
|
|
|
- </v-flex>
|
|
|
- </v-card-actions>
|
|
|
-
|
|
|
- <v-card-actions v-else>
|
|
|
- <v-btn color="secondary" flat @click="dialog = false">Cancel</v-btn>
|
|
|
+ <v-card-actions>
|
|
|
+ <v-btn color="secondary" flat @click="showDialog = false">Cancel</v-btn>
|
|
|
<v-spacer />
|
|
|
- <v-btn color="primary" flat @click="reset({ hostConfig: true })">Reset configuration</v-btn>
|
|
|
- <v-btn color="primary" flat @click="reset({ hostConfig: true, scenesList: true })">Reset everything</v-btn>
|
|
|
+ <v-flex xs6>
|
|
|
+ <v-select
|
|
|
+ v-model="selectedItems"
|
|
|
+ :items="items"
|
|
|
+ label="Data to reset"
|
|
|
+ multiple
|
|
|
+ item-text="text"
|
|
|
+ item-value="value"
|
|
|
+ return-object
|
|
|
+ single-line
|
|
|
+ chips
|
|
|
+ deletable-chips
|
|
|
+ >
|
|
|
+ <template v-slot:prepend-item>
|
|
|
+ <v-list-tile ripple @click="toggle">
|
|
|
+ <v-list-tile-action>
|
|
|
+ <v-icon :color="selectedItems.length > 0 ? 'indigo darken-4' : ''">{{ icon }}</v-icon>
|
|
|
+ </v-list-tile-action>
|
|
|
+ <v-list-tile-content>
|
|
|
+ <v-list-tile-title>Reset All</v-list-tile-title>
|
|
|
+ </v-list-tile-content>
|
|
|
+ </v-list-tile>
|
|
|
+ <v-divider class="mt-2" />
|
|
|
+ </template>
|
|
|
+ </v-select>
|
|
|
+ </v-flex>
|
|
|
+ <v-btn color="primary" flat @click="reset" :disabled="!(selectedItems.length > 0)">Reset</v-btn>
|
|
|
</v-card-actions>
|
|
|
</v-card>
|
|
|
</v-dialog>
|
|
|
+
|
|
|
+ <toast-message ref="toast" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { mapActions } from 'vuex'
|
|
|
+import ToastMessage from '@/components/ToastMessage.vue'
|
|
|
|
|
|
export default {
|
|
|
name: 'ResetAppButton',
|
|
|
+ components: {
|
|
|
+ ToastMessage
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- dialog: false
|
|
|
+ showDialog: false,
|
|
|
+
|
|
|
+ selectedItems: [],
|
|
|
+ items: [
|
|
|
+ { text: 'Host configuration', value: 'hostConfig' },
|
|
|
+ { text: 'Scenes list', value: 'scenesList' },
|
|
|
+ { text: 'Progression', value: 'progression' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ selectAll() {
|
|
|
+ return this.selectedItems.length === this.items.length
|
|
|
+ },
|
|
|
+ selectSome() {
|
|
|
+ return this.selectedItems.length > 0 && !this.selectAll
|
|
|
+ },
|
|
|
+ icon() {
|
|
|
+ if (this.selectAll) return 'mdi-close-box'
|
|
|
+ if (this.selectSome) return 'mdi-minus-box'
|
|
|
+ return 'mdi-checkbox-blank-outline'
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ toggle() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.selectAll) {
|
|
|
+ this.selectedItems = []
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.selectedItems = this.items.slice()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
...mapActions(['resetApp']),
|
|
|
- reset(toResetObj) {
|
|
|
- this.resetApp(toResetObj)
|
|
|
- this.dialog = false
|
|
|
+ reset() {
|
|
|
+ const toReset = this.selectedItems.reduce((acc, x) => {
|
|
|
+ acc[x.value] = true
|
|
|
+ return acc
|
|
|
+ }, {})
|
|
|
+ try {
|
|
|
+ this.resetApp(toReset)
|
|
|
+ this.$refs.toast.show('Successfully reseted requested data')
|
|
|
+ this.showDialog = false
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ this.$refs.toast.show(err.message, 'error', 10000)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|