make search-result links a filter/search for the overview instead of the direct edit-link; show number of total entries in overview; show 'back to overview' button when showing search-result

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-04-01 16:47:22 +02:00
parent 0312548e88
commit 1441ed9a99
17 changed files with 71 additions and 26 deletions

View File

@@ -100,10 +100,10 @@ class GlobalSearch
'c.customernumber', 'c.customernumber',
'c.custom_notes' 'c.custom_notes'
], ],
'result_key' => 'customerid', 'result_key' => 'loginname',
'result_format' => [ 'result_format' => [
'title' => ['\\Froxlor\\User', 'getCorrectFullUserDetails'], 'title' => ['\\Froxlor\\User', 'getCorrectFullUserDetails'],
'href' => 'admin_customers.php?page=customers&action=edit&id=' 'href' => 'admin_customers.php?page=customers&searchfield=c.loginname&searchtext='
] ]
], ],
// domains // domains
@@ -114,11 +114,11 @@ class GlobalSearch
'd.domain_ace', 'd.domain_ace',
'd.documentroot' 'd.documentroot'
], ],
'result_key' => 'id', 'result_key' => 'domain_ace',
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'domain_ace', 'title_args' => 'domain_ace',
'href' => 'admin_domains.php?page=domains&action=edit&id=' 'href' => 'admin_domains.php?page=domains&searchfield=d.domain_ace&searchtext='
] ]
], ],
// ips and ports // ips and ports
@@ -129,12 +129,12 @@ class GlobalSearch
'vhostcontainer', 'vhostcontainer',
'specialsettings' 'specialsettings'
], ],
'result_key' => 'id', 'result_key' => 'ip',
'result_groupkey' => 'ip', 'result_groupkey' => 'ip',
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'ip', 'title_args' => 'ip',
'href' => 'admin_ipsandports.php?page=ipsandports&action=edit&id=' 'href' => 'admin_ipsandports.php?page=ipsandports&searchfield=ip&searchtext='
] ]
], ],
// hosting-plans // hosting-plans
@@ -163,7 +163,7 @@ class GlobalSearch
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'description', 'title_args' => 'description',
'href' => ((bool) $userinfo['change_serversettings'] ? 'admin_phpsettings.php?page=overview&action=edit&id=' : 'admin_phpsettings.php?page=overview&sid=') 'href' => 'admin_phpsettings.php?page=overview&searchfield=id&searchtext='
] ]
], ],
// FPM daemons // FPM daemons
@@ -177,7 +177,7 @@ class GlobalSearch
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'description', 'title_args' => 'description',
'href' => ((bool) $userinfo['change_serversettings'] ? 'admin_phpsettings.php?page=fpmdaemons&action=edit&id=' : 'admin_phpsettings.php?page=fpmdaemons&sid=') 'href' => 'admin_phpsettings.php?page=fpmdaemons&searchfield=id&searchtext='
] ]
] ]
]; ];
@@ -192,11 +192,11 @@ class GlobalSearch
'email', 'email',
'custom_notes' 'custom_notes'
], ],
'result_key' => 'adminid', 'result_key' => 'loginname',
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'name', 'title_args' => 'name',
'href' => 'admin_admins.php?page=admins&action=edit&id=' 'href' => 'admin_admins.php?page=admins&searchfield=loginname&searchtext='
] ]
]; ];
} }
@@ -210,11 +210,11 @@ class GlobalSearch
'd.domain_ace', 'd.domain_ace',
'd.documentroot' 'd.documentroot'
], ],
'result_key' => 'id', 'result_key' => 'domain_ace',
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'domain_ace', 'title_args' => 'domain_ace',
'href' => 'customer_domains.php?page=domains&action=edit&id=' 'href' => 'customer_domains.php?page=domains&searchfield=d.domain_ace&searchtext='
] ]
], ],
// email addresses // email addresses
@@ -224,11 +224,11 @@ class GlobalSearch
'm.email', 'm.email',
'm.email_full' 'm.email_full'
], ],
'result_key' => 'id', 'result_key' => 'email',
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'email', 'title_args' => 'email',
'href' => 'customer_email.php?page=emails&action=edit&id=' 'href' => 'customer_email.php?page=emails&searchfield=m.email&searchtext='
] ]
], ],
// databases // databases
@@ -238,11 +238,11 @@ class GlobalSearch
'databasename', 'databasename',
'description' 'description'
], ],
'result_key' => 'id', 'result_key' => 'databasename',
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'databasename', 'title_args' => 'databasename',
'href' => 'customer_mysql.php?page=mysqls&action=edit&id=' 'href' => 'customer_mysql.php?page=mysqls&searchfield=databasename&searchtext='
] ]
], ],
// ftp user // ftp user
@@ -252,11 +252,11 @@ class GlobalSearch
'username', 'username',
'description' 'description'
], ],
'result_key' => 'id', 'result_key' => 'username',
'result_format' => [ 'result_format' => [
'title' => ['self', 'getFieldFromResult'], 'title' => ['self', 'getFieldFromResult'],
'title_args' => 'username', 'title_args' => 'username',
'href' => 'customer_ftp.php?page=ftps&action=edit&id=' 'href' => 'customer_ftp.php?page=accounts&searchfield=username&searchtext='
] ]
] ]
]; ];

