Linting update

This commit is contained in:
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",
"version": "23.09.1",
"version": "23.10.1",
"scripts": {
"dev": "vite",
"mock": "http-server dummy-data/ --cors",

View File

@ -208,7 +208,7 @@ export default {
if (this.currentPage !== "default") {
let pageConfig = await this.getConfig(
`assets/${this.currentPage}.yml`
`assets/${this.currentPage}.yml`,
);
config = Object.assign(config, pageConfig);
}
@ -245,7 +245,7 @@ export default {
return response
.text()
.then((body) => {
return parse(body, {merge: true});
return parse(body, { merge: true });
})
.then(function (config) {
if (config.externalConfig) {

View File

@ -30,21 +30,21 @@ export default {
that.checkOffline();
}
},
false
false,
);
window.addEventListener(
"online",
function () {
that.checkOffline();
},
false
false,
);
window.addEventListener(
"offline",
function () {
this.offline = true;
},
false
false,
);
},
methods: {
@ -57,7 +57,9 @@ export default {
// extra check to make sure we're not offline
let that = this;
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, {
method: "HEAD",
cache: "no-store",

View File

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

View File

@ -63,12 +63,12 @@ export default {
methods: {
fetchStatus: async function () {
this.status = await this.fetch("/control/status").catch((e) =>
console.log(e)
console.log(e),
);
},
fetchStats: async function () {
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;
if (!apikey) {
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;
}

View File

@ -57,17 +57,19 @@ export default {
computed: {
humanizeSize: function () {
let bytes = this.usage;
if (Math.abs(bytes) < 1024)
return bytes + ' B';
if (Math.abs(bytes) < 1024) return bytes + " B";
const units = ['KiB', 'MiB', 'GiB', 'TiB'];
const units = ["KiB", "MiB", "GiB", "TiB"];
let u = -1;
do {
bytes /= 1024;
++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: {

View File

@ -45,7 +45,7 @@ export default {
if (this.item.subtitle != null) return;
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/", {
headers,

View File

@ -6,7 +6,9 @@
<template v-if="item.subtitle && !state">
{{ item.subtitle }}
</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>
<b v-if="completion">{{ completion.toFixed() }}%</b>
<span class="separator mx-1"> | </span>
@ -17,9 +19,13 @@
</template>
<template v-if="!error && display == 'text' && statusClass == 'ready'">
<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>
<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 v-if="!error && display == 'bar'">
<progress
@ -28,7 +34,7 @@
:value="completion"
max="100"
:title="`${state} - ${completion.toFixed()}%, ${toTime(
printTimeLeft
printTimeLeft,
)} left`"
>
{{ completion }}%
@ -99,7 +105,9 @@ export default {
},
fetchPrinterStatus: async function () {
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.error = response.error;
} catch (e) {

View File

@ -40,7 +40,7 @@ export default {
const apikey = this.item.apikey;
if (!apikey) {
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;
}

View File

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

View File

@ -52,8 +52,9 @@ export default {
const authQueryParams = this.item.apikey
? `?summaryRaw&auth=${this.item.apikey}`
: "";
const result = await this.fetch(`/api.php${authQueryParams}`)
.catch((e) => console.log(e));
const result = await this.fetch(`/api.php${authQueryParams}`).catch((e) =>
console.log(e),
);
this.status = result.status;
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(
(e) => {
console.error(e);
}
},
);
let containers = [];
@ -93,7 +93,7 @@ export default {
const endpointContainers = await this.fetch(uri, { headers }).catch(
(e) => {
console.error(e);
}
},
);
if (endpointContainers) {

View File

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

View File

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

View File

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

View File

@ -51,7 +51,7 @@ export default {
fetchStatus: async function () {
try {
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.stats = response.response.data;

View File

@ -72,14 +72,20 @@ export default {
method: "POST",
headers: {
"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(
`/api/v2/cruddb`,
options
);
const response = await this.fetch(`/api/v2/cruddb`, options);
this.error = false;
this.stats = response;
} catch (e) {

View File

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