add button to restore table column defaults and ux improvements

This commit is contained in:
envoyr
2022-04-23 18:59:25 +02:00
parent 6ca071a31f
commit 91d41af44a
7 changed files with 141 additions and 20 deletions

View File

@@ -110,8 +110,10 @@ class Ajax
return $this->getUpdateCheck();
case 'searchglobal':
return $this->searchGlobal();
case 'tablelisting':
case 'updatetablelisting':
return $this->updateTablelisting();
case 'resettablelisting':
return $this->resetTablelisting();
case 'editapikey':
return $this->editApiKey();
default:
@@ -248,15 +250,19 @@ class Ajax
private function updateTablelisting()
{
$columns = [];
foreach (Request::get('columns') as $requestedColumn => $value) {
$columns[] = $requestedColumn;
foreach (Request::get('columns') as $value) {
$columns[] = $value;
}
Listing::storeColumnListingForUser([Request::get('listing') => $columns]);
return $this->jsonResponse($columns);
}
private function resetTablelisting()
{
Listing::deleteColumnListingForUser([Request::get('listing') => []]);
return $this->jsonResponse([]);
}
private function editApiKey()
{
$keyid = isset($_POST['id']) ? (int) $_POST['id'] : 0;

View File

@@ -197,6 +197,29 @@ class Listing
return $result;
}
/**
* delete column listing selection of user from database
*
* @param array $tabellisting
* @return bool
*/
public static function deleteColumnListingForUser(array $tabellisting): bool
{
$section = array_key_first($tabellisting);
if (empty($section)) {
throw new InvalidArgumentException("Invalid selection array for " . __METHOD__);
}
$userid = 'customerid';
if (CurrentUser::isAdmin()) {
$userid = 'adminid';
}
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_USERCOLUMNS . "` WHERE `" . $userid . "` = :uid AND `section` = :section
");
Database::pexecute($del_stmt, ['uid' => CurrentUser::getField($userid), 'section' => $section]);
return true;
}
/**
* store column listing selection of user to database
* the selection array should look like this:
@@ -208,8 +231,7 @@ class Listing
* ]
* ]
*
* @param array $tablelisting
*
* @param array $tabellisting
* @return bool
*/
public static function storeColumnListingForUser(array $tabellisting): bool
@@ -223,10 +245,7 @@ class Listing
$userid = 'adminid';
}
// delete possible existing entry
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_PANEL_USERCOLUMNS . "` WHERE `" . $userid . "` = :uid AND `section` = :section
");
Database::pexecute($del_stmt, ['uid' => CurrentUser::getField($userid), 'section' => $section]);
self::deleteColumnListingForUser($tabellisting);
// add new entry
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_PANEL_USERCOLUMNS . "` SET

View File

@@ -52,6 +52,80 @@ return [
'label' => $lng['domains']['aliasdomain'],
'field' => 'aliasdomain',
],
'd.documentroot' => [
'label' => $lng['domains']['documentroot'],
'field' => 'documentroot',
],
'd.isbinddomain' => [
'label' => $lng['domains']['isbinddomain'],
'field' => 'isbinddomain',
'callback' => [Text::class, 'boolean'],
],
'd.isemaildomain' => [
'label' => $lng['domains']['isemaildomain'],
'field' => 'isemaildomain',
'callback' => [Text::class, 'boolean'],
],
'd.email_only' => [
'label' => $lng['domains']['email_only'],
'field' => 'email_only',
'callback' => [Text::class, 'boolean'],
],
'd.iswildcarddomain' => [
'label' => $lng['domains']['iswildcarddomain'],
'field' => 'iswildcarddomain',
'callback' => [Text::class, 'boolean'],
],
'd.subcanemaildomain' => [
'label' => $lng['domains']['subcanemaildomain'],
'field' => 'subcanemaildomain',
'callback' => [Text::class, 'boolean'],
],
'd.caneditdomain' => [
'label' => $lng['domains']['caneditdomain'],
'field' => 'caneditdomain',
'callback' => [Text::class, 'boolean'],
],
'd.dkim' => [
'label' => $lng['domains']['dkim'],
'field' => 'dkim',
'callback' => [Text::class, 'boolean'],
],
'd.phpenabled' => [
'label' => $lng['admin']['phpenabled'],
'field' => 'phpenabled',
'callback' => [Text::class, 'boolean'],
],
'd.openbasedir' => [
'label' => $lng['domains']['openbasedir'],
'field' => 'openbasedir',
'callback' => [Text::class, 'boolean'],
],
'd.speciallogfile' => [
'label' => $lng['domains']['speciallogfile'],
'field' => 'speciallogfile',
'callback' => [Text::class, 'boolean'],
],
'd.hsts' => [
'label' => $lng['domains']['hsts'],
'field' => 'hsts',
'callback' => [Text::class, 'boolean'],
],
'd.http2' => [
'label' => $lng['domains']['http2'],
'field' => 'http2',
'callback' => [Text::class, 'boolean'],
],
'd.letsencrypt' => [
'label' => $lng['domains']['letsencrypt'],
'field' => 'letsencrypt',
'callback' => [Text::class, 'boolean'],
],
'd.deactivated' => [
'label' => $lng['domains']['deactivated'],
'field' => 'deactivated',
'callback' => [Text::class, 'boolean'],
],
],
'visible_columns' => Listing::getVisibleColumnsForListing('domain_list', [
'd.domain_ace',