View File

@@ -109,17 +109,24 @@ class Collection
public function withPagination(array $columns): Collection public function withPagination(array $columns): Collection
{ {
// Get only searchable columns // Get only searchable columns
/*
$sortableColumns = []; $sortableColumns = [];
foreach ($columns as $key => $column) { foreach ($columns as $key => $column) {
if (isset($column['sortable']) && $column['sortable']) { if (isset($column['sortable']) && $column['sortable']) {
$sortableColumns[$key] = $column; $sortableColumns[$key] = $column;
} }
} }
*/
// Prepare pagination // Prepare pagination
$this->pagination = new Pagination($sortableColumns, $this->count(), (int) Settings::Get('panel.paging')); $this->pagination = new Pagination($columns, $this->count(), (int) Settings::Get('panel.paging'));
$this->params = array_merge($this->params, $this->pagination->getApiCommandParams()); $this->params = array_merge($this->params, $this->pagination->getApiCommandParams());
return $this; return $this;
} }
public function getPagination(): ?Pagination
{
return $this->pagination;
}
} }

View File

@@ -24,7 +24,7 @@ class Listing
{ {
public static function format(Collection $collection, array $tabellisting): array public static function format(Collection $collection, array $tabellisting): array
{ {
$collection = $collection->get(); $collection_data = $collection->get();
return [ return [
'title' => $tabellisting['title'], 'title' => $tabellisting['title'],
@@ -32,10 +32,13 @@ class Listing
'icon' => $tabellisting['icon'] ?? null, 'icon' => $tabellisting['icon'] ?? null,
'table' => [ 'table' => [
'th' => self::generateTableHeadings($tabellisting), 'th' => self::generateTableHeadings($tabellisting),
'tr' => self::generateTableRows($collection['data']['list'], $tabellisting), 'tr' => self::generateTableRows($collection_data['data']['list'], $tabellisting),
], ],
'pagination' => $collection['pagination'], 'pagination' => $collection_data['pagination'],
'empty_msg' => $tabellisting['empty_msg'] ?? null 'empty_msg' => $tabellisting['empty_msg'] ?? null,
'total_entries' => ($collection->getPagination() instanceof Pagination) ? $collection->getPagination()->getEntries() : 0,
'is_search' => ($collection->getPagination() instanceof Pagination) ? $collection->getPagination()->isSearchResult() : false,
'self_overview' => $tabellisting['self_overview'] ?? []
]; ];
} }

View File

@@ -200,4 +200,9 @@ class Pagination
] ]
]; ];
} }
public function isSearchResult(): bool
{
return $this->is_search;
}
} }

View File

