chore: migrate to eslint 9; optimize chunks (#16887)

This commit is contained in:
Michael Geers 2024-10-26 19:38:31 +02:00 • committed by GitHub
parent 6f7489af2d
commit ce0872d0f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 1639 additions and 1960 deletions

View file

@ -1,24 +0,0 @@
module.exports = {
env: {
browser: true,
node: true,
es6: true,
},
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/eslint-config-typescript",
"@vue/eslint-config-prettier/skip-formatting",
],
parserOptions: {
ecmaVersion: "latest",
},
rules: {
"vue/require-default-prop": "off",
"vue/attribute-hyphenation": "off",
"vue/multi-word-component-names": "off",
"vue/no-reserved-component-names": "off",
/*"vue/no-undef-properties": "warn",*/
"no-param-reassign": "error",
},
};

View file

@ -75,7 +75,11 @@ watch(
() => auth.configured,
(configured) => {
const modal = Modal.getOrCreateInstance(document.getElementById("passwordModal"));
configured ? modal.hide() : modal.show();
if (configured) {
modal.hide();
} else {
modal.show();
}
}
);

View file

@ -30,7 +30,7 @@
</li>
</ul>
<div class="row" v-show="usageTabActive">
<div v-show="usageTabActive" class="row">
<p class="text-center text-md-start col-md-6 order-md-2 col-lg-3 order-lg-3 pt-lg-2">
{{ $t("batterySettings.batteryLevel") }}:
<strong>{{ fmtSoc(batterySoc) }}</strong>
@ -224,7 +224,7 @@
</i18n-t>
</span>
</p>
<div class="form-check form-switch mt-4" v-if="controllable">
<div v-if="controllable" class="form-check form-switch mt-4">
<input
id="batteryDischargeControl"
:checked="batteryDischargeControl"
@ -263,8 +263,8 @@ import smartCostAvailable from "../utils/smartCostAvailable";
export default {
name: "BatterySettingsModal",
mixins: [formatter, collector],
components: { SmartCostLimit, CustomSelect, GenericModal },
mixins: [formatter, collector],
props: {
bufferSoc: Number,
prioritySoc: Number,

View file

@ -95,7 +95,7 @@ export default {
if (!this.targetTime || this.duration === 0) {
return "—";
}
let price = this.activeSlot ? this.activeSlot.price : this.avgPrice;
const price = this.activeSlot ? this.activeSlot.price : this.avgPrice;
if (price === undefined) {
return this.$t("main.targetChargePlan.unknownPrice");
}

View file

@ -7,7 +7,7 @@
@open="open"
>
<p>{{ $t("config.control.description") }}</p>
<p class="text-danger" v-if="error">{{ error }}</p>
<p v-if="error" class="text-danger">{{ error }}</p>
<form ref="form" class="container mx-0 px-0" @submit.prevent="save">
<FormRow
id="controlInterval"

View file

@ -42,20 +42,20 @@ export default {
editable: Boolean,
error: Boolean,
},
emits: ["edit"],
data() {
return {
tooltip: null,
};
},
emits: ["edit"],
mounted() {
this.initTooltip();
},
watch: {
editable() {
this.initTooltip();
},
},
mounted() {
this.initTooltip();
},
methods: {
initTooltip() {
this.$nextTick(() => {

View file

@ -27,10 +27,10 @@ import formatter from "../../mixins/formatter";
export default {
name: "DeviceTags",
mixins: [formatter],
props: {
tags: Object,
},
mixins: [formatter],
computed: {
entries() {
return Object.entries(this.tags).map(

View file

@ -14,7 +14,7 @@
<div v-if="example">{{ $t("config.form.example") }}: {{ example }}</div>
<div v-if="help">
<span class="text-gray" v-html="helpHtml"></span>
<a class="ms-1 text-gray" v-if="link" :href="link" target="_blank">
<a v-if="link" class="ms-1 text-gray" :href="link" target="_blank">
{{ $t("config.general.docsLink") }}
</a>
</div>

View file

@ -109,17 +109,14 @@ import formatter from "../../mixins/formatter";
export default {
name: "GeneralConfig",
components: { TitleModal, EditIcon },
mixins: [formatter],
emits: ["site-changed"],
data() {
return {
title: "",
};
},
components: { TitleModal, EditIcon },
mixins: [formatter],
emits: ["site-changed"],
async mounted() {
await this.load();
},
computed: {
telemetryEnabled() {
return settings.telemetry === true;
@ -148,6 +145,9 @@ export default {
return { name, expiresSoon, cssClass };
},
},
async mounted() {
await this.load();
},
methods: {
async changed() {
this.$emit("site-changed");
@ -155,7 +155,7 @@ export default {
},
async load() {
try {
let res = await api.get("/config/site", {
const res = await api.get("/config/site", {
validateStatus: (code) => [200, 404].includes(code),
});
if (res.status === 200) {

View file

@ -9,7 +9,7 @@
data-testid="influx-modal"
@changed="$emit('changed')"
>
<template v-slot:default="{ values }">
<template #default="{ values }">
<FormRow
id="influxUrl"
:label="$t('config.influx.labelUrl')"
@ -76,10 +76,10 @@
<FormRow id="influxInsecure" :label="$t('config.influx.labelInsecure')">
<div class="d-flex">
<input
class="form-check-input"
id="influxInsecure"
type="checkbox"
v-model="values.insecure"
class="form-check-input"
type="checkbox"
/>
<label class="form-check-label ms-2" for="influxInsecure">
{{ $t("config.influx.labelCheckInsecure") }}

View file

@ -6,7 +6,7 @@
{{ $t("config.general.docsLink") }}
</a>
</p>
<p class="text-danger" v-if="error">
<p v-if="error" class="text-danger">
<span v-if="errorMessage" class="d-block">{{ errorMessage }}</span>
{{ error }}
</p>
@ -71,16 +71,6 @@ import store from "../../store";
export default {
name: "JsonModal",
components: { GenericModal },
emits: ["changed", "open"],
data() {
return {
saving: false,
removing: false,
error: "",
values: {},
serverValues: {},
};
},
props: {
title: String,
description: String,
@ -93,6 +83,16 @@ export default {
stateKey: String,
saveMethod: { type: String, default: "post" },
},
emits: ["changed", "open"],
data() {
return {
saving: false,
removing: false,
error: "",
values: {},
serverValues: {},
};
},
computed: {
docsLink() {
return this.docs ? `${docsPrefix()}${this.docs}` : null;

View file

@ -1,4 +1,5 @@
<template>
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-html="compiledMarkdown"></div>
</template>

View file

@ -41,9 +41,9 @@
<select
id="meterTemplate"
v-model="templateName"
@change="templateChanged"
:disabled="!isNew"
class="form-select w-100"
@change="templateChanged"
>
<option
v-for="option in genericOptions"
@ -83,8 +83,8 @@
/>
<PropertyEntry
v-for="param in normalParams"
:key="param.Name"
:id="`meterParam${param.Name}`"
:key="param.Name"
v-bind="param"
v-model="values[param.Name]"
/>
@ -93,8 +93,8 @@
<template v-if="advancedParams.length" #advanced>
<PropertyEntry
v-for="param in advancedParams"
:key="param.Name"
:id="`meterParam${param.Name}`"
:key="param.Name"
v-bind="param"
v-model="values[param.Name]"
/>

View file

@ -9,7 +9,7 @@
data-testid="mqtt-modal"
@changed="$emit('changed')"
>
<template v-slot:default="{ values }">
<template #default="{ values }">
<FormRow
id="mqttBroker"
:label="$t('config.mqtt.labelBroker')"
@ -53,10 +53,10 @@
<FormRow id="mqttInsecure" :label="$t('config.mqtt.labelInsecure')">
<div class="d-flex">
<input
class="form-check-input"
id="mqttInsecure"
type="checkbox"
v-model="values.insecure"
class="form-check-input"
type="checkbox"
/>
<label class="form-check-label ms-2" for="mqttInsecure">
{{ $t("config.mqtt.labelCheckInsecure") }}

View file

@ -8,7 +8,7 @@
data-testid="network-modal"
@changed="$emit('changed')"
>
<template v-slot:default="{ values }">
<template #default="{ values }">
<FormRow
id="networkSchema"
:label="$t('config.network.labelSchema')"

View file

@ -10,11 +10,11 @@
{{ $t("config.general.readFromFile") }}
</button>
<input
type="file"
ref="fileInput"
type="file"
class="d-none"
@change="readFile"
accept=".crt,.pem,.cer,.csr,.key"
@change="readFile"
/>
</div>
</div>

View file

@ -20,6 +20,7 @@
</template>
<script>
/* eslint-disable vue/prop-name-casing */
import FormRow from "./FormRow.vue";
import PropertyField from "./PropertyField.vue";

View file

@ -46,8 +46,8 @@
<SelectGroup
v-else-if="boolean"
:id="id"
class="w-50"
v-model="value"
class="w-50"
equal-width
transparent
:options="[

View file

@ -13,7 +13,7 @@
@changed="$emit('changed')"
@open="showForm = false"
>
<template v-slot:default="{ values }">
<template #default="{ values }">
<SponsorTokenExpires v-bind="sponsor" />
<div class="mt-4 mb-3">
<Sponsor v-bind="sponsor" />
@ -65,11 +65,6 @@ export default {
data: () => ({
showForm: false,
}),
methods: {
transformReadValues() {
return { token: "" };
},
},
computed: {
sponsor() {
return store?.state?.sponsor;
@ -84,6 +79,11 @@ export default {
: this.$t("config.sponsor.addToken");
},
},
methods: {
transformReadValues() {
return { token: "" };
},
},
};
</script>
<style scoped>

View file

@ -5,10 +5,10 @@
<span>{{ $t("config.validation.label") }}: </span>
<span v-if="unknown">{{ $t("config.validation.unknown") }}</span>
<span v-if="running">{{ $t("config.validation.running") }}</span>
<span class="text-success" v-if="success">
<span v-if="success" class="text-success">
{{ $t("config.validation.success") }}
</span>
<span class="text-danger" v-if="failed">
<span v-if="failed" class="text-danger">
{{ $t("config.validation.failed") }}
</span>
</strong>
@ -22,11 +22,11 @@
{{ $t("config.validation.validate") }}
</a>
</div>
<hr class="divider" v-if="error" />
<div class="text-danger" v-if="error">
<hr v-if="error" class="divider" />
<div v-if="error" class="text-danger">
{{ error }}
</div>
<hr class="divider" v-if="result" />
<hr v-if="result" class="divider" />
<div v-if="result">
<DeviceTags :tags="result" class="success-values" />
</div>
@ -38,6 +38,7 @@ import DeviceTags from "./DeviceTags.vue";
export default {
name: "TestResult",
components: { DeviceTags },
props: {
success: Boolean,
failed: Boolean,
@ -47,7 +48,6 @@ export default {
error: String,
},
emits: ["test"],
components: { DeviceTags },
};
</script>
<style scoped>

View file

@ -10,7 +10,7 @@
disable-remove
@changed="$emit('changed')"
>
<template v-slot:default="{ values }">
<template #default="{ values }">
<FormRow
id="siteTitle"
:label="$t('config.title.label')"

View file

@ -108,12 +108,6 @@ export default {
UNITS,
};
},
mounted() {
document.addEventListener("fullscreenchange", this.fullscreenChange);
},
unmounted() {
document.removeEventListener("fullscreenchange", this.fullscreenChange);
},
computed: {
languageOptions: () => {
const locales = Object.entries(LOCALES).map(([key, value]) => {
@ -149,6 +143,12 @@ export default {
}
},
},
mounted() {
document.addEventListener("fullscreenchange", this.fullscreenChange);
},
unmounted() {
document.removeEventListener("fullscreenchange", this.fullscreenChange);
},
methods: {
enterFullscreen() {
document.documentElement.requestFullscreen();

View file

@ -29,9 +29,9 @@
<select
id="vehicleTemplate"
v-model="templateName"
@change="templateChanged"
:disabled="!isNew"
class="form-select w-100"
@change="templateChanged"
>
<option value="offline">
{{ $t("config.vehicle.offline") }}
@ -70,8 +70,8 @@
<Markdown v-if="description" :markdown="description" class="my-4" />
<PropertyEntry
v-for="param in normalParams"
:key="param.Name"
:id="`vehicleParam${param.Name}`"
:key="param.Name"
v-bind="param"
v-model="values[param.Name]"
/>
@ -80,8 +80,8 @@
<template v-if="advancedParams.length" #advanced>
<PropertyEntry
v-for="param in advancedParams"
:key="param.Name"
:id="`vehicleParam${param.Name}`"
:key="param.Name"
v-bind="param"
v-model="values[param.Name]"
/>
@ -113,8 +113,8 @@
>
<SelectGroup
id="vehicleParamPhases"
class="w-100"
v-model="values.phases"
class="w-100"
:options="[
{ name: '1-phase', value: '1' },
{ name: '2-phases', value: '2' },

View file

@ -1,12 +1,12 @@
<template>
<VueMonacoEditor
v-if="active"
ref="editor"
class="editor"
language="yaml"
:theme="theme"
:options="options"
:value="modelValue"
ref="editor"
@update:value="$emit('update:modelValue', $event)"
@mount="ready"
>
@ -28,12 +28,12 @@ import { VueMonacoEditor, loader } from "@guolao/vue-monaco-editor";
const $html = document.querySelector("html");
export default {
name: "YamlEditor",
components: { VueMonacoEditor },
props: {
modelValue: String,
errorLine: Number,
disabled: Boolean,
},
components: { VueMonacoEditor },
emits: ["update:modelValue"],
data() {
return {
@ -52,9 +52,13 @@ export default {
active: true,
};
},
mounted() {
this.updateTheme();
$html.addEventListener("themechange", this.updateTheme);
computed: {
options() {
return { ...this.defaultOptions, readOnly: this.disabled };
},
lines() {
return (this.modelValue || "").split("\n").length;
},
},
watch: {
errorLine() {
@ -63,13 +67,9 @@ export default {
this.$nextTick(() => (this.active = true));
},
},
computed: {
options() {
return { ...this.defaultOptions, readOnly: this.disabled };
},
lines() {
return (this.modelValue || "").split("\n").length;
},
mounted() {
this.updateTheme();
$html.addEventListener("themechange", this.updateTheme);
},
beforeMount() {
loader.config({

View file

@ -6,7 +6,7 @@
{{ $t("config.general.docsLink") }}
</a>
</p>
<p class="text-danger" v-if="error" data-testid="error">{{ error }}</p>
<p v-if="error" class="text-danger" data-testid="error">{{ error }}</p>
<form ref="form" class="container mx-0 px-0">
<div class="editor-container" :style="{ height }">
<YamlEditor v-model="yaml" class="editor" :errorLine="errorLine" />
@ -48,6 +48,14 @@ import YamlEditor from "./YamlEditor.vue";
export default {
name: "YamlModal",
components: { GenericModal, YamlEditor },
props: {
title: String,
description: String,
docs: String,
endpoint: String,
defaultYaml: String,
size: { type: String, default: "xl" },
},
emits: ["changed"],
data() {
return {
@ -58,14 +66,6 @@ export default {
serverYaml: "",
};
},
props: {
title: String,
description: String,
docs: String,
endpoint: String,
defaultYaml: String,
size: { type: String, default: "xl" },
},
computed: {
docsLink() {
return `${docsPrefix()}${this.docs}`;

View file

@ -24,6 +24,7 @@ import icon from "../../mixins/icon";
export default {
name: "BatteryIcon",
mixins: [icon],
props: {
soc: { type: Number, default: 0 },
hold: { type: Boolean, default: false },
@ -35,6 +36,5 @@ export default {
return `M30 38H18v-${height}h12v${height}z`;
},
},
mixins: [icon],
};
</script>

View file

@ -48,6 +48,11 @@ export default {
size: String,
},
emits: ["open", "closed"],
computed: {
sizeClass() {
return this.size ? `modal-${this.size}` : "";
},
},
mounted() {
this.$refs.modal.addEventListener("show.bs.modal", this.handleShow);
this.$refs.modal.addEventListener("hidden.bs.modal", this.handleHidden);
@ -56,11 +61,6 @@ export default {
this.$refs.modal?.removeEventListener("show.bs.modal", this.handleShow);
this.$refs.modal?.removeEventListener("hidden.bs.modal", this.handleHidden);
},
computed: {
sizeClass() {
return this.size ? `modal-${this.size}` : "";
},
},
methods: {
handleShow() {
this.$emit("open");

View file

@ -18,13 +18,13 @@
<script>
export default {
name: "IconSelectItem",
emits: ["click"],
props: {
value: String,
active: Boolean,
label: String,
disabled: Boolean,
},
emits: ["click"],
};
</script>

View file

@ -39,7 +39,7 @@ export default {
options: function () {
const result = [];
for (let soc = 20; soc <= 100; soc += this.step) {
let text = this.fmtSocOption(soc, this.rangePerSoc, distanceUnit(), this.heating);
const text = this.fmtSocOption(soc, this.rangePerSoc, distanceUnit(), this.heating);
result.push({ soc, text });
}
return result;

View file

@ -62,7 +62,7 @@ export default {
return this.result.activeClients;
},
chargePower() {
let { chargePower = 0 } = this.result;
const { chargePower = 0 } = this.result;
if (chargePower < 1e6) return { value: chargePower / 1e3, unit: "kW" };
if (chargePower < 1e9) return { value: chargePower / 1e6, unit: "MW" };
if (chargePower < 1e12) return { value: chargePower / 1e9, unit: "GW" };

View file

@ -47,26 +47,26 @@ export default {
mode: String,
batteryBoost: Boolean,
},
emits: ["batteryboost-updated"],
data() {
return {
selectedEnabled: this.batteryBoost,
};
},
watch: {
batteryBoost(newVal) {
this.selectedEnabled = newVal;
},
},
computed: {
disabled() {
return ["off", "now"].includes(this.mode);
},
},
watch: {
batteryBoost(newVal) {
this.selectedEnabled = newVal;
},
},
methods: {
handleEnabledChange() {
this.$emit("batteryboost-updated", this.selectedEnabled);
},
},
emits: ["batteryboost-updated"],
};
</script>

View file

@ -2,8 +2,8 @@
<Teleport to="body">
<div
:id="`loadpointSettingsModal_${id}`"
class="modal fade text-dark modal-xl"
ref="modal"
class="modal fade text-dark modal-xl"
data-bs-backdrop="true"
tabindex="-1"
role="dialog"
@ -178,8 +178,8 @@ const insertSorted = (arr, num) => {
export default {
name: "LoadpointSettingsModal",
mixins: [formatter, collector],
components: { SmartCostLimit, LoadpointSettingsBatteryBoost },
mixins: [formatter, collector],
props: {
id: [String, Number],
phasesConfigured: Number,

View file

@ -16,8 +16,8 @@
</label>
<input
id="loginPassword"
v-model="password"
ref="password"
v-model="password"
class="form-control"
autocomplete="current-password"
type="password"

View file

@ -1,16 +1,16 @@
<template>
<div>
<button
:id="id"
class="form-select text-start text-nowrap"
type="button"
:id="id"
data-bs-toggle="dropdown"
aria-expanded="false"
data-bs-auto-close="outside"
>
<slot></slot>
</button>
<ul class="dropdown-menu dropdown-menu-end" ref="dropdown" :aria-labelledby="id">
<ul ref="dropdown" class="dropdown-menu dropdown-menu-end" :aria-labelledby="id">
<template v-if="selectAllLabel">
<li class="dropdown-item p-0">
<label class="form-check px-3 py-2">
@ -18,8 +18,8 @@
class="form-check-input ms-0 me-2"
type="checkbox"
value="all"
@change="toggleCheckAll()"
:checked="allOptionsSelected"
@change="toggleCheckAll()"
/>
<div class="form-check-label">{{ selectAllLabel }}</div>
</label>
@ -29,11 +29,11 @@
<li v-for="option in options" :key="option.value" class="dropdown-item p-0">
<label class="form-check px-3 py-2 d-flex" :for="option.value">
<input
:id="option.value"
v-model="internalValue"
class="form-check-input ms-0 me-2"
type="checkbox"
:id="option.value"
:value="option.value"
v-model="internalValue"
/>
<div class="form-check-label">
{{ option.name }}
@ -61,12 +61,6 @@ export default {
internalValue: [...this.value],
};
},
mounted() {
this.$refs.dropdown.addEventListener("show.bs.dropdown", this.open);
},
unmounted() {
this.$refs.dropdown?.removeEventListener("show.bs.dropdown", this.open);
},
computed: {
allOptionsSelected() {
return this.internalValue.length === this.options.length;
@ -110,6 +104,12 @@ export default {
}
},
},
mounted() {
this.$refs.dropdown.addEventListener("show.bs.dropdown", this.open);
},
unmounted() {
this.$refs.dropdown?.removeEventListener("show.bs.dropdown", this.open);
},
methods: {
open() {
this.$emit("open");

View file

@ -125,7 +125,7 @@ export default {
return lines;
},
clear: function () {
window.app && window.app.clear();
window.app?.clear();
},
},
};

View file

@ -1,6 +1,6 @@
<template>
<div>
<div class="modal-backdrop" v-if="offline" />
<div v-if="offline" class="modal-backdrop" />
<div
class="fixed-bottom alert d-flex justify-content-center align-items-center mb-0 rounded-0 p-2"
:class="{ visible: visible, 'alert-danger': showError, 'alert-secondary': !showError }"
@ -88,14 +88,6 @@ export default {
data() {
return { dismissed: false };
},
watch: {
offline: function () {
if (!this.offline) {
restartComplete();
this.dismissed = false;
}
},
},
computed: {
restartNeeded() {
return restart.restartNeeded;
@ -116,6 +108,14 @@ export default {
);
},
},
watch: {
offline: function () {
if (!this.offline) {
restartComplete();
this.dismissed = false;
}
},
},
methods: {
restart() {
performRestart();

View file

@ -1,8 +1,8 @@
<template>
<GenericModal
id="passwordModal"
:title="title"
ref="modal"
:title="title"
data-testid="password-modal"
:uncloseable="!updateMode"
@open="open"
@ -19,10 +19,10 @@
>
<!-- password manager hint -->
<input
id="username"
class="d-none"
type="text"
name="username"
id="username"
autocomplete="username"
value="admin"
/>
@ -33,8 +33,8 @@
>
<input
id="passwordCurrent"
type="password"
v-model="passwordCurrent"
type="password"
class="form-control"
autocomplete="current-password"
/>
@ -42,8 +42,8 @@
<FormRow id="passwordNew" :label="$t('passwordModal.labelNew')">
<input
id="passwordNew"
type="password"
v-model="passwordNew"
type="password"
class="form-control"
autocomplete="new-password"
required
@ -55,9 +55,9 @@
<FormRow id="passwordRepeat" :label="$t('passwordModal.labelRepeat')">
<input
id="passwordRepeat"
type="password"
ref="passwordRepeat"
v-model="passwordRepeat"
type="password"
class="form-control"
autocomplete="new-password"
/>

View file

@ -32,7 +32,10 @@ export default {
},
methods: {
targetWidth() {
let current = Math.min(Math.max(this.minCurrent, this.chargeCurrent), this.maxCurrent);
const current = Math.min(
Math.max(this.minCurrent, this.chargeCurrent),
this.maxCurrent
);
return (100 / this.maxCurrent) * current;
},
realWidth(num) {

View file

@ -23,6 +23,7 @@ registerChartComponents([RadialLinearScale, ArcElement, Legend, Tooltip]);
export default {
name: "AvgCostGroupedChart",
components: { PolarArea, LegendList },
mixins: [formatter],
props: {
sessions: { type: Array, default: () => [] },
currency: { type: String, default: "EUR" },
@ -31,7 +32,6 @@ export default {
suggestedMax: { type: Number, default: 0 },
costType: { type: String, default: TYPES.PRICE },
},
mixins: [formatter],
computed: {
chartData() {
console.log(`update ${this.costType} grouped data`);

View file

@ -1,5 +1,5 @@
<template>
<div class="row" v-if="chartData.labels.length > 1">
<div v-if="chartData.labels.length > 1" class="row">
<div class="col-12 col-md-6 mb-3">
<Doughnut :data="chartData" :options="options" />
</div>
@ -23,6 +23,7 @@ registerChartComponents([DoughnutController, ArcElement, LinearScale, Legend, To
export default {
name: "CostGroupedChart",
components: { Doughnut, LegendList },
mixins: [formatter],
props: {
sessions: { type: Array, default: () => [] },
groupBy: { type: String, default: GROUPS.LOADPOINT },
@ -30,7 +31,6 @@ export default {
currency: { type: String, default: "EUR" },
costType: { type: String, default: TYPES.PRICE },
},
mixins: [formatter],
computed: {
chartData() {
console.log(`update ${this.costType} grouped data`);

View file

@ -39,6 +39,7 @@ registerChartComponents([
export default {
name: "CostHistoryChart",
components: { Bar, LegendList },
mixins: [formatter],
props: {
sessions: { type: Array, default: () => [] },
groupBy: { type: String, default: GROUPS.NONE },
@ -48,7 +49,6 @@ export default {
colorMappings: { type: Object, default: () => ({ loadpoint: {}, vehicle: {} }) },
suggestedMaxCost: { type: Number, default: 0 },
},
mixins: [formatter],
computed: {
firstDay() {
if (this.sessions.length === 0) {

View file

@ -104,6 +104,7 @@ export default {
CustomSelect,
DateNavigatorButton,
},
mixins: [formatter],
props: {
month: Number,
year: Number,
@ -111,7 +112,6 @@ export default {
showMonth: Boolean,
showYear: Boolean,
},
mixins: [formatter],
emits: ["update-date"],
computed: {
hasPrevMonth() {

View file

@ -1,5 +1,5 @@
<template>
<div class="row" v-if="chartData.labels.length > 1">
<div v-if="chartData.labels.length > 1" class="row">
<div class="col-12 col-md-6 mb-3">
<Doughnut :data="chartData" :options="options" />
</div>
@ -23,12 +23,12 @@ registerChartComponents([DoughnutController, ArcElement, LinearScale, Legend, To
export default {
name: "EnergyGroupedChart",
components: { Doughnut, LegendList },
mixins: [formatter],
props: {
sessions: { type: Array, default: () => [] },
groupBy: { type: String, default: GROUPS.NONE },
colorMappings: { type: Object, default: () => ({ loadpoint: {}, vehicle: {}, solar: {} }) },
},
mixins: [formatter],
computed: {
chartData() {
console.log("update energy aggregate data");

View file

@ -21,13 +21,13 @@ registerChartComponents([BarController, BarElement, CategoryScale, LinearScale,
export default {
name: "EnergyHistoryChart",
components: { Bar, LegendList },
mixins: [formatter],
props: {
sessions: { type: Array, default: () => [] },
groupBy: { type: String, default: GROUPS.NONE },
period: { type: String, default: PERIODS.TOTAL },
colorMappings: { type: Object, default: () => ({ loadpoint: {}, vehicle: {} }) },
},
mixins: [formatter],
computed: {
firstDay() {
if (this.sessions.length === 0) {

View file

@ -7,9 +7,9 @@
}"
>
<li
class="legend-item d-flex align-items-baseline gap-2 no-wrap overflow-hidden"
v-for="legend in legends"
:key="legend.label"
class="legend-item d-flex align-items-baseline gap-2 no-wrap overflow-hidden"
>
<div
v-if="legend.color"
@ -19,8 +19,8 @@
<div class="legend-label text-nowrap">{{ legend.label }}</div>
<div
v-for="value in valueList(legend.value)"
class="text-muted text-nowrap legend-value text-end"
:key="value"
class="text-muted text-nowrap legend-value text-end"
>
{{ value }}
</div>

View file

@ -4,7 +4,7 @@
class="w-100 d-flex d-lg-none"
:options="periodOptions"
:modelValue="period"
@update:modelValue="changePeriod"
@update:model-value="changePeriod"
/>
<SelectGroup
id="sessionsPeriod"
@ -12,7 +12,7 @@
:options="periodOptions"
large
:modelValue="period"
@update:modelValue="changePeriod"
@update:model-value="changePeriod"
/>
</template>
@ -28,6 +28,7 @@ export default {
period: { type: String, required: true },
periodOptions: { type: Array, required: true },
},
emits: ["update:period"],
methods: {
changePeriod(newPeriod) {
this.$emit("update:period", newPeriod);

View file

@ -181,12 +181,12 @@ export default {
vehicleFilter: { type: String, default: "" },
currency: { type: String },
},
emits: ["show-session"],
data() {
return {
selectedColumns: settings.sessionColumns,
};
},
emits: ["show-session"],
computed: {
filteredSessions() {
return this.sessions
@ -266,14 +266,14 @@ export default {
},
sortedColumns() {
const columns = [...this.columns];
let sorted = [];
for (let name of this.selectedColumns) {
const sorted = [];
for (const name of this.selectedColumns) {
if (!name && columns.length) {
sorted.push(columns.shift());
} else if (columns.some((c) => c.name === name)) {
const column = columns.find((c) => c.name === name);
sorted.push(column);
let index = columns.indexOf(column);
const index = columns.indexOf(column);
columns.splice(index, 1);
}
}

View file

@ -23,12 +23,12 @@ registerChartComponents([RadialLinearScale, ArcElement, Legend, Tooltip]);
export default {
name: "SolarGroupedChart",
components: { PolarArea, LegendList },
mixins: [formatter],
props: {
sessions: { type: Array, default: () => [] },
groupBy: { type: String, default: GROUPS.LOADPOINT },
colorMappings: { type: Object, default: () => ({ loadpoint: {}, vehicle: {} }) },
},
mixins: [formatter],
computed: {
chartData() {
console.log("update solar grouped data");

View file

@ -22,11 +22,11 @@ registerChartComponents([RadialLinearScale, PointElement, LineElement, Filler, T
export default {
name: "SolarYearChart",
components: { Radar, LegendList },
mixins: [formatter],
props: {
sessions: { type: Array, default: () => [] },
period: { type: String, default: "total" },
},
mixins: [formatter],
computed: {
firstDay() {
if (this.sessions.length === 0) {

View file

@ -1,6 +1,6 @@
<template>
<div>
<h6 class="mt-0" v-if="isLoadpoint">{{ title }}</h6>
<h6 v-if="isLoadpoint" class="mt-0">{{ title }}</h6>
<p>
{{ description }}
</p>

View file

@ -11,7 +11,7 @@
</template>
</i18n-t>
<em class="d-block mt-2" v-if="!isTrial">
<em v-if="!isTrial" class="d-block mt-2">
{{ $t("settings.sponsorToken.hint") }}
</em>
</div>

View file

@ -30,10 +30,10 @@ import store from "../store";
export default {
name: "TopHeader",
mixins: [collector],
components: {
TopNavigation,
},
mixins: [collector],
props: {
showConfig: Boolean,
title: String,

View file

@ -69,19 +69,19 @@
<li>
<h6 class="dropdown-header">{{ $t("header.login") }}</h6>
</li>
<li v-for="login in providerLogins" :key="login.title">
<li v-for="l in providerLogins" :key="l.title">
<button
type="button"
class="dropdown-item"
@click="handleProviderAuthorization(login)"
@click="handleProviderAuthorization(l)"
>
<span
v-if="!login.loggedIn"
v-if="!l.loggedIn"
class="d-inline-block p-1 rounded-circle border border-light rounded-circle"
:class="badgeClass"
></span>
{{ login.title }}
{{ $t(login.loggedIn ? "main.provider.logout" : "main.provider.login") }}
{{ l.title }}
{{ $t(l.loggedIn ? "main.provider.logout" : "main.provider.login") }}
</button>
</li>
</template>

View file

@ -76,6 +76,7 @@ import formatter from "../mixins/formatter";
export default {
name: "VehicleSoc",
mixins: [formatter],
props: {
connected: Boolean,
vehicleSoc: Number,
@ -92,7 +93,6 @@ export default {
socBasedCharging: Boolean,
socBasedPlanning: Boolean,
},
mixins: [formatter],
emits: ["limit-soc-drag", "limit-soc-updated", "plan-clicked"],
data: function () {
return {
@ -230,7 +230,7 @@ export default {
}
},
movedLimitSoc: function (e) {
let value = parseInt(e.target.value, 10);
const value = parseInt(e.target.value, 10);
e.stopPropagation();
const minLimit = 20;
if (value < minLimit) {

View file

@ -259,73 +259,6 @@ export default {
planProjectedStartDuration: null,
};
},
mounted() {
this.updatePlanStartTooltip();
this.updatePlanActiveTooltip();
this.updateMinSocTooltip();
this.updatePhaseTooltip();
this.updatePvTooltip();
this.updateVehicleClimaterTooltip();
this.updateVehicleWelcomeTooltip();
this.updateSmartCostTooltip();
this.updateVehicleLimitTooltip();
this.updateAwaitingAuthorizationTooltip();
this.updateDisconnectRequiredTooltip();
this.updateDurations();
this.interval = setInterval(this.updateDurations, 1000 * 60);
this.updateBatteryBoostTooltip();
},
beforeUnmount() {
clearInterval(this.interval);
},
watch: {
planActiveTooltipContent() {
this.$nextTick(this.updatePlanActiveTooltip);
},
planStartTooltipContent() {
this.$nextTick(this.updatePlanStartTooltip);
},
minSocTooltipContent() {
this.$nextTick(this.updateMinSocTooltip);
},
phaseTimerContent() {
this.$nextTick(this.updatePhaseTooltip);
},
pvTimerContent() {
this.$nextTick(this.updatePvTooltip);
},
vehicleClimaterTooltipContent() {
this.$nextTick(this.updateVehicleClimaterTooltip);
},
vehicleWelcomeTooltipContent() {
this.$nextTick(this.updateVehicleWelcomeTooltip);
},
smartCostTooltipContent() {
this.$nextTick(this.updateSmartCostTooltip);
},
vehicleLimitTooltipContent() {
this.$nextTick(this.updateVehicleLimitTooltip);
},
awaitingAuthorizationTooltipContent() {
this.$nextTick(this.updateAwaitingAuthorizationTooltip);
},
disconnectRequiredTooltipContent() {
this.$nextTick(this.updateDisconnectRequiredTooltip);
},
batteryBoostTooltipContent() {
this.$nextTick(this.updateBatteryBoostTooltip);
},
planProjectedStart() {
this.updateDurations();
},
planProjectedEnd() {
this.updateDurations();
},
smartCostNextStart() {
this.updateDurations();
},
},
computed: {
phaseTimerActive() {
return (
@ -560,6 +493,73 @@ export default {
return t("connected");
},
},
watch: {
planActiveTooltipContent() {
this.$nextTick(this.updatePlanActiveTooltip);
},
planStartTooltipContent() {
this.$nextTick(this.updatePlanStartTooltip);
},
minSocTooltipContent() {
this.$nextTick(this.updateMinSocTooltip);
},
phaseTimerContent() {
this.$nextTick(this.updatePhaseTooltip);
},
pvTimerContent() {
this.$nextTick(this.updatePvTooltip);
},
vehicleClimaterTooltipContent() {
this.$nextTick(this.updateVehicleClimaterTooltip);
},
vehicleWelcomeTooltipContent() {
this.$nextTick(this.updateVehicleWelcomeTooltip);
},
smartCostTooltipContent() {
this.$nextTick(this.updateSmartCostTooltip);
},
vehicleLimitTooltipContent() {
this.$nextTick(this.updateVehicleLimitTooltip);
},
awaitingAuthorizationTooltipContent() {
this.$nextTick(this.updateAwaitingAuthorizationTooltip);
},
disconnectRequiredTooltipContent() {
this.$nextTick(this.updateDisconnectRequiredTooltip);
},
batteryBoostTooltipContent() {
this.$nextTick(this.updateBatteryBoostTooltip);
},
planProjectedStart() {
this.updateDurations();
},
planProjectedEnd() {
this.updateDurations();
},
smartCostNextStart() {
this.updateDurations();
},
},
mounted() {
this.updatePlanStartTooltip();
this.updatePlanActiveTooltip();
this.updateMinSocTooltip();
this.updatePhaseTooltip();
this.updatePvTooltip();
this.updateVehicleClimaterTooltip();
this.updateVehicleWelcomeTooltip();
this.updateSmartCostTooltip();
this.updateVehicleLimitTooltip();
this.updateAwaitingAuthorizationTooltip();
this.updateDisconnectRequiredTooltip();
this.updateDurations();
this.interval = setInterval(this.updateDurations, 1000 * 60);
this.updateBatteryBoostTooltip();
},
beforeUnmount() {
clearInterval(this.interval);
},
methods: {
updateDurations() {
if (this.planProjectedStart) {

View file

@ -3,8 +3,8 @@
<h4 class="d-flex align-items-center m-0 flex-grow-1 overflow-hidden">
<div
v-if="iconType === 'refresh'"
class="me-2 flex-shrink-0 spin"
ref="refresh"
class="me-2 flex-shrink-0 spin"
:title="$t('main.vehicle.detectionActive')"
data-bs-toggle="tooltip"
>
@ -37,8 +37,8 @@
</span>
<button
v-if="vehicleNotReachable"
class="ms-2 btn-neutral"
ref="notReachable"
class="ms-2 btn-neutral"
data-bs-toggle="tooltip"
:title="$t('main.vehicle.notReachable')"
type="button"
@ -75,13 +75,13 @@ export default {
vehicles: { type: Array, default: () => [] },
title: String,
},
emits: ["change-vehicle", "remove-vehicle"],
data: function () {
return {
refreshTooltip: null,
notReachableTooltip: null,
};
},
emits: ["change-vehicle", "remove-vehicle"],
computed: {
iconType() {
if (this.vehicleDetectionActive) {

View file

@ -11,7 +11,7 @@ export async function performRestart() {
await api.post("/system/shutdown");
restart.restarting = true;
} catch (e) {
alert("Unabled to restart server.");
alert("Unabled to restart server.", e);
}
}

View file

@ -1,6 +1,5 @@
import { createRouter, createWebHashHistory } from "vue-router";
import Modal from "bootstrap/js/dist/modal";
import Main from "./views/Main.vue";
import { ensureCurrentLocaleMessages } from "./i18n";
import { openLoginModal, statusUnknown, updateAuthStatus, isLoggedIn, isConfigured } from "./auth";
@ -32,7 +31,7 @@ export default function setupRouter(i18n) {
const router = createRouter({
history: createWebHashHistory(),
routes: [
{ path: "/", component: Main, props: true },
{ path: "/", component: () => import("./views/Main.vue"), props: true },
{
path: "/config",
component: () => import("./views/Config.vue"),

View file

@ -25,7 +25,7 @@ function save(key) {
delete window.localStorage[key];
}
} catch (e) {
console.error("unable to write to localstorage", { key, value });
console.error("unable to write to localstorage", { key, value, e });
}
};
}

View file

@ -53,20 +53,6 @@ export default {
const siteTitle = store.state.siteTitle;
return { title: siteTitle ? `${siteTitle} | evcc` : "evcc" };
},
watch: {
version: function (now, prev) {
if (!!prev && !!now) {
console.log("new version detected. reloading browser", { now, prev });
this.reload();
}
},
offline: function (offline) {
store.offline(offline);
if (offline) {
this.reconnect();
}
},
},
computed: {
version: function () {
return store.state.version;
@ -84,6 +70,20 @@ export default {
return this.collectProps(OfflineIndicator, store.state);
},
},
watch: {
version: function (now, prev) {
if (!!prev && !!now) {
console.log("new version detected. reloading browser", { now, prev });
this.reload();
}
},
offline: function (offline) {
store.offline(offline);
if (offline) {
this.reconnect();
}
},
},
mounted: function () {
this.connect();
document.addEventListener("visibilitychange", this.pageVisibilityChanged, false);
@ -159,7 +159,7 @@ export default {
};
this.ws.onmessage = (evt) => {
try {
var msg = JSON.parse(evt.data);
const msg = JSON.parse(evt.data);
store.update(msg);
lastDataReceived = new Date();
} catch (error) {

View file

@ -3,7 +3,7 @@
<div class="container px-4">
<TopHeader :title="$t('config.main.title')" />
<div class="wrapper pb-5">
<div class="alert alert-danger my-4 pb-0" role="alert" v-if="$hiddenFeatures()">
<div v-if="$hiddenFeatures()" class="alert alert-danger my-4 pb-0" role="alert">
<p>
<strong>Experimental! 🧪</strong>
Only use these features if you are in the mood for adventure and not afraid
@ -227,8 +227,8 @@
:tags="yamlTags('circuits')"
/>
<template
v-else
v-for="(circuit, idx) in circuits"
v-else
:key="circuit.name"
>
<hr v-if="idx > 0" />
@ -374,6 +374,7 @@ export default {
VehicleIcon,
VehicleModal,
},
mixins: [formatter, collector],
props: {
offline: Boolean,
notifications: Array,
@ -398,7 +399,6 @@ export default {
},
};
},
mixins: [formatter, collector],
computed: {
fatalClass() {
return store.state?.fatal?.class;

View file

@ -38,10 +38,10 @@
</div>
<div class="col-6 offset-lg-1 col-lg-4 mb-4 mb-lg-0">
<input
v-model="search"
type="search"
class="form-control search"
:placeholder="$t('log.search')"
v-model="search"
data-testid="log-search"
/>
</div>
@ -63,7 +63,7 @@
:modelValue="areas"
:options="areaOptions"
:selectAllLabel="$t('log.selectAll')"
@update:modelValue="changeAreas"
@update:model-value="changeAreas"
@open="updateAreas()"
>
{{ areasLabel }}
@ -72,8 +72,8 @@
</div>
<hr class="my-0" />
<div
class="overflow-y-scroll pt-2 pb-4 flex-grow-1 d-flex flex-column"
ref="log"
class="overflow-y-scroll pt-2 pb-4 flex-grow-1 d-flex flex-column"
@scroll="onScroll"
>
<div v-if="showMoreButton" class="my-2">
@ -142,13 +142,6 @@ export default {
busy: false,
};
},
mounted() {
this.startInterval();
this.updateAreas();
},
unmounted() {
this.stopInterval();
},
computed: {
filteredLines() {
return this.lines.filter(
@ -211,6 +204,13 @@ export default {
this.updateLogs();
},
},
mounted() {
this.startInterval();
this.updateAreas();
},
unmounted() {
this.stopInterval();
},
methods: {
async updateLogs(showAll) {
// prevent concurrent requests

33
eslint.config.mjs Normal file
View file

@ -0,0 +1,33 @@
import globals from "globals";
import js from "@eslint/js";
import pluginVue from "eslint-plugin-vue";
import vueTsEslintConfig from "@vue/eslint-config-typescript";
import skipFormattingConfig from "@vue/eslint-config-prettier/skip-formatting";
export default [
js.configs.recommended,
...pluginVue.configs["flat/recommended"],
...vueTsEslintConfig(),
skipFormattingConfig,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
ecmaVersion: "latest",
sourceType: "module",
},
rules: {
"vue/require-default-prop": "off",
"vue/attribute-hyphenation": "off",
"vue/multi-word-component-names": "off",
"vue/no-reserved-component-names": "off",
/*"vue/no-undef-properties": "warn",*/
"no-param-reassign": "error",
"vue/block-lang": "off",
},
},
];

2990
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -14,7 +14,8 @@
"type": "module",
"main": "index.js",
"dependencies": {
"@babel/core": "^7.17.2",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"@guolao/vue-monaco-editor": "^1.5.1",
"@h2d2/shopicons": "^1.2.0",
"@histoire/plugin-vue": "^0.17.1",
@ -24,8 +25,8 @@
"@vitejs/plugin-legacy": "^5.3.0",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/compiler-sfc": "^3.2.30",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/eslint-config-prettier": "^10.1.0",
"@vue/eslint-config-typescript": "^14.1.3",
"@vue/test-utils": "^2.2.7",
"@vue/tsconfig": "^0.5.1",
"axios": "^1.7.4",
@ -34,13 +35,14 @@
"canvas-confetti": "^1.4.0",
"chart.js": "^4.4.4",
"countup.js": "^2.3.2",
"eslint": "^8.57.0",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.0.0-alpha.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-vue": "^9.3.0",
"globals": "^15.11.0",
"happy-dom": "^15.0.0",
"histoire": "^0.17.0",
"markty-toml": "^0.1.1",
@ -66,8 +68,5 @@
"node": ">=22.0.0"
},
"license": "MIT",
"repository": "github:evcc-io/evcc",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.7.1"
}
"repository": "github:evcc-io/evcc"
}