Skip to content

Commit 46abfde

Browse files
author
Kristan Kenney
committed
Merge branch 'fix/ui-sort-order' into feature/user-roles
2 parents 9a7b443 + c85e69b commit 46abfde

31 files changed

+256
-104
lines changed

bin/v-add-user

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ U_BACKUPS='0'
237237
LANGUAGE=''
238238
THEME=''
239239
NOTIFICATIONS='no'
240+
PREF_UI_SORT='name'
240241
TIME='$time'
241242
DATE='$date'" > $USER_DATA/user.conf
242243
chmod 660 $USER_DATA/user.conf

bin/v-change-user-sort-order

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
# info: updates user role
3+
# options: USER SORT_ORDER
4+
# labels: hestia
5+
#
6+
# example: v-change-user-sort-order user date
7+
#
8+
# Changes web UI display sort order for specified user.
9+
10+
#----------------------------------------------------------#
11+
# Variable&Function #
12+
#----------------------------------------------------------#
13+
14+
# Argument definition
15+
user=$1
16+
sort_order=$2
17+
18+
19+
# Includes
20+
# shellcheck source=/usr/local/hestia/func/main.sh
21+
source $HESTIA/func/main.sh
22+
# shellcheck source=/usr/local/hestia/conf/hestia.conf
23+
source $HESTIA/conf/hestia.conf
24+
# Unset THEME variable from $HESTIA/conf/hestia.conf
25+
unset THEME
26+
27+
28+
#----------------------------------------------------------#
29+
# Verifications #
30+
#----------------------------------------------------------#
31+
32+
# Reading user values
33+
source $USER_DATA/user.conf
34+
35+
is_format_valid 'user' 'theme'
36+
is_object_valid 'user' 'USER' "$user"
37+
38+
is_object_unsuspended 'user' 'USER' "$user"
39+
40+
# Perform verification if read-only mode is enabled
41+
check_hestia_demo_mode
42+
43+
#----------------------------------------------------------#
44+
# Action #
45+
#----------------------------------------------------------#
46+
47+
# Set theme value
48+
check_ckey=$(grep "PREF_UI_SORT" $USER_DATA/user.conf)
49+
if [ -z "$check_ckey" ]; then
50+
# Rebuild user configuration to repair missing value
51+
$BIN/v-rebuild-user $user
52+
fi
53+
update_user_value "$user" '$PREF_UI_SORT' "$sort_order"
54+
55+
#----------------------------------------------------------#
56+
# Hestia #
57+
#----------------------------------------------------------#
58+
59+
exit