@@ -27,6 +27,7 @@ return [
'admin_list' => [ 'admin_list' => [
'title' => $lng['admin']['admin'], 'title' => $lng['admin']['admin'],
'icon' => 'fa-solid fa-user', 'icon' => 'fa-solid fa-user',
'self_overview' => ['section' => 'admins', 'page' => 'admins'],
'columns' => [ 'columns' => [
'adminid' => [ 'adminid' => [
'label' => '#', 'label' => '#',

View File

@@ -27,6 +27,7 @@ return [
'title' => $lng['admin']['customers'], 'title' => $lng['admin']['customers'],
'description' => 'Manage your customers', 'description' => 'Manage your customers',
'icon' => 'fa-solid fa-user', 'icon' => 'fa-solid fa-user',
'self_overview' => ['section' => 'customers', 'page' => 'customers'],
'columns' => [ 'columns' => [
'c.name' => [ 'c.name' => [
'label' => $lng['customer']['name'], 'label' => $lng['customer']['name'],

View File

@@ -26,6 +26,7 @@ return [
'title' => $lng['admin']['domains'], 'title' => $lng['admin']['domains'],
'icon' => 'fa-solid fa-globe', 'icon' => 'fa-solid fa-globe',
'empty_msg' => $lng['admin']['domain_nocustomeraddingavailable'], 'empty_msg' => $lng['admin']['domain_nocustomeraddingavailable'],
'self_overview' => ['section' => 'domains', 'page' => 'domains'],
'columns' => [ 'columns' => [
'd.domain_ace' => [ 'd.domain_ace' => [
'label' => $lng['domains']['domainname'], 'label' => $lng['domains']['domainname'],

View File

@@ -24,7 +24,11 @@ return [
'fpmconf_list' => [ 'fpmconf_list' => [
'title' => $lng['menue']['phpsettings']['fpmdaemons'], 'title' => $lng['menue']['phpsettings']['fpmdaemons'],
'icon' => 'fa-brands fa-php', 'icon' => 'fa-brands fa-php',
'self_overview' => ['section' => 'phpsettings', 'page' => 'fpmdaemons'],
'columns' => [ 'columns' => [
'id' => [
'field' => 'id'
],
'description' => [ 'description' => [
'label' => $lng['admin']['phpsettings']['description'], 'label' => $lng['admin']['phpsettings']['description'],
'field' => 'description', 'field' => 'description',

View File

@@ -24,6 +24,7 @@ return [
'ipsandports_list' => [ 'ipsandports_list' => [
'title' => $lng['admin']['ipsandports']['ipsandports'], 'title' => $lng['admin']['ipsandports']['ipsandports'],
'icon' => 'fa-solid fa-ethernet', 'icon' => 'fa-solid fa-ethernet',
'self_overview' => ['section' => 'ipsandports', 'page' => 'ipsandports'],
'columns' => [ 'columns' => [
'ip' => [ 'ip' => [
'label' => $lng['admin']['ipsandports']['ip'], 'label' => $lng['admin']['ipsandports']['ip'],

View File

@@ -25,6 +25,7 @@ return [
'phpconf_list' => [ 'phpconf_list' => [
'title' => $lng['menue']['phpsettings']['maintitle'], 'title' => $lng['menue']['phpsettings']['maintitle'],
'icon' => 'fa-brands fa-php', 'icon' => 'fa-brands fa-php',
'self_overview' => ['section' => 'phpsettings', 'page' => 'overview'],
'columns' => [ 'columns' => [
'c.description' => [ 'c.description' => [
'label' => $lng['admin']['phpsettings']['description'], 'label' => $lng['admin']['phpsettings']['description'],

View File

@@ -23,7 +23,11 @@ return [
'domain_list' => [ 'domain_list' => [
'title' => $lng['admin']['domains'], 'title' => $lng['admin']['domains'],
'icon' => 'fa-solid fa-globe', 'icon' => 'fa-solid fa-globe',
'self_overview' => ['section' => 'domains', 'page' => 'domains'],
'columns' => [ 'columns' => [
'ad.id' => [
'field' => 'aliasdomainid'
],
'd.domain_ace' => [ 'd.domain_ace' => [
'label' => $lng['domains']['domainname'], 'label' => $lng['domains']['domainname'],
'field' => 'domain_ace', 'field' => 'domain_ace',
@@ -92,8 +96,8 @@ return [
'href' => [ 'href' => [
'section' => 'domains', 'section' => 'domains',
'page' => 'domains', 'page' => 'domains',
'searchfield' => 'd.aliasdomain', 'searchfield' => 'ad.id',
'searchtext' => ':domainaliasid' 'searchtext' => ':id'
], ],
'visible' => [Domain::class, 'canEditAlias'] 'visible' => [Domain::class, 'canEditAlias']
], ],

View File

@@ -25,6 +25,7 @@ return [
'email_list' => [ 'email_list' => [
'title' => $lng['menue']['email']['emails'], 'title' => $lng['menue']['email']['emails'],
'icon' => 'fa-solid fa-envelope', 'icon' => 'fa-solid fa-envelope',
'self_overview' => ['section' => 'email', 'page' => 'emails'],
'columns' => [ 'columns' => [
'm.email_full' => [ 'm.email_full' => [
'label' => $lng['emails']['emailaddress'], 'label' => $lng['emails']['emailaddress'],

View File

@@ -24,6 +24,7 @@ return [
'ftp_list' => [ 'ftp_list' => [
'title' => $lng['menue']['ftp']['accounts'], 'title' => $lng['menue']['ftp']['accounts'],
'icon' => 'fa-solid fa-users', 'icon' => 'fa-solid fa-users',
'self_overview' => ['section' => 'ftp', 'page' => 'accounts'],
'columns' => [ 'columns' => [
'username' => [ 'username' => [
'label' => $lng['login']['username'], 'label' => $lng['login']['username'],

View File

@@ -24,6 +24,7 @@ return [
'mysql_list' => [ 'mysql_list' => [
'title' => $lng['menue']['mysql']['databases'], 'title' => $lng['menue']['mysql']['databases'],
'icon' => 'fa-solid fa-database', 'icon' => 'fa-solid fa-database',
'self_overview' => ['section' => 'mysql', 'page' => 'mysqls'],
'columns' => [ 'columns' => [
'databasename' => [ 'databasename' => [
'label' => $lng['mysql']['databasename'], 'label' => $lng['mysql']['databasename'],

View File

@@ -2160,3 +2160,4 @@ $lng['admin']['smtpsettings'] = 'SMTP settings';
$lng['panel']['unspecified'] = 'unspecified'; $lng['panel']['unspecified'] = 'unspecified';
$lng['admin']['smtptestaddr'] = 'Send test-mail to'; $lng['admin']['smtptestaddr'] = 'Send test-mail to';
$lng['admin']['smtptestnote'] = 'Note that the values below reflect your current settings and can only be adjusted there (see link in top right corner)'; $lng['admin']['smtptestnote'] = 'Note that the values below reflect your current settings and can only be adjusted there (see link in top right corner)';
$lng['panel']['backtooverview'] = 'Back to overview';

View File

@@ -1798,3 +1798,4 @@ $lng['admin']['smtpsettings'] = 'SMTP Einstellungen';
$lng['panel']['unspecified'] = 'keine Angabe'; $lng['panel']['unspecified'] = 'keine Angabe';
$lng['admin']['smtptestaddr'] = 'Test-Email senden an'; $lng['admin']['smtptestaddr'] = 'Test-Email senden an';
$lng['admin']['smtptestnote'] = 'Bitte beachten: Die untenstehenden Werte reflektieren die aktuellen Einstellungen und können auch nur dort angepasst werden (siehe Link in der oberen rechten Ecke)'; $lng['admin']['smtptestnote'] = 'Bitte beachten: Die untenstehenden Werte reflektieren die aktuellen Einstellungen und können auch nur dort angepasst werden (siehe Link in der oberen rechten Ecke)';
$lng['panel']['backtooverview'] = 'Zurück zur Übersicht';

View File

@@ -8,6 +8,11 @@
<i class="{{ listing.icon }} me-1"></i> <i class="{{ listing.icon }} me-1"></i>
{% endif %} {% endif %}
{{ listing.title }} {{ listing.title }}
{% if listing.total_entries > 0 %}
<small>
<span class="badge rounded-pill bg-secondary">{{ listing.total_entries }}</span>
</small>
{% endif %}
</h5> </h5>
{% if listing.description is not empty %} {% if listing.description is not empty %}
<span class="text-muted mt-2">{{ listing.description }}</span> <span class="text-muted mt-2">{{ listing.description }}</span>
@@ -18,12 +23,19 @@
{% block actions %} {% block actions %}
{% if listing.is_search and listing.self_overview is defined and listing.self_overview is iterable %}
{% set actions_tmp = actions_links %}
{% set actions_links = {'href': linker(listing.self_overview), 'icon': 'fa fa-reply','label': lng('panel.backtooverview')} %}
{% set actions_links = {actions_links}|merge(actions_tmp) %}
{% endif %}
{% if actions_links is iterable or (entity_info is defined and entity_info is not empty) %} {% if actions_links is iterable or (entity_info is defined and entity_info is not empty) %}
<div> <div>
{% if actions_links is iterable %} {% if actions_links is iterable %}
{% for link in actions_links %} {% for link in actions_links %}
<a class="btn {{ link.class|default('btn-outline-primary') }}" href="{{ link.href|raw }}"> <a class="btn {{ link.class|default('btn-outline-primary') }}" href="{{ link.href|raw }}">
<i class="{{ link.icon|default('fa-solid fa-plus-circle') }}"></i><span class="d-none d-lg-inline ms-lg-1">{{ link.label }}</span> <i class="{{ link.icon|default('fa-solid fa-plus-circle') }}"></i>
<span class="d-none d-lg-inline ms-lg-1">{{ link.label }}</span>
</a> </a>
{% endfor %} {% endfor %}
{% endif %} {% endif %}