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;
|
||||
};
|
||||
|
||||
this.$ovdashboard.api_get_object<LogoConfig>("misc/config/logo", (data) => {
|
||||
this.logo_above = data.above;
|
||||
this.logo_below = data.below;
|
||||
this.$ovdashboard.api_get_object<LogoConfig>("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<ImageConfig>("image/config", (data) => {
|
||||
this.image_height = data.height;
|
||||
this.image_contain = data.contain;
|
||||
this.image_speed = data.speed;
|
||||
this.$ovdashboard.api_get_object<ImageConfig>("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<EventData[]>("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,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -54,11 +54,11 @@ export class OVDashboardPlugin {
|
|||
return this.axios.get<T>(this.api_url(endpoint));
|
||||
}
|
||||
|
||||
public api_get_generic(
|
||||
public api_get<T>(
|
||||
endpoint: string,
|
||||
on_success: (data: unknown) => void
|
||||
on_success: (data: T) => void
|
||||
): void {
|
||||
this.api_get_prepare(endpoint)
|
||||
this.api_get_prepare<T>(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<string>(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<string[]>(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<Type>(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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue