mirror of
https://github.com/bastienwirtz/homer.git
synced 2025-12-16 05:09:50 +01:00
chore: lint apply
This commit is contained in:
@@ -6,11 +6,11 @@
|
|||||||
<template v-if="item.subtitle">
|
<template v-if="item.subtitle">
|
||||||
{{ item.subtitle }}
|
{{ item.subtitle }}
|
||||||
</template>
|
</template>
|
||||||
<i class="fa-solid fa-signal"></i> {{ up }}/{{ total }}
|
<i class="fa-solid fa-signal"></i> {{ up }}/{{ total }}
|
||||||
<template v-if="avgRespTime > 0">
|
<template v-if="avgRespTime > 0">
|
||||||
<span class="separator"> | </span>
|
<span class="separator"> | </span>
|
||||||
<i class="fa-solid fa-stopwatch"></i> {{ avgRespTime }} ms avg.
|
<i class="fa-solid fa-stopwatch"></i> {{ avgRespTime }} ms avg.
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
<template #indicator>
|
<template #indicator>
|
||||||
@@ -37,7 +37,7 @@ export default {
|
|||||||
avgRespTime: NaN,
|
avgRespTime: NaN,
|
||||||
percentageGood: NaN,
|
percentageGood: NaN,
|
||||||
status: false,
|
status: false,
|
||||||
statusMessage: false
|
statusMessage: false,
|
||||||
}),
|
}),
|
||||||
created() {
|
created() {
|
||||||
const updateInterval = parseInt(this.item.updateInterval, 10) || 0;
|
const updateInterval = parseInt(this.item.updateInterval, 10) || 0;
|
||||||
@@ -48,76 +48,76 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchStatus: async function () {
|
fetchStatus: async function () {
|
||||||
this.fetch("/api/v1/endpoints/statuses", { method: "GET", cache: "no-cache" })
|
this.fetch("/api/v1/endpoints/statuses", {
|
||||||
.then((response) => {
|
method: "GET",
|
||||||
// Apply filtering by groups, if defined
|
cache: "no-cache",
|
||||||
if (this.item.groups) {
|
})
|
||||||
response = response?.filter((job) => {
|
.then((response) => {
|
||||||
return this.item.groups.includes(job.group) === true;
|
// Apply filtering by groups, if defined
|
||||||
})
|
if (this.item.groups) {
|
||||||
}
|
response = response?.filter((job) => {
|
||||||
|
return this.item.groups.includes(job.group) === true;
|
||||||
// Initialise counts, avg times
|
});
|
||||||
this.total = response.length;
|
|
||||||
this.up = 0;
|
|
||||||
|
|
||||||
let totalrestime = 0;
|
|
||||||
let totalresults = 0;
|
|
||||||
|
|
||||||
response.forEach((job) => {
|
|
||||||
if (job.results[job.results.length - 1].success === true) {
|
|
||||||
this.up++;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!this.item.hideaverages) {
|
|
||||||
// Update array of average times
|
|
||||||
let totalduration = 0;
|
|
||||||
let rescounter = 0;
|
|
||||||
job.results.forEach((res) => {
|
|
||||||
totalduration += parseInt(res.duration, 10) / 1000000;
|
|
||||||
rescounter++;
|
|
||||||
})
|
|
||||||
|
|
||||||
totalrestime += totalduration;
|
|
||||||
totalresults += rescounter;
|
|
||||||
} else {
|
|
||||||
totalrestime = 0;
|
|
||||||
totalresults = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialise counts, avg times
|
||||||
|
this.total = response.length;
|
||||||
|
this.up = 0;
|
||||||
|
|
||||||
|
let totalrestime = 0;
|
||||||
|
let totalresults = 0;
|
||||||
|
|
||||||
|
response.forEach((job) => {
|
||||||
|
if (job.results[job.results.length - 1].success === true) {
|
||||||
|
this.up++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.item.hideaverages) {
|
||||||
|
// Update array of average times
|
||||||
|
let totalduration = 0;
|
||||||
|
let rescounter = 0;
|
||||||
|
job.results.forEach((res) => {
|
||||||
|
totalduration += parseInt(res.duration, 10) / 1000000;
|
||||||
|
rescounter++;
|
||||||
|
});
|
||||||
|
|
||||||
|
totalrestime += totalduration;
|
||||||
|
totalresults += rescounter;
|
||||||
|
} else {
|
||||||
|
totalrestime = 0;
|
||||||
|
totalresults = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rest are down
|
||||||
|
this.down = this.total - this.up;
|
||||||
|
|
||||||
|
// Calculate overall average response time
|
||||||
|
this.avgRespTime = (totalrestime / totalresults).toFixed(2);
|
||||||
|
|
||||||
|
// Update representations
|
||||||
|
if (this.up == 0 || this.total == 0) {
|
||||||
|
this.percentageGood = 0;
|
||||||
|
} else {
|
||||||
|
this.percentageGood = Math.round((this.up / this.total) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status flag
|
||||||
|
if (this.up == 0 && this.down == 0) {
|
||||||
|
this.status = false;
|
||||||
|
} else if (this.down == this.total) {
|
||||||
|
this.status = "bad";
|
||||||
|
} else if (this.up == this.total) {
|
||||||
|
this.status = "good";
|
||||||
|
} else {
|
||||||
|
this.status = "warn";
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
.catch((e) => {
|
||||||
// Rest are down
|
console.error(e);
|
||||||
this.down = this.total - this.up;
|
});
|
||||||
|
|
||||||
// Calculate overall average response time
|
|
||||||
this.avgRespTime = (totalrestime / totalresults).toFixed(2);
|
|
||||||
|
|
||||||
// Update representations
|
|
||||||
if (this.up == 0 || this.total == 0) {
|
|
||||||
this.percentageGood = 0;
|
|
||||||
} else {
|
|
||||||
this.percentageGood = Math.round((this.up / this.total) * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Status flag
|
|
||||||
if (this.up == 0 && this.down == 0) {
|
|
||||||
this.status = false;
|
|
||||||
} else if (this.down == this.total) {
|
|
||||||
this.status = "bad";
|
|
||||||
} else if (this.up == this.total) {
|
|
||||||
this.status = "good";
|
|
||||||
} else {
|
|
||||||
this.status = "warn";
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
console.error(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user