Simple API queries

This commit is contained in:
Jörn-Michael Miehe 2022-09-16 14:02:18 +00:00
parent ba7c2bd926
commit fc9a51da5d

View file

@ -42,7 +42,6 @@
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { AxiosResponse } from "axios";
import TitleBar from "./components/title/TitleBar.vue";
import Dashboard from "./components/Dashboard.vue";
@ -84,15 +83,99 @@ export default class App extends Vue {
private ticker_html = "<p>changeme</p>";
private ticker_color = "primary";
private update_logo(response: AxiosResponse): void {
this.logo_above = response.data.above;
this.logo_below = response.data.below;
private fail(part: string): (arg0: unknown) => void {
return (reason: unknown) =>
console.warn("Failed to update", part, "-", reason);
}
private update(): void {
// Update Logo Config
this.$axios
.get(this.$ovdashboard.api_url("misc/config/logo"))
.then(this.update_logo);
.then((response) => {
this.logo_above = response.data.above;
this.logo_below = response.data.below;
})
.catch(this.fail("Logo Config"));
// Update Title
this.$axios
.get(this.$ovdashboard.api_url("text/get/html/title"))
.then((response) => {
this.title_html = response.data;
})
.catch(this.fail("Title"));
// Update Images
// Update Image Config
this.$axios
.get(this.$ovdashboard.api_url("image/config"))
.then((response) => {
this.image_height = response.data.height;
this.image_contain = response.data.contain;
this.image_speed = response.data.speed;
})
.catch(this.fail("Image Config"));
// Update Message
this.$axios
.get(this.$ovdashboard.api_url("text/get/html/message"))
.then((response) => {
this.message_html = response.data;
})
.catch(this.fail("Message"));
// Update Calendars
// Update Calendar Config
this.$axios
.get(this.$ovdashboard.api_url("calendar/config"))
.then((response) => {
this.calendar_speed = response.data.speed;
})
.catch(this.fail("Calendar Config"));
// Update Server Config
this.$axios
.get(this.$ovdashboard.api_url("misc/config/server"))
.then((response) => {
this.server_host = response.data.host;
this.server_name = response.data.name;
})
.catch(this.fail("Server Config"));
// Update Version
this.$axios
.get(this.$ovdashboard.api_url("misc/version"))
.then((response) => {
this.dashboard_version = response.data;
})
.catch(this.fail("Version"));
// Update IP
this.$axios
.get(this.$ovdashboard.api_url("misc/lanip"))
.then((response) => {
this.dashboard_ip = response.data;
})
.catch(this.fail("IP"));
// Update Ticker
this.$axios
.get(this.$ovdashboard.api_url("ticker/html"))
.then((response) => {
this.ticker_html = response.data;
})
.catch(this.fail("Ticker"));
// Update Ticker Config
this.$axios
.get(this.$ovdashboard.api_url("ticker/config"))
.then((response) => {
this.ticker_color = response.data.color;
})
.catch(this.fail("Ticker"));
}
public mounted(): void {