Linting update

pull/717/head v23.10.1
Bastien Wirtz 2023-10-21 14:24:05 +02:00
parent ecf664d19b
commit de4b7e6124
20 changed files with 172 additions and 146 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "homer", "name": "homer",
"version": "23.09.1", "version": "23.10.1",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"mock": "http-server dummy-data/ --cors", "mock": "http-server dummy-data/ --cors",

View File

@ -208,7 +208,7 @@ export default {
if (this.currentPage !== "default") { if (this.currentPage !== "default") {
let pageConfig = await this.getConfig( let pageConfig = await this.getConfig(
`assets/${this.currentPage}.yml` `assets/${this.currentPage}.yml`,
); );
config = Object.assign(config, pageConfig); config = Object.assign(config, pageConfig);
} }

View File

@ -30,21 +30,21 @@ export default {
that.checkOffline(); that.checkOffline();
} }
}, },
false false,
); );
window.addEventListener( window.addEventListener(
"online", "online",
function () { function () {
that.checkOffline(); that.checkOffline();
}, },
false false,
); );
window.addEventListener( window.addEventListener(
"offline", "offline",
function () { function () {
this.offline = true; this.offline = true;
}, },
false false,
); );
}, },
methods: { methods: {
@ -57,7 +57,9 @@ export default {
// extra check to make sure we're not offline // extra check to make sure we're not offline
let that = this; let that = this;
const urlPath = window.location.pathname.replace(/\/+$/, ""); const urlPath = window.location.pathname.replace(/\/+$/, "");
const aliveCheckUrl = `${window.location.origin}${urlPath}/index.html?t=${new Date().valueOf()}`; const aliveCheckUrl = `${
window.location.origin
}${urlPath}/index.html?t=${new Date().valueOf()}`;
return fetch(aliveCheckUrl, { return fetch(aliveCheckUrl, {
method: "HEAD", method: "HEAD",
cache: "no-store", cache: "no-store",

View File

@ -84,10 +84,13 @@ export default {
}, },
watchIsDark: function () { watchIsDark: function () {
matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => { matchMedia("(prefers-color-scheme: dark)").addEventListener(
"change",
() => {
this.isDark = this.getIsDark(); this.isDark = this.getIsDark();
this.$emit("updated", this.isDark); this.$emit("updated", this.isDark);
}); },
);
}, },
}, },
}; };

View File

@ -63,12 +63,12 @@ export default {
methods: { methods: {
fetchStatus: async function () { fetchStatus: async function () {
this.status = await this.fetch("/control/status").catch((e) => this.status = await this.fetch("/control/status").catch((e) =>
console.log(e) console.log(e),
); );
}, },
fetchStats: async function () { fetchStats: async function () {
this.stats = await this.fetch("/control/stats").catch((e) => this.stats = await this.fetch("/control/stats").catch((e) =>
console.log(e) console.log(e),
); );
}, },
}, },

View File

@ -66,7 +66,7 @@ export default {
const apikey = this.item.apikey; const apikey = this.item.apikey;
if (!apikey) { if (!apikey) {
console.error( console.error(
"apikey is not present in config.yml for the Healthchecks entry!" "apikey is not present in config.yml for the Healthchecks entry!",
); );
return; return;
} }

View File

@ -57,17 +57,19 @@ export default {
computed: { computed: {
humanizeSize: function () { humanizeSize: function () {
let bytes = this.usage; let bytes = this.usage;
if (Math.abs(bytes) < 1024) if (Math.abs(bytes) < 1024) return bytes + " B";
return bytes + ' B';
const units = ['KiB', 'MiB', 'GiB', 'TiB']; const units = ["KiB", "MiB", "GiB", "TiB"];
let u = -1; let u = -1;
do { do {
bytes /= 1024; bytes /= 1024;
++u; ++u;
} while (Math.round(Math.abs(bytes) * 100) / 100 >= 1024 && u < units.length - 1); } while (
Math.round(Math.abs(bytes) * 100) / 100 >= 1024 &&
u < units.length - 1
);
return bytes.toFixed(2) + ' ' + units[u]; return bytes.toFixed(2) + " " + units[u];
}, },
}, },
methods: { methods: {

View File

@ -45,7 +45,7 @@ export default {
if (this.item.subtitle != null) return; if (this.item.subtitle != null) return;
this.meal = await this.fetch("/api/meal-plans/today/", { headers }).catch( this.meal = await this.fetch("/api/meal-plans/today/", { headers }).catch(
(e) => console.log(e) (e) => console.log(e),
); );
this.stats = await this.fetch("/api/debug/statistics/", { this.stats = await this.fetch("/api/debug/statistics/", {
headers, headers,

View File

@ -6,7 +6,9 @@
<template v-if="item.subtitle && !state"> <template v-if="item.subtitle && !state">
{{ item.subtitle }} {{ item.subtitle }}
</template> </template>
<template v-if="!error && display == 'text' && statusClass == 'in-progress'"> <template
v-if="!error && display == 'text' && statusClass == 'in-progress'"
>
<i class="fa-solid fa-gear mr-1"></i> <i class="fa-solid fa-gear mr-1"></i>
<b v-if="completion">{{ completion.toFixed() }}%</b> <b v-if="completion">{{ completion.toFixed() }}%</b>
<span class="separator mx-1"> | </span> <span class="separator mx-1"> | </span>
@ -17,9 +19,13 @@
</template> </template>
<template v-if="!error && display == 'text' && statusClass == 'ready'"> <template v-if="!error && display == 'text' && statusClass == 'ready'">
<i class="fa-solid fa-temperature-half mr-1"></i> <i class="fa-solid fa-temperature-half mr-1"></i>
<b v-if="printer.temperature.bed">{{ printer.temperature.bed.actual.toFixed() }} C</b> <b v-if="printer.temperature.bed"
>{{ printer.temperature.bed.actual.toFixed() }} C</b
>
<span class="separator mx-1"> | </span> <span class="separator mx-1"> | </span>
<b v-if="printer.temperature.tool0">{{ printer.temperature.tool0.actual.toFixed() }} C</b> <b v-if="printer.temperature.tool0"
>{{ printer.temperature.tool0.actual.toFixed() }} C</b
>
</template> </template>
<template v-if="!error && display == 'bar'"> <template v-if="!error && display == 'bar'">
<progress <progress
@ -28,7 +34,7 @@
:value="completion" :value="completion"
max="100" max="100"
:title="`${state} - ${completion.toFixed()}%, ${toTime( :title="`${state} - ${completion.toFixed()}%, ${toTime(
printTimeLeft printTimeLeft,
)} left`" )} left`"
> >
{{ completion }}% {{ completion }}%
@ -99,7 +105,9 @@ export default {
}, },
fetchPrinterStatus: async function () { fetchPrinterStatus: async function () {
try { try {
const response = await this.fetch(`api/printer?apikey=${this.item.apikey}`); const response = await this.fetch(
`api/printer?apikey=${this.item.apikey}`,
);
this.printer = response; this.printer = response;
this.error = response.error; this.error = response.error;
} catch (e) { } catch (e) {

View File

@ -40,7 +40,7 @@ export default {
const apikey = this.item.apikey; const apikey = this.item.apikey;
if (!apikey) { if (!apikey) {
console.error( console.error(
"apikey is not present in config.yml for the paperless entry!" "apikey is not present in config.yml for the paperless entry!",
); );
return; return;
} }

View File

@ -14,8 +14,12 @@
<strong class="notif alert" title="Down Alerts"> <strong class="notif alert" title="Down Alerts">
{{ downalert }} {{ downalert }}
</strong> </strong>
<strong v-if="serverError" class="notif alert" <strong
title="Connection error to PiAlert server, check the url in config.yml">?</strong> v-if="serverError"
class="notif alert"
title="Connection error to PiAlert server, check the url in config.yml"
>?</strong
>
</div> </div>
</template> </template>
</Generic> </Generic>

View File

@ -52,8 +52,9 @@ export default {
const authQueryParams = this.item.apikey const authQueryParams = this.item.apikey
? `?summaryRaw&auth=${this.item.apikey}` ? `?summaryRaw&auth=${this.item.apikey}`
: ""; : "";
const result = await this.fetch(`/api.php${authQueryParams}`) const result = await this.fetch(`/api.php${authQueryParams}`).catch((e) =>
.catch((e) => console.log(e)); console.log(e),
);
this.status = result.status; this.status = result.status;
this.ads_percentage_today = result.ads_percentage_today; this.ads_percentage_today = result.ads_percentage_today;

View File

@ -78,7 +78,7 @@ export default {
this.endpoints = await this.fetch("/api/endpoints", { headers }).catch( this.endpoints = await this.fetch("/api/endpoints", { headers }).catch(
(e) => { (e) => {
console.error(e); console.error(e);
} },
); );
let containers = []; let containers = [];
@ -93,7 +93,7 @@ export default {
const endpointContainers = await this.fetch(uri, { headers }).catch( const endpointContainers = await this.fetch(uri, { headers }).catch(
(e) => { (e) => {
console.error(e); console.error(e);
} },
); );
if (endpointContainers) { if (endpointContainers) {

View File

@ -72,7 +72,7 @@ export default {
countFiring: function () { countFiring: function () {
if (this.api) { if (this.api) {
return this.api.data?.alerts?.filter( return this.api.data?.alerts?.filter(
(alert) => alert.state === AlertsStatus.firing (alert) => alert.state === AlertsStatus.firing,
).length; ).length;
} }
return 0; return 0;
@ -80,7 +80,7 @@ export default {
countPending: function () { countPending: function () {
if (this.api) { if (this.api) {
return this.api.data?.alerts?.filter( return this.api.data?.alerts?.filter(
(alert) => alert.state === AlertsStatus.pending (alert) => alert.state === AlertsStatus.pending,
).length; ).length;
} }
return 0; return 0;
@ -88,7 +88,7 @@ export default {
countInactive: function () { countInactive: function () {
if (this.api) { if (this.api) {
return this.api.data?.alerts?.filter( return this.api.data?.alerts?.filter(
(alert) => alert.state === AlertsStatus.pending (alert) => alert.state === AlertsStatus.pending,
).length; ).length;
} }
return 0; return 0;

View File

@ -122,7 +122,7 @@ export default {
}; };
const status = await this.fetch( const status = await this.fetch(
`/api2/json/nodes/${this.item.node}/status`, `/api2/json/nodes/${this.item.node}/status`,
options options,
); );
// main metrics: // main metrics:
const decimalsToShow = this.item.hide_decimals ? 0 : 1; const decimalsToShow = this.item.hide_decimals ? 0 : 1;
@ -139,7 +139,7 @@ export default {
if (this.isValueShown("vms")) { if (this.isValueShown("vms")) {
const vms = await this.fetch( const vms = await this.fetch(
`/api2/json/nodes/${this.item.node}/qemu`, `/api2/json/nodes/${this.item.node}/qemu`,
options options,
); );
this.parseVMsAndLXCs(vms, this.vms); this.parseVMsAndLXCs(vms, this.vms);
} }
@ -147,7 +147,7 @@ export default {
if (this.isValueShown("lxcs")) { if (this.isValueShown("lxcs")) {
const lxcs = await this.fetch( const lxcs = await this.fetch(
`/api2/json/nodes/${this.item.node}/lxc`, `/api2/json/nodes/${this.item.node}/lxc`,
options options,
); );
this.parseVMsAndLXCs(lxcs, this.lxcs); this.parseVMsAndLXCs(lxcs, this.lxcs);
} }

View File

@ -41,7 +41,7 @@ const displayRate = (rate) => {
return ( return (
Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format( Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format(
rate || 0 rate || 0,
) + ` ${units[i]}/s` ) + ` ${units[i]}/s`
); );
}; };
@ -105,8 +105,8 @@ export default {
return this.getXml(methodName).then((xml) => return this.getXml(methodName).then((xml) =>
parseInt( parseInt(
xml.getElementsByTagName("value")[0].firstChild.textContent, xml.getElementsByTagName("value")[0].firstChild.textContent,
10 10,
) ),
); );
}, },
// Fetch the numer of torrents by requesting the download list // Fetch the numer of torrents by requesting the download list
@ -143,7 +143,7 @@ export default {
return response.text(); return response.text();
}) })
.then((text) => .then((text) =>
Promise.resolve(new DOMParser().parseFromString(text, "text/xml")) Promise.resolve(new DOMParser().parseFromString(text, "text/xml")),
); );
}, },
}, },

View File

@ -56,7 +56,7 @@ export default {
fetchStatus: async function () { fetchStatus: async function () {
try { try {
const response = await this.fetch( const response = await this.fetch(
`/api?output=json&apikey=${this.item.apikey}&mode=queue` `/api?output=json&apikey=${this.item.apikey}&mode=queue`,
); );
this.error = false; this.error = false;
this.stats = response.queue; this.stats = response.queue;

View File

@ -51,7 +51,7 @@ export default {
fetchStatus: async function () { fetchStatus: async function () {
try { try {
const response = await this.fetch( const response = await this.fetch(
`/api/v2?apikey=${this.item.apikey}&cmd=get_activity` `/api/v2?apikey=${this.item.apikey}&cmd=get_activity`,
); );
this.error = false; this.error = false;
this.stats = response.response.data; this.stats = response.response.data;

View File

@ -72,14 +72,20 @@ export default {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Accept": "application/json", Accept: "application/json",
}, },
body: JSON.stringify({"headers":{"content-Type":"application/json"},"data":{"collection":"StatisticsJSONDB","mode":"getById","docID":"statistics","obj":{}},"timeout":1000}), body: JSON.stringify({
headers: { "content-Type": "application/json" },
data: {
collection: "StatisticsJSONDB",
mode: "getById",
docID: "statistics",
obj: {},
},
timeout: 1000,
}),
}; };
const response = await this.fetch( const response = await this.fetch(`/api/v2/cruddb`, options);
`/api/v2/cruddb`,
options
);
this.error = false; this.error = false;
this.stats = response; this.stats = response;
} catch (e) { } catch (e) {

View File

@ -43,7 +43,7 @@ const displayRate = (rate) => {
} }
return ( return (
Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format( Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format(
rate || 0 rate || 0,
) + ` ${units[i]}/s` ) + ` ${units[i]}/s`
); );
}; };