DashboardInfo self update

This commit is contained in:
Jörn-Michael Miehe 2022-09-24 16:41:25 +00:00
parent 7f46c1761b
commit c3765c1db6
2 changed files with 39 additions and 57 deletions

View file

@ -11,12 +11,7 @@
</template> </template>
<template slot="calendars"> <template slot="calendars">
<CalendarCarousel /> <CalendarCarousel />
<DashboardInfo <DashboardInfo />
:server_host="server_host"
:server_name="server_name"
:version="dashboard_version"
:lan_ip="dashboard_ip"
/>
</template> </template>
</Dashboard> </Dashboard>
<TickerBar /> <TickerBar />
@ -25,7 +20,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Vue } from "@/ovd-vue"; import { Component, Vue } from "vue-property-decorator";
import TitleBar from "./components/title/TitleBar.vue"; import TitleBar from "./components/title/TitleBar.vue";
import Dashboard from "./components/Dashboard.vue"; import Dashboard from "./components/Dashboard.vue";
@ -46,47 +41,7 @@ import TickerBar from "./components/TickerBar.vue";
TickerBar, TickerBar,
}, },
}) })
export default class App extends Vue { export default class App extends Vue {}
// API data
private server_host = "https://oekzident.de";
private server_name = "OEKZident";
private dashboard_version = "0.0.1";
private dashboard_ip = "0.0.0.0";
public created(): void {
super.created();
}
public beforeDestroy(): void {
super.beforeDestroy();
}
protected update(): void {
// Update Server Config
type ServerConfig = {
host: string;
name: string;
};
this.$ovdashboard.api_get_object<ServerConfig>(
"misc/config/server",
(data) => {
this.server_host = data.host;
this.server_name = data.name;
}
);
// Update Version
this.$ovdashboard.api_get_string("misc/version", (data) => {
this.dashboard_version = data;
});
// Update IP
this.$ovdashboard.api_get_string("misc/lanip", (data) => {
this.dashboard_ip = data;
});
}
}
</script> </script>
<style> <style>

View file

@ -14,20 +14,47 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator"; import { Component, Vue } from "@/ovd-vue";
@Component @Component
export default class DashboardInfo extends Vue { export default class DashboardInfo extends Vue {
@Prop({ required: true }) private server_host = "https://oekzident.de";
private readonly version!: string; private server_name = "OEKZident";
private version = "0.0.1";
private lan_ip = "0.0.0.0";
@Prop() public created(): void {
private readonly lan_ip?: string; super.created();
}
@Prop({ required: true }) public beforeDestroy(): void {
private readonly server_host!: string; super.beforeDestroy();
}
@Prop({ required: true }) protected update(): void {
private readonly server_name!: string; // Update Server Config
type ServerConfig = {
host: string;
name: string;
};
this.$ovdashboard.api_get_object<ServerConfig>(
"misc/config/server",
(data) => {
this.server_host = data.host;
this.server_name = data.name;
}
);
// Update Version
this.$ovdashboard.api_get_string("misc/version", (data) => {
this.version = data;
});
// Update IP
this.$ovdashboard.api_get_string("misc/lanip", (data) => {
this.lan_ip = data;
});
}
} }
</script> </script>