added option to remove template

This commit is contained in:
lllllllillllllillll 2024-05-19 02:31:21 -07:00
parent cec389702c
commit 5081100f71
5 changed files with 25 additions and 7 deletions

View File

@ -1,4 +1,4 @@
## v0.60 (dev)
## v0.60 (May 19th 2024)
* Converted JS template literals into HTML.
* Converted modals into HTML/HTMX.
* Moved functions into dashboard controller.

View File

@ -20,15 +20,15 @@
* DweebUI is a management interface and should not be directly exposed to the internet
## Features
* [x] A dynamically updating dashboard that displays server metrics along with individual container metrics and container controls.
* [x] Multi-users with permissions system.
* [x] A dynamically updating dashboard that displays server metrics along with container metrics and container controls.
* [x] Multi-user support with permissions system.
* [x] View container logs.
* [x] Manage your Docker networks, images, and volumes.
* [x] Light/Dark Mode.
* [x] Mobile Friendly.
* [x] Easy to install app templates.
* [x] Windows, Linux, and MacOS compatable.
* [ ] Docker compose (in development).
* [x] Docker Compose Support.
* [ ] Update containers (planned).
* [x] Templates.json maintains compatability with Portainer, allowing you to use the template without needing to use DweebUI.
* [ ] Preset variables (planned).

View File

@ -11,12 +11,19 @@ const upload = multer({storage: multer.diskStorage({
let alert = '';
let templates_global = '';
let json_templates = '';
let remove_button = '';
export const Apps = async (req, res) => {
let page = Number(req.params.page) || 1;
let template_param = req.params.template || 'default';
if ((template_param != 'default') && (template_param != 'compose')) {
remove_button = `<a href="/remove_template/${template_param}" class="btn" hx-confirm="Are you sure you want to remove this template?">Remove</a>`;
} else {
remove_button = '';
}
json_templates = '';
let json_files = readdirSync('templates/json/');
for (let i = 0; i < json_files.length; i++) {
@ -126,14 +133,22 @@ export const Apps = async (req, res) => {
template_list: '',
json_templates: json_templates,
pages: pages,
remove_button: remove_button
});
alert = '';
}
export const removeTemplate = async (req, res) => {
let template = req.params.template;
unlinkSync(`templates/json/${template}.json`);
res.redirect('/apps');
}
export const appSearch = async (req, res) => {
let search = req.body.search;
let page = Number(req.params.page) || 1;
let template_param = req.params.template || 'default';
@ -161,7 +176,6 @@ export const appSearch = async (req, res) => {
if (page == 1) { prev = '/apps/' + (page); }
if (page == last_page) { next = '/apps/' + (page); }
let search = req.body.search;
let apps_list = '';
let results = [];
@ -209,6 +223,7 @@ export const appSearch = async (req, res) => {
appCard = appCard.replace(/AppDesc/g, desc);
appCard = appCard.replace(/AppLogo/g, logo);
appCard = appCard.replace(/AppCategories/g, categories);
appCard = appCard.replace(/AppType/g, 'json');
apps_list += appCard;
}
@ -226,6 +241,7 @@ export const appSearch = async (req, res) => {
template_list: '',
json_templates: json_templates,
pages: pages,
remove_button: remove_button
});
}

View File

@ -6,7 +6,7 @@ export const router = express.Router();
import { Login, submitLogin, Logout } from "../controllers/login.js";
import { Register, submitRegister } from "../controllers/register.js";
import { Dashboard, DashboardAction, Stats, Chart, SSE, UpdatePermissions } from "../controllers/dashboard.js";
import { Apps, appSearch, InstallModal, ImportModal, LearnMore, Upload } from "../controllers/apps.js";
import { Apps, appSearch, InstallModal, ImportModal, LearnMore, Upload, removeTemplate } from "../controllers/apps.js";
import { Users } from "../controllers/users.js";
import { Images } from "../controllers/images.js";
import { Networks, removeNetwork } from "../controllers/networks.js";
@ -85,6 +85,7 @@ router.post("/removeNetwork", adminOnly, removeNetwork);
router.get("/apps/:page?/:template?", adminOnly, Apps);
router.post("/apps", adminOnly, appSearch);
router.get("/remove_template/:template", adminOnly, removeTemplate);
router.get("/install_modal", adminOnly, InstallModal)
router.get("/import_modal", adminOnly, ImportModal)

View File

@ -36,6 +36,7 @@
<div class="card-body text-center">
<div class="d-flex align-items-center">
<div class="me-auto btn"><%= list_start %> - <%= list_end %> of <%= app_count %> Apps</div>
<%- remove_button %>
</div>
</div>
</div>