mirror of https://git.48k.eu/ogcp
72 lines
2.8 KiB
HTML
72 lines
2.8 KiB
HTML
{% macro scopes_tree_collapse(scopes, state='') -%}
|
|
|
|
<ul id="scopes" class="nav flex-column nav-pills">
|
|
{{ scopes_tree_collapse_level(scopes["scope"], "", state) }}
|
|
</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();
|
|
checkParentsCheckboxes();
|
|
}
|
|
});
|
|
</script>
|
|
|
|
{% endmacro %}
|
|
|
|
{% macro scopes_tree_collapse_level(scopes, parent_id, state) -%}
|
|
{% for scope in scopes %}
|
|
<li id="{{ scope["name"]|replace(".", "_")|replace(" ", "_") }}_{{ scope["id"] }}" class="nav-item">
|
|
{% if " ".join(scope["ip"]) %}
|
|
<input class="form-check-input" type="checkbox" form="scopesForm"
|
|
value="{{ " ".join(scope["ip"]) }}"
|
|
{% if state %}style="filter: grayscale(100%);" onclick="return false;"{% endif %}
|
|
{% if scope.get("selected", False) %}checked{% endif %}
|
|
name="{{ scope["name"] }}_{{ scope["id"] }}" />
|
|
{% endif %}
|
|
<a class="nav-link {% if not scope["scope"] %}disabled{% endif %}" href="#scope{{parent_id ~ "-" ~ 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="scope{{parent_id ~ "-" ~ loop.index}}">
|
|
{{ scopes_tree_collapse_level(scope["scope"], parent_id ~ "-" ~ loop.index, state) }}
|
|
</ul>
|
|
{% endif %}
|
|
</li>
|
|
{% endfor %}
|
|
{% endmacro %}
|
|
|
|
{% macro selected_clients() -%}
|
|
<hr><h2>{{_('Selected clients')}}</h2>
|
|
<div id="selected-clients" class="d-flex flex-wrap justify-content-center"></div>
|
|
{% endmacro %}
|
|
|
|
{% macro cmd_selected_clients(selected_clients) -%}
|
|
<div class="d-flex flex-wrap justify-content-center">
|
|
{% set max_clients = 50 %}
|
|
{% for name_id, ip in selected_clients[:max_clients] %}
|
|
<div id="pill-{{ name_id|replace(".", "_")|replace(" ", "_") }}" class="badge badge-pill og-pill badge-light">
|
|
{{ name_id }}<br>{{ ip }}
|
|
</div>
|
|
{% if loop.last and (selected_clients|length > max_clients) %}
|
|
<div class="badge badge-pill badge-light">...</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endmacro %}
|