diff --git a/static/app.js b/static/app.js
index 0b11a38..9257d2d 100644
--- a/static/app.js
+++ b/static/app.js
@@ -12,6 +12,7 @@ var mode = new URLSearchParams(window.location.search).get("mode");
const archiveLink = document.querySelector("#archive-link")
const pendingLink = document.querySelector("#pending-link")
const statusLink = document.querySelector("#status-link")
+function handleForm(event) { event.preventDefault(); }
function main() {
archiveLink.classList.remove("active");
@@ -20,7 +21,7 @@ function main() {
switch (mode) {
case "status":
statusLink.classList.add("active");
- return;
+ return statusPage();
case "pending":
pendingLink.classList.add("active");
break;
@@ -40,6 +41,34 @@ function main() {
}
+function statusPage() {
+ document.getElementById("main-app").innerHTML = '';
+ fetch(`https://thanos.nightmare.haus/api/config`)
+ .then(response => response.json())
+ .then(data => {
+ var node = document.createElement("config-status");
+
+ var upTime = document.createElement("div");
+ upTime.setAttribute("slot", "uptime");
+ upTime.innerText = data.Uptime;
+ node.appendChild(upTime);
+
+ var bumpTime = document.createElement("div");
+ bumpTime.setAttribute("slot", "lastbump")
+ bumpTime.innerText = new Date(data.BumpTime).toLocaleString();
+ node.appendChild(bumpTime);
+
+ node.setData(data);
+
+ document.getElementById("main-app").appendChild(node);
+
+
+
+
+ });
+
+}
+
function searchPage() {
var search = document.getElementById("search-bar");
fetch('https://thanos.nightmare.haus/api/verifications')
@@ -115,7 +144,6 @@ window.onclick = function (event) {
}
}
var form = document.getElementById("search-form");
-function handleForm(event) { event.preventDefault(); }
form.addEventListener('submit', handleForm);
main();
\ No newline at end of file
diff --git a/static/components.js b/static/components.js
index b8defe6..9812c99 100644
--- a/static/components.js
+++ b/static/components.js
@@ -1,6 +1,18 @@
const basicCard = document.createElement('basic-card');
-basicCard.innerHTML = `
+const configStatus = document.createElement('status');
+const style = `
+`;
+
+basicCard.innerHTML = `
+${style}
`;
+configStatus.innerHTML = `
+${style}
+
+
+
+
Status
+
Uptime:
+
Last Bump was
+
by
+
+
+
+
+`;
+
+class ConfigStatusClass extends HTMLElement {
+ constructor() {
+ super();
+ this.attachShadow({ mode: 'open' });
+ this.shadowRoot.appendChild(configStatus.cloneNode(true));
+ }
+ async setData(data) {
+ this.shadowRoot.querySelector("#submitchanges").addEventListener('submit', handleForm);
+ this.shadowRoot.querySelector("#Guild").value = data.GuildID;
+ this.shadowRoot.querySelector("#AdminChannel").value = data.AdminChannel;
+ this.shadowRoot.querySelector("#AdminRole").value = data.AdminRole;
+ this.shadowRoot.querySelector("#MonitorChannel").value = data.MonitorChann;
+ this.shadowRoot.querySelector("#MonitorRole").value = data.MonitorRole;
+ this.shadowRoot.querySelector("#IntroChannel").value = data.IntroChann;
+ this.shadowRoot.querySelector("#VerifiedRole").value = data.VerifiedRole;
+ this.shadowRoot.querySelector("#OutFile").value = data.LogOpts.OutFile;
+ this.shadowRoot.querySelector("#KBTeam").value = data.LogOpts.KBTeam;
+ this.shadowRoot.querySelector("#KBChann").value = data.LogOpts.KBChann;
+ this.shadowRoot.querySelector("#Level").value = data.LogOpts.Level;
+ this.shadowRoot.querySelector("#ProgName").value = data.LogOpts.ProgName;
+ this.shadowRoot.querySelector("#UseStdout").checked = data.LogOpts.UseStdout == "true";
+ fetch('https://thanos.nightmare.haus/api/user?userID=' + data.LastBumper)
+ .then(response => response.json())
+ .then(userData => {
+ this.shadowRoot.querySelector("#lastbumper").innerHTML = userData.user.username;
+ });
+ this.loadStats(data.Stats)
+
+
+ }
+ async loadStats(data) {
+ var shadowRoot = this.shadowRoot;
+ Object.keys(data).forEach(function(uid) {
+ var score = data[uid];
+ fetch('https://thanos.nightmare.haus/api/user?userID=' + uid)
+ .then(response => response.json())
+ .then(userData => {
+ var stats = shadowRoot.querySelector("#admin-stats");
+ var userName = document.createElement("p");
+ userName.innerText = userData.user.username + ": " + score;
+ stats.appendChild(userName);
+ });
+ })
+ }
+
+}
+
class UserCard extends HTMLElement {
constructor() {
@@ -53,20 +178,21 @@ class UserCard extends HTMLElement {
const userID = this.shadowRoot.querySelector('#discord-id').assignedNodes()[0].textContent;
const userPic = this.shadowRoot.querySelector("#pic-link").assignedNodes()[0].querySelector("a").getAttribute("href");
fetch('https://thanos.nightmare.haus/api/user?userID=' + userID)
- .then(response => response.json())
- .then(data => {
- if (data === undefined || data === null) {
- alert("User not found.");
- return;
- }
- document.querySelector("#myModal").style.display = "block";
- document.querySelector('#modal-join').textContent = new Date(data.joined_at).toLocaleString();
- document.querySelector('#modal-userID').textContent = data.user.username;
- document.querySelector('#modal-avatar').src = `https://cdn.discordapp.com/avatars/${data.user.id}/${data.user.avatar}.png?size=256`;
- document.querySelector('#modal-verification').src = userPic;
- document.querySelector('#modal-verification').style = "max-height: 500px;";
- });
+ .then(response => response.json())
+ .then(data => {
+ if (data === undefined || data === null) {
+ alert("User not found.");
+ return;
+ }
+ document.querySelector("#myModal").style.display = "block";
+ document.querySelector('#modal-join').textContent = new Date(data.joined_at).toLocaleString();
+ document.querySelector('#modal-userID').textContent = data.user.username;
+ document.querySelector('#modal-avatar').src = `https://cdn.discordapp.com/avatars/${data.user.id}/${data.user.avatar}.png?size=256`;
+ document.querySelector('#modal-verification').src = userPic;
+ document.querySelector('#modal-verification').style = "max-height: 500px;";
+ });
}
}
window.customElements.define('user-card', UserCard);
+window.customElements.define('config-status', ConfigStatusClass);
diff --git a/static/index.html b/static/index.html
index 4bbe078..7b6cd86 100644
--- a/static/index.html
+++ b/static/index.html
@@ -16,7 +16,7 @@
-
+
@@ -75,8 +75,8 @@
-
-
+
+