mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-13 17:22:54 -05:00
Add national days
This commit is contained in:
6
WebDisplay/src/models/calendar/national-day.ts
Normal file
6
WebDisplay/src/models/calendar/national-day.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export default interface NationalDayEntry {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
except: string;
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
@@ -7,11 +7,10 @@
|
|||||||
import { useCalendarStore } from '@/stores/calendarStore';
|
import { useCalendarStore } from '@/stores/calendarStore';
|
||||||
import { format, startOfDay, endOfDay } from 'date-fns';
|
import { format, startOfDay, endOfDay } from 'date-fns';
|
||||||
import CalendarDay from '@/models/calendar/calendar-day';
|
import CalendarDay from '@/models/calendar/calendar-day';
|
||||||
|
import NationalDayEntry from '@/models/calendar/national-day';
|
||||||
|
|
||||||
const calendarDayCount = 7;
|
const calendarDayCount = 7;
|
||||||
|
|
||||||
const calendarReady = ref(false);
|
|
||||||
|
|
||||||
const weatherStore = useWeatherStore();
|
const weatherStore = useWeatherStore();
|
||||||
weatherStore.start();
|
weatherStore.start();
|
||||||
|
|
||||||
@@ -28,6 +27,10 @@
|
|||||||
|
|
||||||
const currentTime = ref(new Date());
|
const currentTime = ref(new Date());
|
||||||
const calendarDays = ref([] as CalendarDay[]);
|
const calendarDays = ref([] as CalendarDay[]);
|
||||||
|
const calendarReady = ref(false);
|
||||||
|
|
||||||
|
const nationalDays = ref([] as NationalDayEntry[]);
|
||||||
|
const nationalDaysReady = ref(false);
|
||||||
|
|
||||||
const timeFormatter = new Intl.DateTimeFormat('en-US', { hour: 'numeric', minute: '2-digit' });
|
const timeFormatter = new Intl.DateTimeFormat('en-US', { hour: 'numeric', minute: '2-digit' });
|
||||||
const dateFormatter = new Intl.DateTimeFormat('en-US', { weekday: 'long', month: 'long', day: 'numeric' });
|
const dateFormatter = new Intl.DateTimeFormat('en-US', { weekday: 'long', month: 'long', day: 'numeric' });
|
||||||
@@ -77,8 +80,19 @@
|
|||||||
|
|
||||||
loadCalendar();
|
loadCalendar();
|
||||||
|
|
||||||
|
function loadNationalDays() {
|
||||||
|
calendarStore.getNationalDays().then((data) => {
|
||||||
|
nationalDays.value = data;
|
||||||
|
|
||||||
|
nationalDaysReady.value = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
loadNationalDays();
|
||||||
|
|
||||||
setInterval(() => (currentTime.value = new Date()), 1000);
|
setInterval(() => (currentTime.value = new Date()), 1000);
|
||||||
setInterval(() => loadCalendar(), 30 * 60 * 1000);
|
setInterval(() => loadCalendar(), 30 * 60 * 1000);
|
||||||
|
setInterval(() => loadNationalDays(), 2 * 60 * 60 * 1000);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -202,6 +216,13 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="kiosk-national-days"
|
||||||
|
v-if="nationalDaysReady">
|
||||||
|
<div v-for="nationalDay in nationalDays">
|
||||||
|
{{ nationalDay.name }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
@@ -250,12 +271,14 @@
|
|||||||
.kiosk-content {
|
.kiosk-content {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
max-height: 100vh;
|
max-height: 100vh;
|
||||||
padding: 0;
|
padding: 10px;
|
||||||
|
gap: 10px;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
grid-template-rows: repeat(2, 50%);
|
grid-template-rows: repeat(3, auto);
|
||||||
grid-auto-flow: row;
|
grid-auto-flow: row;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
|
'kiosk-calendar kiosk-national-days kiosk-national-days'
|
||||||
'kiosk-calendar . .'
|
'kiosk-calendar . .'
|
||||||
'kiosk-calendar . .';
|
'kiosk-calendar . .';
|
||||||
}
|
}
|
||||||
@@ -315,13 +338,20 @@
|
|||||||
.kiosk-calendar {
|
.kiosk-calendar {
|
||||||
grid-area: kiosk-calendar;
|
grid-area: kiosk-calendar;
|
||||||
background-color: #121212;
|
background-color: #121212;
|
||||||
margin: 10px;
|
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.kiosk-national-days {
|
||||||
|
grid-area: kiosk-national-days;
|
||||||
|
background-color: #121212;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.kiosk-calendar-header {
|
.kiosk-calendar-header {
|
||||||
font-size: 1.15em;
|
font-size: 1.15em;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { defineStore } from 'pinia';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import Environment from '@/environment';
|
import Environment from '@/environment';
|
||||||
import CalendarEntry from '@/models/calendar/calendar-entry';
|
import CalendarEntry from '@/models/calendar/calendar-entry';
|
||||||
|
import NationalDayEntry from '@/models/calendar/national-day';
|
||||||
|
|
||||||
export const useCalendarStore = defineStore('calendar', {
|
export const useCalendarStore = defineStore('calendar', {
|
||||||
state: () => {
|
state: () => {
|
||||||
@@ -11,6 +12,11 @@ export const useCalendarStore = defineStore('calendar', {
|
|||||||
async getUpcoming(days: number, includeHolidays: boolean): Promise<CalendarEntry[]> {
|
async getUpcoming(days: number, includeHolidays: boolean): Promise<CalendarEntry[]> {
|
||||||
const response = await axios.get<CalendarEntry[]>(Environment.getUrlPrefix() + `:8081/api/calendar/calendar/upcoming?days=${days}&includeHolidays=${includeHolidays}`);
|
const response = await axios.get<CalendarEntry[]>(Environment.getUrlPrefix() + `:8081/api/calendar/calendar/upcoming?days=${days}&includeHolidays=${includeHolidays}`);
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
async getNationalDays(): Promise<NationalDayEntry[]> {
|
||||||
|
const response = await axios.get<NationalDayEntry[]>(Environment.getUrlPrefix() + `:8081/api/calendar/national-days/today`);
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user