detached f360c82

fix: Toggle states for all buttons ok

commit
f360c82de983b788859083eba5595ad45e28edc4
author
bnema · · 2023-09-27 12:50 UTC
parent
5ac253f
signature
unsigned
5 files · +17 -4
M internal/gotemplate/models/html/fragments/containerlist.gohtml +1 -1
@@ -1,4 +1,4 @@
1-<div class="flex flex-col p-4">
1+<div class="flex flex-col p-4" hx-boost="true">
22 <h1 class="text-lg md:text-xl font-bold">Containers</h1>
33 <table class="p-4 border-t-2" hx-ext="response-targets">
44 <!-- <thead>
@@ -1,4 +1,4 @@
1-<div class="flex flex-col p-4">1+<div class="flex flex-col p-4" hx-boost="true">
2 <h1 class="text-lg md:text-xl font-bold">Containers</h1>2 <h1 class="text-lg md:text-xl font-bold">Containers</h1>
3 <table class="p-4 border-t-2" hx-ext="response-targets">3 <table class="p-4 border-t-2" hx-ext="response-targets">
4 <!-- <thead>4 <!-- <thead>
M internal/gotemplate/models/html/fragments/createcontainer.gohtml +1 -0
@@ -136,6 +136,7 @@
136136 <input
137137 type="submit"
138138 value="Create"
139+ id="create-container-submit"
139140 class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
140141 />
141142 </form>
@@ -136,6 +136,7 @@
136 <input136 <input
137 type="submit"137 type="submit"
138 value="Create"138 value="Create"
139+ id="create-container-submit"
139 class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"140 class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
140 />141 />
141 </form>142 </form>
M internal/gotemplate/models/html/fragments/editcontainer.gohtml +1 -0
@@ -11,6 +11,7 @@
1111 <input
1212 type="submit"
1313 value="Save"
14+ id="save-button-{{.ID}}"
1415 class="bg-gordonmascot-mblue text-white px-4 py-2 rounded-md md:text-xl hover:bg-gordonmascot-hblue"
1516 />
1617 </form>
@@ -11,6 +11,7 @@
11 <input11 <input
12 type="submit"12 type="submit"
13 value="Save"13 value="Save"
14+ id="save-button-{{.ID}}"
14 class="bg-gordonmascot-mblue text-white px-4 py-2 rounded-md md:text-xl hover:bg-gordonmascot-hblue"15 class="bg-gordonmascot-mblue text-white px-4 py-2 rounded-md md:text-xl hover:bg-gordonmascot-hblue"
15 />16 />
16 </form>17 </form>
M internal/gotemplate/models/html/fragments/imagelist.gohtml +1 -0
@@ -7,6 +7,7 @@
77 hx-get="/htmx/upload-image"
88 hx-target="#upload-image"
99 hx-swap="innerHTML"
10+ data-active="false"
1011 class="py-1 px-2 bg-blue-500 hover:bg-blue-700 text-white font-bold rounded"
1112 >
1213 <span class="iconoir-upload text-xl align-middle"></span>
@@ -7,6 +7,7 @@
7 hx-get="/htmx/upload-image"7 hx-get="/htmx/upload-image"
8 hx-target="#upload-image"8 hx-target="#upload-image"
9 hx-swap="innerHTML"9 hx-swap="innerHTML"
10+ data-active="false"
10 class="py-1 px-2 bg-blue-500 hover:bg-blue-700 text-white font-bold rounded"11 class="py-1 px-2 bg-blue-500 hover:bg-blue-700 text-white font-bold rounded"
11 >12 >
12 <span class="iconoir-upload text-xl align-middle"></span>13 <span class="iconoir-upload text-xl align-middle"></span>
M internal/webui/public/assets/js/custom.js +13 -3
@@ -36,12 +36,22 @@ function toggleButtonState(event) {
3636 }
3737 }
3838
39-// Attach event listeners to buttons
39+// Attach event listeners to buttons that needs to toggle state
4040 document.body.addEventListener("htmx:afterSwap", function (event) {
41- const buttons = document.querySelectorAll('[id^="start-button-"], [id^="stop-button-"], [id^="edit-button-"], [id^="remove-button-img-"], [id^="add-button-img-"]');
41+ const buttons = document.querySelectorAll('[id^="edit-button-"], [id^="add-button-img-"]', '[id^="upload-button"]');
4242 buttons.forEach(button => {
43- console.log("button: ", button);
4443 button.addEventListener('click', toggleButtonState);
4544 });
4645 });
4746
47+// Attach event listeners to buttons that needs to set a full location reload
48+document.body.addEventListener("htmx:afterOnLoad", function (event) {
49+ const buttons = document.querySelectorAll('[id^="start-button-"], [id^="stop-button-"], [id^="remove-button-img-"], [id^="create-container-submit"], [id^="save-button-"]');
50+ buttons.forEach(button => {
51+ button.addEventListener('click', function(event) {
52+ setTimeout(function() {
53+ location.reload();
54+ }, 5000);
55+ });
56+ });
57+});⏎̸
@@ -36,12 +36,22 @@ function toggleButtonState(event) {
36 }36 }
37 }37 }
38 38
39-// Attach event listeners to buttons39+// Attach event listeners to buttons that needs to toggle state
40 document.body.addEventListener("htmx:afterSwap", function (event) {40 document.body.addEventListener("htmx:afterSwap", function (event) {
41- const buttons = document.querySelectorAll('[id^="start-button-"], [id^="stop-button-"], [id^="edit-button-"], [id^="remove-button-img-"], [id^="add-button-img-"]');41+ const buttons = document.querySelectorAll('[id^="edit-button-"], [id^="add-button-img-"]', '[id^="upload-button"]');
42 buttons.forEach(button => {42 buttons.forEach(button => {
43- console.log("button: ", button);
44 button.addEventListener('click', toggleButtonState);43 button.addEventListener('click', toggleButtonState);
45 });44 });
46 });45 });
47 46
47+// Attach event listeners to buttons that needs to set a full location reload
48+document.body.addEventListener("htmx:afterOnLoad", function (event) {
49+ const buttons = document.querySelectorAll('[id^="start-button-"], [id^="stop-button-"], [id^="remove-button-img-"], [id^="create-container-submit"], [id^="save-button-"]');
50+ buttons.forEach(button => {
51+ button.addEventListener('click', function(event) {
52+ setTimeout(function() {
53+ location.reload();
54+ }, 5000);
55+ });
56+ });
57+});⏎̸

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close