Skip to content

Commit 2ecc92b

Browse files
committed
src: mini-widgets: BatteryIndicator: add reset for color config
1 parent 3530ea4 commit 2ecc92b

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

src/components/mini-widgets/BatteryIndicator.vue

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,32 @@
102102
<div class="flex justify-between items-center -mt-1">
103103
<v-checkbox
104104
v-model="miniWidget.options.useVoltageToColor"
105-
label="Use voltage to color scheme"
105+
label="Change color by voltage"
106106
hide-details
107107
class="mr-1"
108108
/>
109-
<v-tooltip
110-
location="top"
111-
text="Configure these voltage levels according to your battery pack. Defaults are based on Blue Robotics' 4S Li-ion battery pack."
112-
>
113-
<template #activator="{ props: infoProps }">
114-
<v-icon
115-
v-bind="infoProps"
116-
icon="mdi-information-outline"
117-
class="ml-1 text-yellow-300 cursor-pointer"
118-
size="18"
119-
/>
120-
</template>
121-
</v-tooltip>
109+
<div class="flex items-center gap-x-1">
110+
<v-tooltip
111+
location="top"
112+
text="Configure these voltage levels according to your battery pack. Defaults are based on Blue Robotics' 4S Li-ion battery pack."
113+
>
114+
<template #activator="{ props: infoProps }">
115+
<v-icon
116+
v-bind="infoProps"
117+
icon="mdi-information-outline"
118+
class="ml-1 text-yellow-300 cursor-pointer"
119+
size="18"
120+
/>
121+
</template>
122+
</v-tooltip>
123+
<v-tooltip location="top" text="Reset colors and voltage thresholds to default values">
124+
<template #activator="{ props: resetProps }">
125+
<v-btn v-bind="resetProps" icon size="small" variant="text" class="text-white" @click="resetToDefaults">
126+
<v-icon icon="mdi-restore" size="18" />
127+
</v-btn>
128+
</template>
129+
</v-tooltip>
130+
</div>
122131
</div>
123132

124133
<div class="flex items-start gap-x-2">
@@ -245,6 +254,11 @@ miniWidget.value.options.batteryThresholds ??= Object.assign({}, defaultBatteryL
245254
246255
const batteryThresholds = computed<BatteryLevelThresholds>(() => miniWidget.value.options.batteryThresholds)
247256
257+
const resetToDefaults = (): void => {
258+
miniWidget.value.options.voltageToColorScheme = Object.assign({}, defaultBatteryLevelColorScheme)
259+
miniWidget.value.options.batteryThresholds = Object.assign({}, defaultBatteryLevelThresholds)
260+
}
261+
248262
// Round voltage to 0.1V precision for values < 100V, integer precision for >= 100V
249263
const roundedVoltage = computed(() => {
250264
const voltage = store?.powerSupply?.voltage

0 commit comments

Comments
 (0)