summaryrefslogtreecommitdiffstats
path: root/ogcp/templates/repos.html
blob: 8477d298a75c3cec4eeb045df7c0c12138c20731 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{% 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 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 }}
            </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"
                           data-server="{{server_ip_port}}"
                           value="{{ r["id"] }}"
                           name="{{ r["name"]~_~r["id"] }}" />
                    {{ 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()
                checkRepoServer()
            }
        });
    </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">
  <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()">
      {{ _("Back") }}
    </button>
  {% endif %}
{% endblock %}