summaryrefslogtreecommitdiffstats
path: root/ogcp/templates/repos.html
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2023-12-05 09:58:43 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2023-12-05 10:21:09 +0100
commit152337b6bdb8ad95c516ec818d9f625cb9dff54d (patch)
treed2dfb0fe3e26bde48756a579e0db5a04c5cf1bfd /ogcp/templates/repos.html
parent0718ccac75ef2991da1b19fbddf4583e602e304f (diff)
views: add action to delete repo
allow the user to delete a repo by selecting one and pressing the delete button. Previous to deletion, show the user a confirmation page (a form) with the details of the repo to delete the confirmation form is constructed with the fields of Repoform. RepoForm is also used in template used to create a repo. To make both templates work with RepoForm, RepoForm's field 'create' has been renamed to 'submit' ogcp.js: add a function to make that, when the user selects a repository, the server in which it is contained is automatically checked. We need it checked so that action_repo_delete can know the server to which it has to send the delete request. Use data-server in repos_details.html to make this work Validate, in action_delete_repo, that user has only selected one repo to delete. In order to do that, action_delete_repo view needs to be able to get a list of all selected repos. This is only possible if <input> elements that are associated with repos info contain a different name attribute per repo. In this case, template repos.html has been modified to use name={repo name}-{repo_id}. After this, parse_elements() will work and parse a set containing all selected repos. modify html input associated to repos server in order to follow same convention as in other templates. For example, images uses image-server; scopes, scope-server.
Diffstat (limited to 'ogcp/templates/repos.html')
-rw-r--r--ogcp/templates/repos.html10
1 files changed, 7 insertions, 3 deletions
diff --git a/ogcp/templates/repos.html b/ogcp/templates/repos.html
index 881057b..8477d29 100644
--- a/ogcp/templates/repos.html
+++ b/ogcp/templates/repos.html
@@ -17,8 +17,8 @@
{% set server_ip_port = repos["server"].ip ~ ":" ~ repos["server"].port %}
{% set repos_list = repos["json"]["repositories"] %}
<li class="nav-item">
- <input class="form-check-input" type="checkbox" form="reposForm"
- value="{{ server_ip_port }}" name="selected-server" />
+ <input id="{{ server_ip_port }}"class="form-check-input" type="checkbox" form="reposForm"
+ value="{{ server_ip_port }}" name="repos-server" />
<a class="nav-link {% if not repos_list %}disabled{% endif %}" href="#server{{loop.index}}"
{% if repos_list %}data-toggle="collapse"{% endif %}>
{{ server_name }}
@@ -27,8 +27,9 @@
{% for r in repos_list %}
<li class="nav-item">
<input class="form-check-input" type="checkbox" form="reposForm"
+ data-server="{{server_ip_port}}"
value="{{ r["id"] }}"
- name="selected-repo" />
+ name="{{ r["name"]~_~r["id"] }}" />
{{ r["name"] }}
</li>
{% endfor %}
@@ -42,6 +43,7 @@
document.addEventListener('readystatechange', () => {
if (document.readyState === 'complete') {
keepReposTreeState()
+ checkRepoServer()
}
});
</script>
@@ -50,6 +52,8 @@
{% block commands %}
<input class="btn btn-light {% block nav_repo_add %}{% endblock %}" type="submit" value="{{ _('Add repo') }}"
form="reposForm" formaction="{{ url_for('repo_add_get') }}" formmethod="get">
+ <input class="btn btn-light {% block nav_repo_delete %}{% endblock %}" type="submit" value="{{ _('Delete repo') }}"
+ form="reposForm" formaction="{{ url_for('action_repo_delete') }}" formmethod="get">
{% if btn_back %}
<button class="btn btn-danger ml-3" type="button" id="backButton" onclick="history.back()">