Skip to content

chore: Typescript: Rewrite views #21714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
beee2b0
typify
Maschga Jun 8, 2025
6b254b9
Update vite.config.js
Maschga Jun 8, 2025
f8e4f04
Revert "Update vite.config.js"
Maschga Jun 8, 2025
ac6233b
Merge branch 'evcc-io:master' into tsc/views
Maschga Jun 8, 2025
82219db
typify
Maschga Jun 8, 2025
4110cb9
Merge branch 'tsc/views' of https://github.com/Maschga/evcc into tsc/…
Maschga Jun 8, 2025
00ddb5f
rename method
Maschga Jun 8, 2025
ecf007c
rename to Circuit
Maschga Jun 8, 2025
24395c4
typify
Maschga Jun 8, 2025
e0726ed
Merge branch 'master' of https://github.com/Maschga/evcc
Maschga Jun 8, 2025
0f5d40b
Revert "typify"
Maschga Jun 8, 2025
0acf564
Merge branch 'evcc-io:master' into master
Maschga Jun 14, 2025
c91fdfc
Merge branch 'evcc-io:master' into master
Maschga Jun 15, 2025
6be7ee9
Merge branch 'evcc-io:master' into master
Maschga Jun 16, 2025
ff4a5e0
Merge branch 'evcc-io:master' into master
Maschga Jun 17, 2025
ff05d67
format ts
Maschga Jun 17, 2025
cbd50b8
Merge branch 'master' into tsc/views
Maschga Jun 17, 2025
1894dcd
lint
Maschga Jun 17, 2025
587a909
fix lint
Maschga Jun 17, 2025
c1a8c81
remove newline
Maschga Jun 17, 2025
311cce3
fix
Maschga Jun 17, 2025
1947571
use record
Maschga Jun 17, 2025
3a669ac
simplify
Maschga Jun 17, 2025
7fb980f
Merge branch 'master' into tsc/views
naltatis Jun 20, 2025
696abc0
remove function editorType
Maschga Jun 20, 2025
291ac08
Merge branch 'tsc/views' of https://github.com/Maschga/evcc into tsc/…
Maschga Jun 20, 2025
9325e2b
lint
Maschga Jun 20, 2025
5d6daa7
Merge branch 'master' into tsc/views
Maschga Jun 28, 2025
5bfee67
Merge branch 'master' into tsc/views
Maschga Jul 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
typify
  • Loading branch information
