A few fixes
This commit is contained in:
parent
6e576faefd
commit
4811b2062c
@ -75,5 +75,5 @@ steps:
|
|||||||
#- docker login -u $${DOCKER_USER} -p $${DOCKER_PASS}
|
#- docker login -u $${DOCKER_USER} -p $${DOCKER_PASS}
|
||||||
- docker-compose -p infoscreen -f docker-compose.yml rm -s -v -f
|
- docker-compose -p infoscreen -f docker-compose.yml rm -s -v -f
|
||||||
- docker rmi $${REGISTRY_HOST}/$${IMAGE} || true
|
- docker rmi $${REGISTRY_HOST}/$${IMAGE} || true
|
||||||
- docker pull $${REGISTRY_HOST}/$${IMAGE}
|
- docker pull $${REGISTRY_HOST}/$${IMAGE}:latest
|
||||||
- docker-compose -p infoscreen -f docker-compose.yml up --no-build -d
|
- docker-compose -p infoscreen -f docker-compose.yml up --no-build -d
|
@ -19,17 +19,6 @@ const Calendar = ({ secrets }: { secrets: SecretsCalendar }) => {
|
|||||||
const [token, setToken] = React.useState("")
|
const [token, setToken] = React.useState("")
|
||||||
const [events, setEvents] = React.useState([])
|
const [events, setEvents] = React.useState([])
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
requestToken().then(pullCalendar)
|
|
||||||
const calendarInterval = setInterval(pullCalendar, CALENDAR_REFRESH_INTERVAL);
|
|
||||||
const calendarTokenInterval = setInterval(requestToken, CALENDAR_TOKEN_REFRESH_INTERVAL);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clearInterval(calendarInterval);
|
|
||||||
clearInterval(calendarTokenInterval);
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const processEventData = (events: Event[]) => {
|
const processEventData = (events: Event[]) => {
|
||||||
const eventTable = [];
|
const eventTable = [];
|
||||||
let lastDate = "";
|
let lastDate = "";
|
||||||
@ -110,6 +99,17 @@ const Calendar = ({ secrets }: { secrets: SecretsCalendar }) => {
|
|||||||
setEvents(processEventData(events.items));
|
setEvents(processEventData(events.items));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
requestToken().then(pullCalendar)
|
||||||
|
const calendarInterval = setInterval(pullCalendar, CALENDAR_REFRESH_INTERVAL);
|
||||||
|
const calendarTokenInterval = setInterval(requestToken, CALENDAR_TOKEN_REFRESH_INTERVAL);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearInterval(calendarInterval);
|
||||||
|
clearInterval(calendarTokenInterval);
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
return <div className={`container ${styles.container}`}>
|
return <div className={`container ${styles.container}`}>
|
||||||
<table><tbody>
|
<table><tbody>
|
||||||
{events}
|
{events}
|
||||||
|
@ -9,13 +9,6 @@ const DVB = ({ stopId }: { stopId: number }) => {
|
|||||||
const [departuresHead, setDeparturesHead] = React.useState("")
|
const [departuresHead, setDeparturesHead] = React.useState("")
|
||||||
const [departuresTable, setDeparturesTable] = React.useState([])
|
const [departuresTable, setDeparturesTable] = React.useState([])
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
pullDepartures();
|
|
||||||
const dvbInterval = setInterval(pullDepartures, DVB_REFRESH_INTERVAL);
|
|
||||||
|
|
||||||
return () => clearInterval(dvbInterval);
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const processDepatures = (departures: Departure[]) => {
|
const processDepatures = (departures: Departure[]) => {
|
||||||
const depTable = [];
|
const depTable = [];
|
||||||
|
|
||||||
@ -55,13 +48,19 @@ const DVB = ({ stopId }: { stopId: number }) => {
|
|||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.Name !== departuresHead) setDeparturesHead(data.Name);
|
if (data.Name !== departuresHead) setDeparturesHead(data.Name);
|
||||||
console.log(data)
|
//console.log(data)
|
||||||
processDepatures(data.Departures);
|
processDepatures(data.Departures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
pullDepartures();
|
||||||
|
const dvbInterval = setInterval(pullDepartures, DVB_REFRESH_INTERVAL);
|
||||||
|
|
||||||
|
return () => clearInterval(dvbInterval);
|
||||||
|
}, [])
|
||||||
|
|
||||||
return (<div className={`container ${styles.container}`}>
|
return (<div className={`container ${styles.container}`}>
|
||||||
<table>
|
<table>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{departuresTable}
|
{departuresTable}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -8,13 +8,6 @@ const NEWS_REFRESH_INTERVAL = 15 * 60 * 1000;
|
|||||||
const News = () => {
|
const News = () => {
|
||||||
const [news, setNews] = React.useState([])
|
const [news, setNews] = React.useState([])
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
pullNews()
|
|
||||||
const newsInterval = setInterval(pullNews, NEWS_REFRESH_INTERVAL);
|
|
||||||
|
|
||||||
return () => clearInterval(newsInterval);
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const processNews = (news: NewsType[], postillon: PostillonNews[]) => {
|
const processNews = (news: NewsType[], postillon: PostillonNews[]) => {
|
||||||
const newsTable = []
|
const newsTable = []
|
||||||
|
|
||||||
@ -49,7 +42,7 @@ const News = () => {
|
|||||||
const pullNews = async () => {
|
const pullNews = async () => {
|
||||||
const xml = new XMLParser();
|
const xml = new XMLParser();
|
||||||
const response = await fetch("https://www.tagesschau.de/xml/atom/");
|
const response = await fetch("https://www.tagesschau.de/xml/atom/");
|
||||||
const feed: {title: string; updated: string;}[] = xml.parse(await response.text()).feed.entry;
|
const feed: { title: string; updated: string; }[] = xml.parse(await response.text()).feed.entry;
|
||||||
|
|
||||||
// Feedburner does not allow cors but at least we get JSON
|
// Feedburner does not allow cors but at least we get JSON
|
||||||
const postResponse = await fetch("https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Ffeeds.feedburner.com%2Fblogspot%2FrkEL");
|
const postResponse = await fetch("https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Ffeeds.feedburner.com%2Fblogspot%2FrkEL");
|
||||||
@ -58,6 +51,13 @@ const News = () => {
|
|||||||
processNews(feed, data.items);
|
processNews(feed, data.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
pullNews()
|
||||||
|
const newsInterval = setInterval(pullNews, NEWS_REFRESH_INTERVAL);
|
||||||
|
|
||||||
|
return () => clearInterval(newsInterval);
|
||||||
|
}, [])
|
||||||
|
|
||||||
return <div className={`container ${styles.container}`}>
|
return <div className={`container ${styles.container}`}>
|
||||||
<div className={styles.inner}>
|
<div className={styles.inner}>
|
||||||
<table>
|
<table>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
//import useWebSocket from "react-use-websocket";
|
//import useWebSocket from "react-use-websocket";
|
||||||
import {connect} from "mqtt"
|
import { connect } from "mqtt"
|
||||||
import type { SecretsMQTT, SongInfo } from "../lib/interfaces"
|
import type { SecretsMQTT, SongInfo } from "../lib/interfaces"
|
||||||
import * as styles from "../styles/containers/Spotify.module.css"
|
import * as styles from "../styles/containers/Spotify.module.css"
|
||||||
|
|
||||||
const Spotify = ({ mqtt, Alternative }: { mqtt: SecretsMQTT, Alternative: any }) => {
|
const Spotify = ({ mqtt, Alternative }: { mqtt: SecretsMQTT, Alternative: any }) => {
|
||||||
const [lastSongInfo, setLastSongInfo] = React.useState<SongInfo|undefined>(undefined)
|
const [lastSongInfo, setLastSongInfo] = React.useState<SongInfo | undefined>(undefined)
|
||||||
|
|
||||||
const handleMessage = (_topic: string, message: string) => {
|
const handleMessage = (_topic: string, message: string) => {
|
||||||
try {
|
try {
|
||||||
@ -31,7 +31,7 @@ const Spotify = ({ mqtt, Alternative }: { mqtt: SecretsMQTT, Alternative: any })
|
|||||||
client.subscribe("infoscreen/spotify")
|
client.subscribe("infoscreen/spotify")
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => {client.end()}
|
return () => { client.end() }
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
if (true || !lastSongInfo || lastSongInfo.playbackState !== "PLAYING") {
|
if (true || !lastSongInfo || lastSongInfo.playbackState !== "PLAYING") {
|
||||||
|
@ -52,6 +52,12 @@ const WeatherAndTime = ({ secrets }: { secrets: SecretsWeather }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const pullWeather = () => {
|
||||||
|
fetch(`https://api.pirateweather.net/forecast/${secrets.apiKey}/${secrets.coords}?exclude=minutely,hourly&lang=de&units=ca`)
|
||||||
|
.then(resp => resp.json())
|
||||||
|
.then(setWeather);
|
||||||
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const dateInterval = setInterval(() => {
|
const dateInterval = setInterval(() => {
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
@ -69,12 +75,6 @@ const WeatherAndTime = ({ secrets }: { secrets: SecretsWeather }) => {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const pullWeather = () => {
|
|
||||||
fetch(`https://api.pirateweather.net/forecast/${secrets.apiKey}/${secrets.coords}?exclude=minutely,hourly&lang=de&units=ca`)
|
|
||||||
.then(resp => resp.json())
|
|
||||||
.then(setWeather);
|
|
||||||
}
|
|
||||||
|
|
||||||
const time = `${date.getHours()}:${date.getMinutes().toString().padStart(2, "0")}`;
|
const time = `${date.getHours()}:${date.getMinutes().toString().padStart(2, "0")}`;
|
||||||
const dateString = `${dowToString(date.getDay())}, der ${date.getDate()}. ${monthToString(date.getMonth())} ${date.getFullYear()}`;
|
const dateString = `${dowToString(date.getDay())}, der ${date.getDate()}. ${monthToString(date.getMonth())} ${date.getFullYear()}`;
|
||||||
|
|
||||||
|
@ -16,6 +16,12 @@ const images = importAll(require.context('../images/custom/bg/', false, /\.(png|
|
|||||||
|
|
||||||
const IndexPage = () => {
|
const IndexPage = () => {
|
||||||
const [currentBg, setCurrentBg] = React.useState(0);
|
const [currentBg, setCurrentBg] = React.useState(0);
|
||||||
|
|
||||||
|
const updateBackground = () => {
|
||||||
|
let nextBg = Math.floor(Math.random() * images.length)
|
||||||
|
while (nextBg == currentBg) nextBg = Math.floor(Math.random() * images.length)
|
||||||
|
setCurrentBg(nextBg)
|
||||||
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
// This effect is executed onload
|
// This effect is executed onload
|
||||||
@ -28,12 +34,6 @@ const IndexPage = () => {
|
|||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const updateBackground = () => {
|
|
||||||
let nextBg = Math.floor(Math.random() * images.length)
|
|
||||||
while (nextBg == currentBg) nextBg = Math.floor(Math.random() * images.length)
|
|
||||||
setCurrentBg(nextBg)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (<main style={{ backgroundImage: `url(${images[currentBg].default})` }}>
|
return (<main style={{ backgroundImage: `url(${images[currentBg].default})` }}>
|
||||||
<WeatherAndTimeContainer secrets={secrets.weather} />
|
<WeatherAndTimeContainer secrets={secrets.weather} />
|
||||||
<Calendar secrets={secrets.calendar} />
|
<Calendar secrets={secrets.calendar} />
|
||||||
|
Loading…
Reference in New Issue
Block a user