Skip to content

Commit 27c0aa4

Browse files
author
Kristan Kenney
authored
Merge pull request hestiacp#998 from hestiacp/fix/dns-ui-fixes
Fix/dns ui fixes
2 parents 32a4516 + 85c6b70 commit 27c0aa4

File tree

6 files changed

+89
-33
lines changed

6 files changed

+89
-33
lines changed

bin/v-change-dns-record

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,17 @@ check_hestia_demo_mode
5858
line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
5959
parse_object_kv_list "$line"
6060

61+
if [ -z $type ]; then
62+
type=$TYPE
63+
fi
64+
6165
# Null priority for none MX/SRV records
62-
if [ "$TYPE" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then
66+
if [ "$type" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then
6367
priority=''
6468
fi
6569

6670
# Add trailing dot at the end of NS/CNAME/MX/PTR/SRV record
67-
if [[ $TYPE =~ NS|CNAME|MX|PTR|SRV ]]; then
71+
if [[ $type =~ NS|CNAME|MX|PTR|SRV ]]; then
6872
trailing_dot=$(echo $dvalue | grep "\.$")
6973
if [ -z $trailing_dot ]; then
7074
dvalue="$dvalue."

web/add/dns/index.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@
123123
$v_val = escapeshellarg($_POST['v_val']);
124124
$v_priority = escapeshellarg($_POST['v_priority']);
125125
$v_ttl = escapeshellarg($_POST['v_ttl']);
126-
127126
// Add dns record
128127
if (empty($_SESSION['error_msg'])) {
129128
exec (HESTIA_CMD."v-add-dns-record ".$user." ".$v_domain." ".$v_rec." ".$v_type." ".$v_val." ".$v_priority." '' false ".$v_ttl, $output, $return_var);
130129
check_return_code($return_var,$output);
131130
unset($output);
132-
$v_type = $_POST['v_type'];
131+
133132
}
134-
133+
$v_type = $_POST['v_type'];
134+
135135
// Flush field values on success
136136
if (empty($_SESSION['error_msg'])) {
137137
$_SESSION['ok_msg'] = __('DNS_RECORD_CREATED_OK',htmlentities($_POST['v_rec']),htmlentities($_POST['v_domain']));
@@ -179,8 +179,10 @@
179179
render_page($user, $TAB, 'add_dns');
180180
} else {
181181
// Display body for dns record
182-
183182
$v_domain = $_GET['domain'];
183+
if (empty($v_rec)){
184+
$v_rec = '@';
185+
}
184186
render_page($user, $TAB, 'add_dns_rec');
185187
}
186188

web/js/pages/edit_dns_rec.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
//
3+
// Updates database dns record dynamically, showing its full domain path
4+
App.Actions.DB.update_dns_record_hint = function(elm, hint) {
5+
// clean hint
6+
if (hint.trim() == '') {
7+
$(elm).parent().find('.hint').html('');
8+
}
9+
10+
// set domain name without rec in case of @ entries
11+
if (hint == '@') {
12+
hint = '';
13+
}
14+
15+
// dont show pregix if domain name = rec value
16+
if (hint == GLOBAL.DNS_REC_PREFIX + '.') {
17+
hint = '';
18+
}
19+
20+
// add dot at the end if needed
21+
if (hint != '' && hint.slice(-1) != '.') {
22+
hint += '.';
23+
}
24+
25+
$(elm).parent().find('.hint').text(hint + GLOBAL.DNS_REC_PREFIX);
26+
}
27+
28+
//
29+
// listener that triggers dns record name hint updating
30+
App.Listeners.DB.keypress_dns_rec_entry = function() {
31+
var ref = $('input[name="v_rec"]');
32+
var current_rec = ref.val();
33+
if (current_rec.trim() != '') {
34+
App.Actions.DB.update_dns_record_hint(ref, current_rec);
35+
}
36+
37+
ref.bind('keypress input', function(evt) {
38+
clearTimeout(window.frp_usr_tmt);
39+
window.frp_usr_tmt = setTimeout(function() {
40+
var elm = $(evt.target);
41+
App.Actions.DB.update_dns_record_hint(elm, $(elm).val());
42+
}, 100);
43+
});
44+
}
45+
46+
//
47+
// Page entry point
48+
// Trigger listeners
49+
App.Listeners.DB.keypress_dns_rec_entry();

web/templates/admin/add_dns_rec.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@
7575
<select class="vst-list" name="v_type">
7676
<option value="A" <?php if ($v_type == 'A') echo selected; ?>>A</option>
7777
<option value="AAAA" <?php if ($v_type == 'AAAA') echo selected; ?>>AAAA</option>
78-
<option value="NS" <?php if ($v_type == 'NS') echo selected; ?>>NS</option>
78+
<option value="CAA" <?php if ($v_type == 'CAA') echo selected; ?>>CAA</option>
7979
<option value="CNAME" <?php if ($v_type == 'CNAME') echo selected; ?>>CNAME</option>
80-
<option value="MX" <?php if ($v_type == 'MX') echo selected; ?>>MX</option>
81-
<option value="TXT" <?php if ($v_type == 'TXT') echo selected; ?>>TXT</option>
82-
<option value="SRV" <?php if ($v_type == 'SRV') echo selected; ?>>SRV</option>
8380
<option value="DNSKEY" <?php if ($v_type == 'DNSKEY') echo selected; ?>>DNSKEY</option>
84-
<option value="KEY" <?php if ($v_type == 'KEY') echo selected; ?>>KEY</option>
8581
<option value="IPSECKEY" <?php if ($v_type == 'IPSECKEY') echo selected; ?>>IPSECKEY</option>
82+
<option value="KEY" <?php if ($v_type == 'KEY') echo selected; ?>>KEY</option>
83+
<option value="MX" <?php if ($v_type == 'MX') echo selected; ?>>MX</option>
84+
<option value="NS" <?php if ($v_type == 'NS') echo selected; ?>>NS</option>
8685
<option value="PTR" <?php if ($v_type == 'PTR') echo selected; ?>>PTR</option>
8786
<option value="SPF" <?php if ($v_type == 'SPF') echo selected; ?>>SPF</option>
87+
<option value="SRV" <?php if ($v_type == 'SRV') echo selected; ?>>SRV</option>
8888
<option value="TLSA" <?php if ($v_type == 'TLSA') echo selected; ?>>TLSA</option>
89-
<option value="CAA" <?php if ($v_type == 'CAA') echo selected; ?>>CAA</option>
89+
<option value="TXT" <?php if ($v_type == 'TXT') echo selected; ?>>TXT</option>
9090
</select>
9191
</td>
9292
</tr>

web/templates/admin/edit_dns_rec.html

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<td>
7474
<input type="text" size="20" class="vst-input" name="v_rec" value="<?=htmlentities(trim($v_rec, "'"))?>">
7575
<input type="hidden" name="v_record_id" value="<?=htmlentities($v_record_id)?>">
76+
<small class="hint"></small>
7677
</td>
7778
</tr>
7879
<tr>
@@ -85,18 +86,18 @@
8586
<select class="vst-list" name="v_type">
8687
<option value="A" <?php if ($v_type == 'A') echo selected; ?>>A</option>
8788
<option value="AAAA" <?php if ($v_type == 'AAAA') echo selected; ?>>AAAA</option>
88-
<option value="NS" <?php if ($v_type == 'NS') echo selected; ?>>NS</option>
89+
<option value="CAA" <?php if ($v_type == 'CAA') echo selected; ?>>CAA</option>
8990
<option value="CNAME" <?php if ($v_type == 'CNAME') echo selected; ?>>CNAME</option>
90-
<option value="MX" <?php if ($v_type == 'MX') echo selected; ?>>MX</option>
91-
<option value="TXT" <?php if ($v_type == 'TXT') echo selected; ?>>TXT</option>
92-
<option value="SRV" <?php if ($v_type == 'SRV') echo selected; ?>>SRV</option>
9391
<option value="DNSKEY" <?php if ($v_type == 'DNSKEY') echo selected; ?>>DNSKEY</option>
94-
<option value="KEY" <?php if ($v_type == 'KEY') echo selected; ?>>KEY</option>
9592
<option value="IPSECKEY" <?php if ($v_type == 'IPSECKEY') echo selected; ?>>IPSECKEY</option>
93+
<option value="KEY" <?php if ($v_type == 'KEY') echo selected; ?>>KEY</option>
94+
<option value="MX" <?php if ($v_type == 'MX') echo selected; ?>>MX</option>
95+
<option value="NS" <?php if ($v_type == 'NS') echo selected; ?>>NS</option>
9696
<option value="PTR" <?php if ($v_type == 'PTR') echo selected; ?>>PTR</option>
9797
<option value="SPF" <?php if ($v_type == 'SPF') echo selected; ?>>SPF</option>
98+
<option value="SRV" <?php if ($v_type == 'SRV') echo selected; ?>>SRV</option>
9899
<option value="TLSA" <?php if ($v_type == 'TLSA') echo selected; ?>>TLSA</option>
99-
<option value="CAA" <?php if ($v_type == 'CAA') echo selected; ?>>CAA</option>
100+
<option value="TXT" <?php if ($v_type == 'TXT') echo selected; ?>>TXT</option>
100101
</select>
101102
</td>
102103
</tr>
@@ -139,14 +140,9 @@
139140
<input type="text" size="20" class="vst-input" name="v_ttl" value="<?=htmlentities(trim($v_ttl, "'"))?>">
140141
</td>
141142
</tr>
142-
<tr>
143-
<td class="vst-text input-label">
144-
<?php print __('Record Number');?> <span class="optional">(<?=__('internal');?>)</span>
145-
</td>
146-
</tr>
147143
<tr>
148144
<td>
149-
<input type="text" size="20" class="vst-input" name="v_record_id" value="<?=htmlentities(trim($v_record_id, "'"))?>">
145+
<input type="hidden" size="20" class="vst-input" name="v_record_id" value="<?=htmlentities(trim($v_record_id, "'"))?>">
150146
</td>
151147
</tr>
152148
</table>
@@ -156,3 +152,6 @@
156152
</table>
157153
</form>
158154
</div>
155+
<script>
156+
GLOBAL.DNS_REC_PREFIX = <?=json_encode($_GET['domain'])?>;
157+
</script>

web/templates/admin/list_dns_rec.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@
4444
<input id="toggle-all" type="checkbox" name="toggle-all" value="toggle-all" onChange="checkedAll('objects');">
4545
</div>
4646
<div class="clearfix l-unit__stat-col--left small"><b><?php print __('Record');?></b></div>
47-
<div class="clearfix l-unit__stat-col--left compact text-right"><b>&nbsp;</b></div>
48-
<div class="clearfix l-unit__stat-col--left compact text-center"><b><?php print __('Type');?></b></div>
49-
<div class="clearfix l-unit__stat-col--left compact"><b><?php print __('Priority');?></b></div>
50-
<div class="clearfix l-unit__stat-col--left compact"><b><?php print __('TTL');?></b></div>
47+
<div class="clearfix l-unit__stat-col--left super-compact text-right"><b>&nbsp;</b></div>
48+
<div class="clearfix l-unit__stat-col--left compact text-center" style="padding-left: 32px;"><b><?php print __('Type');?></b></div>
49+
<div class="clearfix l-unit__stat-col--left compact text-center"><b><?php print __('Priority');?></b></div>
50+
<div class="clearfix l-unit__stat-col--left compact text-center"><b><?php print __('TTL');?></b></div>
51+
<div class="clearfix l-unit__stat-col--left super-compact"><b>&nbsp;</b></div>
5152
<div class="clearfix l-unit__stat-col--left wide-6"><b><?php print __('IP or Value');?></b></div>
5253
</div>
5354
</div>
@@ -74,7 +75,7 @@
7475
</div>
7576
<div class="clearfix l-unit__stat-col--left small"><b><a href="/edit/dns/?domain=<?=htmlspecialchars($_GET['domain'])?>&record_id=<?=$data[$key]['ID']?>&token=<?=$_SESSION['token']?>" title="<?=__('Editing DNS Record').': '.htmlspecialchars($data[$key]['RECORD'])?>"><? echo substr($data[$key]['RECORD'], 0, 12); if(strlen($data[$key]['RECORD']) > 12 ) echo '...'; ?></a></b></div>
7677
<!-- START QUICK ACTION TOOLBAR AREA -->
77-
<div class="clearfix l-unit__stat-col--left compact text-right">
78+
<div class="clearfix l-unit__stat-col--left super-compact text-right">
7879
<div class="l-unit-toolbar__col l-unit-toolbar__col--right noselect">
7980
<div class="actions-panel clearfix">
8081
<div class="actions-panel__col actions-panel__logs shortcut-enter" key-action="href"><a href="/edit/dns/?domain=<?=htmlspecialchars($_GET['domain'])?>&record_id=<?=$data[$key]['ID']?>&token=<?=$_SESSION['token']?>" title="<?=__('Editing DNS Record')?>"><i class="fas fa-pencil-alt status-icon orange status-icon dim"></i></a></div>
@@ -91,10 +92,11 @@
9192
</div>
9293
</div>
9394
<!-- END QUICK ACTION TOOLBAR AREA -->
94-
<div class="clearfix l-unit__stat-col--left compact text-center"><b><?=$data[$key]['TYPE']?></b></div>
95-
<div class="clearfix l-unit__stat-col--left compact"><?=$data[$key]['PRIORITY']?>&nbsp;</div>
96-
<div class="clearfix l-unit__stat-col--left compact"><?php if($data[$key]['TTL'] == ''){ echo __('Default'); }else{ echo $data[$key]['TTL'];} ?></div>
97-
<div class="clearfix l-unit__stat-col--left wide-6"><?=htmlspecialchars($data[$key]['VALUE'], ENT_QUOTES, 'UTF-8')?></div>
95+
<div class="clearfix l-unit__stat-col--left compact text-center" style="padding-left: 32px;"><b><?=$data[$key]['TYPE']?></b></div>
96+
<div class="clearfix l-unit__stat-col--left compact text-center"><?=$data[$key]['PRIORITY']?>&nbsp;</div>
97+
<div class="clearfix l-unit__stat-col--left compact text-center"><?php if($data[$key]['TTL'] == ''){ echo __('Default'); }else{ echo $data[$key]['TTL'];} ?></div>
98+
<div class="clearfix l-unit__stat-col--left super-compact"><b>&nbsp;</b></div>
99+
<div class="clearfix l-unit__stat-col--left wide-6" style="word-break: break-word;"><?=htmlspecialchars($data[$key]['VALUE'], ENT_QUOTES, 'UTF-8')?></div>
98100
</div>
99101
</div>
100102
<?}?>

0 commit comments

Comments
 (0)