diff --git a/ui/src/App.vue b/ui/src/App.vue index a73d92e..baf6af8 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -111,101 +111,74 @@ export default class App extends Vue { private api_query_simple_object( endpoint: string, - on_success: (data: Record) => void + on_success: (data: Record) => void ): void { this.api_query_simple(endpoint, (data) => { if (typeof data !== "object") return; if (data === null) return; - on_success(data as Record); + on_success(data as Record); }); } private update(): void { // Update Logo Config this.api_query_simple_object("misc/config/logo", (data) => { - this.logo_above = data.above; - this.logo_below = data.below; + this.logo_above = data.above as string; + this.logo_below = data.below as string; }); // Update Title - this.$axios - .get(this.$ovdashboard.api_url("text/get/html/title")) - .then((response) => { - this.title_html = response.data; - }) - .catch(this.fail("Title")); + this.api_query_simple_string("text/get/html/title", (data) => { + this.title_html = data; + }); // 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")); + this.api_query_simple_object("image/config", (data) => { + this.image_height = data.height as number; + this.image_contain = data.contain as boolean; + this.image_speed = data.speed as number; + }); // Update Message - this.$axios - .get(this.$ovdashboard.api_url("text/get/html/message")) - .then((response) => { - this.message_html = response.data; - }) - .catch(this.fail("Message")); + this.api_query_simple_string("text/get/html/message", (data) => { + this.message_html = data; + }); // 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")); + this.api_query_simple_object("calendar/config", (data) => { + this.calendar_speed = data.speed as number; + }); // 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")); + this.api_query_simple_object("misc/config/server", (data) => { + this.server_host = data.host as string; + this.server_name = data.name as string; + }); // Update Version - this.$axios - .get(this.$ovdashboard.api_url("misc/version")) - .then((response) => { - this.dashboard_version = response.data; - }) - .catch(this.fail("Version")); + this.api_query_simple_string("misc/version", (data) => { + this.dashboard_version = data; + }); // Update IP - this.$axios - .get(this.$ovdashboard.api_url("misc/lanip")) - .then((response) => { - this.dashboard_ip = response.data; - }) - .catch(this.fail("IP")); + this.api_query_simple_string("misc/lanip", (data) => { + this.dashboard_ip = data; + }); // Update Ticker - this.$axios - .get(this.$ovdashboard.api_url("ticker/html")) - .then((response) => { - this.ticker_html = response.data; - }) - .catch(this.fail("Ticker")); + this.api_query_simple_string("ticker/html", (data) => { + this.ticker_html = data; + }); // Update Ticker Config - this.$axios - .get(this.$ovdashboard.api_url("ticker/config")) - .then((response) => { - this.ticker_color = response.data.color; - }) - .catch(this.fail("Ticker")); + this.api_query_simple_object("ticker/config", (data) => { + this.ticker_color = data.color as string; + }); } public mounted(): void {