CalendarCarousel self update
This commit is contained in:
parent
6f455869a5
commit
7f46c1761b
3 changed files with 48 additions and 47 deletions
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template slot="calendars">
|
<template slot="calendars">
|
||||||
<CalendarCarousel :speed="calendar_speed" :data="calendar_data" />
|
<CalendarCarousel />
|
||||||
<DashboardInfo
|
<DashboardInfo
|
||||||
:server_host="server_host"
|
:server_host="server_host"
|
||||||
:server_name="server_name"
|
:server_name="server_name"
|
||||||
|
@ -26,8 +26,6 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue } from "@/ovd-vue";
|
import { Component, Vue } from "@/ovd-vue";
|
||||||
import { EventData } from "./components/calendar/EventModel";
|
|
||||||
import { CalendarData } from "./components/calendar/CalendarModel";
|
|
||||||
|
|
||||||
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";
|
||||||
|
@ -50,8 +48,6 @@ import TickerBar from "./components/TickerBar.vue";
|
||||||
})
|
})
|
||||||
export default class App extends Vue {
|
export default class App extends Vue {
|
||||||
// API data
|
// API data
|
||||||
private calendar_data: CalendarData[] = require("@/assets/calendar_testdata.json");
|
|
||||||
private calendar_speed = 10000;
|
|
||||||
private server_host = "https://oekzident.de";
|
private server_host = "https://oekzident.de";
|
||||||
private server_name = "OEKZident";
|
private server_name = "OEKZident";
|
||||||
private dashboard_version = "0.0.1";
|
private dashboard_version = "0.0.1";
|
||||||
|
@ -66,35 +62,6 @@ export default class App extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected update(): void {
|
protected update(): void {
|
||||||
// Update Calendar Aggregates
|
|
||||||
this.$ovdashboard.api_get_list("aggregate/list", (names) => {
|
|
||||||
this.$ovdashboard.api_get_object_multi<EventData[]>(
|
|
||||||
names.map((name) => `aggregate/get/${name}`),
|
|
||||||
(calendars) => {
|
|
||||||
this.calendar_data = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < names.length; i++) {
|
|
||||||
this.calendar_data.push({
|
|
||||||
title: names[i],
|
|
||||||
events: calendars[i],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update Calendar Config
|
|
||||||
type CalendarConfig = {
|
|
||||||
speed: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.$ovdashboard.api_get_object<CalendarConfig>(
|
|
||||||
"calendar/config",
|
|
||||||
(data) => {
|
|
||||||
this.calendar_speed = data.speed;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update Server Config
|
// Update Server Config
|
||||||
type ServerConfig = {
|
type ServerConfig = {
|
||||||
host: string;
|
host: string;
|
||||||
|
|
|
@ -15,9 +15,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Prop, Ref, Vue } from "vue-property-decorator";
|
import { Component, Ref, Vue } from "@/ovd-vue";
|
||||||
import Calendar from "./Calendar.vue";
|
import Calendar from "./Calendar.vue";
|
||||||
import { CalendarData, CalendarModel } from "./CalendarModel";
|
import { CalendarData, CalendarModel } from "./CalendarModel";
|
||||||
|
import { EventData } from "./EventModel";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
|
@ -27,15 +28,52 @@ import { CalendarData, CalendarModel } from "./CalendarModel";
|
||||||
export default class CalendarCarousel extends Vue {
|
export default class CalendarCarousel extends Vue {
|
||||||
private interval?: number;
|
private interval?: number;
|
||||||
|
|
||||||
@Prop({ default: 10000 })
|
private data: CalendarData[] = require("@/assets/calendar_testdata.json");
|
||||||
private readonly speed!: number;
|
private speed = 10000;
|
||||||
|
|
||||||
@Prop({ required: true })
|
|
||||||
private readonly data!: CalendarData[];
|
|
||||||
|
|
||||||
@Ref("main")
|
@Ref("main")
|
||||||
private readonly _main?: Vue;
|
private readonly _main?: Vue;
|
||||||
|
|
||||||
|
public created(): void {
|
||||||
|
super.created();
|
||||||
|
}
|
||||||
|
|
||||||
|
public beforeDestroy(): void {
|
||||||
|
super.beforeDestroy();
|
||||||
|
clearInterval(this.interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected update(): void {
|
||||||
|
// Update Calendar Aggregates
|
||||||
|
this.$ovdashboard.api_get_list("aggregate/list", (names) => {
|
||||||
|
this.$ovdashboard.api_get_object_multi<EventData[]>(
|
||||||
|
names.map((name) => `aggregate/get/${name}`),
|
||||||
|
(calendars) => {
|
||||||
|
this.data = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < names.length; i++) {
|
||||||
|
this.data.push({
|
||||||
|
title: names[i],
|
||||||
|
events: calendars[i],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update Calendar Config
|
||||||
|
type CalendarConfig = {
|
||||||
|
speed: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$ovdashboard.api_get_object<CalendarConfig>(
|
||||||
|
"calendar/config",
|
||||||
|
(data) => {
|
||||||
|
this.speed = data.speed;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private update_height(): void {
|
private update_height(): void {
|
||||||
const diff = 150;
|
const diff = 150;
|
||||||
|
|
||||||
|
@ -60,10 +98,6 @@ export default class CalendarCarousel extends Vue {
|
||||||
this.interval = setInterval(this.update_height, 10000);
|
this.interval = setInterval(this.update_height, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public beforeDestroy(): void {
|
|
||||||
clearInterval(this.interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
private get calendars(): CalendarModel[] {
|
private get calendars(): CalendarModel[] {
|
||||||
let arr = [];
|
let arr = [];
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,16 @@ import { Vue as _Vue } from "vue-property-decorator";
|
||||||
export * from "vue-property-decorator";
|
export * from "vue-property-decorator";
|
||||||
|
|
||||||
export abstract class Vue extends _Vue {
|
export abstract class Vue extends _Vue {
|
||||||
private interval?: number;
|
private _ovd_interval?: number;
|
||||||
|
|
||||||
protected abstract update(): void;
|
protected abstract update(): void;
|
||||||
|
|
||||||
public created(): void {
|
public created(): void {
|
||||||
this.update();
|
this.update();
|
||||||
this.interval = setInterval(this.update, 30000);
|
this._ovd_interval = setInterval(this.update, 30000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public beforeDestroy(): void {
|
public beforeDestroy(): void {
|
||||||
clearInterval(this.interval);
|
clearInterval(this._ovd_interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue