[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,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`));