chore(lint): apply config update

pull/878/head
Bastien Wirtz 2025-02-22 19:52:51 +01:00
parent 1cc724c800
commit 474dc3ae8c
16 changed files with 113 additions and 81 deletions

View File

@ -2,11 +2,14 @@
<div v-if="offline" class="offline-message mb-4"> <div v-if="offline" class="offline-message mb-4">
<i class="fa-solid fa-triangle-exclamation"></i> <i class="fa-solid fa-triangle-exclamation"></i>
<h1> <h1>
Network unreachable Network unreachable
<span @click="checkOffline"> <i class="fas fa-redo-alt"></i></span> <span @click="checkOffline"> <i class="fas fa-redo-alt"></i></span>
</h1> </h1>
<p> <p>
<a href="https://github.com/bastienwirtz/homer/blob/main/docs/configuration.md#connectivity-checks">More information </a> <a
href="https://github.com/bastienwirtz/homer/blob/main/docs/configuration.md#connectivity-checks"
>More information </a
>
</p> </p>
</div> </div>
</template> </template>

View File

@ -18,7 +18,7 @@ export default {
props: { props: {
defaultValue: String, defaultValue: String,
}, },
emits: ['updated'], emits: ["updated"],
data: function () { data: function () {
return { return {
isDark: null, isDark: null,

View File

@ -73,7 +73,7 @@ export default {
return; return;
} }
return response.json(); return response.json();
} },
); );
}, },

View File

