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,13 +250,17 @@ 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);
}
Listing::storeColumnListingForUser([Request::get('listing') => $columns]);
return $this->jsonResponse($columns);
private function resetTablelisting()
{
Listing::deleteColumnListingForUser([Request::get('listing') => []]);
return $this->jsonResponse([]);
}
private function editApiKey()

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',

View File

@@ -3,19 +3,35 @@ $(document).ready(function () {
* table columns - manage columns modal
*/
let form = $('#manageColumnsModal form');
form.submit(function (event) {
$.ajax({
url: 'lib/ajax.php?action=tablelisting&listing=' + form.data('listing') + '&theme=' + window.$theme,
url: 'lib/ajax.php?action=updatetablelisting&listing=' + form.data('listing') + '&theme=' + window.$theme,
type : 'POST',
dataType : 'json',
data : form.serialize(),
success : function (result) {
window.location.reload();
success : function () {
window.location.href = '';
},
error: function (xhr, resp, text) {
console.log(xhr, resp, text);
error: function (request) {
alert(request.responseJSON.message);
}
});
event.preventDefault();
});
$('#manageColumnsModal form #reset').click(function () {
$.ajax({
url: 'lib/ajax.php?action=resettablelisting&listing=' + form.data('listing') + '&theme=' + window.$theme,
type : 'POST',
dataType : 'json',
data : {},
success : function () {
window.location.href = '';
},
error: function (request) {
alert(request.responseJSON.message);
}
});
});
});

View File

@@ -7,7 +7,7 @@ import 'chart.js/dist/chart';
global.$ = require('jquery');
global.bootstrap = require('bootstrap');
$(function() {
$(function () {
window.$theme = 'Froxlor';
});

View File

@@ -58,3 +58,8 @@
border-bottom: none;
}
}
.focus-none {
outline: none !important;
box-shadow: none !important;
}

View File

@@ -11,8 +11,8 @@
</div>
{% else %}
<div class="d-flex flex-column align-items-end mt-n2">
<div class="rounded-top bg-white small py-1 px-2 me-3 opacity-75" data-bs-toggle="modal" data-bs-target="#manageColumnsModal">
<i class="fa fa-cog"></i>
<div class="rounded-top bg-white small py-1 px-2 me-3 opacity-75">
<span type="button" data-bs-toggle="modal" data-bs-target="#manageColumnsModal"><i class="fa fa-cog"></i></span>
</div>
</div>
<div class="card table-responsive">
@@ -74,7 +74,7 @@
<p>{{ lng('panel.managetablecolumnsmodal.description') }}</p>
{% for key, column in listing.available_columns %}
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="checkColumn{{ key }}" name="columns[{{ key }}]" {{ column.checked ? 'checked' : '' }}>
<input class="form-check-input" type="checkbox" value="{{ key }}" id="checkColumn{{ key }}" name="columns[{{ key }}]" {{ column.checked ? 'checked' : '' }}>
<label class="form-check-label" for="checkColumn{{ key }}">
{{ column.label }}
</label>
@@ -82,6 +82,7 @@
{% endfor %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="reset">{{ lng('panel.default') }}</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ lng('panel.modalclose') }}</button>
<button type="submit" class="btn btn-primary">{{ lng('panel.save') }}</button>
</div>