added image pull to the images page

This commit is contained in:
lllllllillllllillll 2024-05-21 19:54:05 -07:00
parent d0db603efe
commit 869b7b30e7
3 changed files with 65 additions and 4 deletions

View File

@ -18,6 +18,7 @@
* New - admin checks, session checks, and permission checks for router.
* Added titles to activity indicators.
* Created Github Wiki.
* Added image pull to images page.
## v0.40 (Feb 26th 2024) - HTMX rewrite
* Pages rewritten to use HTMX.

View File

@ -3,6 +3,7 @@ import { docker } from '../server.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;
@ -22,9 +23,25 @@ export const Images = async function(req, res) {
}
}
}
res.redirect("/images");
return;
res.redirect("/images");
return;
} else if (action == "add") {
console.log("Adding images");
let image = req.body.image;
let tag = req.body.tag;
try {
console.log(`Pulling image: ${image}:${tag}`);
await docker.pull(`${image}:${tag}`);
} catch (error) {
console.log(`Unable to pull image: ${image}:${tag}`);
}
res.redirect("/images");
return;
}
let images = await docker.listImages({ all: true });

View File

@ -39,7 +39,7 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-refresh" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"></path> <path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"></path> </svg>
Refresh
</a>
<a href="#" class="btn" data-bs-toggle="modal" data-bs-target="#not_add-site">
<a href="#" class="btn" data-bs-toggle="modal" data-bs-target="#modals-here">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-plus" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none"></path> <path d="M12 5l0 14"></path> <path d="M5 12l14 0"></path> </svg>
New Image
</a>
@ -55,6 +55,7 @@
</table>
</div>
<div class="card-footer d-flex align-items-center">
<button class="btn" type="submit" formaction="/images/remove">Remove</button>
@ -64,7 +65,49 @@
<p class="m-0 text-muted ms-auto"><%- image_count %> Images</p>
</div>
</form>
</form>
<!-- HTMX Modal Target -->
<div id="modals-here" class="modal modal-blur fade" style="display: none" aria-hidden="false" tabindex="-1">
<div class="modal-dialog modal-sm modal-dialog-centered modal-dialog-scrollables">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">New Image</h5>
</div>
<div class="modal-body text-center">
<form method="post" action="/images/add">
<div class="row row-cards">
<div class="col-sm-6 col-md-6">
</div>
<div class="col-sm-6 col-md-6">
</div>
</div>
<div class="row g-2 align-items-end">
<div class="col-7">
<label class="form-label text-muted">Image</label>
<input type="text" class="form-control" name="image" placeholder="lllllllillllllillll/dweebui">
</div>
<div class="col-3">
<label class="form-label text-muted">Tag</label>
<input type="text" class="form-control" name="tag" placeholder="latest">
</div>
<div class="col-2">
<button type="submit" class="btn mt-2">Pull</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>