@ -52,7 +52,7 @@ export default {
}, },
links: Array, links: Array,
}, },
emits: ['navbar-toggle'], emits: ["navbar-toggle"],
computed: { computed: {
showMenu: function () { showMenu: function () {
return this.open && this.isSmallScreen(); return this.open && this.isSmallScreen();

View File

@ -2,20 +2,27 @@
<Generic :item="item"> <Generic :item="item">
<template #indicator> <template #indicator>
<div class="notifs"> <div class="notifs">
<strong v-if="subscriptions > 0" class="notif subscriptions" title="Subscriptions"> <strong
v-if="subscriptions > 0"
class="notif subscriptions"
title="Subscriptions"
>
{{ subscriptions }} {{ subscriptions }}
</strong> </strong>
<strong v-if="unread > 0" class="notif unread" title="Unread"> <strong v-if="unread > 0" class="notif unread" title="Unread">
{{ unread }} {{ unread }}
</strong> </strong>
<strong <strong
v-if="serverError" class="notif errors" v-if="serverError"
title="Connection error to the FreshRSS API, check url username and password in config.yml">?</strong> class="notif errors"
title="Connection error to the FreshRSS API, check url username and password in config.yml"
>?</strong
>
</div> </div>
</template> </template>
</Generic> </Generic>
</template> </template>
<script> <script>
import service from "@/mixins/service.js"; import service from "@/mixins/service.js";
import Generic from "./Generic.vue"; import Generic from "./Generic.vue";
@ -45,20 +52,29 @@ export default {
}, },
methods: { methods: {
fetchConfig: async function () { fetchConfig: async function () {
if (!this.auth) { if (!this.auth) {
const match = await this.fetch(`/api/greader.php/accounts/ClientLogin?Email=${this.item.username}&Passwd=${this.item.password}`, { method: 'GET', cache: "no-cache" }, false) const match = await this.fetch(
.then(response => { return response.text(); }) `/api/greader.php/accounts/ClientLogin?Email=${this.item.username}&Passwd=${this.item.password}`,
.then(body => { return body.match(/Auth=(([([a-z0-9]+)\/([([a-z0-9]+))/i); }); { method: "GET", cache: "no-cache" },
if (match !== null) false,
this.auth = match[1]; )
.then((response) => {
return response.text();
})
.then((body) => {
return body.match(/Auth=(([([a-z0-9]+)\/([([a-z0-9]+))/i);
});
if (match !== null) this.auth = match[1];
} }
const headers = { const headers = {
"Authorization": `GoogleLogin auth=${this.auth}`, Authorization: `GoogleLogin auth=${this.auth}`,
}; };
this.fetch(`/api/greader.php/reader/api/0/subscription/list?output=json`, { headers }) this.fetch(
`/api/greader.php/reader/api/0/subscription/list?output=json`,
{ headers },
)
.then((subscription) => { .then((subscription) => {
this.subscriptions = subscription.subscriptions.length; this.subscriptions = subscription.subscriptions.length;
}) })
@ -66,7 +82,9 @@ export default {
console.error(e); console.error(e);
this.serverError = true; this.serverError = true;
}); });
this.fetch(`/api/greader.php/reader/api/0/unread-count?output=json`, { headers }) this.fetch(`/api/greader.php/reader/api/0/unread-count?output=json`, {
headers,
})
.then((unreadcount) => { .then((unreadcount) => {
this.unread = unreadcount.max; this.unread = unreadcount.max;
}) })
@ -78,7 +96,7 @@ export default {
}, },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.notifs { .notifs {
position: absolute; position: absolute;
@ -104,4 +122,4 @@ export default {
} }
} }
} }
</style> </style>

View File

@ -20,16 +20,21 @@
<slot name="content"> <slot name="content">
<p class="title">{{ item.name }}</p> <p class="title">{{ item.name }}</p>
<p v-if="item.quick" class="quicklinks"> <p v-if="item.quick" class="quicklinks">
<a <a
v-for="(link, linkIndex) in item.quick" v-for="(link, linkIndex) in item.quick"
:key="linkIndex" :key="linkIndex"
:style="`background-color:${link.color};`" :style="`background-color:${link.color};`"
:href="link.url" :href="link.url"
:target="link.target" :target="link.target"
rel="noreferrer" rel="noreferrer"
> >
<span v-if="item.icon"><i style="font-size: 12px" :class="['fa-fw', link.icon]"></i></span> <span v-if="item.icon"
{{ link.name }} ><i
style="font-size: 12px"
:class="['fa-fw', link.icon]"
></i
></span>
{{ link.name }}
</a> </a>
</p> </p>
<p v-if="item.subtitle" class="subtitle"> <p v-if="item.subtitle" class="subtitle">
@ -92,5 +97,4 @@ a[href=""] {
pointer-events: all; pointer-events: all;
} }
} }
</style> </style>

View File

@ -5,8 +5,9 @@
<p class="subtitle is-6"> <p class="subtitle is-6">
<template v-for="(statItem, index) in item.stats" :key="statItem"> <template v-for="(statItem, index) in item.stats" :key="statItem">
<span v-if="stats[statItem]" :title="stats[statItem].label"> <span v-if="stats[statItem]" :title="stats[statItem].label">
<i :class="stats[statItem].icon"></i> {{ stats[statItem].value }} {{ stats[statItem].unit }} <i :class="stats[statItem].icon"></i> {{ stats[statItem].value }}
<span v-if="index != item.stats.length-1"> / </span> {{ stats[statItem].unit }}
<span v-if="index != item.stats.length - 1"> / </span>
</span> </span>
</template> </template>
</p> </p>
@ -18,7 +19,6 @@
import service from "@/mixins/service.js"; import service from "@/mixins/service.js";
import Generic from "./Generic.vue"; import Generic from "./Generic.vue";
export default { export default {
name: "Glances", name: "Glances",
components: { components: {
@ -48,25 +48,25 @@ export default {
label: "System load", label: "System load",
icon: "fa-solid fa-bolt", icon: "fa-solid fa-bolt",
unit: "%", unit: "%",
} };
this.stats["cpu"] = { this.stats["cpu"] = {
value: response.cpu, value: response.cpu,
label: `CPU usage (${response.cpu_name})`, label: `CPU usage (${response.cpu_name})`,
icon: "fa-solid fa-microchip", icon: "fa-solid fa-microchip",
unit: "%", unit: "%",
} };
this.stats["mem"] = { this.stats["mem"] = {
value: response.mem, value: response.mem,
label: `RAM usage`, label: `RAM usage`,
icon: "fa-solid fa-memory", icon: "fa-solid fa-memory",
unit: "%", unit: "%",
} };
this.stats["swap"] = { this.stats["swap"] = {
value: response.swap, value: response.swap,
label: `Swap usage`, label: `Swap usage`,
icon: "fa-solid fa-file-arrow-down", icon: "fa-solid fa-file-arrow-down",
unit: "%", unit: "%",
} };
}) })
.catch((e) => { .catch((e) => {
console.log(e); console.log(e);

View File

@ -31,7 +31,7 @@ export default {
item: Object, item: Object,
}, },
data: () => ({ data: () => ({
health: {}, health: {},
messages: 0, messages: 0,
}), }),
computed: { computed: {
@ -45,7 +45,7 @@ export default {
} }
return "green"; return "green";
} },
}, },
created() { created() {
this.fetchStatus(); this.fetchStatus();
@ -55,7 +55,7 @@ export default {
fetchStatus: async function () { fetchStatus: async function () {
await this.fetch(`/health`) await this.fetch(`/health`)
.catch((e) => console.log(e)) .catch((e) => console.log(e))
.then((resp) => this.health = resp); .then((resp) => (this.health = resp));
}, },
fetchMessages: async function () { fetchMessages: async function () {
const headers = { const headers = {
@ -63,7 +63,7 @@ export default {
}; };
await this.fetch(`/message?limit=100`, { headers }) await this.fetch(`/message?limit=100`, { headers })
.catch((e) => console.log(e)) .catch((e) => console.log(e))
.then((resp) => this.messages = resp.messages.length); .then((resp) => (this.messages = resp.messages.length));
}, },
}, },
}; };

View File

@ -46,7 +46,7 @@ export default {
return `Happily keeping ${this.stats.totalRecipes} recipes organized`; return `Happily keeping ${this.stats.totalRecipes} recipes organized`;
} }
return null; return null;
} },
}, },
created() { created() {
this.fetchStatus(); this.fetchStatus();
@ -60,9 +60,9 @@ export default {
if (this.item.subtitle != null) return; if (this.item.subtitle != null) return;
this.meal = await this.fetch("/api/groups/mealplans/today", { headers }).catch( this.meal = await this.fetch("/api/groups/mealplans/today", {
(e) => console.log(e), headers,
); }).catch((e) => console.log(e));
this.stats = await this.fetch("/api/admin/about/statistics", { this.stats = await this.fetch("/api/admin/about/statistics", {
headers, headers,
}).catch((e) => console.log(e)); }).catch((e) => console.log(e));

View File

@ -3,9 +3,7 @@
<template #content> <template #content>
<p class="title is-4">{{ item.name }}</p> <p class="title is-4">{{ item.name }}</p>
<p class="subtitle is-6"> <p class="subtitle is-6">
<template v-if="versionstring"> <template v-if="versionstring"> Version {{ versionstring }} </template>
Version {{ versionstring }}
</template>
</p> </p>
</template> </template>
<template #indicator> <template #indicator>

View File

@ -34,7 +34,7 @@
:value="completion" :value="completion"
max="100" max="100"
:title="`${state} - ${completion.toFixed()}%, ${formatTime( :title="`${state} - ${completion.toFixed()}%, ${formatTime(
printTimeLeft printTimeLeft,
)} left`" )} left`"
> >
{{ completion }}% {{ completion }}%
@ -123,9 +123,9 @@ export default {
const minutes = Math.floor(remainingSeconds / 60); const minutes = Math.floor(remainingSeconds / 60);
const secs = remainingSeconds % 60; const secs = remainingSeconds % 60;
const formattedHrs = hours.toString().padStart(2, '0') const formattedHrs = hours.toString().padStart(2, "0");
const formattedMins = minutes.toString().padStart(2, '0') const formattedMins = minutes.toString().padStart(2, "0");
const formattedSecs = secs.toString().padStart(2, '0') const formattedSecs = secs.toString().padStart(2, "0");
if (days > 0) { if (days > 0) {
return `${days}d ${formattedHrs}h ${formattedMins}m`; return `${days}d ${formattedHrs}h ${formattedMins}m`;
@ -136,7 +136,7 @@ export default {
} else { } else {
return `${secs} seconds`; return `${secs} seconds`;
} }
} },
}, },
}; };
</script> </script>

