showing info in dashboard
This commit is contained in:
@@ -3,6 +3,7 @@ import cors from 'cors';
|
||||
import cookieParser from 'cookie-parser';
|
||||
import http from 'http';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import chalk from 'chalk';
|
||||
import moment from 'moment';
|
||||
import path from 'path';
|
||||
@@ -21,6 +22,7 @@ class Server {
|
||||
auth;
|
||||
UIPath = path.join(__dirname, '../ui')
|
||||
DBPath = path.join(__dirname, '../db')
|
||||
ComalPath = path.join(os.homedir(), 'Sites/comalyr.com')
|
||||
|
||||
registerRoutes(router) {
|
||||
/* Stripe */
|
||||
@@ -35,10 +37,33 @@ class Server {
|
||||
/* Site */
|
||||
router.post('/signup', this.verifySignupToken, this.newUserSubmission)
|
||||
router.get('/db/images/*', this.getUserImage)
|
||||
router.get('/app/comaldata', this.getComalData)
|
||||
router.get('/*', this.get)
|
||||
return router
|
||||
}
|
||||
|
||||
getComalData = async (req, res, next) => {
|
||||
try {
|
||||
const pathOne = path.join(this.ComalPath, "db", "join.json");
|
||||
const pathTwo = path.join(this.ComalPath, "db", "contact.json");
|
||||
|
||||
const [joinRaw, contactRaw] = await Promise.all([
|
||||
fs.promises.readFile(pathOne, "utf8"),
|
||||
fs.promises.readFile(pathTwo, "utf8")
|
||||
]);
|
||||
|
||||
const join = joinRaw.trim() ? JSON.parse(joinRaw) : [];
|
||||
const contact = contactRaw.trim() ? JSON.parse(contactRaw) : [];
|
||||
|
||||
res.json({
|
||||
join,
|
||||
contact
|
||||
});
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
|
||||
verifySignupToken = (req, res, next) => {
|
||||
const { token } = req.query;
|
||||
if (!token) {
|
||||
|
||||
@@ -16,7 +16,6 @@ class Home extends Shadow {
|
||||
|
||||
HStack(() => {
|
||||
let selected = document.documentElement.className
|
||||
console.log(selected)
|
||||
select(() => {
|
||||
option("")
|
||||
option("Light").attr({value: "light"})
|
||||
|
||||
@@ -1,10 +1,97 @@
|
||||
class Dashboard extends Shadow {
|
||||
|
||||
COL = {
|
||||
time: 17,
|
||||
fname: 6,
|
||||
lname: 6,
|
||||
email: 20,
|
||||
phone: 12,
|
||||
message: 24,
|
||||
county: 10
|
||||
};
|
||||
|
||||
cell(type, value) {
|
||||
return p(value)
|
||||
.width(this.COL[type], pct)
|
||||
.whiteSpace("nowrap")
|
||||
.overflowX("auto")
|
||||
.overflowY("hidden");
|
||||
}
|
||||
|
||||
render() {
|
||||
VStack(() => {
|
||||
h1("Website Inquiries");
|
||||
|
||||
p("Contact Us")
|
||||
.fontWeight("bold")
|
||||
.marginTop(4, em)
|
||||
.marginBottom(1, em)
|
||||
.fontStyle("italic")
|
||||
|
||||
HStack(() => {
|
||||
p("Time").width(this.COL.time, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("First").width(this.COL.fname, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("Last").width(this.COL.lname, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("Email").width(this.COL.email, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("Phone").width(this.COL.phone, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("Message").width(this.COL.message, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("County").width(this.COL.county, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
})
|
||||
.width(95, pct)
|
||||
.maxWidth(95, pct)
|
||||
.gap(8);
|
||||
|
||||
window.comalData.contact.forEach((entry) => {
|
||||
HStack(() => {
|
||||
this.cell("time", entry.time);
|
||||
this.cell("fname", entry.fname);
|
||||
this.cell("lname", entry.lname);
|
||||
this.cell("email", entry.email);
|
||||
this.cell("phone", entry.phone);
|
||||
this.cell("message", entry.message);
|
||||
this.cell("county", entry.county ?? "Not Specified");
|
||||
})
|
||||
.width(95, pct)
|
||||
.maxWidth(95, pct)
|
||||
.gap(8);
|
||||
});
|
||||
|
||||
p("Join")
|
||||
.fontWeight("bold")
|
||||
.marginTop(4, em)
|
||||
.marginBottom(1, em)
|
||||
.fontStyle("italic")
|
||||
|
||||
HStack(() => {
|
||||
p("Time").width(this.COL.time, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("First").width(this.COL.fname, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("Last").width(this.COL.lname, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("Email").width(this.COL.email, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("Phone").width(this.COL.phone, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
p("County").width(this.COL.county, pct).fontWeight("bold").whiteSpace("nowrap");
|
||||
})
|
||||
.width(95, pct)
|
||||
.maxWidth(95, pct)
|
||||
.gap(8);
|
||||
|
||||
window.comalData.join.forEach((entry) => {
|
||||
HStack(() => {
|
||||
this.cell("time", entry.time);
|
||||
this.cell("fname", entry.fname);
|
||||
this.cell("lname", entry.lname);
|
||||
this.cell("email", entry.email);
|
||||
this.cell("phone", entry.phone);
|
||||
this.cell("county", entry.county ?? "Not Specified");
|
||||
})
|
||||
.width(95, pct)
|
||||
.maxWidth(95, pct)
|
||||
.gap(8);
|
||||
});
|
||||
})
|
||||
.paddingTop(4, pct)
|
||||
.paddingLeft(5, pct)
|
||||
.width(100, pct)
|
||||
.height(100, pct)
|
||||
.height(100, pct);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class AppMenu extends Shadow {
|
||||
.onEvent("themechange", () => {
|
||||
this.rerender()
|
||||
})
|
||||
.onEvent("appchanged", () => {
|
||||
.onEvent("appchange", () => {
|
||||
console.log("event firing successfully")
|
||||
this.rerender()
|
||||
})
|
||||
|
||||
@@ -39,13 +39,16 @@ class AppWindow extends Shadow {
|
||||
break;
|
||||
}
|
||||
})
|
||||
.overflow("scroll")
|
||||
.position("fixed")
|
||||
.width(window.innerWidth - this.calculateWidth(), px)
|
||||
.height(window.innerHeight - this.calculateHeight(), px)
|
||||
.background("var(--app)")
|
||||
.x(this.calculateWidth(), px)
|
||||
.yBottom(this.calculateHeight(), px)
|
||||
.onEvent("appchange", () => this.rerender())
|
||||
.onEvent("appchange", () => {
|
||||
this.rerender()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ window.addEventListener("navigate", () => {
|
||||
|
||||
if(window.currentApp !== selectedApp()) {
|
||||
window.currentApp = selectedApp()
|
||||
const event = new CustomEvent('appchanged', {
|
||||
const event = new CustomEvent('appchange', {
|
||||
detail: { name: window.currentApp }
|
||||
});
|
||||
window.dispatchEvent(event)
|
||||
@@ -56,7 +56,7 @@ window.openApp = function(appName) {
|
||||
console.log(newPath)
|
||||
window.navigateTo(newPath)
|
||||
// window.history.replaceState({}, '', newPath);
|
||||
const event = new CustomEvent('appchanged', {
|
||||
const event = new CustomEvent('appchange', {
|
||||
detail: { name: appName }
|
||||
});
|
||||
window.dispatchEvent(event)
|
||||
@@ -82,7 +82,7 @@ async function getProfile() {
|
||||
}
|
||||
}
|
||||
|
||||
getProfile().then(() => {
|
||||
getProfile().then(async () => {
|
||||
let path = "";
|
||||
let defaultNetwork = window.profile.networks[0]
|
||||
|
||||
@@ -95,6 +95,10 @@ getProfile().then(() => {
|
||||
path += defaultApp.toLowerCase()
|
||||
}
|
||||
|
||||
let appData = await fetch("/app/comaldata", {method: "GET"})
|
||||
let json = await appData.json()
|
||||
window.comalData = json
|
||||
|
||||
window.navigateTo(path)
|
||||
Home()
|
||||
})
|
||||
Reference in New Issue
Block a user