ntopng/httpdocs/templates/pages/modals/pools/pool_modal.template
2020-07-30 16:24:49 +02:00

120 lines
No EOL
7.2 KiB
Text

<div class="modal show fade" tabindex="-1" role="dialog" id="{{ modal_type }}-pool">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ i18n(modal_type) }} {{ i18n("pools.pool_name." .. pool.name) }} {{ i18n("pools.pool") }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form role="form">
<div class="modal-body">
<div class="form-group row">
<label class="col-form-label col-sm-4" for="{{ modal_type }}-pool-name-input">
<b>{{ i18n("pools.name") }}</b>
</label>
<div class="col-sm-7">
<input placeholder="{{ i18n('pools.insert_name') }}" pattern=".*\S.*" maxlength="32" minlength="1" required name="name" type="text" class="form-control" id="{{ modal_type }}-pool-name-input">
<small class="text-muted form-text">
{{ i18n("pools.name_requirements") }}
</small>
</div>
</div>
{# the host pool modal doesn't have the members field #}
{% if (pool.name ~= "host") then %}
<div class="form-group row members-container">
<label class="col-form-label col-sm-4" for="{{ modal_type }}-pool-members-input">
<b>{{ i18n("pools.members") }}</b>
</label>
<div class="col-sm-7">
<select class="form-control multiple-select" multiple name="members" id="{{ modal_type }}-pool-members-select">
{%
local sorting_order = nil
if (pool.name == "snmp" or pool.name == "network") then
sorting_order = ip_address_asc
else
sorting_order = asc
end
%}
{% for key, member in pairsByKeys(pool.all_members, sorting_order) do %}
{%
-- If the name field is not set then use the key as the name
-- for the pool member
local name = member.name or key
%}
{# If a member is assigned then write who is using it and disable it #}
{% if (pool.assigned_members[key] ~= nil) then %}
<option data-pool-id="{{pool.assigned_members[key]["pool_id"]}}" disabled value="{{key}}">
{{ name }} ({{ pool.instance:get_pool(pool.assigned_members[key]["pool_id"]).name}})
</option>
{% else %}
<option value="{{key}}">{{name}}</option>
{% end %}
{% end %}
</select>
<small class="text-muted text-form">
{* i18n("howto_multiselect") *}
</small>
</div>
</div>
{% elseif (pool.name == "host" and modal_type == "edit") then %}
<div class="form-group row members-container">
<label class="col-form-label col-sm-4" for="{{ modal_type }}-pool-members-input">
{{ i18n("pools.members") }}
</label>
<label class="col-form-label col-sm-7">
<a id="edit-link" href="{{ ntop.getHttpPrefix() }}/lua/admin/manage_host_members.lua?pool=0"><i class="fas fa-edit"></i> {{ i18n("host_pools.edit_host_pool_member") }}</a>
</label>
</div>
{% end %}
<div class="form-group row">
<label class="col-form-label col-sm-4" for="{{ modal_type }}-pool-config-select">
<b>{{ i18n("pools.configuration") }}</b>
</label>
<div class="col-sm-7">
<select required class="form-control" name="configset" id="{{ modal_type }}-pool-config-select">
{% for key, configset in pairsByKeys(pool.configsets, asc) do %}
{# Select the "Default" config as default #}
<option {{ (configset.configset_id == 0 and "selected" or "") }} value="{{ configset.configset_id }}">{{configset.configset_name}}</option>
{% end %}
</select>
</div>
</div>
{%
-- show recipient multiselect if only there are recipients to show
if (#pool.notification_recipients > 0) then
%}
<div class="form-group row">
<label class="col-form-label col-sm-4" for="{{ modal_type }}-pool-recipient-select">
<b>{{ i18n("pools.recipients") }}</b>
</label>
<div class="col-sm-7">
<select multiple class="form-control multiple-select" name="recipients" id="{{ modal_type }}-pool-recipient-select">
{% for key, recipient in pairsByKeys(pool.notification_recipients, asc) do %}
<option value="{{ recipient.recipient_name }}">{{ recipient.recipient_name }}</option>
{% end %}
</select>
<small class="text-muted text-form">
{* i18n("howto_multiselect") *}
</small>
</div>
{% end %}
</div>
<span class="invalid-feedback" id="{{ modal_type }}-modal-feedback"></span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ i18n("cancel") }}</button>
<button type="submit" class="btn btn-primary">
{% if modal_type == "add" then %}
{{ i18n("add") }}
{% else %}
{{ i18n("edit") }}
{% end %}
</button>
</div>
</form>
</div>
</div>
</div>