[deploy] Emit frontend bundle as ESM for browser
All checks were successful
Deploy Discord Bot / deploy (push) Successful in 38s

This commit is contained in:
Pascal Prießnitz
2025-12-04 17:06:27 +01:00
parent 18a47c0426
commit 7a296f7b4a
28 changed files with 185 additions and 273 deletions

View File

@@ -1,3 +1 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("./core/app.js");
import './core/app.js';

View File

@@ -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 = '<p class="muted">Lade Admin-Daten...</p>';
try {
const data = await api_js_1.api.settings(guildId);
const data = await api.settings(guildId);
section.innerHTML = `
<h2 class="section-title">Admin</h2>
<div class="card">
@@ -21,6 +18,6 @@ async function initAdminSection(guildId) {
catch (err) {
console.error(err);
section.innerHTML = '<div class="empty-state">Admin-Daten konnten nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Admin-Daten', true);
showToast('Fehler beim Laden der Admin-Daten', true);
}
}

View File

@@ -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 = `<option>Loading...</option>`;
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`));

View File

@@ -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 = '<p class="muted">Lade Events...</p>';
try {
const data = await api_js_1.api.events(guildId);
const data = await api.events(guildId);
const events = data?.events || data || [];
section.innerHTML = '<h2 class="section-title">Events</h2>';
if (!events.length) {
@@ -38,6 +35,6 @@ async function initEventsSection(guildId) {
catch (err) {
console.error(err);
section.innerHTML = '<div class="empty-state">Events konnten nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Events', true);
showToast('Fehler beim Laden der Events', true);
}
}

View File

@@ -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 = '<div class="muted">Lade Guilds...</div>';
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 = '<div class="empty-state">Fehler beim Laden der Guilds</div>';
(0, toast_js_1.showToast)('Guilds konnten nicht geladen werden', true);
showToast('Guilds konnten nicht geladen werden', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Dynamic Voice...</p>';
try {
const data = await api_js_1.api.dynamicVoice(guildId);
const data = await api.dynamicVoice(guildId);
const cfg = data?.config || data?.dynamicVoiceConfig || {};
container.innerHTML = `
<h3 class="label">Dynamic Voice</h3>
@@ -21,6 +18,6 @@ async function renderDynamicVoiceModule(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">Dynamic Voice konnte nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden von Dynamic Voice', true);
showToast('Fehler beim Laden von Dynamic Voice', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Module...</p>';
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 = '<div class="empty-state">Module konnten nicht geladen werden.</div>';
(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);
}
}

View File

@@ -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 = '<p class="muted">Lade Logging...</p>';
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 = `
<h3 class="label">Logging</h3>
@@ -21,6 +18,6 @@ async function renderLoggingModule(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">Logging konnte nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden von Logging', true);
showToast('Fehler beim Laden von Logging', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Reaction Roles...</p>';
try {
const data = await api_js_1.api.reactionRoles(guildId);
const data = await api.reactionRoles(guildId);
const entries = data?.entries || data?.reactionRoles || [];
container.innerHTML = '<h3 class="label">Reaction Roles</h3>';
if (!entries.length) {
@@ -32,6 +29,6 @@ async function renderReactionRolesModule(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">Reaction Roles konnten nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Reaction Roles', true);
showToast('Fehler beim Laden der Reaction Roles', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Server Stats...</p>';
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 = '<div class="empty-state">Server Stats konnten nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Server Stats', true);
showToast('Fehler beim Laden der Server Stats', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Statuspage...</p>';
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 = '<div class="empty-state">Statuspage konnte nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Statuspage', true);
showToast('Fehler beim Laden der Statuspage', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Welcome...</p>';
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 = `
<h3 class="label">Welcome</h3>
@@ -21,6 +18,6 @@ async function renderWelcomeModule(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">Welcome konnte nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden von Welcome', true);
showToast('Fehler beim Laden von Welcome', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Uebersicht...</p>';
try {
const data = await api_js_1.api.overview(guildId);
const data = await api.overview(guildId);
const stats = data?.stats || {};
section.innerHTML = `
<h2 class="section-title">Uebersicht</h2>
@@ -32,6 +29,6 @@ async function renderOverview(guildId) {
catch (err) {
console.error(err);
section.innerHTML = '<div class="empty-state">Uebersicht konnte nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Uebersicht', true);
showToast('Fehler beim Laden der Uebersicht', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Einstellungen...</p>';
try {
const data = await api_js_1.api.settings(guildId);
const data = await api.settings(guildId);
const settings = data?.settings || {};
section.innerHTML = `
<h2 class="section-title">Einstellungen</h2>
@@ -21,6 +18,6 @@ async function renderSettingsSection(guildId) {
catch (err) {
console.error(err);
section.innerHTML = '<div class="empty-state">Einstellungen konnten nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Einstellungen', true);
showToast('Fehler beim Laden der Einstellungen', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Automationen...</p>';
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 = '<div class="empty-state">Keine Regeln angelegt.</div>';
@@ -37,6 +34,6 @@ async function renderAutomations(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">Automationen konnten nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Automationen', true);
showToast('Fehler beim Laden der Automationen', true);
}
}

View File

@@ -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) {
</div>
`;
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)
]);
}

View File

@@ -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 = '<p class="muted">Lade Knowledge Base...</p>';
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 = '<div class="empty-state">Keine KB-Eintraege.</div>';
@@ -32,6 +29,6 @@ async function renderKb(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">KB konnte nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der KB', true);
showToast('Fehler beim Laden der KB', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Tickets...</p>';
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 = '<div class="empty-state">Keine Tickets</div>';
@@ -38,6 +35,6 @@ async function renderTicketList(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">Tickets konnten nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Tickets', true);
showToast('Fehler beim Laden der Tickets', true);
}
}

View File

@@ -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 = '<p class="muted">Lade Pipeline...</p>';
try {
const data = await api_js_1.api.pipeline(guildId);
const data = await api.pipeline(guildId);
const lanes = data?.lanes || [];
container.innerHTML = '<h3 class="label">Pipeline</h3>';
if (!lanes.length) {
@@ -32,6 +29,6 @@ async function renderPipeline(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">Pipeline konnte nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der Pipeline', true);
showToast('Fehler beim Laden der Pipeline', true);
}
}

View File

@@ -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 = '<p class="muted">Lade SLA...</p>';
try {
const data = await api_js_1.api.sla(guildId);
const data = await api.sla(guildId);
const stats = data?.stats || {};
container.innerHTML = `
<h3 class="label">SLA</h3>
@@ -20,6 +17,6 @@ async function renderSla(guildId) {
catch (err) {
console.error(err);
container.innerHTML = '<div class="empty-state">SLA konnte nicht geladen werden.</div>';
(0, toast_js_1.showToast)('Fehler beim Laden der SLA', true);
showToast('Fehler beim Laden der SLA', true);
}
}

View File

@@ -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);
});

View File

@@ -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 } }),

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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) => {

View File

@@ -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);

View File

@@ -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;

View File

@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"module": "ES2020",
"moduleResolution": "Bundler",
"outDir": "public/ts-build",
"rootDir": "public/ts",
"skipLibCheck": true,