bin/v-list-user

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ json_list() {
8080
"LANGUAGE": "'$LANGUAGE'",
8181
"THEME": "'$THEME'",
8282
"NOTIFICATIONS": "'$NOTIFICATIONS'",
83+
"PREF_UI_SORT": "'$PREF_UI_SORT'",
8384
"PHPCLI": "'$PHPCLI'",
8485
"TIME": "'$TIME'",
8586
"DATE": "'$DATE'"

func/rebuild.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ rebuild_user_conf() {
3939
if [ -z "${THEME+x}" ]; then
4040
sed -i "/LANGUAGE/a THEME=''" $USER_DATA/user.conf
4141
fi
42+
if [ -z "${PREF_UI_SORT+x}" ]; then
43+
sed -i "/NOTIFICATIONS/a PREF_UI_SORT='name'" $USER_DATA/user.conf
44+
fi
4245
# Run template trigger
4346
if [ -x "$HESTIA/data/packages/$PACKAGE.sh" ]; then
4447
$HESTIA/data/packages/$PACKAGE.sh "$user" "$CONTACT" "$NAME"

func/syshealth.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function syshealth_update_user_config_format() {
9595
# USER CONFIGURATION
9696
# Create array of known keys in configuration file
9797
system="user"
98-
known_keys=(NAME PACKAGE CONTACT CRON_REPORTS MD5 RKEY TWOFA QRCODE PHPCLI ROLE SUSPENDED SUSPENDED_USERS SUSPENDED_WEB SUSPENDED_DNS SUSPENDED_MAIL SUSPENDED_DB SUSPENDED_CRON IP_AVAIL IP_OWNED U_USERS U_DISK U_DISK_DIRS U_DISK_WEB U_DISK_MAIL U_DISK_DB U_BANDWIDTH U_WEB_DOMAINS U_WEB_SSL U_WEB_ALIASES U_DNS_DOMAINS U_DNS_RECORDS U_MAIL_DKIM U_MAIL_DKIM U_MAIL_ACCOUNTS U_MAIL_DOMAINS U_MAIL_SSL U_DATABASES U_CRON_JOBS U_BACKUPS LANGUAGE THEME NOTIFICATIONS TIME DATE)
98+
known_keys=(NAME PACKAGE CONTACT CRON_REPORTS MD5 RKEY TWOFA QRCODE PHPCLI ROLE SUSPENDED SUSPENDED_USERS SUSPENDED_WEB SUSPENDED_DNS SUSPENDED_MAIL SUSPENDED_DB SUSPENDED_CRON IP_AVAIL IP_OWNED U_USERS U_DISK U_DISK_DIRS U_DISK_WEB U_DISK_MAIL U_DISK_DB U_BANDWIDTH U_WEB_DOMAINS U_WEB_SSL U_WEB_ALIASES U_DNS_DOMAINS U_DNS_RECORDS U_MAIL_DKIM U_MAIL_DKIM U_MAIL_ACCOUNTS U_MAIL_DOMAINS U_MAIL_SSL U_DATABASES U_CRON_JOBS U_BACKUPS LANGUAGE THEME NOTIFICATIONS PREF_UI_SORT TIME DATE)
9999
write_kv_config_file
100100
unset system
101101
unset known_keys

web/css/src/themes/default.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,11 +1333,13 @@ div.l-content > div.l-separator:nth-of-type(4) {
13331333
inset -1px -1px 4px rgba(220,220,220,0.4);
13341334
}
13351335

1336-
.context-menu.sort-order span.name i.fas.fa-sort-amount-down {
1336+
.context-menu.sort-order span.name i.fas.fa-sort-amount-down,
1337+
.context-menu.sort-order span.name i.fas.fa-sort-alpha-down {
13371338
float: right;
13381339
margin-top: 2px;
13391340
}
13401341

1342+
13411343
.context-menu.sort-order li:last-child {
13421344
border-bottom: none;
13431345
}

web/css/themes/default.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/edit/user/index.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
$v_package = $data[$v_username]['PACKAGE'];
4747
$v_language = $data[$v_username]['LANGUAGE'];
4848
$v_user_theme = $data[$v_username]['THEME'];
49+
$v_sort_order = $data[$v_username]['PREF_UI_SORT'];
4950
$v_name = $data[$v_username]['NAME'];
5051
$v_shell = $data[$v_username]['SHELL'];
5152
$v_twofa = $data[$v_username]['TWOFA'];
@@ -165,6 +166,15 @@
165166
$v_qrcode = '';
166167
}
167168

169+
// Change default sort order
170+
if (($v_sort_order != $_POST['v_sort_order']) && (empty($_SESSION['error_msg']))) {
171+
$v_sort_order = escapeshellarg($_POST['v_sort_order']);
172+
exec (HESTIA_CMD."v-change-user-sort-order ".escapeshellarg($v_username)." ".$v_sort_order, $output, $return_var);
173+
check_return_code($return_var,$output);
174+
unset($output);
175+
}
176+
177+
168178
// Change package (admin only)
169179
if (($v_package != $_POST['v_package']) && ($_SESSION['userContext'] === 'admin') && (empty($_SESSION['error_msg']))) {
170180
$v_package = escapeshellarg($_POST['v_package']);

web/js/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ $(document).ready(function(){
120120
VE.tmp.sort_direction = $(this).hasClass('up')*1 || -1;
121121

122122
$('.l-sort .sort-by span b').html($(this).parent('li').find('.name').html());
123-
$('.l-sort .sort-by i').removeClass('fa-sort-amount-up fa-sort-amount-down');
124-
$(this).hasClass('up') ? $('.l-sort .sort-by i').addClass('fa-sort-amount-up') : $('.l-sort .sort-by i').addClass('fa-sort-amount-down');
123+
$('.l-sort .sort-by i').removeClass('fa-sort-alpha-up fa-sort-alpha-down');
124+
$(this).hasClass('up') ? $('.l-sort .sort-by i').addClass('fa-sort-alpha-up') : $('.l-sort .sort-by i').addClass('fa-sort-alpha-down');
125125
$('.units .l-unit').sort(function (a, b) {
126126
if(VE.tmp.sort_as_int)
127127
return parseInt($(a).attr(VE.tmp.sort_par)) >= parseInt($(b).attr(VE.tmp.sort_par)) ? VE.tmp.sort_direction : VE.tmp.sort_direction * -1;

web/templates/admin/edit_user.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@
199199
if ((!empty($_SESSION['userTheme'])) && ( $value == $v_user_theme )) {
200200
echo ' selected' ;
201201
}
202+
if ((empty($v_user_theme) && (!empty($_SESSION['THEME']))) && ( $value == $_SESSION['THEME'] )) {
203+
echo ' selected' ;
204+
}
202205
if ((!empty($_SESSION['userTheme'])) && ( $value == $_POST['v_user_theme'])){
203206
echo ' selected' ;
204207
}
@@ -209,6 +212,19 @@
209212
</td>
210213
</tr>
211214
<?}?>
215+
<tr>
216+
<td class="vst-text input-label">
217+
<?php print _('Default sort order');?>
218+
</td>
219+
</tr>
220+
<tr>
221+
<td>
222+
<select class="vst-list" name="v_sort_order">
223+
<option value='date' <?php if($data[$user]['PREF_UI_SORT'] === '') echo 'selected' ?>><?php print _('Date'); ?></option>
224+
<option value='name' <?php if($data[$user]['PREF_UI_SORT'] === 'name') echo 'selected' ?>><?php print _('Name'); ?></option>
225+
</select>
226+
</td>
227+
</tr>
212228
<tr>
213229
<td class="vst-text input-label">
214230
<?php print _('Package');?>

0 commit comments

Comments
 (0)