Compare commits
No commits in common. "7df24feb00221f2ff021d83d383c634f83fee296" and "ba7c2bd926454dba34a6ea53b801d52eb06adb4a" have entirely different histories.
7df24feb00
...
ba7c2bd926
1 changed files with 7 additions and 93 deletions
100
ui/src/App.vue
100
ui/src/App.vue
|
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue } from "vue-property-decorator";
|
import { Component, Vue } from "vue-property-decorator";
|
||||||
|
import { AxiosResponse } from "axios";
|
||||||
|
|
||||||
import TitleBar from "./components/title/TitleBar.vue";
|
import TitleBar from "./components/title/TitleBar.vue";
|
||||||
import Dashboard from "./components/Dashboard.vue";
|
import Dashboard from "./components/Dashboard.vue";
|
||||||
|
|
@ -83,102 +84,15 @@ export default class App extends Vue {
|
||||||
private ticker_html = "<p>changeme</p>";
|
private ticker_html = "<p>changeme</p>";
|
||||||
private ticker_color = "primary";
|
private ticker_color = "primary";
|
||||||
|
|
||||||
private fail(name: string): (arg0: unknown) => void {
|
private update_logo(response: AxiosResponse): void {
|
||||||
return (reason: unknown) =>
|
this.logo_above = response.data.above;
|
||||||
console.warn("Failed to query", name, "-", reason);
|
this.logo_below = response.data.below;
|
||||||
}
|
|
||||||
|
|
||||||
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<string, unknown>) => void
|
|
||||||
): void {
|
|
||||||
this.api_query_simple(endpoint, (data) => {
|
|
||||||
if (typeof data !== "object") return;
|
|
||||||
if (data === null) return;
|
|
||||||
|
|
||||||
on_success(data as Record<string, unknown>);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private update(): void {
|
private update(): void {
|
||||||
// Update Logo Config
|
this.$axios
|
||||||
this.api_query_simple_object("misc/config/logo", (data) => {
|
.get(this.$ovdashboard.api_url("misc/config/logo"))
|
||||||
this.logo_above = data.above as string;
|
.then(this.update_logo);
|
||||||
this.logo_below = data.below as string;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update Title
|
|
||||||
this.api_query_simple_string("text/get/html/title", (data) => {
|
|
||||||
this.title_html = data;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update Images
|
|
||||||
|
|
||||||
// Update 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.api_query_simple_string("text/get/html/message", (data) => {
|
|
||||||
this.message_html = data;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update Calendars
|
|
||||||
|
|
||||||
// Update Calendar Config
|
|
||||||
this.api_query_simple_object("calendar/config", (data) => {
|
|
||||||
this.calendar_speed = data.speed as number;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update 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.api_query_simple_string("misc/version", (data) => {
|
|
||||||
this.dashboard_version = data;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update IP
|
|
||||||
this.api_query_simple_string("misc/lanip", (data) => {
|
|
||||||
this.dashboard_ip = data;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update Ticker
|
|
||||||
this.api_query_simple_string("ticker/html", (data) => {
|
|
||||||
this.ticker_html = data;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update Ticker Config
|
|
||||||
this.api_query_simple_object("ticker/config", (data) => {
|
|
||||||
this.ticker_color = data.color as string;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public mounted(): void {
|
public mounted(): void {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue