4 <p class="title is-4">{{ item.name }}</p>
5 <p class="subtitle is-6">
6 <template v-if="item.subtitle">
9 <template v-else-if="api"> {{ count }} {{ level }} alerts </template>
13 <div v-if="api" class="status" :class="level">
21 import service from "@/mixins/service.js";
22 import Generic from "./Generic.vue";
24 const AlertsStatus = Object.freeze({
53 this.countFiring() || this.countPending() || this.countInactive() || 0
57 if (this.countFiring()) {
58 return AlertsStatus.firing;
59 } else if (this.countPending()) {
60 return AlertsStatus.pending;
62 return AlertsStatus.inactive;
69 fetchStatus: async function () {
70 this.api = await this.fetch("api/v1/alerts").catch((e) => console.log(e));
72 countFiring: function () {
74 return this.api.data?.alerts?.filter(
75 (alert) => alert.state === AlertsStatus.firing
80 countPending: function () {
82 return this.api.data?.alerts?.filter(
83 (alert) => alert.state === AlertsStatus.pending
88 countInactive: function () {
90 return this.api.data?.alerts?.filter(
91 (alert) => alert.state === AlertsStatus.pending
100 <style scoped lang="scss">
113 color: var(--text-title);
116 background-color: #d65c68;
117 border-color: #e87d88;
118 box-shadow: 0 0 5px 1px #d65c68;
122 background-color: #e8bb7d;
123 border-color: #d6a35c;
124 box-shadow: 0 0 5px 1px #e8bb7d;
128 background-color: #8fe87d;
129 border-color: #70d65c;
130 box-shadow: 0 0 5px 1px #8fe87d;
135 display: inline-block;
139 border: 1px solid #000;