mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-18 18:49:50 +00:00
Feature: calendar widget (#2077)
* Implemented calendar Signed-off-by: Denis Papec <denis.papec@gmail.com> * Added lidarr events to calendar Signed-off-by: Denis Papec <denis.papec@gmail.com> * Added radarr events to calendar Signed-off-by: Denis Papec <denis.papec@gmail.com> * Added readarr events to calendar Signed-off-by: Denis Papec <denis.papec@gmail.com> * Added sonarr events to calendar Signed-off-by: Denis Papec <denis.papec@gmail.com> * fix sonarr series title * integrations * fix bad setstate call * handle user sets includeSeries: false for sonarr * Translate radarr release strings * Support all widths * readarr get author * Finished first day in week config Signed-off-by: Denis Papec <denis.papec@gmail.com> --------- Signed-off-by: Denis Papec <denis.papec@gmail.com> Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
855f12e4c1
commit
4cd4103edf
19 changed files with 439 additions and 3 deletions
|
@ -357,6 +357,7 @@ export function cleanServiceGroups(groups) {
|
|||
method, // openmediavault widget
|
||||
mappings, // customapi widget
|
||||
refreshInterval,
|
||||
integrations, // calendar widget
|
||||
} = cleanedService.widget;
|
||||
|
||||
let fieldsList = fields;
|
||||
|
@ -440,6 +441,9 @@ export function cleanServiceGroups(groups) {
|
|||
if (mappings) cleanedService.widget.mappings = mappings;
|
||||
if (refreshInterval) cleanedService.widget.refreshInterval = refreshInterval;
|
||||
}
|
||||
if (type === "calendar") {
|
||||
if (integrations) cleanedService.widget.integrations = integrations;
|
||||
}
|
||||
}
|
||||
|
||||
return cleanedService;
|
||||
|
|
28
src/utils/contexts/calendar.jsx
Normal file
28
src/utils/contexts/calendar.jsx
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { createContext, useState, useMemo } from "react";
|
||||
|
||||
export const EventContext = createContext();
|
||||
export const ShowDateContext = createContext();
|
||||
|
||||
export function EventProvider({ initialEvent, children }) {
|
||||
const [events, setEvents] = useState({});
|
||||
|
||||
if (initialEvent) {
|
||||
setEvents(initialEvent);
|
||||
}
|
||||
|
||||
const value = useMemo(() => ({ events, setEvents }), [events]);
|
||||
|
||||
return <EventContext.Provider value={value}>{children}</EventContext.Provider>;
|
||||
}
|
||||
|
||||
export function ShowDateProvider({ initialDate, children }) {
|
||||
const [showDate, setShowDate] = useState(null);
|
||||
|
||||
if (initialDate) {
|
||||
setShowDate(initialDate);
|
||||
}
|
||||
|
||||
const value = useMemo(() => ({ showDate, setShowDate }), [showDate]);
|
||||
|
||||
return <ShowDateContext.Provider value={value}>{children}</ShowDateContext.Provider>;
|
||||
}
|
|
@ -18,7 +18,8 @@ export default async function genericProxyHandler(req, res, map) {
|
|||
}
|
||||
|
||||
if (widget) {
|
||||
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
||||
// if there are more than one question marks, replace others to &
|
||||
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }).replace(/(?<=\?.*)\?/g, '&'));
|
||||
|
||||
const headers = req.extraHeaders ?? widget.headers ?? {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue