added loading icon

This commit is contained in:
Edward Tirado Jr 2025-04-22 19:32:12 -05:00
parent eef0435197
commit 4a3422889f
5 changed files with 34 additions and 6 deletions

Binary file not shown.

View file

@ -0,0 +1,15 @@
<script lang="ts" setup></script>
<template>
<video
alt="Loading"
autoplay
class="flex absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2"
loop
muted
src="/assets/img/movie-loader.webm"
type="video/webm"
/>
</template>
<style scoped></style>

View file

@ -1,4 +1,5 @@
<template> <template>
<LoadingIcon v-if="loading" />
<div v-if="list_id !== 0" class="p-5 sm:p-0"> <div v-if="list_id !== 0" class="p-5 sm:p-0">
<Modal ref="movie_modal"> <Modal ref="movie_modal">
<ShowMovie <ShowMovie
@ -73,6 +74,7 @@ import { useCookie } from "#app";
const list_id = ref(0); const list_id = ref(0);
const list = defineModel<MovieList>("movie_list", { default: [] }); const list = defineModel<MovieList>("movie_list", { default: [] });
const loading = ref(true);
const modal_movie: Ref<Movie | null> = ref(null); const modal_movie: Ref<Movie | null> = ref(null);
const movies = defineModel<Movie[] | []>("movies", { const movies = defineModel<Movie[] | []>("movies", {
default: [], default: [],
@ -83,6 +85,7 @@ const logged_in = ref(false);
const hide_scheduled = ref(false); const hide_scheduled = ref(false);
const getList = async function (list_id: number) { const getList = async function (list_id: number) {
loading.value = true;
let config = useRuntimeConfig(); let config = useRuntimeConfig();
let headers: any = { let headers: any = {
"Content-type": "application/json", "Content-type": "application/json",
@ -100,6 +103,7 @@ const getList = async function (list_id: number) {
list.value = data; list.value = data;
movies.value = data?.movies || []; movies.value = data?.movies || [];
filtered_movies.value = movies.value; filtered_movies.value = movies.value;
loading.value = false;
}) })
.catch((err) => { .catch((err) => {
if (err.statusCode === 401) { if (err.statusCode === 401) {

View file

@ -1,8 +1,10 @@
<template> <template>
<div class="p-5 sm:p-0"> <div class="p-5 sm:p-0">
<div v-if="lists.length < 1"> <div v-if="lists.length < 1 && !loading">
<p>No lists found</p> <p>No lists found</p>
</div> </div>
<LoadingIcon v-if="loading" />
<ul class="grid grid-cols-2 gap-3 mt-5"> <ul class="grid grid-cols-2 gap-3 mt-5">
<li v-for="list in lists" class="movie-card neon-border p-5 rounded"> <li v-for="list in lists" class="movie-card neon-border p-5 rounded">
<div class="grid grid-rows-2 gap-3"> <div class="grid grid-rows-2 gap-3">
@ -21,7 +23,10 @@ import type { MovieList } from "~/types/movielist";
import { useCookie } from "#app"; import { useCookie } from "#app";
const lists = defineModel<MovieList[]>("movie_list", { default: [] }); const lists = defineModel<MovieList[]>("movie_list", { default: [] });
const loading = ref(true);
const updateLists = async function () { const updateLists = async function () {
loading.value = true;
let config = useRuntimeConfig(); let config = useRuntimeConfig();
let headers: any = { let headers: any = {
"Content-type": "application/json", "Content-type": "application/json",
@ -37,6 +42,7 @@ const updateLists = async function () {
}) })
.then((data) => { .then((data) => {
lists.value = data || []; lists.value = data || [];
loading.value = false;
}) })
.catch((err) => { .catch((err) => {
if (err.statusCode === 401) { if (err.statusCode === 401) {

View file

@ -1,8 +1,12 @@
<template> <template>
<div class="p-5 sm:p-0"> <div class="p-5 sm:p-0">
<div v-if="schedule && schedule?.showings.length < 1" class="p-5"> <div
v-if="schedule && schedule?.showings.length < 1 && !loading"
class="p-5"
>
<span>No Showings Found</span> <span>No Showings Found</span>
</div> </div>
<LoadingIcon v-if="loading" />
<ul class="flex flex-col gap-5"> <ul class="flex flex-col gap-5">
<li <li
v-for="showing in schedule?.showings" v-for="showing in schedule?.showings"
@ -36,7 +40,6 @@
> >
Previous Showings Previous Showings
</span> </span>
<span id="loader" class="hidden">Loading...</span>
<ul class="flex flex-col gap-5"> <ul class="flex flex-col gap-5">
<li v-for="showing in past_showings" class="p-5 movie-card neon-border"> <li v-for="showing in past_showings" class="p-5 movie-card neon-border">
<div class="sm:grid grid-cols-2 lg:grid-cols-3"> <div class="sm:grid grid-cols-2 lg:grid-cols-3">
@ -68,6 +71,7 @@ const schedule = defineModel<Schedule>("schedule");
const past_showings = defineModel<Showing[]>("past_showings", { const past_showings = defineModel<Showing[]>("past_showings", {
default: [], default: [],
}); });
const loading = ref(true);
const got_previous = ref(false); const got_previous = ref(false);
const months = [ const months = [
"January", "January",
@ -92,13 +96,12 @@ const formatDate = function (date_string: string) {
}; };
const getSchedule = async function (previous = false) { const getSchedule = async function (previous = false) {
loading.value = true;
let config = useRuntimeConfig(); let config = useRuntimeConfig();
if (got_previous.value) { if (got_previous.value) {
return false; return false;
} }
document.getElementById("loader")?.classList.toggle("hidden");
let params = ""; let params = "";
if (previous) params = "?past_showings=true"; if (previous) params = "?past_showings=true";
@ -120,7 +123,7 @@ const getSchedule = async function (previous = false) {
} else { } else {
schedule.value = data; schedule.value = data;
} }
document.getElementById("loader")?.classList.toggle("hidden"); loading.value = false;
}) })
.catch((err) => { .catch((err) => {
switch (err.statusCode) { switch (err.statusCode) {