From 7cf8b84169754be73665193f9eb318b04719ac9f Mon Sep 17 00:00:00 2001 From: lllllllillllllillll Date: Thu, 23 May 2024 17:25:54 -0700 Subject: [PATCH] buttons trigger from 'mousedown' John Carmack and Theo told me to: https://www.youtube.com/watch?v=yaMGtiPckAQ --- CHANGELOG.md | 4 ++++ controllers/images.js | 24 ++++++++++++++---------- views/partials/containerFull.html | 20 ++++++++++---------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a23abe..d007056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ * Added titles to activity indicators. * Created Github Wiki. * Added image pull to images page. +* Images display 'In use' or 'Unused'. +* Images display tag. +* Image pull gets latest if not set. +* Updated buttons to trigger from 'mousedown' (John Carmack + Theo told me to). ## v0.40 (Feb 26th 2024) - HTMX rewrite * Pages rewritten to use HTMX. diff --git a/controllers/images.js b/controllers/images.js index 344924e..2a89cf8 100644 --- a/controllers/images.js +++ b/controllers/images.js @@ -1,11 +1,11 @@ import { docker } from '../server.js'; +import { addAlert } from './dashboard.js'; export const Images = async function(req, res) { let action = req.params.action; if (action == "remove") { - console.log("Removing images"); let images = req.body.select; if (typeof(images) == 'string') { @@ -26,9 +26,8 @@ export const Images = async function(req, res) { res.redirect("/images"); return; } else if (action == "add") { - console.log("Adding images"); let image = req.body.image; - let tag = req.body.tag; + let tag = req.body.tag || 'latest'; try { console.log(`Pulling image: ${image}:${tag}`); @@ -53,8 +52,8 @@ export const Images = async function(req, res) { - + @@ -66,29 +65,34 @@ export const Images = async function(req, res) { for (let i = 0; i < images.length; i++) { + let name = ''; + let tag = ''; + try { name = images[i].RepoTags[0].split(':')[0]; } catch {} + try { tag = images[i].RepoTags[0].split(':')[1]; } catch {} + let date = new Date(images[i].Created * 1000); let created = date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }); let size = images[i].Size / 1000 / 1000; // to match docker desktop size = size.toFixed(2); - let status = 'Unused'; - let status_color = 'red'; + let status = 'unused'; + let status_color = 'yellow'; if (container_images.includes(images[i].RepoTags[0])) { - status = 'In use'; + status = 'In Use'; status_color = 'green'; } let details = ` - ${images[i].RepoTags} + ${name} + ${tag} ${images[i].Id} - - ${status} ${created} ${size} MB - Details + ` image_list += details; } diff --git a/views/partials/containerFull.html b/views/partials/containerFull.html index 3a39cc8..e93a8de 100644 --- a/views/partials/containerFull.html +++ b/views/partials/containerFull.html @@ -9,16 +9,16 @@
- - - -