dashboard-resource-items
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -65,23 +65,34 @@ if ($page == 'overview') {
|
||||
];
|
||||
}
|
||||
$overview_stmt = Database::prepare("SELECT COUNT(*) AS `number_customers`,
|
||||
SUM(case when `diskspace` > 0 then `diskspace` else 0 end) AS `diskspace_assigned`,
|
||||
SUM(`diskspace_used`) AS `diskspace_used`,
|
||||
SUM(case when `mysqls` > 0 then `mysqls` else 0 end) AS `mysqls_assigned`,
|
||||
SUM(`mysqls_used`) AS `mysqls_used`,
|
||||
SUM(case when `emails` > 0 then `emails` else 0 end) AS `emails_assigned`,
|
||||
SUM(`emails_used`) AS `emails_used`,
|
||||
SUM(case when `email_accounts` > 0 then `email_accounts` else 0 end) AS `email_accounts_assigned`,
|
||||
SUM(`email_accounts_used`) AS `email_accounts_used`,
|
||||
SUM(case when `email_forwarders` > 0 then `email_forwarders` else 0 end) AS `email_forwarders_assigned`,
|
||||
SUM(`email_forwarders_used`) AS `email_forwarders_used`,
|
||||
SUM(case when `email_quota` > 0 then `email_quota` else 0 end) AS `email_quota_assigned`,
|
||||
SUM(`email_quota_used`) AS `email_quota_used`,
|
||||
SUM(case when `ftps` > 0 then `ftps` else 0 end) AS `ftps_assigned`,
|
||||
SUM(`ftps_used`) AS `ftps_used`,
|
||||
SUM(case when `subdomains` > 0 then `subdomains` else 0 end) AS `subdomains_assigned`,
|
||||
SUM(`subdomains_used`) AS `subdomains_used`,
|
||||
SUM(case when `traffic` > 0 then `traffic` else 0 end) AS `traffic_assigned`,
|
||||
SUM(`traffic_used`) AS `traffic_used`
|
||||
FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid "));
|
||||
$overview = Database::pexecute_first($overview_stmt, $params);
|
||||
|
||||
$dec_places = Settings::Get('panel.decimal_places');
|
||||
$overview['traffic_bytes_used'] = $overview['traffic_used'] * 1024;
|
||||
$overview['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($overview['traffic_used'] * 1024, null, 'bi');
|
||||
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1;
|
||||
$overview['diskspace_bytes'] = $overview['diskspace_assigned'] * 1024;
|
||||
$overview['diskspace_bytes_used'] = $overview['diskspace_used'] * 1024;
|
||||
$overview['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($overview['diskspace_used'] * 1024, null, 'bi');
|
||||
|
||||
$userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : - 1;
|
||||
$overview['traffic_bytes'] = $overview['traffic_assigned'] * 1024;
|
||||
$overview['traffic_bytes_used'] = $overview['traffic_used'] * 1024;
|
||||
|
||||
$number_domains_stmt = Database::prepare("
|
||||
SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||
@@ -111,19 +122,6 @@ if ($page == 'overview') {
|
||||
$isnewerversion = 0;
|
||||
}
|
||||
|
||||
$dec_places = Settings::Get('panel.decimal_places');
|
||||
// get everything in bytes for the percentage calculation on the dashboard
|
||||
$userinfo['diskspace_bytes'] = ($userinfo['diskspace'] > -1) ? $userinfo['diskspace'] * 1024 : -1;
|
||||
$userinfo['diskspace_bytes_used'] = $userinfo['diskspace_used'] * 1024;
|
||||
$userinfo['traffic_bytes'] = ($userinfo['traffic'] > -1) ? $userinfo['traffic'] * 1024 : - 1;
|
||||
$userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024;
|
||||
|
||||
$userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1;
|
||||
$userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace_used'] * 1024, null, 'bi');
|
||||
$userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1;
|
||||
$userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi');
|
||||
$userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace diskspace_bytes traffic traffic_bytes mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
|
||||
|
||||
$cron_last_runs = \Froxlor\System\Cronjob::getCronjobsLastRun();
|
||||
$outstanding_tasks = \Froxlor\System\Cronjob::getOutstandingTasks();
|
||||
|
||||
|
||||
@@ -96,24 +96,12 @@ if ($page == 'overview') {
|
||||
$userinfo['traffic_bytes_used'] = $userinfo['traffic_used'] * 1024;
|
||||
|
||||
if ($usages) {
|
||||
$userinfo['diskspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['webspace'] * 1024, null, 'bi');
|
||||
$userinfo['mailspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mail'] * 1024, null, 'bi');
|
||||
$userinfo['dbspace_used'] = \Froxlor\PhpHelper::sizeReadable($usages['mysql'] * 1024, null, 'bi');
|
||||
$userinfo['total_used'] = \Froxlor\PhpHelper::sizeReadable(($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024, null, 'bi');
|
||||
$userinfo['diskspace_bytes_used'] = $usages['webspace'] * 1024;
|
||||
$userinfo['total_bytes_used'] = ($usages['webspace'] + $usages['mail'] + $usages['mysql']) * 1024;
|
||||
} else {
|
||||
$userinfo['diskspace_used'] = 0;
|
||||
$userinfo['mailspace_used'] = 0;
|
||||
$userinfo['dbspace_used'] = 0;
|
||||
$userinfo['total_used'] = 0;
|
||||
$userinfo['diskspace_bytes_used'] = 0;
|
||||
$userinfo['total_bytes_used'] = 0;
|
||||
}
|
||||
$userinfo['diskspace'] = ($userinfo['diskspace'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['diskspace'] * 1024, null, 'bi') : - 1;
|
||||
$userinfo['traffic'] = ($userinfo['traffic'] > -1) ? \Froxlor\PhpHelper::sizeReadable($userinfo['traffic'] * 1024, null, 'bi') : - 1;
|
||||
$userinfo['traffic_used'] = \Froxlor\PhpHelper::sizeReadable($userinfo['traffic_used'] * 1024, null, 'bi');
|
||||
$userinfo = \Froxlor\PhpHelper::strReplaceArray('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace diskspace_bytes traffic traffic_bytes mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
|
||||
|
||||
UI::Twig()->addGlobal('userinfo', $userinfo);
|
||||
UI::TwigBuffer('user/index.html.twig', [
|
||||
|
||||
29
templates/Froxlor/user/dashboard-item.html.twig
Normal file
29
templates/Froxlor/user/dashboard-item.html.twig
Normal file
@@ -0,0 +1,29 @@
|
||||
{% macro ditem(lngstr, available, used, assigned = null, formatbytes = false) %}
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<div class="row mb-1">
|
||||
<div class="col">{{ lng(lngstr) }}</div>
|
||||
<div class="col-auto">
|
||||
<small>{% if formatbytes %}{{ used|formatBytes }}{% else %}{{ used }}{% endif %}/{% if available < 0 %}{{ lng('customer.unlimited') }}{% else %}{% if formatbytes %}{{ available|formatBytes }}{% else %}{{ available }}{% endif %}{% endif %}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="progress my-auto" style="height: .25rem;">
|
||||
{% set usageperc = 1 %}
|
||||
{% if available > 0 %}
|
||||
{% set usageperc = (used / available) * 100|round %}
|
||||
{% endif %}
|
||||
<div class="progress-bar{% if available < 0 %} bg-secondary{% elseif usageperc >= 75 and usageperc < 90 %} bg-warning{% elseif usageperc >= 90 %} bg-danger{% endif %}"
|
||||
role="progressbar"
|
||||
style="width: {% if available < 0 %}100{% else %}{{ usageperc }}{% endif %}%;" aria-valuenow="{% if available < 0 %}100{% else %}{{ used }}{% endif %}" aria-valuemin="0" aria-valuemax="{% if available < 0 %}100{% else %}{{ available }}{% endif %}"></div>
|
||||
</div>
|
||||
{% if assigned is not empty %}
|
||||
<div class="progress my-auto" style="height: .25rem;">
|
||||
<div class="progress-bar bg-info" role="progressbar"
|
||||
style="width:{% if available > 0 %}{{ (assigned / available) * 100|round }}{% else %}1{% endif %}%;"
|
||||
aria-valuenow="{{ assigned }}" aria-valuemin="0"
|
||||
aria-valuemax="{{ available }}"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
@@ -20,92 +20,33 @@
|
||||
{{ lng('panel.usage_statistics') }}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div
|
||||
class="row row-cols-1 row-cols-md-2{% if userinfo.adminsession == 0 %} row-cols-lg-3 row-cols-xl-4{% endif %} g-4">
|
||||
{# admin-resources #}
|
||||
<div class="row row-cols-1 row-cols-md-2{% if userinfo.adminsession == 0 %} row-cols-lg-3 row-cols-xl-4{% endif %} g-4">
|
||||
{% import "Froxlor/user/dashboard-item.html.twig" as dashboard %}
|
||||
{% if userinfo.adminsession == 1 %}
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
{# admin-resources #}
|
||||
{{ dashboard.ditem('admin.customers', userinfo.customers, overview.number_customers) }}
|
||||
{{ dashboard.ditem('admin.domains', userinfo.domains, overview.number_domains) }}
|
||||
|
||||
{{ dashboard.ditem('customer.diskspace', userinfo.diskspace_bytes, overview.diskspace_bytes_used, overview.diskspace_bytes, true) }}
|
||||
{{ dashboard.ditem('customer.traffic', userinfo.traffic_bytes, overview.traffic_bytes_used, overview.traffic_bytes, true) }}
|
||||
|
||||
{{ dashboard.ditem('customer.subdomains', userinfo.subdomains, overview.subdomains_used, overview.subdomains_assigned) }}
|
||||
{{ dashboard.ditem('customer.mysqls', userinfo.mysqls, overview.mysqls_used, overview.mysqls_assigned) }}
|
||||
{{ dashboard.ditem('customer.emails', userinfo.emails, overview.emails_used, overview.emails_assigned) }}
|
||||
{{ dashboard.ditem('customer.accounts', userinfo.email_accounts, overview.email_accounts_used, overview.email_accounts_assigned) }}
|
||||
{{ dashboard.ditem('customer.forwarders', userinfo.email_forwarders, overview.email_forwarders_used, overview.email_forwarders_assigned) }}
|
||||
{{ dashboard.ditem('customer.ftps', userinfo.ftps, overview.ftps_used, overview.ftps_assigned) }}
|
||||
{% else %}
|
||||
{# customer-resources #}
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card bg-light h-100 p-2">
|
||||
<h5>{{ lng('admin.customers') }} <small>{{ overview.number_customers }}/{{ userinfo.customers }}</small></h5>
|
||||
<div class="progress" style="height: .25rem;">
|
||||
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ dashboard.ditem('customer.diskspace', userinfo.diskspace_bytes, userinfo.diskspace_bytes_used, null, true) }}
|
||||
{{ dashboard.ditem('customer.traffic', userinfo.traffic_bytes, userinfo.traffic_bytes_used, null, true) }}
|
||||
|
||||
{{ dashboard.ditem('customer.subdomains', userinfo.subdomains, userinfo.subdomains_used) }}
|
||||
{{ dashboard.ditem('customer.mysqls', userinfo.mysqls, userinfo.mysqls_used) }}
|
||||
{{ dashboard.ditem('customer.emails', userinfo.emails, userinfo.emails_used) }}
|
||||
{{ dashboard.ditem('customer.accounts', userinfo.email_accounts, userinfo.email_accounts_used) }}
|
||||
{{ dashboard.ditem('customer.forwarders', userinfo.email_forwarders, userinfo.email_forwarders_used) }}
|
||||
{{ dashboard.ditem('customer.ftps', userinfo.ftps, userinfo.ftps_used) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -122,15 +63,22 @@
|
||||
<div class="ms-2 me-auto">
|
||||
<div class="fw-bold">{{ lng('tasks.outstanding_tasks') }}</div>
|
||||
{% for task in outstanding_tasks %}
|
||||
<i class="fa-regular fa-clock"></i> {{ task.desc }}<br>
|
||||
<i class="fa-regular fa-clock"></i>
|
||||
{{ task.desc }}<br>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</li>
|
||||
{% for cronrun in cron_last_runs %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-start">
|
||||
<div class="ms-2 me-auto">{{ cronrun.title }}</div>
|
||||
<span class="badge bg-primary">{% if cronrun.lastrun > 0 %}{{ cronrun.lastrun|date('d.m.Y H:i') }}{% else %}{{ lng('cronjobs.notyetrun') }}{% endif %}</span>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-start">
|
||||
<div class="ms-2 me-auto">{{ cronrun.title }}</div>
|
||||
<span class="badge bg-primary">
|
||||
{% if cronrun.lastrun > 0 %}
|
||||
{{ cronrun.lastrun|date('d.m.Y H:i') }}
|
||||
{% else %}
|
||||
{{ lng('cronjobs.notyetrun') }}
|
||||
{% endif %}
|
||||
</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user