diff --git a/Server/public/res/css/main.css b/Server/public/res/css/main.css new file mode 100644 index 0000000..d057e2a --- /dev/null +++ b/Server/public/res/css/main.css @@ -0,0 +1,142 @@ +.node-card { + position: relative; + display: flex; + flex-direction: column; + min-width: 0; + word-wrap: break-word; + background-color: #fff; + background-clip: border-box; + border: 1px solid #eff0f2; + border-radius: 1rem; + margin-bottom: 24px; + box-shadow: 0 2px 3px #e4e8f0; +} + +.avatar-md { + height: 4rem; + width: 4rem; +} + +.rounded-circle { + border-radius: 50% !important; +} + +.img-thumbnail { + padding: 0.25rem; + background-color: #f1f3f7; + border: 1px solid #eff0f2; + border-radius: 0.75rem; +} + +.avatar-title { + align-items: center; + background-color: #3b76e1; + color: #fff; + display: flex; + font-weight: 500; + height: 100%; + justify-content: center; + width: 100%; +} + +.bg-soft-primary { + background-color: rgba(59, 118, 225, .25) !important; +} + +a { + text-decoration: none !important; +} + +.badge-soft-danger { + color: #f56e6e !important; + background-color: rgba(245, 110, 110, .1); +} + +.badge-soft-success { + color: #63ad6f !important; + background-color: rgba(99, 173, 111, .1); +} + +.mb-0 { + margin-bottom: 0 !important; +} + +.badge { + display: inline-block; + padding: 0.25em 0.6em; + font-size: 75%; + font-weight: 500; + line-height: 1; + color: #fff; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: 0.75rem; +} + +/* Info Card Section */ +.info-card { + background-color: #fff; + border-radius: 10px; + border: none; + position: relative; + margin-bottom: 30px; + box-shadow: 0 0.46875rem 2.1875rem rgba(90, 97, 105, 0.1), 0 0.9375rem 1.40625rem rgba(90, 97, 105, 0.1), 0 0.25rem 0.53125rem rgba(90, 97, 105, 0.12), 0 0.125rem 0.1875rem rgba(90, 97, 105, 0.1); +} + +.info-card .card-statistic .card-icon-large .bi { + font-size: 110px; +} + +.info-card .card-statistic .card-icon { + text-align: center; + line-height: 50px; + margin-left: 15px; + color: #000; + position: absolute; + right: -5px; + top: 20px; + opacity: 0.1; +} + +/* Info Card Background Colors */ + +.l-bg-cherry { + background: linear-gradient(to right, #493240, #f09) !important; + color: #fff; +} + +.l-bg-blue-dark { + background: linear-gradient(to right, #373b44, #4286f4) !important; + color: #fff; +} + +.l-bg-green-dark { + background: linear-gradient(to right, #0a504a, #38ef7d) !important; + color: #fff; +} + +.l-bg-orange-dark { + background: linear-gradient(to right, #a86008, #ffba56) !important; + color: #fff; +} + +.l-bg-cyan { + background: linear-gradient(135deg, #289cf5, #84c0ec) !important; + color: #fff; +} + +.l-bg-green { + background: linear-gradient(135deg, #23bdb8 0%, #43e794 100%) !important; + color: #fff; +} + +.l-bg-orange { + background: linear-gradient(to right, #f9900e, #ffba56) !important; + color: #fff; +} + +/* Global Section */ +.sidebar-container { + min-height: 94.2vh; +} \ No newline at end of file diff --git a/Server/public/res/js/controller.js b/Server/public/res/js/controller.js new file mode 100644 index 0000000..04c0fd9 --- /dev/null +++ b/Server/public/res/js/controller.js @@ -0,0 +1,3 @@ +function sendNodeHeartbeat(nodeId) { + console.log(nodeId); +} \ No newline at end of file diff --git a/Server/routes/index.js b/Server/routes/index.js index a188406..1f43b2a 100644 --- a/Server/routes/index.js +++ b/Server/routes/index.js @@ -1,11 +1,12 @@ -const libCore = require("../libCore"); var express = require('express'); var router = express.Router(); +const { getAllNodes, getNodeInfoFromId } = require("../utilities/mysqlHandler"); + /* GET home page. */ router.get('/', (req, res) => { - var sources = libCore.getSources(); - //res.render('index', { "sources": sources }); + //var sources = libCore.getSources(); + return res.render('index'); var htmlOutput = ""; @@ -28,4 +29,24 @@ router.get('/', (req, res) => { res.send(htmlOutput); }); +/* GET node controller page. */ +router.get('/controller', async (req, res) => { + var nodes = await new Promise((recordResolve, recordReject) => { + getAllNodes((nodeRows) => { + recordResolve(nodeRows); + }); + }); + + //var sources = libCore.getSources(); + return res.render('controller', {'nodes' : nodes}); +}); + +/* GET individual node page. */ +router.get('/node/:id', async (req, res) => { + var node = await getNodeInfoFromId(req.params.id); + + //var sources = libCore.getSources(); + return res.render('node', {'node' : node}); +}); + module.exports = router; diff --git a/Server/views/controller.ejs b/Server/views/controller.ejs new file mode 100644 index 0000000..28099a9 --- /dev/null +++ b/Server/views/controller.ejs @@ -0,0 +1,11 @@ +<%- include('partials/htmlHead.ejs') %> +
+
+ <% for(const node of nodes) {%> + <%- include('partials/nodeCard.ejs', {'node': node}) %> + <% } %> +
+
+<%- include('partials/bodyEnd.ejs') %> + +<%- include('partials/htmlFooter.ejs') %> \ No newline at end of file diff --git a/Server/views/index.ejs b/Server/views/index.ejs index 7b7a1d6..b6524a3 100644 --- a/Server/views/index.ejs +++ b/Server/views/index.ejs @@ -1,11 +1,133 @@ - - - - <%= title %> - - - -

<%= title %>

-

Welcome to <%= title %>

- - +<%- include('partials/htmlHead.ejs') %> +
+
+
+
+
+
+
+
New Orders
+
+
+
+

+ 3,243 +

+
+
+ 12.5% +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
New Orders
+
+
+
+

+ 3,243 +

+
+
+ 12.5% +
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+
Phyllis Gatlin
+ Full Stack Developer +
+
+
+

070 2860 5375 +

+

+ PhyllisGatlin@spy.com

+

52 + Ilchester MYBSTER 9WX

+
+
+
+
+ +
+
+
+ +
+
+
+
Diana Owens
+ UI/UX Designer +
+
+
+

087 6321 3235 +

+

+ DianaOwens@spy.com

+

52 + Ilchester MYBSTER 9WX

+
+
+ + +
+
+
+
+ + +
+
+<%- include('partials/bodyEnd.ejs') %> + +<%- include('partials/htmlFooter.ejs') %> \ No newline at end of file diff --git a/Server/views/node.ejs b/Server/views/node.ejs new file mode 100644 index 0000000..941e326 --- /dev/null +++ b/Server/views/node.ejs @@ -0,0 +1,41 @@ +<%- include('partials/htmlHead.ejs') %> +
+
+ Account Details + <% if(node.online){%> Online + <% } else {%> Offline + <% } %> +
+
+
+
+ + +
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+ + +
+ + +
+
+
+<%- include('partials/bodyEnd.ejs') %> +<%- include('partials/htmlFooter.ejs') %> \ No newline at end of file diff --git a/Server/views/partials/bodyEnd.ejs b/Server/views/partials/bodyEnd.ejs new file mode 100644 index 0000000..2a347cf --- /dev/null +++ b/Server/views/partials/bodyEnd.ejs @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/Server/views/partials/head.ejs b/Server/views/partials/head.ejs new file mode 100644 index 0000000..3429389 --- /dev/null +++ b/Server/views/partials/head.ejs @@ -0,0 +1,9 @@ + + + + Bootstrap demo + + + + \ No newline at end of file diff --git a/Server/views/partials/htmlFooter.ejs b/Server/views/partials/htmlFooter.ejs new file mode 100644 index 0000000..62d09b8 --- /dev/null +++ b/Server/views/partials/htmlFooter.ejs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Server/views/partials/htmlHead.ejs b/Server/views/partials/htmlHead.ejs new file mode 100644 index 0000000..5a3ef3b --- /dev/null +++ b/Server/views/partials/htmlHead.ejs @@ -0,0 +1,6 @@ + + + <%- include('head.ejs') %> + + <%- include('navbar.ejs') %> + <%- include('sidebar.ejs') %> \ No newline at end of file diff --git a/Server/views/partials/navbar.ejs b/Server/views/partials/navbar.ejs new file mode 100644 index 0000000..ccac10e --- /dev/null +++ b/Server/views/partials/navbar.ejs @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/Server/views/partials/nodeCard.ejs b/Server/views/partials/nodeCard.ejs new file mode 100644 index 0000000..b676560 --- /dev/null +++ b/Server/views/partials/nodeCard.ejs @@ -0,0 +1,57 @@ +
+
+
+ +
+
+ +
+
+
+ <%= node.name %> +
+ <% if(node.online){%> Online + <% } else {%> Offline + <% } %> +
+
+
+

+ + <%= node.location %> +

+

+ + + <%= node.ip %>:<%= node.port %> + +

+

+

+

+
+
+
+
\ No newline at end of file diff --git a/Server/views/partials/sidebar.ejs b/Server/views/partials/sidebar.ejs new file mode 100644 index 0000000..8eb5815 --- /dev/null +++ b/Server/views/partials/sidebar.ejs @@ -0,0 +1,83 @@ +
+
+
+ +
+
\ No newline at end of file