{% if page != "servers.py" %}
<div id="user-add-table" style="display: none;">
    <table class="overview" id="user-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new2}} {{lang.words.user2}}">
        {% include 'include/tr_validate_tips.html' %}
        {% include 'include/admin_add_user.html' %}
        <tr>
            <td class="padding20">
                {{lang.words.role|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                <select id="new-role" name="new-role">
                    <option disabled selected>{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.role}}</option>
                    {% for role in roles %}
                    <option value="{{ role.role_id }}">{{ role.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        <tr>
            <td class="padding20">
                {{lang.words.group|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                <select id="new-group" name="new-group">
                    <option disabled selected>{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.group2}}</option>
                    {% for group in groups %}
                    <option value="{{ group.group_id }}">{{ group.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
    </table>
</div>
<div id="group-add-table" style="display: none;">
    <table class="overview" id="group-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new3}} {{lang.words.group2}}">
        {% include 'include/tr_validate_tips.html' %}
        <tr>
            <td class="padding20">
                {{lang.words.name|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                {{ input('new-group-add', autofocus='autofocus') }}
            </td>
        </tr>
        <td class="padding20">{{lang.words.desc|title()}}</td>
        <td>{{ input('new-desc', size="40") }}</td>
        </tr>
    </table>
</div>
{% else %}
<div id="user-add-table" style="display: none;">
    <table class="overview" id="user-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new2}} {{lang.words.user2}}">
        {% include 'include/tr_validate_tips.html' %}
        {% include 'include/admin_add_user.html' %}
        <td class="padding20">
            {{lang.words.role|title()}}
            <span class="need-field">*</span>
        </td>
        <td>
            <select id="new-role" name="new-role">
                <option disabled selected>{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.role}}</option>
                {% for role in roles %}
                {% if role.name != "superAdmin" %}
                <option value="{{ role.name }}">{{ role.name }}</option>
                {% endif %}
                {% endfor %}
            </select>
        </td>
        </tr>
    </table>
</div>
{% endif %}
<div id="server-add-table" style="display: none;">
    <table class="overview" id="server-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} {{lang.words.server}}">
        {% include 'include/tr_validate_tips.html' %}
        {% include 'include/admin_add_server.html' %}
        <tr>
            <td class="padding20">
                {{lang.words.creds|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                <select id="credentials" required>
                    <option disabled selected>{{lang.words.select|title()}} {{lang.words.creds}}</option>
                    {% for ssh in sshs %}
                    <option value="{{ssh.id}}">{{ssh.name}}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% if page != "servers.py" %}
        <tr>
            <td class="padding20">
                {{lang.words.group|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                <select id="new-server-group-add" name="new-server-group-add">
                    <option disabled selected value="0">{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.group2}}</option>
                    {% for group in groups %}
                    <option value="{{ group.group_id }}">{{ group.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% endif %}
    </table>
</div>
<div id="ssh-add-table" style="display: none;">
    <table class="overview" id="ssh-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new4}} SSH {{lang.words.creds}}">
        {% include 'include/tr_validate_tips.html' %}
        <tr>
            <td class="padding20">
                {{lang.words.name|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                {{ input('new-ssh-add', autofocus='autofocus') }}
            </td>
        </tr>
        <tr>
            <td class="padding20">SSH {{lang.words.key}}</td>
            <td>
                <label for="new-ssh_enable">{{lang.words.enabled|title()}} SSH {{lang.words.key}}</label><input type="checkbox" id="new-ssh_enable" checked>
            </td>
        </tr>
        {% if page != "servers.py" %}
        <tr>
            <td class="padding20">{{lang.words.group|title()}}</td>
            <td>
                <select id="new-sshgroup" name="new-sshgroup">
                    {% for group in groups %}
                    <option value="{{ group.group_id }}">{{ group.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% endif %}
        <tr>
            <td class="padding20">
                {{lang.words.username|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                <p style="width: 100px;">
                    {{ input('ssh_user', value=ssh_user, title='SSH ' + lang.words.username|title()) }}
                </p>
                {{ input('ssh_pass', type='password', style="display: none;", title="User password, if SSH key is disabled") }}
            </td>
        </tr>
    </table>
</div>
<div id="telegram-add-table" style="display: none;">
    <table class="overview" id="telegram-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} Telegram {{lang.words.channel}}">
        {% include 'include/tr_validate_tips.html' %}
        <tr>
            <td class="padding20">
                <span title="Token that gave you @father_bot">{{lang.words.token|title()}}</span>
                <span class="need-field">*</span>
            </td>
            <td>
                {{ input('telegram-token-add', size='30') }}
            </td>
        </tr>
        <tr>
            <td class="padding20">
                {{lang.words.channel|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                {{ input('telegram-chanel-add') }}
            </td>
        </tr>
        {% if page != "servers.py" %}
        <tr>
            <td class="padding20">{{lang.words.group|title()}}</td>
            <td>
                <select id="new-telegram-group-add" name="new-telegram-group-add">
                    <option disabled selected value="0">{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.group2}}</option>
                    {% for group in groups %}
                    <option value="{{ group.group_id }}">{{ group.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% endif %}
    </table>
</div>
<div id="slack-add-table" style="display: none;">
    <table class="overview" id="slack-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} Slack {{lang.words.channel}}">
        {% include 'include/tr_validate_tips.html' %}
        <tr>
            <td class="padding20">
                <span title="Token that has given with APP registration">{{lang.words.token|title()}}</span>
                <span class="need-field">*</span>
            </td>
            <td>
                {{ input('slack-token-add', size='30') }}
            </td>
        </tr>
        <tr>
            <td class="padding20">
                {{lang.words.channel|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                {{ input('slack-chanel-add') }}
            </td>
        </tr>
        {% if page != "servers.py" %}
        <tr>
            <td class="padding20">{{lang.words.group|title()}}</td>
            <td>
                <select id="new-slack-group-add" name="new-slack-group-add">
                    <option disabled selected value="0">{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.group2}}</option>
                    {% for group in groups %}
                    <option value="{{ group.group_id }}">{{ group.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% endif %}
    </table>
</div>
<div id="pd-add-table" style="display: none;">
    <table class="overview" id="pd-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} PagerDuty {{lang.words.channel}}">
        {% include 'include/tr_validate_tips.html' %}
        <tr>
            <td class="padding20">
                <span title="Integration key from Events API V2 integration">{{lang.words.token|title()}}</span>
                <span class="need-field">*</span>
            </td>
            <td>
                {{ input('pd-token-add', size='30') }}
            </td>
        </tr>
        <tr>
            <td class="padding20">
                {{lang.words.channel|title()}}
                <span class="need-field">*</span>
            </td>
            <td>
                {{ input('pd-chanel-add') }}
            </td>
        </tr>
        {% if page != "servers.py" %}
        <tr>
            <td class="padding20">{{lang.words.group|title()}}</td>
            <td>
                <select id="new-pd-group-add" name="new-pd-group-add">
                    <option disabled selected value="0">{{lang.words.select|title()}} {{lang.words.w_a}} {{lang.words.group2}}</option>
                    {% for group in groups %}
                    <option value="{{ group.group_id }}">{{ group.name }}</option>
                    {% endfor %}
                </select>
            </td>
        </tr>
        {% endif %}
    </table>
</div>
<div id="backup-add-table" title="Add a new backup job " style="display: none;">
    <table class="overview" id="backup-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} {{lang.words.backup}}">
        {% include 'include/tr_validate_tips.html' %}
        {% include 'include/add_backup.html' %}
        <tr>
            <td class="padding20">
                {{lang.words.creds|title()}} {{lang.words.for}} {{lang.words.w_a}} {{lang.words.remote}} {{lang.words.server}}
                <span class="need-field">*</span>
            </td>
            <td>
                <select id="backup-credentials" required>
                    <option disabled selected>{{lang.words.select|title()}} {{lang.words.creds}}</option>
                    {% for ssh in sshs %}
                         {% if ssh.enable == 1 %}
                            <option value="{{ssh.id}}">{{ssh.name}}</option>
                        {% endif %}
                    {% endfor %}
                </select>
            </td>
        </tr>
        <tr>
            <td class="padding20">
                {{lang.words.desc|title()}}
            </td>
            <td>
                {{ input('backup-description', size='30') }}
            </td>
        </tr>
    </table>
</div>
<div id="s3-backup-add-table" style="display: none;">
    <table class="overview" id="s3-backup-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} S3 {{lang.words.backup}}">
        {% include 'include/tr_validate_tips.html' %}
        {% include 'include/add_s3_backup.html' %}
    </table>
</div>
<div id="git-add-table" style="display: none;">
    <table class="overview" id="git-add-table-overview" title="{{lang.words.add|title()}} {{lang.words.w_a}} {{lang.words.new}} git {{lang.words.job}}">
        {% include 'include/tr_validate_tips.html' %}
        <tr>
			<td class="padding20" style="width: 40%;">
				{{lang.words.server|title()}}
				<span class="need-field">*</span>
			</td>
			<td>
				<select autofocus required name="git-server" id="git-server">
					<option disabled>------</option>
						{% for s in servers %}
							<option value="{{ s.0 }}">{{ s.1 }}</option>
						{% endfor %}
				</select>
			</td>
		</tr>
        <tr>
			<td class="padding20" style="width: 40%;">
				{{lang.words.service|title()}}
				<span class="need-field">*</span>
			</td>
			<td>
                <select id="git-service" required>
                    <option disabled selected>------</option>
                    {% for s in services %}
                        <option value="{{s.service_id}}">{{s.service}}</option>
                    {% endfor %}
                </select>
			</td>
		</tr>
        <tr>
			<td class="padding20">
				{{lang.words.period|title()}}
				<span class="need-field">*</span>
			</td>
			<td>
				{% set values = {'hourly':'hourly','daily':'daily','weekly':'weekly', 'monthly':'monthly'} %}
				{{ select('git-time', values=values, selected='hourly', required='required', class='force_close') }}
			</td>
		</tr>
        <tr>
           <td class="padding20">
               {{lang.words.init|title()}} {{lang.words.w_a}} {{lang.words.new}} {{lang.words.repository}}
           </td>
            <td>
                {{ checkbox('git-init')}}
            </td>
        </tr>
        <tr style="display: none" class="git-init-params">
			<td class="padding20">
				{{lang.words.repository|title()}}
                <span class="need-field">*</span>
			</td>
			<td>
				{{ input('git-repo', size='30', placeholder="git@github.com:user/haproxy_configs.git", title="Use only connect via SSH") }}
			</td>
		</tr>
        <tr>
			<td class="padding20">
				Branch {{lang.words.name}}
                <span class="need-field">*</span>
			</td>
			<td>
				{{ input('git-branch', size='30', placeholder="main") }}
			</td>
		</tr>
        <tr>
            <td class="padding20">
                {{lang.words.creds|title()}} {{lang.words.for}} {{lang.words.w_a}} git {{lang.words.user}}
                <span class="need-field">*</span>
            </td>
            <td>
                <select id="git-credentials" required>
                    <option disabled selected>------</option>
                    {% for ssh in sshs %}
                        {% if ssh.enable == 1 %}
                            <option value="{{ssh.id}}">{{ssh.name}}</option>
                        {% endif %}
                    {% endfor %}
                </select>
            </td>
        </tr>
        <tr>
            <td class="padding20">
                {{lang.words.desc|title()}}
            </td>
            <td>
                {{ input('git-description', size='30') }}
            </td>
        </tr>
    </table>
</div>
<div id="dialog-confirm-services" style="display: none;">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>{{lang.phrases.are_you_sure}}</p>
</div>
<div id="firewall_rules" style="display: none; padding: 0 2px 0 0; margin-left: 1px; margin-right: -4px;">
    <div id="firewall_rules_body"></div>
</div>
<div id="change-user-service-dialog" style="display: none;">
	<div id="change-user-service-form"></div>
</div>
<div id="dialog-server-info" style="display: none;">
	<table class="overview" style="font-size: 1em;">
        <tr id="server-info"></tr>
    </table>
</div>
<div id="groups-roles"></div>
