diff --git a/ui/src/App.vue b/ui/src/App.vue index 9435e9a..a73d92e 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -83,20 +83,50 @@ export default class App extends Vue { private ticker_html = "
changeme
"; private ticker_color = "primary"; - private fail(part: string): (arg0: unknown) => void { + private fail(name: string): (arg0: unknown) => void { return (reason: unknown) => - console.warn("Failed to update", part, "-", reason); + console.warn("Failed to query", name, "-", reason); + } + + private api_query_simple( + endpoint: string, + on_success: (data: unknown) => void + ): void { + this.$axios + .get(this.$ovdashboard.api_url(endpoint)) + .then((response) => on_success(response.data)) + .catch(this.fail(endpoint)); + } + + private api_query_simple_string( + endpoint: string, + on_success: (data: string) => void + ): void { + this.api_query_simple(endpoint, (data) => { + if (typeof data !== "string") return; + + on_success(data); + }); + } + + private api_query_simple_object( + endpoint: string, + on_success: (data: Record