From 7c5670e92b2a77feca118e07eab261f6d01359a7 Mon Sep 17 00:00:00 2001 From: lllllllillllllillll Date: Sun, 17 Mar 2024 19:32:02 -0700 Subject: [PATCH] Fixed app search and install --- CHANGELOG.md | 2 ++ README.md | 10 +++++----- controllers/apps.js | 30 +++++++++++++++++++++++++++--- database/models.js | 34 ++++++++++++++++++++++++++++++++-- docker-compose.yaml | 4 ++-- functions/install.js | 7 ------- views/apps.html | 35 +++++++++++------------------------ 7 files changed, 79 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a945070..af22209 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * Independently updating container cards. * Container cards display pending actions (starting, stopping, pausing, restarting). * Dynamically generated avatars. +* Updated database models. +* Persistent Database. ## v0.40 (Feb 26th 2024) - HTMX rewrite * Pages rewritten to use HTMX. diff --git a/README.md b/README.md index e2a0685..cf0e3b5 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ Alpha v0.50 ( :fire: Experimental :fire: ) [![GitHub License](https://img.shields.io/github/license/lllllllillllllillll/DweebUI)](https://github.com/lllllllillllllillll/DweebUI/blob/main/LICENSE) [![Coffee](https://img.shields.io/badge/-buy_me_a%C2%A0coffee-gray?logo=buy-me-a-coffee)](https://www.buymeacoffee.com/lllllllillllllillll) -* This is a personal project I started to get more familiar with Javascript and Node.js. -* Some UI elements are placeholders and every version may have breaking changes. +* I started this as a personal project to get more familiar with Javascript and Node.js. +* 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. @@ -30,6 +30,7 @@ Alpha v0.50 ( :fire: Experimental :fire: ) ## Features * [x] Dashboard provides server metrics, container metrics, and container controls, on a single page. * [x] View container logs. +* [x] View container logs. * [ ] Update containers (planned). * [x] Manage your Docker networks, images, and volumes. * [x] Light/Dark Mode. @@ -38,9 +39,8 @@ Alpha v0.50 ( :fire: Experimental :fire: ) * [x] Multi-User built-in. * [ ] Permissions system (in development). * [x] Support for Windows, Linux, and MacOS. -* [ ] Docker compose import (in development). +* [ ] Docker compose (in development). * [x] Templates.json maintains compatability with Portainer, allowing you to use the template without needing to use DweebUI. -* [x] Automatically persists data in docker volumes if bind mount isn't used. * [ ] Preset variables (planned). * [ ] Themes (planned). @@ -53,7 +53,7 @@ version: "3.9" services: dweebui: container_name: dweebui - image: lllllllillllllillll/dweebui:v0.40 + image: lllllllillllllillll/dweebui:v0.50 environment: PORT: 8000 SECRET: MrWiskers diff --git a/controllers/apps.js b/controllers/apps.js index 86a3919..d3070e2 100644 --- a/controllers/apps.js +++ b/controllers/apps.js @@ -103,8 +103,32 @@ export const appSearch = async (req, res) => { searchTemplates(search); for (let i = 0; i < results.length; i++) { - let app_card = appCard(results[i]); - apps_list += app_card; + let appCard = readFileSync('./views/partials/appCard.html', 'utf8'); + let name = results[i].name || results[i].title.toLowerCase(); + let desc = results[i].description.slice(0, 60) + "..."; + let description = results[i].description.replaceAll(". ", ".\n") || "no description available"; + let note = results[i].note ? results[i].note.replaceAll(". ", ".\n") : "no notes available"; + let image = results[i].image; + let logo = results[i].logo; + + let categories = ''; + + // set data.catagories to 'other' if data.catagories is empty or undefined + if (results[i].categories == null || results[i].categories == undefined || results[i].categories == '') { + results[i].categories = ['Other']; + } + + for (let c = 0; c < results[i].categories.length; c++) { + categories += CatagoryColor(results[i].categories[c]); + } + + appCard = appCard.replace(/AppName/g, name); + appCard = appCard.replace(/AppShortName/g, name); + appCard = appCard.replace(/AppDesc/g, desc); + appCard = appCard.replace(/AppLogo/g, logo); + appCard = appCard.replace(/AppCategories/g, categories); + + apps_list += appCard; } res.render("apps", { @@ -113,7 +137,7 @@ export const appSearch = async (req, res) => { avatar: req.session.avatar, list_start: list_start + 1, list_end: list_end, - app_count: templates.length, + app_count: results.length, prev: prev, next: next, apps_list: apps_list diff --git a/database/models.js b/database/models.js index cb83c4e..6a66019 100644 --- a/database/models.js +++ b/database/models.js @@ -154,10 +154,10 @@ export const Permission = sequelize.define('Permission', { hide: { type: DataTypes.STRING }, - view: { + reset_view: { type: DataTypes.STRING }, - reset_view: { + view: { type: DataTypes.STRING }, }); @@ -207,10 +207,40 @@ export const Notification = sequelize.define('Notification', { color: { type: DataTypes.STRING, }, + read: { + type: DataTypes.STRING, + }, createdAt : { type: DataTypes.STRING }, createdBy : { type: DataTypes.STRING }, +}); + + +export const Settings = sequelize.define('Settings', { + id: { + type: DataTypes.INTEGER, + autoIncrement: true, + primaryKey: true + }, + key: { + type: DataTypes.STRING, + allowNull: false + }, + value: { + type: DataTypes.STRING, + allowNull: false + } +}); + + +export const Variables = sequelize.define('Variables', { + find: { + type: DataTypes.STRING, + }, + replace: { + type: DataTypes.STRING, + } }); \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index b4268d7..14c0d30 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,10 +7,10 @@ services: PORT: 8000 SECRET: MrWiskers restart: unless-stopped - expose: + ports: - 8000:8000 volumes: - - dweebui:/app + - dweebui:/app/database/ # Docker socket - /var/run/docker.sock:/var/run/docker.sock # Podman socket diff --git a/functions/install.js b/functions/install.js index 67dc575..7e00074 100644 --- a/functions/install.js +++ b/functions/install.js @@ -88,13 +88,6 @@ export const Install = async (req, res) => { if ((data[`volume${i}`] == 'on') && (data[`volume_${i}_bind`] != '') && (data[`volume_${i}_container`] != '')) { compose_file += `\n - ${data[`volume_${i}_bind`]}:${data[`volume_${i}_container`]}:${data[`volume_${i}_readwrite`]}` } - - // if bind is empty create a docker volume (ex container_name_config:/config) convert any '/' in container name to '_' - else if ((data[`volume${i}`] == 'on') && (data[`volume_${i}_bind`] == '') && (data[`volume_${i}_container`] != '')) { - let volume_name = data[`volume_${i}_container`].replace(/\//g, '_'); - compose_file += `\n - ${name}_${volume_name}:${data[`volume_${i}_container`]}:${data[`volume_${i}_readwrite`]}` - docker_volumes.push(`${name}_${volume_name}`); - } } diff --git a/views/apps.html b/views/apps.html index 493deaa..7e787f0 100644 --- a/views/apps.html +++ b/views/apps.html @@ -27,45 +27,32 @@
-