From a7eed28bf39dacaece74c69f0f3f83a64f3058cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Fri, 16 Sep 2022 22:29:03 +0000 Subject: [PATCH] some better naming --- ui/src/App.vue | 30 +++++++++++++++--------------- ui/src/plugins/ovdashboard.ts | 14 +++++++------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ui/src/App.vue b/ui/src/App.vue index 6ce0781..ba00bc5 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -95,19 +95,19 @@ export default class App extends Vue { below: string; }; - this.$ovdashboard.api_get_object("misc/config/logo", (data) => { - this.logo_above = data.above; - this.logo_below = data.below; + this.$ovdashboard.api_get_object("misc/config/logo", (cfg) => { + this.logo_above = cfg.above; + this.logo_below = cfg.below; }); // Update Title - this.$ovdashboard.api_get_string("text/get/html/title", (data) => { - this.title_html = data; + this.$ovdashboard.api_get_string("text/get/html/title", (title) => { + this.title_html = title; }); // Update Images - this.$ovdashboard.api_get_list("image/list", (data) => { - this.image_urls = data.map((name: string) => + this.$ovdashboard.api_get_list("image/list", (names) => { + this.image_urls = names.map((name: string) => this.$ovdashboard.api_url("image/get/" + name) ); }); @@ -119,10 +119,10 @@ export default class App extends Vue { speed: number; }; - this.$ovdashboard.api_get_object("image/config", (data) => { - this.image_height = data.height; - this.image_contain = data.contain; - this.image_speed = data.speed; + this.$ovdashboard.api_get_object("image/config", (cfg) => { + this.image_height = cfg.height; + this.image_contain = cfg.contain; + this.image_speed = cfg.speed; }); // Update Message @@ -132,8 +132,8 @@ export default class App extends Vue { ); // Update Calendar Aggregates - this.$ovdashboard.api_get_list("aggregate/list", (data) => { - let promises = data.map((name: string) => + this.$ovdashboard.api_get_list("aggregate/list", (names) => { + let promises = names.map((name: string) => this.$ovdashboard.api_get_prepare("aggregate/get/" + name) ); @@ -141,9 +141,9 @@ export default class App extends Vue { .then((responses) => { this.calendar_data = []; - for (let i = 0; i < data.length; i++) { + for (let i = 0; i < names.length; i++) { this.calendar_data.push({ - title: data[i], + title: names[i], events: responses[i].data, }); } diff --git a/ui/src/plugins/ovdashboard.ts b/ui/src/plugins/ovdashboard.ts index 873baa3..c5b7c52 100644 --- a/ui/src/plugins/ovdashboard.ts +++ b/ui/src/plugins/ovdashboard.ts @@ -54,11 +54,11 @@ export class OVDashboardPlugin { return this.axios.get(this.api_url(endpoint)); } - public api_get_generic( + public api_get( endpoint: string, - on_success: (data: unknown) => void + on_success: (data: T) => void ): void { - this.api_get_prepare(endpoint) + this.api_get_prepare(endpoint) .then((response) => on_success(response.data)) .catch(this.fail(endpoint)); } @@ -67,7 +67,7 @@ export class OVDashboardPlugin { endpoint: string, on_success: (data: string) => void ): void { - this.api_get_generic(endpoint, (data) => { + this.api_get(endpoint, (data) => { if (typeof data !== "string") { console.error("Endpoint", endpoint, "did not return a string:", data); return; @@ -81,7 +81,7 @@ export class OVDashboardPlugin { endpoint: string, on_success: (data: string[]) => void ): void { - this.api_get_generic(endpoint, (data) => { + this.api_get(endpoint, (data) => { if (!Array.isArray(data)) { console.error("Endpoint", endpoint, "did not return an Array:", data); return; @@ -100,7 +100,7 @@ export class OVDashboardPlugin { endpoint: string, on_success: (data: Type) => void ): void { - this.api_get_generic(endpoint, (data) => { + this.api_get(endpoint, (data) => { if (typeof data !== "object") { console.error("Endpoint", endpoint, "did not return an Object:", data); return; @@ -111,7 +111,7 @@ export class OVDashboardPlugin { return; } - on_success(data as Type); + on_success(data); }); } }