mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-11 16:05:47 +01:00
✨ Make Calendar module fetch way more data
This commit is contained in:
@@ -44,66 +44,67 @@ export default function CalendarComponent(props: any) {
|
|||||||
const lidarrService = filtered.filter((service) => service.type === 'Lidarr').at(0);
|
const lidarrService = filtered.filter((service) => service.type === 'Lidarr').at(0);
|
||||||
const readarrService = filtered.filter((service) => service.type === 'Readarr').at(0);
|
const readarrService = filtered.filter((service) => service.type === 'Readarr').at(0);
|
||||||
const nextMonth = new Date(new Date().setMonth(new Date().getMonth() + 2)).toISOString();
|
const nextMonth = new Date(new Date().setMonth(new Date().getMonth() + 2)).toISOString();
|
||||||
|
const lastMonth = new Date(new Date().setMonth(new Date().getMonth() - 2)).toISOString();
|
||||||
if (sonarrService && sonarrService.apiKey) {
|
if (sonarrService && sonarrService.apiKey) {
|
||||||
const baseUrl = new URL(sonarrService.url).origin;
|
const baseUrl = new URL(sonarrService.url).origin;
|
||||||
fetch(`${baseUrl}/api/calendar?apikey=${sonarrService?.apiKey}&end=${nextMonth}`).then(
|
fetch(
|
||||||
(response) => {
|
`${baseUrl}/api/calendar?apikey=${sonarrService?.apiKey}&end=${nextMonth}&start=${lastMonth}`
|
||||||
response.ok &&
|
).then((response) => {
|
||||||
response.json().then((data) => {
|
response.ok &&
|
||||||
setSonarrMedias(data);
|
response.json().then((data) => {
|
||||||
showNotification({
|
setSonarrMedias(data);
|
||||||
title: 'Sonarr',
|
showNotification({
|
||||||
icon: <Check />,
|
title: 'Sonarr',
|
||||||
color: 'green',
|
icon: <Check />,
|
||||||
autoClose: 1500,
|
color: 'green',
|
||||||
radius: 'md',
|
autoClose: 1500,
|
||||||
message: `Loaded ${data.length} releases`,
|
radius: 'md',
|
||||||
});
|
message: `Loaded ${data.length} releases`,
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
if (radarrService && radarrService.apiKey) {
|
if (radarrService && radarrService.apiKey) {
|
||||||
const baseUrl = new URL(radarrService.url).origin;
|
const baseUrl = new URL(radarrService.url).origin;
|
||||||
fetch(`${baseUrl}/api/v3/calendar?apikey=${radarrService?.apiKey}&end=${nextMonth}`).then(
|
fetch(
|
||||||
(response) => {
|
`${baseUrl}/api/v3/calendar?apikey=${radarrService?.apiKey}&end=${nextMonth}&start=${lastMonth}`
|
||||||
response.ok &&
|
).then((response) => {
|
||||||
response.json().then((data) => {
|
response.ok &&
|
||||||
setRadarrMedias(data);
|
response.json().then((data) => {
|
||||||
showNotification({
|
setRadarrMedias(data);
|
||||||
title: 'Radarr',
|
showNotification({
|
||||||
icon: <Check />,
|
title: 'Radarr',
|
||||||
color: 'green',
|
icon: <Check />,
|
||||||
autoClose: 1500,
|
color: 'green',
|
||||||
radius: 'md',
|
autoClose: 1500,
|
||||||
message: `Loaded ${data.length} releases`,
|
radius: 'md',
|
||||||
});
|
message: `Loaded ${data.length} releases`,
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
if (lidarrService && lidarrService.apiKey) {
|
if (lidarrService && lidarrService.apiKey) {
|
||||||
const baseUrl = new URL(lidarrService.url).origin;
|
const baseUrl = new URL(lidarrService.url).origin;
|
||||||
fetch(`${baseUrl}/api/v1/calendar?apikey=${lidarrService?.apiKey}&end=${nextMonth}`).then(
|
fetch(
|
||||||
(response) => {
|
`${baseUrl}/api/v1/calendar?apikey=${lidarrService?.apiKey}&end=${nextMonth}&start=${lastMonth}`
|
||||||
response.ok &&
|
).then((response) => {
|
||||||
response.json().then((data) => {
|
response.ok &&
|
||||||
setLidarrMedias(data);
|
response.json().then((data) => {
|
||||||
showNotification({
|
setLidarrMedias(data);
|
||||||
title: 'Lidarr',
|
showNotification({
|
||||||
icon: <Check />,
|
title: 'Lidarr',
|
||||||
color: 'green',
|
icon: <Check />,
|
||||||
autoClose: 1500,
|
color: 'green',
|
||||||
radius: 'md',
|
autoClose: 1500,
|
||||||
message: `Loaded ${data.length} releases`,
|
radius: 'md',
|
||||||
});
|
message: `Loaded ${data.length} releases`,
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
if (readarrService && readarrService.apiKey) {
|
if (readarrService && readarrService.apiKey) {
|
||||||
const baseUrl = new URL(readarrService.url).origin;
|
const baseUrl = new URL(readarrService.url).origin;
|
||||||
fetch(`${baseUrl}/api/v1/calendar?apikey=${readarrService?.apiKey}&end=${nextMonth}`).then(
|
fetch(`${baseUrl}/api/v1/calendar?apikey=${readarrService?.apiKey}&end=${nextMonth}&start=${lastMonth}`).then(
|
||||||
(response) => {
|
(response) => {
|
||||||
response.ok &&
|
response.ok &&
|
||||||
response.json().then((data) => {
|
response.json().then((data) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user