|
| 1 | +<template> |
| 2 | + <ExpansiblePanel :is-expanded="false"> |
| 3 | + <template #title>BlueOS monitoring alerts:</template> |
| 4 | + <template #info> |
| 5 | + Configure alerts for BlueOS system monitoring including CPU temperature and usage thresholds. <br /> |
| 6 | + Set custom thresholds and minimum intervals between alerts to prevent spam. |
| 7 | + </template> |
| 8 | + <template #content> |
| 9 | + <!-- CPU Temperature Configuration --> |
| 10 | + <div class="mb-6"> |
| 11 | + <div class="flex items-center justify-start mb-3 gap-x-6"> |
| 12 | + <span class="text-sm font-medium">CPU Temperature Alert</span> |
| 13 | + <v-switch |
| 14 | + v-model="vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].enabled" |
| 15 | + color="white" |
| 16 | + hide-details |
| 17 | + density="compact" |
| 18 | + /> |
| 19 | + </div> |
| 20 | + <div class="ml-4 space-y-3"> |
| 21 | + <div class="flex items-center gap-4"> |
| 22 | + <span class="text-sm text-slate-200 min-w-[100px]">Threshold (°C):</span> |
| 23 | + <input |
| 24 | + v-model.number="vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].threshold" |
| 25 | + type="number" |
| 26 | + class="px-2 py-1 rounded-sm bg-[#FFFFFF22] max-w-[82px]" |
| 27 | + :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].enabled" |
| 28 | + /> |
| 29 | + </div> |
| 30 | + <div class="flex items-center gap-4"> |
| 31 | + <span class="text-sm text-slate-200 min-w-[100px]">Min interval (s):</span> |
| 32 | + <input |
| 33 | + v-model.number="cpuTemperatureIntervalSeconds" |
| 34 | + type="number" |
| 35 | + class="px-2 py-1 rounded-sm bg-[#FFFFFF22] max-w-[82px]" |
| 36 | + :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].enabled" |
| 37 | + /> |
| 38 | + </div> |
| 39 | + </div> |
| 40 | + </div> |
| 41 | + |
| 42 | + <!-- CPU Usage Configuration --> |
| 43 | + <div class="mb-4"> |
| 44 | + <div class="flex items-center justify-start mb-3 gap-x-6"> |
| 45 | + <span class="text-sm font-medium">CPU Usage Alert</span> |
| 46 | + <v-switch |
| 47 | + v-model="vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].enabled" |
| 48 | + color="white" |
| 49 | + hide-details |
| 50 | + density="compact" |
| 51 | + /> |
| 52 | + </div> |
| 53 | + <div class="ml-4 space-y-3"> |
| 54 | + <div class="flex items-center gap-4"> |
| 55 | + <span class="text-sm text-slate-200 min-w-[100px]">Threshold (%):</span> |
| 56 | + <input |
| 57 | + v-model.number="vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].threshold" |
| 58 | + type="number" |
| 59 | + class="px-2 py-1 rounded-sm bg-[#FFFFFF22] max-w-[82px]" |
| 60 | + :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].enabled" |
| 61 | + /> |
| 62 | + </div> |
| 63 | + <div class="flex items-center gap-4"> |
| 64 | + <span class="text-sm text-slate-200 min-w-[100px]">Min interval (s):</span> |
| 65 | + <input |
| 66 | + v-model.number="cpuUsageIntervalSeconds" |
| 67 | + type="number" |
| 68 | + class="px-2 py-1 rounded-sm bg-[#FFFFFF22] max-w-[82px]" |
| 69 | + :disabled="!vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].enabled" |
| 70 | + /> |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + </template> |
| 75 | + </ExpansiblePanel> |
| 76 | +</template> |
| 77 | + |
| 78 | +<script setup lang="ts"> |
| 79 | +import { computed } from 'vue' |
| 80 | +
|
| 81 | +import ExpansiblePanel from '@/components/ExpansiblePanel.vue' |
| 82 | +import { useVehicleAlerterStore } from '@/stores/vehicleAlerter' |
| 83 | +
|
| 84 | +const vehicleAlerterStore = useVehicleAlerterStore() |
| 85 | +
|
| 86 | +// Convert between seconds (UI) and milliseconds (store) |
| 87 | +const cpuTemperatureIntervalSeconds = computed({ |
| 88 | + get: () => vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].minInterval / 1000, |
| 89 | + set: (value: number) => { |
| 90 | + vehicleAlerterStore.blueOsAlertsConfig['cpu-temperature'].minInterval = value * 1000 |
| 91 | + }, |
| 92 | +}) |
| 93 | +
|
| 94 | +const cpuUsageIntervalSeconds = computed({ |
| 95 | + get: () => vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].minInterval / 1000, |
| 96 | + set: (value: number) => { |
| 97 | + vehicleAlerterStore.blueOsAlertsConfig['cpu-usage'].minInterval = value * 1000 |
| 98 | + }, |
| 99 | +}) |
| 100 | +</script> |
0 commit comments