From e86995800fe7d1a98e7634903fe8be860c915566 Mon Sep 17 00:00:00 2001 From: NovaFox161 Date: Mon, 16 Mar 2020 20:20:47 -0500 Subject: [PATCH] Start work on additional dashboard modules This starts work on adding other dashboard modules by defining the page in data as well as adding in links for the modules and highlighting active page dynamically (hopefully). --- web/src/main/javascript/index.ts | 34 +++++++-- .../templates/dashboard/dashboard.html | 2 +- .../resources/templates/dashboard/guild.html | 73 +++++++++++++++++-- 3 files changed, 95 insertions(+), 14 deletions(-) diff --git a/web/src/main/javascript/index.ts b/web/src/main/javascript/index.ts index 9e01c701..7c40437c 100644 --- a/web/src/main/javascript/index.ts +++ b/web/src/main/javascript/index.ts @@ -11,12 +11,34 @@ function loadEmbedCalendar(embedKey: string, apiUrl: string) { embedRunner.init(embedKey, apiUrl); } -const body = document.getElementById("page-top"); -if (body!.dataset.embedKey != null) { - loadEmbedCalendar(body!.dataset.embedKey, body!.dataset.apiUrl); -} else if (body!.dataset.apiKey != null) { - loadDashboardGuildPage(body!.dataset.apiKey, - body!.dataset.apiUrl, body!.dataset.userId) +const body = document.getElementById("page-top")!; +if (body.dataset.embedKey != null) { + //This will eventually be a switch or something when we get more embed pages. + loadEmbedCalendar(body.dataset.embedKey, body.dataset.apiUrl); +} else if (body.dataset.dashboard != null) { + //Get the various data attributes we need... + const dash = body.dataset.dashboard; + const apiKey = body.dataset.apiKey; + const apiUrl = body.dataset.apiUrl; + const userId = body.dataset.userId; + + switch (dash.toUpperCase()) { + case "GUILD": + loadDashboardGuildPage(apiKey, apiUrl, userId); + break; + case "CALENDAR": + //TODO: load dashboard calendar page + break; + case "EVENTS": + //TODO: load dashboard events page + break; + case "ANNOUNCEMENTS": + //TODO: load dashboard announcements page + break; + default: + //No default action, if its incorrect we don't do anything. + break; + } } (function ($) { diff --git a/web/src/main/resources/templates/dashboard/dashboard.html b/web/src/main/resources/templates/dashboard/dashboard.html index a9b2fbd8..6b72c38e 100644 --- a/web/src/main/resources/templates/dashboard/dashboard.html +++ b/web/src/main/resources/templates/dashboard/dashboard.html @@ -103,7 +103,7 @@ - -