3 Commits

Author SHA1 Message Date
Logan Cusano
8a0baa5bc9 Small tweaks
- Update local webUI to refresh when joining server to clear modal
- Updated client webUI page title
- Re-added join modal to node page (client & server)
- updated join modal to use node.nearbySystems
2023-07-22 15:01:48 -04:00
Logan Cusano
ec091c0017 Only concat the stored toasts with new toast when there are stored toasts 2023-07-22 14:46:51 -04:00
Logan Cusano
a5996ccfc0 Added page titles to server webUI 2023-07-22 04:21:06 -04:00
10 changed files with 48 additions and 47 deletions

View File

@@ -30,13 +30,15 @@ function addToastToStorage(time, message) {
var toasts = [{ 'time': time, 'message': message }]
var storedToasts = getStoredToasts();
console.log("Adding new notification to storage: ", toasts);
toasts = toasts.concat(storedToasts);
console.log("Combined new and stored notifications: ", toasts);
toasts = toasts.filter((value, index, self) =>
index === self.findIndex((t) => (
t.time === value.time && t.message === value.message
))
)
if (storedToasts) {
toasts = toasts.concat(storedToasts);
console.log("Combined new and stored notifications: ", toasts);
toasts = toasts.filter((value, index, self) =>
index === self.findIndex((t) => (
t.time === value.time && t.message === value.message
))
)
}
console.log("Deduped stored notifications: ", toasts);
localStorage.setItem("toasts", JSON.stringify(toasts));
navbarUpdateNotificationBellCount(toasts);
@@ -251,8 +253,8 @@ function joinServer() {
const responseObject = JSON.parse(Http.responseText)
console.log(Http.status);
console.log(responseObject);
createToast(`${responseObject.name} will join shortly`, { showNow: true });
$("#joinModal").modal('toggle');
createToast(`${responseObject.name} will join shortly`);
location.reload();
}
}

View File

@@ -3,7 +3,7 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<title>'<%=node.name%>' - Configuration</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css">
@@ -153,7 +153,9 @@
</div>
<% // new System Modal %>
<%- include("partials/modifySystemModal.ejs", {'system': "New System" , 'frequencies' : [], 'mode' : '' }) %>
<%- include("partials/modifySystemModal.ejs", {'system': "New System" , 'frequencies' : [], 'mode' : '' }) %>
<% // Join Server Modal %>
<%- include("partials/joinModal.ejs", {'node': node}) %>
</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"
integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>

View File

@@ -24,7 +24,7 @@
<div class="col-md-6">
<label class="small mb-1" for="selectRadioPreset">Selected Preset:</label>
<select class="custom-select" id="selectRadioPreset">
<% for(const system in nearbySystems) { %>
<% for(const system in node.nearbySystems) { %>
<option value="<%=system%>"><%=system%></option>
<% } %>
</select>

View File

@@ -30,13 +30,15 @@ function addToastToStorage(time, message) {
var toasts = [{ 'time': time, 'message': message }]
var storedToasts = getStoredToasts();
console.log("Adding new notification to storage: ", toasts);
toasts = toasts.concat(storedToasts);
console.log("Combined new and stored notifications: ", toasts);
toasts = toasts.filter((value, index, self) =>
index === self.findIndex((t) => (
t.time === value.time && t.message === value.message
))
)
if (storedToasts) {
toasts = toasts.concat(storedToasts);
console.log("Combined new and stored notifications: ", toasts);
toasts = toasts.filter((value, index, self) =>
index === self.findIndex((t) => (
t.time === value.time && t.message === value.message
))
)
}
console.log("Deduped stored notifications: ", toasts);
localStorage.setItem("toasts", JSON.stringify(toasts));
navbarUpdateNotificationBellCount(toasts);
@@ -254,7 +256,7 @@ function joinServer() {
console.log(Http.status);
console.log(responseObject);
createToast(`${responseObject.name} will join shortly`, { showNow: true });
$("#joinModal").modal('toggle');
location.reload();
}
}

View File

@@ -6,27 +6,7 @@ const { getAllNodes, getNodeInfoFromId } = require("../utilities/mysqlHandler");
/* GET home page. */
router.get('/', (req, res) => {
//var sources = libCore.getSources();
return res.render('index');
var htmlOutput = "";
sources.forEach(source => {
htmlOutput += `
<div style='margin-bottom:15px;'>
<div> Title: ${source.title} </div>
<div> Link: ${source.link} </div>
<div> category: ${source.category} </div>
</div>
<div>
<hr />
</div>
`
});
res.send(htmlOutput);
return res.render('index', {'page': 'index'});
});
/* GET node controller page. */
@@ -38,7 +18,7 @@ router.get('/controller', async (req, res) => {
});
//var sources = libCore.getSources();
return res.render('controller', {'nodes' : nodes});
return res.render('controller', {'nodes' : nodes, 'page': 'controller'});
});
/* GET individual node page. */
@@ -46,7 +26,7 @@ router.get('/node/:id', async (req, res) => {
var node = await getNodeInfoFromId(req.params.id);
//var sources = libCore.getSources();
return res.render('node', {'node' : node});
return res.render('node', {'node' : node, 'page': 'node'});
});
module.exports = router;

View File

@@ -1,4 +1,4 @@
<%- include('partials/htmlHead.ejs') %>
<%- include('partials/htmlHead.ejs', {'page': page}) %>
<div class="container">
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-4">
<div class="col-xl-3 col-lg-6">

View File

@@ -134,5 +134,7 @@
<% // new System Modal %>
<%- include("partials/modifySystemModal.ejs", {'system': "New System", 'frequencies': [], 'mode': ''}) %>
<% // Join Server Modal %>
<%- include("partials/joinModal.ejs", {'node': node}) %>
<%- include('partials/bodyEnd.ejs') %>
<%- include('partials/htmlFooter.ejs') %>

View File

@@ -1,7 +1,20 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<% switch (page) {
case "index":%>
<title>Node Dashboard</title>
<% break;
case "controller":%>
<title>Node Controller</title>
<% break;
case "node":%>
<title>Node Configuration</title>
<% break;
default:%>
<title>DRB_CnC Server</title>
<%break;
} %>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css">

View File

@@ -1,6 +1,6 @@
<!doctype html>
<html lang="en" data-bs-theme="auto">
<%- include('head.ejs') %>
<%- include('head.ejs', {'page': page}) %>
<body>
<%- include('navbar.ejs') %>
<%- include('sidebar.ejs') %>

View File

@@ -24,7 +24,7 @@
<div class="col-md-6">
<label class="small mb-1" for="selectRadioPreset">Selected Preset:</label>
<select class="custom-select" id="selectRadioPreset">
<% for(const system in nearbySystems) { %>
<% for(const system in node.nearbySystems) { %>
<option value="<%=system%>"><%=system%></option>
<% } %>
</select>