Free and Open-Source WebUI For Managing Your Containers.
-
-
@@ -12,13 +10,11 @@
+
-
-
-
## About
-* I started this as a personal project to get more familiar with Javascript and Node.js. There may be some rough edges and spaghetti code .
+* I started this as a personal project to get more familiar with Javascript and Node.js, so there may be some rough edges and spaghetti code.
* I'm open to any contributions but you may want to wait until I reach v1.0 first.
* Please post issues and discussions so I know what bugs and features to focus on.
* DweebUI is a management interface and should not be directly exposed to the internet
diff --git a/controllers/dashboard.js b/controllers/dashboard.js
index 99e035a..25c6f05 100644
--- a/controllers/dashboard.js
+++ b/controllers/dashboard.js
@@ -1,12 +1,15 @@
import { Readable } from 'stream';
-import { Permission, Container } from '../database/models.js';
+import { Permission, Container, User } from '../database/models.js';
import { docker } from '../server.js';
import { dockerContainerStats } from 'systeminformation';
import { readFileSync } from 'fs';
import { currentLoad, mem, networkStats, fsSize } from 'systeminformation';
+let hidden = '';
+
// The actual page
export const Dashboard = (req, res) => {
+
res.render("dashboard", {
name: req.session.user,
role: req.session.role,
@@ -33,12 +36,15 @@ export const Stats = async (req, res) => {
case 'NET':
let down = 0;
let up = 0;
+ let percent = 0;
await networkStats().then(data => {
down = Math.round(data[0].rx_bytes / (1024 * 1024));
up = Math.round(data[0].tx_bytes / (1024 * 1024));
+ // percent of download vs max download if max download was 1GB
+ percent = Math.round((down / 1000) * 100);
});
let net = `
-
+
@@ -143,10 +149,6 @@ async function createCard (details) {
let [ cardList, newCards, containersArray, sentArray, updatesArray ] = [ '', '', [], [], [] ];
-let hidden = await Container.findAll({ where: {visibility:false}});
-hidden = hidden.map((container) => container.name);
-
-
export async function addCard (name, state) {
console.log(`Adding card for ${name}: ${state}`);
@@ -321,15 +323,195 @@ export const Logs = (req, res) => {
export const Modals = async (req, res) => {
let name = req.header('hx-trigger-name');
let id = req.header('hx-trigger');
+ let title = name.charAt(0).toUpperCase() + name.slice(1);
if (id == 'permissions') {
let modal = readFileSync('./views/modals/permissions.html', 'utf8');
- modal = modal.replace(/AppName/g, name);
- // let containerPermissions = await Permission.findAll({ where: {containerName: name}});
+ let permissions_list = '';
+ modal = modal.replace(/AppName/g, title);
+ let users = await User.findAll({ attributes: ['username', 'UUID']});
+
+ for (let i = 0; i < users.length; i++) {
+ // check if user Permission contains an entry for this container for this user. If not, create one.
+ let exists = await Permission.findOne({ where: {containerName: name, user: users[i].username}});
+ if (!exists) {
+ const newPermission = await Permission.create({ containerName: name, user: users[i].username, userID: users[i].UUID});
+ }
+
+ let user_permissions = `
+
+