summaryrefslogtreecommitdiffstats
path: root/ogcp/templates
diff options
context:
space:
mode:
authorJavier Hernandez <jhernandez@soleta.eu>2023-12-01 15:55:15 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2023-12-01 17:20:08 +0100
commit285843634162860b1ba19f71834f06f4fca54583 (patch)
treeacff35ea64421e7153fa9ea6d39172cd3b6ef07f /ogcp/templates
parent215e3c2fc0453122b5fefcc7fe39f14797bee17f (diff)
src: add menu to manage repos
The menu includes a list of the repos of each server. The user can select a server or a repo to make changes. As of now, the only action possible is to add a repo to selected server. The work contained in this commit can be structured in: 1. Add the repos menu: - Add a 'repos' button in the menus bar (base.html). - Add repos.html template to create the management repos menu. - In ogcp.js, add function to store in browser's local storage which elements of the sidebar are uncollapsed. This saves the sidebar state after a page refresh. - Add manage_repos() in views.py 2. Allow to add a repo: - Add template with form to add a repo (repos_details.html) - Create RepoForm(FlaskForm) in action_forms.py - Add repo_add_get() and repo_add_post() in views.py
Diffstat (limited to 'ogcp/templates')
-rw-r--r--ogcp/templates/actions/repos_details.html16
-rw-r--r--ogcp/templates/base.html3
-rw-r--r--ogcp/templates/repos.html59
3 files changed, 78 insertions, 0 deletions
diff --git a/ogcp/templates/actions/repos_details.html b/ogcp/templates/actions/repos_details.html
new file mode 100644
index 0000000..32b96bf
--- /dev/null
+++ b/ogcp/templates/actions/repos_details.html
@@ -0,0 +1,16 @@
+{% extends 'repos.html' %}
+{% import "bootstrap/wtf.html" as wtf %}
+{% set btn_back = true %}
+
+{% block nav_repos %} active{% endblock %}
+{% block nav_repos_details %} active{% endblock %}
+{% block nav_repos_add %}active{% endblock %}
+{% block content %}
+
+<h1 class="m-5">{{_('Repo details')}}</h1>
+
+{{ wtf.quick_form(form,
+ method='post',
+ button_map={'create': 'primary'},
+ extra_classes="mx-5") }}
+{% endblock %}
diff --git a/ogcp/templates/base.html b/ogcp/templates/base.html
index a7e8b94..8ef8f3a 100644
--- a/ogcp/templates/base.html
+++ b/ogcp/templates/base.html
@@ -37,6 +37,9 @@
<li class="nav-item {% block nav_scopes%}{% endblock %}">
<a class="nav-link" href="{{ url_for('scopes') }}">{{ _('Scopes management') }}</a>
</li>
+ <li class="nav-item {% block nav_repos %}{% endblock %}">
+ <a class="nav-link" href="{{ url_for('manage_repos') }}">{{ _('Repos') }}</a>
+ </li>
<li class="nav-item {% block nav_servers %}{% endblock %}">
<a class="nav-link" href="{{ url_for('manage_servers') }}">{{ _('Servers') }}</a>
</li>
diff --git a/ogcp/templates/repos.html b/ogcp/templates/repos.html
new file mode 100644
index 0000000..881057b
--- /dev/null
+++ b/ogcp/templates/repos.html
@@ -0,0 +1,59 @@
+{% extends 'base.html' %}
+
+{% block nav_repos %}active{% endblock %}
+
+{% block container %}
+ <form id="reposForm">
+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
+ </form>
+ {{ super() }}
+</form>
+{% endblock %}
+
+{% block sidebar %}
+ <ul id="repos-list" class="nav ogcp-nav flex-column nav-pills">
+ {% for repos in repos_resp %}
+ {% set server_name = repos["server"].name %}
+ {% 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" />
+ <a class="nav-link {% if not repos_list %}disabled{% endif %}" href="#server{{loop.index}}"
+ {% if repos_list %}data-toggle="collapse"{% endif %}>
+ {{ server_name }}
+ </a>
+ <ul class="nav flex-column collapse" id="server{{loop.index}}">
+ {% for r in repos_list %}
+ <li class="nav-item">
+ <input class="form-check-input" type="checkbox" form="reposForm"
+ value="{{ r["id"] }}"
+ name="selected-repo" />
+ {{ r["name"] }}
+ </li>
+ {% endfor %}
+ </ul>
+ </li>
+ {% endfor %}
+ </ul>
+ <script>
+ // Launch the javascript on document ready, so all the global functions exists
+ // in the scope
+ document.addEventListener('readystatechange', () => {
+ if (document.readyState === 'complete') {
+ keepReposTreeState()
+ }
+ });
+ </script>
+{% endblock %}
+
+{% 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">
+
+ {% if btn_back %}
+ <button class="btn btn-danger ml-3" type="button" id="backButton" onclick="history.back()">
+ {{ _("Back") }}
+ </button>
+ {% endif %}
+{% endblock %}