summaryrefslogtreecommitdiffstats
path: root/ogcp/templates/macros.html
blob: a779dd7b5c0a15881f603aac3df03425141efdda (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
{% macro scopes_tree_collapse(scopes) -%}

<ul id="scopes" class="nav flex-column nav-pills">
  {{ scopes_tree_collapse_level(scopes["scope"], 1, "") }}
</ul>
<script>
    // Launch the javascript on document ready, so all the global functions exists
    // in the scope
    document.addEventListener('readystatechange', () => {
        if (document.readyState === 'complete') {
            showSelectedClientsOnEvents();
            updateScopeState();
            keepScopesTreeState();
            keepSelectedClients();
            checkChildrenCheckboxes();
        }
    });
</script>

{% endmacro %}

{% macro scopes_tree_collapse_level(scopes, i, parent_id) -%}
{% for scope in scopes %}
  <li id="{{ scope["name"] }}_{{ scope["id"] }}" class="nav-item">
    {% if " ".join(scope["ip"]) %}
        <input class="form-check-input" type="checkbox" form="scopesForm"
               value="{{ " ".join(scope["ip"]) }}"
               {% if scope.get("selected", False) %}checked{% endif %}
               name="{{ scope["name"] }}_{{ scope["id"] }}" />
    {% endif %}
    <a class="nav-link {% if not scope["scope"] %}disabled{% endif %}" href="#id{{parent_id ~ "_" ~ i ~ "-" ~ loop.index}}"
                       {% if scope["scope"] %}data-toggle="collapse"{% endif %}>
      {% if "state" in scope %}
        <i class="nav-icon fa-circle
                  {% if scope['state'] == 'OPG' %}fas text-warning
                  {% elif scope['state'] == 'BSY' %}fas text-danger
                  {% elif scope['state'] == 'VDI' %}fas text-success
                  {% elif scope['state'] == 'WOL_SENT' %}fas text-wol
                  {% else %}far{% endif %}"></i>
      {% endif %}
      {{ scope["name"] }}
    </a>
    {% if scope["scope"] %}
      <ul class="nav flex-column collapse level{{i}}" id="id{{parent_id ~ "_" ~ i ~ "-" ~ loop.index}}">
          {{ scopes_tree_collapse_level(scope["scope"], i + 1, parent_id ~ "_" ~ i ~ "-" ~ loop.index) }}
      </ul>
    {% endif %}
  </li>
{% endfor %}
{% endmacro %}

{% macro selected_clients() -%}
<div id="selected-clients" class="d-flex flex-wrap justify-content-center"></div>
{% endmacro %}

{% macro cmd_selected_clients(ip_list) -%}
<ul class="list-group mx-5 list-group-horizontal-sm d-flex flex-wrap">
{% for ip in ip_list %}
    <li class="list-group-item flex-fill list-group-item-info">{{ ip }}</li>
{% endfor %}
</ul>
{% endmacro %}