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 slot="calendars">
<CalendarCarousel />
<DashboardInfo
:server_host="server_host"
:server_name="server_name"
:version="dashboard_version"
:lan_ip="dashboard_ip"
/>
<DashboardInfo />
</template>
</Dashboard>
<TickerBar />
@ -25,7 +20,7 @@
</template>
<script lang="ts">
import { Component, Vue } from "@/ovd-vue";
import { Component, Vue } from "vue-property-decorator";
import TitleBar from "./components/title/TitleBar.vue";
import Dashboard from "./components/Dashboard.vue";
@ -46,47 +41,7 @@ import TickerBar from "./components/TickerBar.vue";
TickerBar,
},
})
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;
});
}
}
export default class App extends Vue {}
</script>
<style>

View file

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