From 24aab951a8373642b36e1063789a20bb05965586 Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Thu, 14 Dec 2023 12:30:16 +0100 Subject: Group images by repos Make the sidebar from the images menu display the list of repos grouped by repos --- ogcp/static/js/ogcp.js | 19 +++++++++++++++++++ ogcp/templates/images.html | 30 ++++++++++++++++++++---------- ogcp/views.py | 30 +++++++++++++++++++++++++++--- 3 files changed, 66 insertions(+), 13 deletions(-) diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index 5259ea1..964e68d 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -137,6 +137,25 @@ function keepSelectedClients() { }); } +function keepImagesTreeState() { + const images_tree = $('#servers .collapse') + console.log(images_tree) + images_tree.on('hidden.bs.collapse', function (event) { + event.stopPropagation(); + localStorage.removeItem(this.id); + }); + images_tree.on('shown.bs.collapse', function (event) { + event.stopPropagation(); + localStorage.setItem(this.id, 'show'); + }); + + images_tree.each(function () { + if (localStorage.getItem(this.id) == 'show') { + $(this).collapse('show'); + } + }); +} + function keepReposTreeState() { const repos_tree = $('#repos-list .collapse') diff --git a/ogcp/templates/images.html b/ogcp/templates/images.html index 3b1a296..2a50d39 100644 --- a/ogcp/templates/images.html +++ b/ogcp/templates/images.html @@ -14,6 +14,7 @@ // in the scope document.addEventListener('readystatechange', () => { if (document.readyState === 'complete') { + keepImagesTreeState(); checkImageServer(); } }); @@ -24,22 +25,31 @@