some better naming
This commit is contained in:
parent
800cc87d51
commit
a7eed28bf3
2 changed files with 22 additions and 22 deletions
|
@ -95,19 +95,19 @@ export default class App extends Vue {
|
||||||
below: string;
|
below: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$ovdashboard.api_get_object<LogoConfig>("misc/config/logo", (data) => {
|
this.$ovdashboard.api_get_object<LogoConfig>("misc/config/logo", (cfg) => {
|
||||||
this.logo_above = data.above;
|
this.logo_above = cfg.above;
|
||||||
this.logo_below = data.below;
|
this.logo_below = cfg.below;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update Title
|
// Update Title
|
||||||
this.$ovdashboard.api_get_string("text/get/html/title", (data) => {
|
this.$ovdashboard.api_get_string("text/get/html/title", (title) => {
|
||||||
this.title_html = data;
|
this.title_html = title;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update Images
|
// Update Images
|
||||||
this.$ovdashboard.api_get_list("image/list", (data) => {
|
this.$ovdashboard.api_get_list("image/list", (names) => {
|
||||||
this.image_urls = data.map((name: string) =>
|
this.image_urls = names.map((name: string) =>
|
||||||
this.$ovdashboard.api_url("image/get/" + name)
|
this.$ovdashboard.api_url("image/get/" + name)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -119,10 +119,10 @@ export default class App extends Vue {
|
||||||
speed: number;
|
speed: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$ovdashboard.api_get_object<ImageConfig>("image/config", (data) => {
|
this.$ovdashboard.api_get_object<ImageConfig>("image/config", (cfg) => {
|
||||||
this.image_height = data.height;
|
this.image_height = cfg.height;
|
||||||
this.image_contain = data.contain;
|
this.image_contain = cfg.contain;
|
||||||
this.image_speed = data.speed;
|
this.image_speed = cfg.speed;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update Message
|
// Update Message
|
||||||
|
@ -132,8 +132,8 @@ export default class App extends Vue {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update Calendar Aggregates
|
// Update Calendar Aggregates
|
||||||
this.$ovdashboard.api_get_list("aggregate/list", (data) => {
|
this.$ovdashboard.api_get_list("aggregate/list", (names) => {
|
||||||
let promises = data.map((name: string) =>
|
let promises = names.map((name: string) =>
|
||||||
this.$ovdashboard.api_get_prepare<EventData[]>("aggregate/get/" + name)
|
this.$ovdashboard.api_get_prepare<EventData[]>("aggregate/get/" + name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -141,9 +141,9 @@ export default class App extends Vue {
|
||||||
.then((responses) => {
|
.then((responses) => {
|
||||||
this.calendar_data = [];
|
this.calendar_data = [];
|
||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < names.length; i++) {
|
||||||
this.calendar_data.push({
|
this.calendar_data.push({
|
||||||
title: data[i],
|
title: names[i],
|
||||||
events: responses[i].data,
|
events: responses[i].data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,11 +54,11 @@ export class OVDashboardPlugin {
|
||||||
return this.axios.get<T>(this.api_url(endpoint));
|
return this.axios.get<T>(this.api_url(endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
public api_get_generic(
|
public api_get<T>(
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
on_success: (data: unknown) => void
|
on_success: (data: T) => void
|
||||||
): void {
|
): void {
|
||||||
this.api_get_prepare(endpoint)
|
this.api_get_prepare<T>(endpoint)
|
||||||
.then((response) => on_success(response.data))
|
.then((response) => on_success(response.data))
|
||||||
.catch(this.fail(endpoint));
|
.catch(this.fail(endpoint));
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ export class OVDashboardPlugin {
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
on_success: (data: string) => void
|
on_success: (data: string) => void
|
||||||
): void {
|
): void {
|
||||||
this.api_get_generic(endpoint, (data) => {
|
this.api_get<string>(endpoint, (data) => {
|
||||||
if (typeof data !== "string") {
|
if (typeof data !== "string") {
|
||||||
console.error("Endpoint", endpoint, "did not return a string:", data);
|
console.error("Endpoint", endpoint, "did not return a string:", data);
|
||||||
return;
|
return;
|
||||||
|
@ -81,7 +81,7 @@ export class OVDashboardPlugin {
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
on_success: (data: string[]) => void
|
on_success: (data: string[]) => void
|
||||||
): void {
|
): void {
|
||||||
this.api_get_generic(endpoint, (data) => {
|
this.api_get<string[]>(endpoint, (data) => {
|
||||||
if (!Array.isArray(data)) {
|
if (!Array.isArray(data)) {
|
||||||
console.error("Endpoint", endpoint, "did not return an Array:", data);
|
console.error("Endpoint", endpoint, "did not return an Array:", data);
|
||||||
return;
|
return;
|
||||||
|
@ -100,7 +100,7 @@ export class OVDashboardPlugin {
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
on_success: (data: Type) => void
|
on_success: (data: Type) => void
|
||||||
): void {
|
): void {
|
||||||
this.api_get_generic(endpoint, (data) => {
|
this.api_get<Type>(endpoint, (data) => {
|
||||||
if (typeof data !== "object") {
|
if (typeof data !== "object") {
|
||||||
console.error("Endpoint", endpoint, "did not return an Object:", data);
|
console.error("Endpoint", endpoint, "did not return an Object:", data);
|
||||||
return;
|
return;
|
||||||
|
@ -111,7 +111,7 @@ export class OVDashboardPlugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
on_success(data as Type);
|
on_success(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue