Source

iredadmin-ose / templates / default / ldap / domain / list.html

{% extends "layout.html" %}

{% from "macros/general.html" import
        load_jquery,
        display_csrf_token,
        display_number_of_account_limited,
        set_account_status_img,
        display_csrf_token,
        display_add_domain,
        show_pages,
        with context
        %}

{% from "macros/msgHandlers.html" import domainMsgHandler, with context %}

{% block title %}{{ _('Domains and Accounts') }}{% endblock %}
{% block navlinks_active_domains %}class="active"{% endblock %}

{% block main %}
{# Show system message #}
{{ domainMsgHandler(msg) }}

{# List all domains under control. #}
    <div class="content-box">
        <div class="box-body">
            <div class="box-header clear">
                <ul class="tabs clear">
                    <li class="active"><a href="{{ctx.homepath}}/domains">{{ _('All domains') }}</a></li>
                    {% if session.get('domainGlobalAdmin') is sameas true %}
                        <li><a href="{{ctx.homepath}}/create/domain"><img src="{{ctx.homepath}}/static/{{skin}}/images/ico_add_12.png" /> {{ _('Add domain') }}</a></li>
                    {% endif %}
                </ul>

                <h2>
                    {{ _('All domains under your control.') }}
                    {% if total is defined and allDomains|length > 0 %}
                        ({{ (cur_page-1) * pageSizeLimit + 1 }}-{{ (cur_page-1) * pageSizeLimit + allDomains|length}}/{{ total }})
                    {% endif %}
                </h2>
            </div>

            <form name="domains" id="list_table" method="post" action="{{ctx.homepath}}/domains">
            {{ display_csrf_token() }}
            <table class="style1 tablesorter" cellspacing="0">
                <thead>
                <tr>
                    {% if session.get('domainGlobalAdmin') is sameas true %}
                        <th class="checkbox"><input type="checkbox" class="checkbox select-all" /></th>
                    {% endif %}
                    <th>{{ _('Domain') }}</th>
                    <th>{{ _('Name') }}</th>
                    <th>{{ _('Quota') }}</th>
                    <th>{{ _('Users') }}</th>
                </tr>
                </thead>

                <tbody>
                {% if allDomains is not string and allDomains |length != 0 %}
                    {# List domain attributes/avalues. #}
                    {% for (dn, entries) in allDomains %}
                        {% set domain = entries.get('domainName')[0] |string |e %}
                        {% set cn = entries.get('cn', [domain])[0].decode('utf-8') |e %}
                        {% set accountStatus = entries.get('accountStatus', ['disabled'])[0] |e %}
                        {% set accountSetting = allAccountSettings.get(domain, {}) %}

                        {# Get domain quota size & unit #}
                        {% set domainQuota = accountSetting.get('domainQuota', '0:GB') |e %}
                        {% set domainQuotaSize, domainQuotaUnit = domainQuota.split(':') %}

                        {% if domainQuotaUnit == 'TB' %}
                            {% set domainQuotaBytes = domainQuotaSize |int * 1024 * 1024 * 1024 * 1024 %}
                        {% elif domainQuotaUnit == 'GB' %}
                            {% set domainQuotaBytes = domainQuotaSize |int * 1024 * 1024 * 1024 %}
                        {% else %}
                            {% set domainQuotaBytes = domainQuotaSize |int * 1024 * 1024 %}
                        {% endif %}

                        {# Get account limits. #}
                        {% set numberOfUsers = accountSetting.get('numberOfUsers', '0') |int %}

                        {# Get number of current accounts #}
                        {% set domainCurrentUserNumber = entries.get('domainCurrentUserNumber', ['0'])[0] |int %}

                        <tr class="{{ accountStatus |lower }}">
                            {% if session.get('domainGlobalAdmin') is sameas true %}
                                <td class="checkbox"><input type="checkbox" class="checkbox " name="domainName" value="{{domain}}" /></td>
                            {% endif %}
                            <td class="vcenter">
                                <a href="{{ctx.homepath}}/profile/domain/general/{{domain}}"><img src="{{ctx.homepath}}/static/{{skin}}/images/action_edit.png" title="{{ _('Edit account profile') }}" class="fr-space"/></a>
                                {{ set_account_status_img(accountStatus) }}
                                {{ domain }}
                            </td>

                            <td class="vcenter">{% if cn != '' and cn != domain %}{{ cn |cutString }}{% endif %}</td>

                            <td class="vcenter">{{ _('Unlimited') }}</td>
                            {# Mail user count #}
                            <td class="vcenter">
                                 <a href="{{ctx.homepath}}/users/{{domain}}" title="{{ _('List all mail users.') }}" style="text-decoration: none;">{{domainCurrentUserNumber}}</a>
                            </td>
                        </tr>
                    {% endfor %}
                {% else %}
                    <tr>
                    {% if session.get('domainGlobalAdmin') is sameas true %}
                        <td class="checkbox"></td>
                        <td class="vcenter" colspan="7">{{ _('No mail domain available.') }}
                            <a href="{{ctx.homepath}}/create/domain">{{ _('Add one') }}</a>?
                        </td>
                    {% else %}
                        <td class="vcenter" colspan="6">{{ _('No mail domain available.') }}</td>
                    {% endif %}
                    </tr>
                {% endif %}
                </tbody>
            </table>

                <div class="tab-footer clear f1">
                    {% if session.get('domainGlobalAdmin') is sameas true %}
                        <div class="fl">
                            <select name="action" class="fl-space">
                                <option>{{ _('Choose Action') }}</option>
                                <option value="enable">{{ _('Enable') }}</option>
                                <option value="disable">{{ _('Disable') }}</option>
                                <option value="delete">{{ _('Delete') }}</option>
                            </select>
                            <input type="submit" value="{{ _('Apply') }}" class="button fl-space" />
                        </div>
                    {% endif %}

                    {{ show_pages(baseurl=ctx.homepath + '/domains', total=total, cur_page=cur_page) }}
                </div>
            </form>
        </div>
    </div>

{% endblock main %}

{% block js %}
    {% if session.get('domainGlobalAdmin') is sameas true %}
        {% set nonSortedCols = [0] %}
    {% else %}
        {% set nonSortedCols = [] %}
    {% endif %}

    {{ load_jquery(['tablesorter'], nonSortedCols=nonSortedCols) }}
{% endblock js %}