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

View File

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

View File

@@ -52,6 +52,80 @@ return [
'label' => $lng['domains']['aliasdomain'], 'label' => $lng['domains']['aliasdomain'],
'field' => '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', [ 'visible_columns' => Listing::getVisibleColumnsForListing('domain_list', [
'd.domain_ace', 'd.domain_ace',

View File

@@ -3,19 +3,35 @@ $(document).ready(function () {
* table columns - manage columns modal * table columns - manage columns modal
*/ */
let form = $('#manageColumnsModal form'); let form = $('#manageColumnsModal form');
form.submit(function (event) { form.submit(function (event) {
$.ajax({ $.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', type : 'POST',
dataType : 'json', dataType : 'json',
data : form.serialize(), data : form.serialize(),
success : function (result) { success : function () {
window.location.reload(); window.location.href = '';
}, },
error: function (xhr, resp, text) { error: function (request) {
console.log(xhr, resp, text); alert(request.responseJSON.message);
} }
}); });
event.preventDefault(); 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.$ = require('jquery');
global.bootstrap = require('bootstrap'); global.bootstrap = require('bootstrap');
$(function() { $(function () {
window.$theme = 'Froxlor'; window.$theme = 'Froxlor';
}); });

View File

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

View File

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