igor_nadein 63b6fff1ef feat: migrate frontend to django-scheduler API
- Updated API endpoints from /api/v1/calendar/ to /api/v1/schedule/
- Removed subscriptions concept (django-scheduler uses simpler approach)
- Adapted CalendarSerializer to accept 'title' field for EUSRR compatibility
- All calendar visibility now stored in localStorage
- Removed deprecated subscribe/unsubscribe functions
2026-02-24 17:54:46 +03:00

71 lines
2.3 KiB
JavaScript

/**
* @fileoverview API URL constants - константы URL API эндпоинтов
* @module constants/apiUrls
*/
/**
* Базовые URL API эндпоинтов (django-scheduler)
* @enum {string}
*/
export const API_URLS = {
// Schedule Events API (django-scheduler)
EVENTS: "/api/v1/schedule/events/",
EVENT_DETAIL: (id) => `/api/v1/schedule/events/${id}/`,
EVENT_OCCURRENCES: "/api/v1/schedule/events/occurrences/",
// Schedule Calendars API (django-scheduler)
CALENDARS: "/api/v1/schedule/calendars/",
CALENDARS_MY: "/api/v1/schedule/calendars/", // django-scheduler не требует отдельного endpoint
CALENDAR_DETAIL: (id) => `/api/v1/schedule/calendars/${id}/`,
// Schedule Rules API (RFC 5545 rrule)
RULES: "/api/v1/schedule/rules/",
RULE_DETAIL: (id) => `/api/v1/schedule/rules/${id}/`,
// Schedule Occurrences API (materialized recurring events)
OCCURRENCES: "/api/v1/schedule/occurrences/",
OCCURRENCE_DETAIL: (id) => `/api/v1/schedule/occurrences/${id}/`,
// Schedule Relations API (event attendees)
RELATIONS: "/api/v1/schedule/relations/",
RELATION_DETAIL: (id) => `/api/v1/schedule/relations/${id}/`,
// Departments API
MY_DEPARTMENTS: "/api/v1/departments/my-departments/",
DEPARTMENT_DETAIL: (id) => `/api/v1/departments/${id}/`,
// Employees API
EMPLOYEES: "/api/v1/employees/",
EMPLOYEE_DETAIL: (id) => `/api/v1/employees/${id}/`,
};
/**
* Дефолтные параметры для API запросов
* @enum {*}
*/
export const API_DEFAULTS = {
// Time-to-live для кеша (в миллисекундах)
TTL: {
EVENTS: 30000, // 30 секунд
EVENT_DETAIL: 60000, // 1 минута
CALENDARS: 60000, // 1 минута
DEPARTMENTS: 300000, // 5 минут
},
// Таймауты для запросов
TIMEOUT: {
DEFAULT: 10000, // 10 секунд
UPLOAD: 30000, // 30 секунд
},
};
/**
* Получить полный URL для API эндпоинта
* @param {string} path - Путь к эндпоинту
* @param {string} [baseUrl] - Базовый URL (по умолчанию window.location.origin)
* @returns {string} Полный URL
*/
export function getApiUrl(path, baseUrl = window.location.origin) {
return new URL(path, baseUrl).toString();
}