Maschga committed Jun 8, 2025
commit beee2b02ae21f2f884f4eccd29d05080bc713227
2 changes: 2 additions & 0 deletions assets/js/components/Footer/OfflineIndicator.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ Fatal.args = {
error: `cannot create charger 'wallbox_cphl': cannot create charger type 'template': cannot create
charger type 'hardybarth-ecbl: Post http://192.168.2.219/api/v1/chargecontrols/1/mode: context deadline exceeded (Client.Timeout
exceeded while awaiting headers)`,
class: "",
device: "",
},
};
95 changes: 93 additions & 2 deletions assets/js/types/evcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export interface Auth {
export type VehicleLogins = Record<string, { authenticated: boolean; uri: string }>;

export interface FatalError {
error: any;
class?: any;
error: string;
class: string;
device: string;
}

export interface State {
Expand All @@ -30,6 +31,96 @@ export interface State {
currency?: CURRENCY;
fatal?: FatalError;
auth?: Auth;
version?: string;
battery?: Battery[];
tariffGrid?: number;
tariffFeedIn?: number;
tariffCo2?: number;
tariffSolar?: number;
mqtt?: {
broker: string;
topic: string;
};
influx?: {
url: string;
database: any;
org: any;
};
hems?: {
type: any;
};
sponsor?: Sponsor;
eebus?: any;
modbusproxy?: [];
messaging?: any;
interval?: number;
circuits?: Record<string, Curcuit>;
}

export interface Config {
template?: string;
title?: string;
icon?: string;
[key: string]: number | string | undefined;
}

export interface Curcuit {
name: string;
maxPower: number;
power?: number;
maxCurrent: number;
current?: number;
config?: Config;
}

export interface Entity {
name: string;
type: string;
id: number;
config: Config;
}

export interface Meter extends Entity {
deviceTitle?: string;
deviceIcon?: string;
}
export type ConfigVehicle = Entity;
export type Charger = Entity;

export interface LoadpointThreshold {
delay: number;
threshold: number;
}

export interface Loadpoint {
id: number;
name: string;
charger: string;
meter: string;
vehicle: string;
title: string;
defaultMode: string;
priority: number;
phasesConfigured: number;
minCurrent: number;
maxCurrent: number;
smartCostLimit: number | null;
planEnergy: number;
planTime: string;
planPrecondition: number;
limitEnergy: number;
limitSoc: number;
thresholds: {
enable: LoadpointThreshold;
disable: LoadpointThreshold;
};
soc: {
poll: {
mode: string;
interval: number;
};
estimate: boolean;
};
}

export interface LoadpointCompact {
Expand Down
31 changes: 21 additions & 10 deletions assets/js/views/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
</template>

<script>
<script lang="ts">
import store from "../store";
import GlobalSettingsModal from "../components/GlobalSettings/GlobalSettingsModal.vue";
import BatterySettingsModal from "../components/Battery/BatterySettingsModal.vue";
Expand All @@ -22,18 +22,19 @@ import PasswordModal from "../components/Auth/PasswordModal.vue";
import LoginModal from "../components/Auth/LoginModal.vue";
import HelpModal from "../components/HelpModal.vue";
import collector from "../mixins/collector";
import { defineComponent } from "vue";

// assume offline if not data received for 5 minutes
let lastDataReceived = new Date();
const maxDataAge = 60 * 1000 * 5;
setInterval(() => {
if (new Date() - lastDataReceived > maxDataAge) {
if (new Date().getTime() - lastDataReceived.getTime() > maxDataAge) {
console.log("no data received, assume we are offline");
window.app.setOffline();
}
}, 1000);

export default {
export default defineComponent({
name: "App",
components: {
GlobalSettingsModal,
Expand All @@ -50,7 +51,11 @@ export default {
offline: Boolean,
},
data: () => {
return { reconnectTimeout: null, ws: null, authNotConfigured: false };
return {
reconnectTimeout: null as number | null,
ws: null as WebSocket | null,
authNotConfigured: false,
};
},
head() {
return { title: "...", titleTemplate: "%s | evcc" };
Expand Down Expand Up @@ -95,20 +100,25 @@ export default {
},
unmounted() {
this.disconnect();
window.clearTimeout(this.reconnectTimeout);
this.clearTimeout();
document.removeEventListener("visibilitychange", this.pageVisibilityChanged, false);
},
methods: {
clearTimeout() {
if (this.reconnectTimeout) {
window.clearTimeout(this.reconnectTimeout);
}
},
pageVisibilityChanged() {
if (document.hidden) {
window.clearTimeout(this.reconnectTimeout);
this.clearTimeout();
this.disconnect();
} else {
this.connect();
}
},
reconnect() {
window.clearTimeout(this.reconnectTimeout);
this.clearTimeout();
this.reconnectTimeout = window.setTimeout(() => {
this.disconnect();
this.connect();
Expand Down Expand Up @@ -152,7 +162,7 @@ export default {
this.ws = new WebSocket(uri);
this.ws.onerror = () => {
console.log({ message: "Websocket error. Trying to reconnect." });
this.ws.close();
this.ws?.close();
};
this.ws.onopen = () => {
console.log("websocket connected");
Expand All @@ -171,8 +181,9 @@ export default {
store.update(msg);
lastDataReceived = new Date();
} catch (error) {
const e = error as Error;
window.app.raise({
message: `Failed to parse web socket data: ${error.message} [${evt.data}]`,
message: `Failed to parse web socket data: ${e.message} [${evt.data}]`,
});
}
};
Expand All @@ -181,7 +192,7 @@ export default {
window.location.reload();
},
},
};
});
</script>
<style scoped>
.app {
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy