ovdashboard/ui/src/components/ImageCarousel.vue

75 lines
1.5 KiB
Vue
Raw Normal View History

<template>
<v-carousel
cycle
2022-09-24 16:29:55 +00:00
v-if="urls.length > 0"
:interval="speed"
2022-09-15 18:08:04 +00:00
:height="height"
:show-arrows="false"
touchless
hide-delimiters
>
2022-09-15 18:08:04 +00:00
<v-carousel-item
v-for="url in urls"
:key="url"
:src="url"
:contain="contain"
/>
</v-carousel>
</template>
<script lang="ts">
2022-09-24 16:29:55 +00:00
import { Component, Vue } from "@/ovd-vue";
@Component
export default class ImageCarousel extends Vue {
2023-10-26 22:28:59 +00:00
public urls: string[] = require("@/assets/image_testdata.json");
public height = 300;
public contain = false;
public speed = 10000;
2022-09-24 16:29:55 +00:00
public created(): void {
super.created();
}
public beforeDestroy(): void {
super.beforeDestroy();
}
2022-09-15 18:08:04 +00:00
2022-09-24 16:29:55 +00:00
protected update(): void {
// Update Images
this.$ovdashboard.api_get_list("image/list", (names) => {
this.urls = names.map((name: string) =>
2023-10-26 22:28:59 +00:00
this.$ovdashboard.api_url(`image/get/${name}`),
2022-09-24 16:29:55 +00:00
);
});
2022-09-15 18:08:04 +00:00
2022-09-24 16:29:55 +00:00
// Update Image Config
type ImageConfig = {
height: number;
contain: boolean;
speed: number;
};
this.$ovdashboard.api_get_object<ImageConfig>("image/config", (cfg) => {
this.height = cfg.height;
this.contain = cfg.contain;
this.speed = cfg.speed;
});
}
}
</script>
<style lang="scss" scoped>
.v-window {
&-x-transition,
&-x-reverse-transition,
&-y-transition,
&-y-reverse-transition {
&-enter-active,
&-leave-active {
transition: 1.5s cubic-bezier(0.25, 0.8, 0.5, 1) !important;
}
}
}
2023-10-26 22:28:59 +00:00
</style>