View File

@ -6,9 +6,7 @@
<template v-if="item.subtitle"> <template v-if="item.subtitle">
{{ item.subtitle }} {{ item.subtitle }}
</template> </template>
<template v-else-if="load"> <template v-else-if="load"> {{ load }}&percnt; UPS Load </template>
{{ load }}&percnt; UPS Load
</template>
</p> </p>
</template> </template>
<template #indicator> <template #indicator>
@ -42,7 +40,7 @@ export default {
case "OL": case "OL":
return "online"; return "online";
case "OB": case "OB":
return "on battery" return "on battery";
case "LB": case "LB":
return "low battery"; return "low battery";
default: default:
@ -54,7 +52,7 @@ export default {
case "OL": case "OL":
return "online"; return "online";
case "OB": // On battery case "OB": // On battery
return "pending" return "pending";
case "LB": // Low battery case "LB": // Low battery
return "offline"; return "offline";
default: default:
@ -73,7 +71,7 @@ export default {
}, },
methods: { methods: {
fetchStatus: async function () { fetchStatus: async function () {
const device = this.item.device || ''; const device = this.item.device || "";
const result = await this.fetch(`/api/v1/devices/${device}`).catch((e) => const result = await this.fetch(`/api/v1/devices/${device}`).catch((e) =>
console.log(e), console.log(e),

View File

@ -8,12 +8,12 @@
<template #content> <template #content>
<p class="title is-4">{{ item.name }}</p> <p class="title is-4">{{ item.name }}</p>
<p class="subtitle is-6"> <p class="subtitle is-6">
<template v-if="item.subtitle"> <template v-if="item.subtitle">
{{ item.subtitle }} {{ item.subtitle }}
</template> </template>
<template v-else> <template v-else>
{{ rttLabel }} {{ rttLabel }}
</template> </template>
</p> </p>
</template> </template>
</Generic> </Generic>
@ -38,11 +38,11 @@ export default {
}), }),
computed: { computed: {
rttLabel: function () { rttLabel: function () {
if (this.status === 'online') { if (this.status === "online") {
return `${this.rtt}ms`; return `${this.rtt}ms`;
} }
return "unavailable"; return "unavailable";
} },
}, },
created() { created() {
const updateInterval = parseInt(this.item.updateInterval, 10) || 0; const updateInterval = parseInt(this.item.updateInterval, 10) || 0;
@ -66,10 +66,10 @@ export default {
const startTime = performance.now(); const startTime = performance.now();
const timeout = parseInt(this.item.timeout, 10) || 2000; const timeout = parseInt(this.item.timeout, 10) || 2000;
const params = { const params = {
method, method,
cache: "no-cache", cache: "no-cache",
signal: AbortSignal.timeout(timeout) signal: AbortSignal.timeout(timeout),
}; };
this.fetch("/", params, false) this.fetch("/", params, false)
@ -117,4 +117,3 @@ export default {
} }
} }
</style> </style>

View File

@ -106,14 +106,17 @@ export default {
}) })
.catch(handleError); .catch(handleError);
if (!this.item.legacyApi) { if (!this.item.legacyApi) {
this.fetch(`${this.apiPath}/wanted/missing?pageSize=1&apikey=${this.item.apikey}`) this.fetch(
`${this.apiPath}/wanted/missing?pageSize=1&apikey=${this.item.apikey}`,
)
.then((overview) => { .then((overview) => {
this.fetch(`${this.apiPath}/wanted/missing?pageSize=${overview.totalRecords}&apikey=${this.item.apikey}`) this.fetch(
.then((movies) => { `${this.apiPath}/wanted/missing?pageSize=${overview.totalRecords}&apikey=${this.item.apikey}`,
this.missing = movies.records.filter( ).then((movies) => {
(m) => m.monitored && m.isAvailable && !m.hasFile this.missing = movies.records.filter(
).length; (m) => m.monitored && m.isAvailable && !m.hasFile,
}) ).length;
});
}) })
.catch(handleError); .catch(handleError);
} }

View File

@ -55,8 +55,15 @@ export default {
this.fetch(`/api/summary`) this.fetch(`/api/summary`)
.then((scrutinyData) => { .then((scrutinyData) => {
const devices = Object.values(scrutinyData.data.summary); const devices = Object.values(scrutinyData.data.summary);
this.passed = devices.filter(device => device.device.device_status === 0)?.length || 0; this.passed =
this.failed = devices.filter(device => device.device.device_status > 0 && device.device.device_status <= 3)?.length || 0; devices.filter((device) => device.device.device_status === 0)
?.length || 0;
this.failed =
devices.filter(
(device) =>
device.device.device_status > 0 &&
device.device.device_status <= 3,
)?.length || 0;
this.unknown = devices.length - (this.passed + this.failed) || 0; this.unknown = devices.length - (this.passed + this.failed) || 0;
}) })
.catch((e) => { .catch((e) => {

View File

@ -53,7 +53,9 @@ export default {
} }
if (!success) { if (!success) {
throw new Error(`Ping: target not available (${response.status} error)`); throw new Error(
`Ping: target not available (${response.status} error)`,
);
} }
return json ? response.json() : response.text(); return json ? response.json() : response.text();