diff --git a/ui/src/App.vue b/ui/src/App.vue index 6516a33..841ccab 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -89,10 +89,18 @@ export default class App extends Vue { private update(): void { // Update Logo Config - this.$ovdashboard.api_query_simple_object("misc/config/logo", (data) => { - this.logo_above = data.above as string; - this.logo_below = data.below as string; - }); + type LogoConfig = { + above: string; + below: string; + }; + + this.$ovdashboard.api_query_simple_object( + "misc/config/logo", + (data) => { + this.logo_above = data.above; + this.logo_below = data.below; + } + ); // Update Title this.$ovdashboard.api_query_simple_string("text/get/html/title", (data) => { @@ -107,11 +115,20 @@ export default class App extends Vue { }); // Update Image Config - this.$ovdashboard.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; - }); + type ImageConfig = { + height: number; + contain: boolean; + speed: number; + }; + + this.$ovdashboard.api_query_simple_object( + "image/config", + (data) => { + this.image_height = data.height; + this.image_contain = data.contain; + this.image_speed = data.speed; + } + ); // Update Message this.$ovdashboard.api_query_simple_string( @@ -140,15 +157,30 @@ export default class App extends Vue { }); // Update Calendar Config - this.$ovdashboard.api_query_simple_object("calendar/config", (data) => { - this.calendar_speed = data.speed as number; - }); + type CalendarConfig = { + speed: number; + }; + + this.$ovdashboard.api_query_simple_object( + "calendar/config", + (data) => { + this.calendar_speed = data.speed; + } + ); // Update Server Config - this.$ovdashboard.api_query_simple_object("misc/config/server", (data) => { - this.server_host = data.host as string; - this.server_name = data.name as string; - }); + type ServerConfig = { + host: string; + name: string; + }; + + this.$ovdashboard.api_query_simple_object( + "misc/config/server", + (data) => { + this.server_host = data.host; + this.server_name = data.name; + } + ); // Update Version this.$ovdashboard.api_query_simple_string("misc/version", (data) => { @@ -166,9 +198,16 @@ export default class App extends Vue { }); // Update Ticker Config - this.$ovdashboard.api_query_simple_object("ticker/config", (data) => { - this.ticker_color = data.color as string; - }); + type TickerConfig = { + color: string; + }; + + this.$ovdashboard.api_query_simple_object( + "ticker/config", + (data) => { + this.ticker_color = data.color; + } + ); } public created(): void { diff --git a/ui/src/plugins/ovdashboard.ts b/ui/src/plugins/ovdashboard.ts index 8942b07..72bcd55 100644 --- a/ui/src/plugins/ovdashboard.ts +++ b/ui/src/plugins/ovdashboard.ts @@ -83,15 +83,15 @@ export class OVDashboardPlugin { }); } - public api_query_simple_object( + public api_query_simple_object( endpoint: string, - on_success: (data: Record) => void + on_success: (data: Type) => 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 Type); }); } }