diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js index 8a6db02..dc1c063 100644 --- a/ogcp/static/js/ogcp.js +++ b/ogcp/static/js/ogcp.js @@ -2,6 +2,34 @@ const Endpoint = '/scopes/status'; const Interval = 1000; let updateTimeoutId = null; +function showSelectedClient(client_checkbox) { + const container = $('#selected-clients'); + const pill_id = 'pill-' + client_checkbox.name.replaceAll('.', '_'); + + if (client_checkbox.checked) { + if (!($('#' + pill_id).length)) + $(container).append('
' + client_checkbox.name + + '
' + client_checkbox.value + '
'); + return; + } + + $('#' + pill_id).remove(); +} + +function showSelectedClientsOnEvents() { + const checkboxes = $('input:checkbox[form|="scopesForm"]'); + const container = $('#selected-clients'); + + const client_checkboxes = checkboxes.filter(function () { + return $(this).siblings().length == "1"; + }); + + client_checkboxes.on('change show-client', function () { + showSelectedClient(this); + }); +} + function storeCheckboxStatus(checkbox) { if (checkbox.checked) localStorage.setItem(checkbox.name, "check"); @@ -18,6 +46,7 @@ function checkChildrenCheckboxes() { children.each(function () { this.checked = checked; storeCheckboxStatus(this); + $(this).trigger('show-client'); }); }); } @@ -32,6 +61,7 @@ function keepSelectedClients() { checkboxes.each(function () { if (localStorage.getItem(this.name) == 'check') { this.checked = true; + $(this).trigger('show-client'); } }); } diff --git a/ogcp/templates/commands.html b/ogcp/templates/commands.html index 1b51701..9fa8617 100644 --- a/ogcp/templates/commands.html +++ b/ogcp/templates/commands.html @@ -96,3 +96,6 @@ {% endblock %} +{% block content %} + {{ macros.selected_clients() }} +{% endblock %} diff --git a/ogcp/templates/macros.html b/ogcp/templates/macros.html index a1b5ebb..7864cd4 100644 --- a/ogcp/templates/macros.html +++ b/ogcp/templates/macros.html @@ -8,6 +8,7 @@ // in the scope document.addEventListener('readystatechange', () => { if (document.readyState === 'complete') { + showSelectedClientsOnEvents(); updateScopeState(); keepScopesTreeState(); keepSelectedClients(); @@ -47,3 +48,7 @@ {% endfor %} {% endmacro %} + +{% macro selected_clients() -%} +
+{% endmacro %} diff --git a/ogcp/templates/scopes.html b/ogcp/templates/scopes.html index 6c543fa..81b2403 100644 --- a/ogcp/templates/scopes.html +++ b/ogcp/templates/scopes.html @@ -29,3 +29,7 @@ {% endblock %} + +{% block content %} + {{ macros.selected_clients() }} +{% endblock %}