ai helps with documentation
This commit is contained in:
1 parent
3c4a5eba9a
commit
979ef840e8
6 files changed
+81
-27
No files matched your search
@@ -1,22 +1,38 @@
|
||||
# frontend to [cal_filter][cfb]
|
||||
# Frontend for Calendar Filter
|
||||
|
||||
real
|
||||
A frontend application for managing and filtering calendar events using FullCalendar.
|
||||
|
||||
[cfb]: https://git.ldlda.com/lda/cal_filter_be
|
||||
## Usage
|
||||
|
||||
## usage
|
||||
1. Clone the repository:
|
||||
|
||||
put a valid .ics url with the right mime in the input and hit button
|
||||
```bash
|
||||
git clone https://git.ldlda.com/lda/cal_filter_fe.git
|
||||
```
|
||||
|
||||
## run
|
||||
2. Install dependencies:
|
||||
|
||||
```sh
|
||||
git clone this repo
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
## ass pull
|
||||
3. Start the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- FullCalendar integration for event visualization.
|
||||
- UI for managing event sources and applying filters.
|
||||
- Responsive design with Bootstrap.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please open an issue or submit a pull request.
|
||||
|
||||
## **ass pull**
|
||||
|
||||
Got it! Let’s create a **long-term plan** to improve your project. The goal is to make it feature-rich, maintainable, and user-friendly while leveraging FullCalendar’s capabilities and your existing backend.
|
||||
|
||||
@@ -28,7 +44,7 @@ Got it! Let’s create a **long-term plan** to improve your project. The goal is
|
||||
|
||||
Move filtering logic (date, regex, etc.) to the frontend using FullCalendar’s `getEvents()` and `eventDataTransform`.
|
||||
|
||||
##### **Steps:**
|
||||
**Steps:**
|
||||
|
||||
1. Use `getEvents()` to retrieve all events from the calendar.
|
||||
2. Apply filters (date range, regex, etc.) directly on the frontend.
|
||||
@@ -41,7 +57,7 @@ Move filtering logic (date, regex, etc.) to the frontend using FullCalendar’s
|
||||
|
||||
Replace the current placeholder/spinner logic with FullCalendar’s built-in `loading` callback.
|
||||
|
||||
##### **Steps:**
|
||||
**Steps:**
|
||||
|
||||
1. Use the `loading` callback to show/hide a spinner or loading message.
|
||||
2. Remove manual spinner logic from your code.
|
||||
@@ -56,7 +72,7 @@ Display a list of all added event sources and allow users to:
|
||||
- Refetch events from a source.
|
||||
- Toggle visibility of events from a source.
|
||||
|
||||
##### **Steps:**
|
||||
**Steps:**
|
||||
|
||||
1. Use `getEventSources()` to retrieve all sources.
|
||||
2. Display them in a list with controls (e.g., remove, refetch, toggle).
|
||||
@@ -77,7 +93,7 @@ If the backend is only for bypassing Google Calendar’s CORS issues, consider:
|
||||
|
||||
Centralize FullCalendar configuration into a reusable function or object.
|
||||
|
||||
##### **Steps:**
|
||||
**Steps:**
|
||||
|
||||
1. Create a `getCalendarConfig()` function that returns the calendar configuration.
|
||||
2. Pass dynamic options (e.g., theme, initial view) as arguments.
|
||||
|
||||
@@ -11,6 +11,13 @@ import { glued } from "./main";
|
||||
|
||||
let calendar: Calendar | null = null;
|
||||
|
||||
/**
|
||||
* Initializes and renders the FullCalendar instance.
|
||||
* @param element - The DOM element to render the calendar into.
|
||||
* @param url - The URL for the initial event source.
|
||||
* @param onEventMouseEnter - Callback for mouse enter on events.
|
||||
* @param onEventMouseLeave - Callback for mouse leave on events.
|
||||
*/
|
||||
export function initializeCalendar(
|
||||
element: HTMLElement,
|
||||
url: string | URL,
|
||||
@@ -55,12 +62,20 @@ export function initializeCalendar(
|
||||
calendar.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new event source to the calendar.
|
||||
* @param url - The URL for the event source.
|
||||
*/
|
||||
export const addEventSource = (url: string): void => {
|
||||
if (calendar) {
|
||||
calendar.addEventSource(init_ics_source(url));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the current calendar instance.
|
||||
* @returns The FullCalendar instance or null if not initialized.
|
||||
*/
|
||||
export const getCalendarInstance = (): Calendar | null => {
|
||||
return calendar;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
let sourceCount = 0;
|
||||
|
||||
/** how ass would this shit be? */
|
||||
export function getNextColor() {
|
||||
/**
|
||||
* Generates the next color in a sequence using the golden angle.
|
||||
* @returns A string representing the next HSL color.
|
||||
*/
|
||||
export function getNextColor(): string {
|
||||
// Spread hues evenly around the color wheel
|
||||
const hue = (sourceCount * 137) % 360; // 137 is the golden angle
|
||||
sourceCount++;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { Calendar } from "@fullcalendar/core";
|
||||
|
||||
/**
|
||||
* Updates the event source list in the DOM.
|
||||
* @param {HTMLElement | null} eventSourceList - The DOM element to display the event sources.
|
||||
* @returns {(calendar: import("@fullcalendar/core").Calendar) => void} A function that updates the event source list for a given calendar.
|
||||
* @param eventSourceList - The DOM element to display the event sources.
|
||||
* @returns A function that updates the event source list for a given calendar.
|
||||
*/
|
||||
export const updateEventSourceList2 = (eventSourceList: HTMLElement | null) =>
|
||||
function updateEventSourceList(calendar: import("@fullcalendar/core").Calendar): void {
|
||||
export const updateEventSourceList2 = (eventSourceList: HTMLElement | null) => {
|
||||
return function updateEventSourceList(calendar: Calendar): void {
|
||||
if (!calendar) return;
|
||||
if (!eventSourceList) return;
|
||||
|
||||
@@ -62,3 +64,4 @@ export const updateEventSourceList2 = (eventSourceList: HTMLElement | null) =>
|
||||
eventSourceList.appendChild(card);
|
||||
});
|
||||
};
|
||||
};
|
||||
+18
-1
@@ -11,7 +11,6 @@ import "bootstrap/dist/css/bootstrap.css";
|
||||
import "bootstrap-icons/font/bootstrap-icons.css";
|
||||
import "tippy.js/dist/tippy.css";
|
||||
|
||||
// Fix type for text_field
|
||||
const text_field = document.getElementById("ics_file") as HTMLInputElement;
|
||||
|
||||
const confirm_button = document.getElementById("ics_run") as HTMLButtonElement;
|
||||
@@ -29,16 +28,26 @@ const eventSourceList = document.getElementById(
|
||||
) as HTMLElement;
|
||||
const updateEventSourceList = updateEventSourceList2(eventSourceList);
|
||||
|
||||
/**
|
||||
* Shows the placeholder message and hides the calendar.
|
||||
*/
|
||||
function showPlaceholder(): void {
|
||||
placeholder_message.style.display = "block";
|
||||
cal_ele.style.display = "none";
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the placeholder message and shows the calendar.
|
||||
*/
|
||||
function hidePlaceholder(): void {
|
||||
placeholder_message.style.display = "none";
|
||||
cal_ele.style.display = "block";
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the event source list when the calendar is modified.
|
||||
* @param _e - The event triggering the update (unused).
|
||||
*/
|
||||
export const glued = (_e: unknown): void => {
|
||||
const calendar = getCalendarInstance();
|
||||
if (calendar) {
|
||||
@@ -46,6 +55,10 @@ export const glued = (_e: unknown): void => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles the click event for the confirm button.
|
||||
* Validates the input URL and initializes the calendar.
|
||||
*/
|
||||
confirm_button.addEventListener("click", () => {
|
||||
const url = create_url(text_field.value);
|
||||
if (!url)
|
||||
@@ -57,6 +70,10 @@ confirm_button.addEventListener("click", () => {
|
||||
initializeCalendar(cal_ele, url, newTippy, tippyDie);
|
||||
});
|
||||
|
||||
/**
|
||||
* Handles the click event for the add button.
|
||||
* Validates the input URL and adds a new event source to the calendar.
|
||||
*/
|
||||
add_button.addEventListener("click", () => {
|
||||
const url = create_url(text_field.value);
|
||||
if (!url) {
|
||||
|
||||
+4
-4
@@ -9,14 +9,14 @@ let currentTippy: Instance<Props> | null = null;
|
||||
interface TippyElement extends HTMLElement {
|
||||
_tippy?: Instance<Props>;
|
||||
}
|
||||
interface thisguy extends EventHoveringArg {
|
||||
interface tippyHoverArgs extends EventHoveringArg {
|
||||
el: TippyElement;
|
||||
}
|
||||
/**
|
||||
* Creates a new Tippy instance for an event.
|
||||
* @param info - The event information.
|
||||
* @param info - The event information, including the DOM element and event details.
|
||||
*/
|
||||
export function newTippy(info: thisguy): void {
|
||||
export function newTippy(info: tippyHoverArgs): void {
|
||||
if (info.el._tippy && info.el._tippy === currentTippy) {
|
||||
currentTippy?.show(); // Add optional chaining to handle null
|
||||
} else {
|
||||
@@ -40,7 +40,7 @@ export function newTippy(info: thisguy): void {
|
||||
|
||||
/**
|
||||
* Hides the current Tippy instance.
|
||||
* @param info - The event information.
|
||||
* @param info - The event information, including the JavaScript event.
|
||||
*/
|
||||
export function tippyDie(info: EventHoveringArg): void {
|
||||
if (currentTippy) {
|
||||
|
||||
Reference in new issue
Block a user