From 7a296f7b4af883b7499afb33a3f25e08f8e6fd17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Prie=C3=9Fnitz?= Date: Thu, 4 Dec 2025 17:06:27 +0100 Subject: [PATCH] [deploy] Emit frontend bundle as ESM for browser --- public/ts-build/app.js | 4 +- public/ts-build/components/admin/index.js | 13 ++-- public/ts-build/components/dashboard.js | 61 +++++++++---------- public/ts-build/components/events/index.js | 13 ++-- public/ts-build/components/guildSelect.js | 19 +++--- .../components/modules/dynamicVoice.js | 13 ++-- public/ts-build/components/modules/index.js | 47 +++++++------- public/ts-build/components/modules/logging.js | 13 ++-- .../components/modules/reactionRoles.js | 13 ++-- .../components/modules/serverstats.js | 13 ++-- .../ts-build/components/modules/statuspage.js | 13 ++-- public/ts-build/components/modules/welcome.js | 13 ++-- public/ts-build/components/overview.js | 13 ++-- public/ts-build/components/settings.js | 13 ++-- .../components/tickets/automations.js | 13 ++-- public/ts-build/components/tickets/index.js | 25 ++++---- public/ts-build/components/tickets/kb.js | 13 ++-- public/ts-build/components/tickets/list.js | 13 ++-- .../ts-build/components/tickets/pipeline.js | 13 ++-- public/ts-build/components/tickets/sla.js | 13 ++-- public/ts-build/core/app.js | 38 ++++++------ public/ts-build/services/api.js | 9 +-- public/ts-build/state/store.js | 17 ++---- public/ts-build/ui/modal.js | 8 +-- public/ts-build/ui/navigation.js | 12 ++-- public/ts-build/ui/switch.js | 11 +--- public/ts-build/ui/toast.js | 8 +-- tsconfig.frontend.json | 4 +- 28 files changed, 185 insertions(+), 273 deletions(-) diff --git a/public/ts-build/app.js b/public/ts-build/app.js index 2eca8c0..c2c03c1 100644 --- a/public/ts-build/app.js +++ b/public/ts-build/app.js @@ -1,3 +1 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -require("./core/app.js"); +import './core/app.js'; diff --git a/public/ts-build/components/admin/index.js b/public/ts-build/components/admin/index.js index d9d1b48..0ef0909 100644 --- a/public/ts-build/components/admin/index.js +++ b/public/ts-build/components/admin/index.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.initAdminSection = initAdminSection; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function initAdminSection(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function initAdminSection(guildId) { const section = document.getElementById('section-admin'); if (!section) return; section.innerHTML = '

Lade Admin-Daten...

'; try { - const data = await api_js_1.api.settings(guildId); + const data = await api.settings(guildId); section.innerHTML = `

Admin

@@ -21,6 +18,6 @@ async function initAdminSection(guildId) { catch (err) { console.error(err); section.innerHTML = '
Admin-Daten konnten nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Admin-Daten', true); + showToast('Fehler beim Laden der Admin-Daten', true); } } diff --git a/public/ts-build/components/dashboard.js b/public/ts-build/components/dashboard.js index 6b36a84..bd5a14a 100644 --- a/public/ts-build/components/dashboard.js +++ b/public/ts-build/components/dashboard.js @@ -1,25 +1,22 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.initDashboardView = initDashboardView; -const api_js_1 = require("../services/api.js"); -const store_js_1 = require("../state/store.js"); -const toast_js_1 = require("../ui/toast.js"); -const overview_js_1 = require("./overview.js"); -const index_js_1 = require("./tickets/index.js"); -const index_js_2 = require("./modules/index.js"); -const index_js_3 = require("./events/index.js"); -const index_js_4 = require("./admin/index.js"); -const settings_js_1 = require("./settings.js"); +import { api } from '../services/api.js'; +import { getConfig, getState, setState } from '../state/store.js'; +import { showToast } from '../ui/toast.js'; +import { renderOverview } from './overview.js'; +import { initTicketsSection } from './tickets/index.js'; +import { initModulesSection } from './modules/index.js'; +import { initEventsSection } from './events/index.js'; +import { initAdminSection } from './admin/index.js'; +import { renderSettingsSection } from './settings.js'; let overviewInterval = null; let ticketsInterval = null; async function populateGuildSelect() { const select = document.getElementById('guildSelect'); - const cfg = (0, store_js_1.getConfig)(); + const cfg = getConfig(); if (!select || !cfg) return; select.innerHTML = ``; try { - const data = await api_js_1.api.guilds(); + const data = await api.guilds(); select.innerHTML = ''; data.guilds.forEach((g) => { const opt = document.createElement('option'); @@ -30,12 +27,12 @@ async function populateGuildSelect() { select.appendChild(opt); }); const current = select.value || cfg.initialGuildId || data.guilds[0]?.id; - (0, store_js_1.setState)({ guildId: current || undefined }); + setState({ guildId: current || undefined }); select.value = current || ''; } catch (err) { console.error(err); - (0, toast_js_1.showToast)('Guilds konnten nicht geladen werden', true); + showToast('Guilds konnten nicht geladen werden', true); } } function registerGuildChange() { @@ -44,43 +41,43 @@ function registerGuildChange() { return; select.addEventListener('change', () => { const guildId = select.value; - (0, store_js_1.setState)({ guildId }); + setState({ guildId }); refreshSections(); }); } async function refreshSections() { - const { guildId } = (0, store_js_1.getState)(); + const { guildId } = getState(); if (!guildId) return; - await (0, overview_js_1.renderOverview)(guildId); - await (0, index_js_1.initTicketsSection)(guildId); - await (0, index_js_2.initModulesSection)(guildId); - await (0, settings_js_1.renderSettingsSection)(guildId); - await (0, index_js_3.initEventsSection)(guildId); - const cfg = (0, store_js_1.getConfig)(); + await renderOverview(guildId); + await initTicketsSection(guildId); + await initModulesSection(guildId); + await renderSettingsSection(guildId); + await initEventsSection(guildId); + const cfg = getConfig(); if (cfg?.isAdmin) { - await (0, index_js_4.initAdminSection)(guildId); + await initAdminSection(guildId); } } function setupPolling() { - const { guildId } = (0, store_js_1.getState)(); + const { guildId } = getState(); if (overviewInterval) window.clearInterval(overviewInterval); if (ticketsInterval) window.clearInterval(ticketsInterval); overviewInterval = window.setInterval(() => { - const current = (0, store_js_1.getState)().guildId; + const current = getState().guildId; if (current) - (0, overview_js_1.renderOverview)(current); + renderOverview(current); }, 10000); ticketsInterval = window.setInterval(() => { - const current = (0, store_js_1.getState)().guildId; + const current = getState().guildId; if (current) - (0, index_js_1.initTicketsSection)(current); + initTicketsSection(current); }, 12000); } -function initDashboardView() { - const cfg = (0, store_js_1.getConfig)(); +export function initDashboardView() { + const cfg = getConfig(); const logoutBtn = document.getElementById('logoutBtn'); if (logoutBtn && cfg) { logoutBtn.addEventListener('click', () => (window.location.href = `${cfg.baseAuth}/logout`)); diff --git a/public/ts-build/components/events/index.js b/public/ts-build/components/events/index.js index 0ecc8bf..1c5b375 100644 --- a/public/ts-build/components/events/index.js +++ b/public/ts-build/components/events/index.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.initEventsSection = initEventsSection; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function initEventsSection(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function initEventsSection(guildId) { const section = document.getElementById('section-events'); if (!section) return; section.innerHTML = '

Lade Events...

'; try { - const data = await api_js_1.api.events(guildId); + const data = await api.events(guildId); const events = data?.events || data || []; section.innerHTML = '

Events

'; if (!events.length) { @@ -38,6 +35,6 @@ async function initEventsSection(guildId) { catch (err) { console.error(err); section.innerHTML = '
Events konnten nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Events', true); + showToast('Fehler beim Laden der Events', true); } } diff --git a/public/ts-build/components/guildSelect.js b/public/ts-build/components/guildSelect.js index a8566fa..4574589 100644 --- a/public/ts-build/components/guildSelect.js +++ b/public/ts-build/components/guildSelect.js @@ -1,11 +1,8 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.initSelectionView = initSelectionView; -const api_js_1 = require("../services/api.js"); -const store_js_1 = require("../state/store.js"); -const toast_js_1 = require("../ui/toast.js"); -async function initSelectionView() { - const cfg = (0, store_js_1.getConfig)(); +import { api } from '../services/api.js'; +import { getConfig } from '../state/store.js'; +import { showToast } from '../ui/toast.js'; +export async function initSelectionView() { + const cfg = getConfig(); const grid = document.getElementById('guildGrid'); const logoutBtn = document.getElementById('logoutBtn'); const userInfo = document.getElementById('userInfo'); @@ -15,7 +12,7 @@ async function initSelectionView() { }); } try { - const me = await api_js_1.api.me(); + const me = await api.me(); if (userInfo && me?.user) userInfo.textContent = `${me.user.username}#${me.user.discriminator}`; } @@ -26,7 +23,7 @@ async function initSelectionView() { return; grid.innerHTML = '
Lade Guilds...
'; try { - const data = await api_js_1.api.guilds(); + const data = await api.guilds(); grid.innerHTML = ''; (data.guilds || []).forEach((g) => { const card = document.createElement('div'); @@ -54,6 +51,6 @@ async function initSelectionView() { catch (err) { console.error(err); grid.innerHTML = '
Fehler beim Laden der Guilds
'; - (0, toast_js_1.showToast)('Guilds konnten nicht geladen werden', true); + showToast('Guilds konnten nicht geladen werden', true); } } diff --git a/public/ts-build/components/modules/dynamicVoice.js b/public/ts-build/components/modules/dynamicVoice.js index d658ab5..4e5039b 100644 --- a/public/ts-build/components/modules/dynamicVoice.js +++ b/public/ts-build/components/modules/dynamicVoice.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderDynamicVoiceModule = renderDynamicVoiceModule; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderDynamicVoiceModule(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderDynamicVoiceModule(guildId) { const container = document.getElementById('module-dynamicvoice'); if (!container) return; container.innerHTML = '

Lade Dynamic Voice...

'; try { - const data = await api_js_1.api.dynamicVoice(guildId); + const data = await api.dynamicVoice(guildId); const cfg = data?.config || data?.dynamicVoiceConfig || {}; container.innerHTML = `

Dynamic Voice

@@ -21,6 +18,6 @@ async function renderDynamicVoiceModule(guildId) { catch (err) { console.error(err); container.innerHTML = '
Dynamic Voice konnte nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden von Dynamic Voice', true); + showToast('Fehler beim Laden von Dynamic Voice', true); } } diff --git a/public/ts-build/components/modules/index.js b/public/ts-build/components/modules/index.js index f164ab0..0940946 100644 --- a/public/ts-build/components/modules/index.js +++ b/public/ts-build/components/modules/index.js @@ -1,16 +1,13 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.initModulesSection = initModulesSection; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -const switch_js_1 = require("../../ui/switch.js"); -const welcome_js_1 = require("./welcome.js"); -const logging_js_1 = require("./logging.js"); -const reactionRoles_js_1 = require("./reactionRoles.js"); -const dynamicVoice_js_1 = require("./dynamicVoice.js"); -const statuspage_js_1 = require("./statuspage.js"); -const serverstats_js_1 = require("./serverstats.js"); -async function initModulesSection(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +import { setSwitch, getSwitch } from '../../ui/switch.js'; +import { renderWelcomeModule } from './welcome.js'; +import { renderLoggingModule } from './logging.js'; +import { renderReactionRolesModule } from './reactionRoles.js'; +import { renderDynamicVoiceModule } from './dynamicVoice.js'; +import { renderStatuspageModule } from './statuspage.js'; +import { renderServerStatsModule } from './serverstats.js'; +export async function initModulesSection(guildId) { const section = document.getElementById('section-modules'); if (!section) return; @@ -30,12 +27,12 @@ async function initModulesSection(guildId) { `; await Promise.all([ renderModuleToggles(guildId), - (0, welcome_js_1.renderWelcomeModule)(guildId), - (0, logging_js_1.renderLoggingModule)(guildId), - (0, reactionRoles_js_1.renderReactionRolesModule)(guildId), - (0, dynamicVoice_js_1.renderDynamicVoiceModule)(guildId), - (0, statuspage_js_1.renderStatuspageModule)(guildId), - (0, serverstats_js_1.renderServerStatsModule)(guildId) + renderWelcomeModule(guildId), + renderLoggingModule(guildId), + renderReactionRolesModule(guildId), + renderDynamicVoiceModule(guildId), + renderStatuspageModule(guildId), + renderServerStatsModule(guildId) ]); } async function renderModuleToggles(guildId) { @@ -44,7 +41,7 @@ async function renderModuleToggles(guildId) { return; container.innerHTML = '

Lade Module...

'; try { - const data = await api_js_1.api.modules(guildId); + const data = await api.modules(guildId); const modules = data?.modules || data || {}; container.innerHTML = ''; const entries = [ @@ -72,7 +69,7 @@ async function renderModuleToggles(guildId) { `; const toggle = row.querySelector('.switch'); toggle.addEventListener('click', async () => { - (0, switch_js_1.setSwitch)(toggle, !(0, switch_js_1.getSwitch)(toggle)); + setSwitch(toggle, !getSwitch(toggle)); await saveModules(guildId); }); container.appendChild(row); @@ -81,7 +78,7 @@ async function renderModuleToggles(guildId) { catch (err) { console.error(err); container.innerHTML = '
Module konnten nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Module', true); + showToast('Fehler beim Laden der Module', true); } } async function saveModules(guildId) { @@ -94,11 +91,11 @@ async function saveModules(guildId) { payload[key] = t.classList.contains('on'); }); try { - await api_js_1.api.saveSettings(payload); - (0, toast_js_1.showToast)('Module gespeichert'); + await api.saveSettings(payload); + showToast('Module gespeichert'); } catch (err) { console.error(err); - (0, toast_js_1.showToast)('Module speichern fehlgeschlagen', true); + showToast('Module speichern fehlgeschlagen', true); } } diff --git a/public/ts-build/components/modules/logging.js b/public/ts-build/components/modules/logging.js index 7faf5f1..911e99a 100644 --- a/public/ts-build/components/modules/logging.js +++ b/public/ts-build/components/modules/logging.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderLoggingModule = renderLoggingModule; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderLoggingModule(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderLoggingModule(guildId) { const container = document.getElementById('module-logging'); if (!container) return; container.innerHTML = '

Lade Logging...

'; try { - const data = await api_js_1.api.settings(guildId); + const data = await api.settings(guildId); const cfg = data?.settings?.loggingConfig || data?.loggingConfig || {}; container.innerHTML = `

Logging

@@ -21,6 +18,6 @@ async function renderLoggingModule(guildId) { catch (err) { console.error(err); container.innerHTML = '
Logging konnte nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden von Logging', true); + showToast('Fehler beim Laden von Logging', true); } } diff --git a/public/ts-build/components/modules/reactionRoles.js b/public/ts-build/components/modules/reactionRoles.js index 160df16..a5bdde1 100644 --- a/public/ts-build/components/modules/reactionRoles.js +++ b/public/ts-build/components/modules/reactionRoles.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderReactionRolesModule = renderReactionRolesModule; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderReactionRolesModule(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderReactionRolesModule(guildId) { const container = document.getElementById('module-reactionroles'); if (!container) return; container.innerHTML = '

Lade Reaction Roles...

'; try { - const data = await api_js_1.api.reactionRoles(guildId); + const data = await api.reactionRoles(guildId); const entries = data?.entries || data?.reactionRoles || []; container.innerHTML = '

Reaction Roles

'; if (!entries.length) { @@ -32,6 +29,6 @@ async function renderReactionRolesModule(guildId) { catch (err) { console.error(err); container.innerHTML = '
Reaction Roles konnten nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Reaction Roles', true); + showToast('Fehler beim Laden der Reaction Roles', true); } } diff --git a/public/ts-build/components/modules/serverstats.js b/public/ts-build/components/modules/serverstats.js index b41a47b..0825bb5 100644 --- a/public/ts-build/components/modules/serverstats.js +++ b/public/ts-build/components/modules/serverstats.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderServerStatsModule = renderServerStatsModule; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderServerStatsModule(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderServerStatsModule(guildId) { const container = document.getElementById('module-serverstats'); if (!container) return; container.innerHTML = '

Lade Server Stats...

'; try { - const data = await api_js_1.api.serverStats(guildId); + const data = await api.serverStats(guildId); const cfg = data?.config || data || {}; const items = cfg.items || []; container.innerHTML = ` @@ -22,6 +19,6 @@ async function renderServerStatsModule(guildId) { catch (err) { console.error(err); container.innerHTML = '
Server Stats konnten nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Server Stats', true); + showToast('Fehler beim Laden der Server Stats', true); } } diff --git a/public/ts-build/components/modules/statuspage.js b/public/ts-build/components/modules/statuspage.js index e620860..6ffa53b 100644 --- a/public/ts-build/components/modules/statuspage.js +++ b/public/ts-build/components/modules/statuspage.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderStatuspageModule = renderStatuspageModule; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderStatuspageModule(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderStatuspageModule(guildId) { const container = document.getElementById('module-statuspage'); if (!container) return; container.innerHTML = '

Lade Statuspage...

'; try { - const data = await api_js_1.api.statuspage(guildId); + const data = await api.statuspage(guildId); const cfg = data?.config || data || {}; const services = cfg.services || []; container.innerHTML = ` @@ -22,6 +19,6 @@ async function renderStatuspageModule(guildId) { catch (err) { console.error(err); container.innerHTML = '
Statuspage konnte nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Statuspage', true); + showToast('Fehler beim Laden der Statuspage', true); } } diff --git a/public/ts-build/components/modules/welcome.js b/public/ts-build/components/modules/welcome.js index e5aa2ed..9a5db76 100644 --- a/public/ts-build/components/modules/welcome.js +++ b/public/ts-build/components/modules/welcome.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderWelcomeModule = renderWelcomeModule; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderWelcomeModule(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderWelcomeModule(guildId) { const container = document.getElementById('module-welcome'); if (!container) return; container.innerHTML = '

Lade Welcome...

'; try { - const data = await api_js_1.api.settings(guildId); + const data = await api.settings(guildId); const cfg = data?.settings?.welcomeConfig || data?.welcomeConfig || {}; container.innerHTML = `

Welcome

@@ -21,6 +18,6 @@ async function renderWelcomeModule(guildId) { catch (err) { console.error(err); container.innerHTML = '
Welcome konnte nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden von Welcome', true); + showToast('Fehler beim Laden von Welcome', true); } } diff --git a/public/ts-build/components/overview.js b/public/ts-build/components/overview.js index 685229d..5f2f14a 100644 --- a/public/ts-build/components/overview.js +++ b/public/ts-build/components/overview.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderOverview = renderOverview; -const api_js_1 = require("../services/api.js"); -const toast_js_1 = require("../ui/toast.js"); -async function renderOverview(guildId) { +import { api } from '../services/api.js'; +import { showToast } from '../ui/toast.js'; +export async function renderOverview(guildId) { const section = document.getElementById('section-overview'); if (!section) return; section.innerHTML = '

Lade Uebersicht...

'; try { - const data = await api_js_1.api.overview(guildId); + const data = await api.overview(guildId); const stats = data?.stats || {}; section.innerHTML = `

Uebersicht

@@ -32,6 +29,6 @@ async function renderOverview(guildId) { catch (err) { console.error(err); section.innerHTML = '
Uebersicht konnte nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Uebersicht', true); + showToast('Fehler beim Laden der Uebersicht', true); } } diff --git a/public/ts-build/components/settings.js b/public/ts-build/components/settings.js index fac4e9e..817aaf1 100644 --- a/public/ts-build/components/settings.js +++ b/public/ts-build/components/settings.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderSettingsSection = renderSettingsSection; -const api_js_1 = require("../services/api.js"); -const toast_js_1 = require("../ui/toast.js"); -async function renderSettingsSection(guildId) { +import { api } from '../services/api.js'; +import { showToast } from '../ui/toast.js'; +export async function renderSettingsSection(guildId) { const section = document.getElementById('section-settings'); if (!section) return; section.innerHTML = '

Lade Einstellungen...

'; try { - const data = await api_js_1.api.settings(guildId); + const data = await api.settings(guildId); const settings = data?.settings || {}; section.innerHTML = `

Einstellungen

@@ -21,6 +18,6 @@ async function renderSettingsSection(guildId) { catch (err) { console.error(err); section.innerHTML = '
Einstellungen konnten nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Einstellungen', true); + showToast('Fehler beim Laden der Einstellungen', true); } } diff --git a/public/ts-build/components/tickets/automations.js b/public/ts-build/components/tickets/automations.js index 0726330..10df096 100644 --- a/public/ts-build/components/tickets/automations.js +++ b/public/ts-build/components/tickets/automations.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderAutomations = renderAutomations; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderAutomations(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderAutomations(guildId) { const container = document.getElementById('tickets-automations'); if (!container) return; container.innerHTML = '

Lade Automationen...

'; try { - const data = await api_js_1.api.automations(guildId); + const data = await api.automations(guildId); const rules = data?.rules || data || []; if (!rules.length) { container.innerHTML = '
Keine Regeln angelegt.
'; @@ -37,6 +34,6 @@ async function renderAutomations(guildId) { catch (err) { console.error(err); container.innerHTML = '
Automationen konnten nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Automationen', true); + showToast('Fehler beim Laden der Automationen', true); } } diff --git a/public/ts-build/components/tickets/index.js b/public/ts-build/components/tickets/index.js index f38c463..b06bc75 100644 --- a/public/ts-build/components/tickets/index.js +++ b/public/ts-build/components/tickets/index.js @@ -1,12 +1,9 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.initTicketsSection = initTicketsSection; -const list_js_1 = require("./list.js"); -const pipeline_js_1 = require("./pipeline.js"); -const sla_js_1 = require("./sla.js"); -const automations_js_1 = require("./automations.js"); -const kb_js_1 = require("./kb.js"); -async function initTicketsSection(guildId) { +import { renderTicketList } from './list.js'; +import { renderPipeline } from './pipeline.js'; +import { renderSla } from './sla.js'; +import { renderAutomations } from './automations.js'; +import { renderKb } from './kb.js'; +export async function initTicketsSection(guildId) { const section = document.getElementById('section-tickets'); if (!section) return; @@ -23,10 +20,10 @@ async function initTicketsSection(guildId) {
`; await Promise.all([ - (0, list_js_1.renderTicketList)(guildId), - (0, pipeline_js_1.renderPipeline)(guildId), - (0, sla_js_1.renderSla)(guildId), - (0, automations_js_1.renderAutomations)(guildId), - (0, kb_js_1.renderKb)(guildId) + renderTicketList(guildId), + renderPipeline(guildId), + renderSla(guildId), + renderAutomations(guildId), + renderKb(guildId) ]); } diff --git a/public/ts-build/components/tickets/kb.js b/public/ts-build/components/tickets/kb.js index 8369db2..045e8b6 100644 --- a/public/ts-build/components/tickets/kb.js +++ b/public/ts-build/components/tickets/kb.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderKb = renderKb; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderKb(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderKb(guildId) { const container = document.getElementById('tickets-kb'); if (!container) return; container.innerHTML = '

Lade Knowledge Base...

'; try { - const data = await api_js_1.api.kb(guildId); + const data = await api.kb(guildId); const entries = data?.articles || data?.kb || []; if (!entries.length) { container.innerHTML = '
Keine KB-Eintraege.
'; @@ -32,6 +29,6 @@ async function renderKb(guildId) { catch (err) { console.error(err); container.innerHTML = '
KB konnte nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der KB', true); + showToast('Fehler beim Laden der KB', true); } } diff --git a/public/ts-build/components/tickets/list.js b/public/ts-build/components/tickets/list.js index 7a72c58..d923921 100644 --- a/public/ts-build/components/tickets/list.js +++ b/public/ts-build/components/tickets/list.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderTicketList = renderTicketList; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderTicketList(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderTicketList(guildId) { const container = document.getElementById('tickets-list'); if (!container) return; container.innerHTML = '

Lade Tickets...

'; try { - const data = await api_js_1.api.tickets(guildId); + const data = await api.tickets(guildId); const tickets = data?.tickets || []; if (!tickets.length) { container.innerHTML = '
Keine Tickets
'; @@ -38,6 +35,6 @@ async function renderTicketList(guildId) { catch (err) { console.error(err); container.innerHTML = '
Tickets konnten nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Tickets', true); + showToast('Fehler beim Laden der Tickets', true); } } diff --git a/public/ts-build/components/tickets/pipeline.js b/public/ts-build/components/tickets/pipeline.js index 5cdfcbf..2ea9c83 100644 --- a/public/ts-build/components/tickets/pipeline.js +++ b/public/ts-build/components/tickets/pipeline.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderPipeline = renderPipeline; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderPipeline(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderPipeline(guildId) { const container = document.getElementById('tickets-pipeline'); if (!container) return; container.innerHTML = '

Lade Pipeline...

'; try { - const data = await api_js_1.api.pipeline(guildId); + const data = await api.pipeline(guildId); const lanes = data?.lanes || []; container.innerHTML = '

Pipeline

'; if (!lanes.length) { @@ -32,6 +29,6 @@ async function renderPipeline(guildId) { catch (err) { console.error(err); container.innerHTML = '
Pipeline konnte nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der Pipeline', true); + showToast('Fehler beim Laden der Pipeline', true); } } diff --git a/public/ts-build/components/tickets/sla.js b/public/ts-build/components/tickets/sla.js index ee42a37..0b5a3b2 100644 --- a/public/ts-build/components/tickets/sla.js +++ b/public/ts-build/components/tickets/sla.js @@ -1,15 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderSla = renderSla; -const api_js_1 = require("../../services/api.js"); -const toast_js_1 = require("../../ui/toast.js"); -async function renderSla(guildId) { +import { api } from '../../services/api.js'; +import { showToast } from '../../ui/toast.js'; +export async function renderSla(guildId) { const container = document.getElementById('tickets-sla'); if (!container) return; container.innerHTML = '

Lade SLA...

'; try { - const data = await api_js_1.api.sla(guildId); + const data = await api.sla(guildId); const stats = data?.stats || {}; container.innerHTML = `

SLA

@@ -20,6 +17,6 @@ async function renderSla(guildId) { catch (err) { console.error(err); container.innerHTML = '
SLA konnte nicht geladen werden.
'; - (0, toast_js_1.showToast)('Fehler beim Laden der SLA', true); + showToast('Fehler beim Laden der SLA', true); } } diff --git a/public/ts-build/core/app.js b/public/ts-build/core/app.js index a89217e..6c1ab4b 100644 --- a/public/ts-build/core/app.js +++ b/public/ts-build/core/app.js @@ -1,11 +1,9 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const api_js_1 = require("../services/api.js"); -const store_js_1 = require("../state/store.js"); -const navigation_js_1 = require("../ui/navigation.js"); -const toast_js_1 = require("../ui/toast.js"); -const guildSelect_js_1 = require("../components/guildSelect.js"); -const dashboard_js_1 = require("../components/dashboard.js"); +import { api } from '../services/api.js'; +import { initConfig, setState, getConfig } from '../state/store.js'; +import { renderSidebar, initNavigation } from '../ui/navigation.js'; +import { showToast } from '../ui/toast.js'; +import { initSelectionView } from '../components/guildSelect.js'; +import { initDashboardView } from '../components/dashboard.js'; function readConfig() { const root = document.getElementById('app'); if (!root) @@ -20,50 +18,50 @@ function readConfig() { const userLabel = root.dataset.userName ? `${root.dataset.userName}${root.dataset.userDisc ? '#' + root.dataset.userDisc : ''}` : undefined; - (0, store_js_1.initConfig)({ baseRoot, baseDashboard, baseAuth, baseApi, view, initialGuildId, isAdmin, userLabel }); + initConfig({ baseRoot, baseDashboard, baseAuth, baseApi, view, initialGuildId, isAdmin, userLabel }); } async function ensureAuth() { try { - const me = await api_js_1.api.me(); + const me = await api.me(); if (!me?.user) { - const cfg = (0, store_js_1.getConfig)(); + const cfg = getConfig(); window.location.href = (cfg?.baseAuth || '/auth') + '/discord'; return null; } const userInfo = document.getElementById('userInfo'); if (userInfo && me.user) userInfo.textContent = `${me.user.username}#${me.user.discriminator}`; - (0, store_js_1.setState)({ isAdmin: !!me.user?.isAdmin, userLabel: me.user ? `${me.user.username}#${me.user.discriminator}` : undefined }); + setState({ isAdmin: !!me.user?.isAdmin, userLabel: me.user ? `${me.user.username}#${me.user.discriminator}` : undefined }); return me; } catch (err) { console.error(err); - (0, toast_js_1.showToast)('Authentifizierung fehlgeschlagen', true); + showToast('Authentifizierung fehlgeschlagen', true); return null; } } async function bootstrap() { readConfig(); - const cfg = (0, store_js_1.getConfig)(); + const cfg = getConfig(); if (!cfg) return; const sidebarRoot = document.getElementById('sidebar-root'); if (sidebarRoot) - (0, navigation_js_1.renderSidebar)(sidebarRoot, !!cfg.isAdmin); + renderSidebar(sidebarRoot, !!cfg.isAdmin); if (cfg.view === 'selection') { - (0, guildSelect_js_1.initSelectionView)(); + initSelectionView(); } else { await ensureAuth(); - (0, dashboard_js_1.initDashboardView)(); - (0, navigation_js_1.initNavigation)((section) => { + initDashboardView(); + initNavigation((section) => { // Sections werden innerhalb der jeweiligen Komponenten bedient if (section === 'admin' && !cfg.isAdmin) - (0, toast_js_1.showToast)('Kein Admin-Recht', true); + showToast('Kein Admin-Recht', true); }); } } bootstrap().catch((err) => { console.error(err); - (0, toast_js_1.showToast)('Fehler beim Laden', true); + showToast('Fehler beim Laden', true); }); diff --git a/public/ts-build/services/api.js b/public/ts-build/services/api.js index b52bb74..e2212ed 100644 --- a/public/ts-build/services/api.js +++ b/public/ts-build/services/api.js @@ -1,9 +1,6 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.api = void 0; -const store_js_1 = require("../state/store.js"); +import { getConfig } from '../state/store.js'; function buildUrl(path, query) { - const cfg = (0, store_js_1.getConfig)(); + const cfg = getConfig(); const base = cfg?.baseApi || ''; const url = new URL(path.startsWith('http') ? path : `${base}${path}`, window.location.origin); if (query) { @@ -35,7 +32,7 @@ async function request(path, options = {}) { } return (await res.text()); } -exports.api = { +export const api = { me: () => request('/me'), guilds: () => request('/guilds'), overview: (guildId) => request(`/overview`, { query: { guildId } }), diff --git a/public/ts-build/state/store.js b/public/ts-build/state/store.js index a1c6943..45d1105 100644 --- a/public/ts-build/state/store.js +++ b/public/ts-build/state/store.js @@ -1,14 +1,7 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.initConfig = initConfig; -exports.getConfig = getConfig; -exports.getState = getState; -exports.setState = setState; -exports.subscribe = subscribe; let config = null; let state = {}; const listeners = new Set(); -function initConfig(next) { +export function initConfig(next) { config = next; state = { guildId: next.initialGuildId, @@ -16,17 +9,17 @@ function initConfig(next) { userLabel: next.userLabel }; } -function getConfig() { +export function getConfig() { return config; } -function getState() { +export function getState() { return state; } -function setState(partial) { +export function setState(partial) { state = { ...state, ...partial }; listeners.forEach((l) => l(state)); } -function subscribe(listener) { +export function subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener); } diff --git a/public/ts-build/ui/modal.js b/public/ts-build/ui/modal.js index c7dc843..3cb31de 100644 --- a/public/ts-build/ui/modal.js +++ b/public/ts-build/ui/modal.js @@ -1,7 +1,3 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.showModal = showModal; -exports.hideModal = hideModal; let activeModal = null; let backdrop = null; function ensureBackdrop() { @@ -13,14 +9,14 @@ function ensureBackdrop() { document.body.appendChild(backdrop); return backdrop; } -function showModal(content) { +export function showModal(content) { const bd = ensureBackdrop(); if (!content.parentElement) bd.appendChild(content); activeModal = content; bd.classList.add('show'); } -function hideModal() { +export function hideModal() { if (backdrop) backdrop.classList.remove('show'); activeModal = null; diff --git a/public/ts-build/ui/navigation.js b/public/ts-build/ui/navigation.js index 2369c27..3a6d476 100644 --- a/public/ts-build/ui/navigation.js +++ b/public/ts-build/ui/navigation.js @@ -1,8 +1,4 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.renderSidebar = renderSidebar; -exports.initNavigation = initNavigation; -const store_js_1 = require("../state/store.js"); +import { setState } from '../state/store.js'; const defaultNav = [ { id: 'overview', label: 'Uebersicht', icon: '[*]' }, { id: 'tickets', label: 'Ticketsystem', icon: '[*]' }, @@ -11,7 +7,7 @@ const defaultNav = [ { id: 'events', label: 'Events', icon: '[*]' }, { id: 'admin', label: 'Admin', icon: '[*]', requiresAdmin: true } ]; -function renderSidebar(container, isAdmin) { +export function renderSidebar(container, isAdmin) { container.innerHTML = ''; const brand = document.createElement('div'); brand.className = 'brand'; @@ -30,14 +26,14 @@ function renderSidebar(container, isAdmin) { container.appendChild(brand); container.appendChild(nav); } -function initNavigation(onChange) { +export function initNavigation(onChange) { const navLinks = Array.from(document.querySelectorAll('.nav a')); const activate = (section) => { navLinks.forEach((link) => link.classList.toggle('active', link.dataset.target === section)); document.querySelectorAll('.section').forEach((sec) => { sec.classList.toggle('active', sec.id === `section-${section}`); }); - (0, store_js_1.setState)({}); // trigger listeners for potential observers + setState({}); // trigger listeners for potential observers onChange(section); }; navLinks.forEach((link) => { diff --git a/public/ts-build/ui/switch.js b/public/ts-build/ui/switch.js index 46b01ba..e7749b4 100644 --- a/public/ts-build/ui/switch.js +++ b/public/ts-build/ui/switch.js @@ -1,18 +1,13 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.toggleSwitch = toggleSwitch; -exports.getSwitch = getSwitch; -exports.setSwitch = setSwitch; -function toggleSwitch(el, force) { +export function toggleSwitch(el, force) { if (!el) return; const next = force === undefined ? !el.classList.contains('on') : force; el.classList.toggle('on', next); } -function getSwitch(el) { +export function getSwitch(el) { return el?.classList.contains('on') ?? false; } -function setSwitch(el, value) { +export function setSwitch(el, value) { if (!el) return; el.classList.toggle('on', value); diff --git a/public/ts-build/ui/toast.js b/public/ts-build/ui/toast.js index dbdf5b8..be44457 100644 --- a/public/ts-build/ui/toast.js +++ b/public/ts-build/ui/toast.js @@ -1,9 +1,5 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.showToast = showToast; -exports.hideToast = hideToast; let currentTimeout = null; -function showToast(message, isError = false, duration = 2500) { +export function showToast(message, isError = false, duration = 2500) { let toast = document.getElementById('toast-root'); if (!toast) { toast = document.createElement('div'); @@ -19,7 +15,7 @@ function showToast(message, isError = false, duration = 2500) { window.clearTimeout(currentTimeout); currentTimeout = window.setTimeout(() => hideToast(), duration); } -function hideToast() { +export function hideToast() { const toast = document.getElementById('toast-root'); if (!toast) return; diff --git a/tsconfig.frontend.json b/tsconfig.frontend.json index 3e29cb2..c199baa 100644 --- a/tsconfig.frontend.json +++ b/tsconfig.frontend.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "ES2020", - "module": "NodeNext", - "moduleResolution": "NodeNext", + "module": "ES2020", + "moduleResolution": "Bundler", "outDir": "public/ts-build", "rootDir": "public/ts", "skipLibCheck": true,