Skip to content

Commit 3d5ee58

Browse files
committed
Show confirmation dialog when rebooting server; stopping or restarting services
Resolves issue hestiacp#366
1 parent 533425e commit 3d5ee58

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

web/inc/i18n/en.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@
487487
'DELETE_RULE_CONFIRMATION' => 'Are you sure you want to delete rule #%s?',
488488
'SUSPEND_RULE_CONFIRMATION' => 'Are you sure you want to suspend rule #%s?',
489489
'UNSUSPEND_RULE_CONFIRMATION' => 'Are you sure you want to unsuspend rule #%s?',
490+
'Are you sure you want to stop service' => 'Are you sure you want to stop service %s?',
490491
'LEAVE_PAGE_CONFIRMATION' => 'Leave Page?',
491492
'RESTART_CONFIRMATION' => 'Are you sure you want to restart %s?',
492493
'Welcome' => 'Welcome',

web/js/events.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ VE.callbacks.click.do_delete = function(evt, elm) {
9999
VE.helpers.createConfirmationDialog(dialog_elm, '', url);
100100
}
101101

102+
VE.callbacks.click.do_servicerestart = function(evt, elm) {
103+
var ref = elm.hasClass('actions-panel') ? elm : elm.parents('.actions-panel');
104+
var url = $('input[name="servicerestart_url"]', ref).val();
105+
var dialog_elm = ref.find('.confirmation-text-servicerestart');
106+
VE.helpers.createConfirmationDialog(dialog_elm, '', url);
107+
}
108+
109+
VE.callbacks.click.do_servicestop = function(evt, elm) {
110+
var ref = elm.hasClass('actions-panel') ? elm : elm.parents('.actions-panel');
111+
var url = $('input[name="servicestop_url"]', ref).val();
112+
var dialog_elm = ref.find('.confirmation-text-servicestop');
113+
VE.helpers.createConfirmationDialog(dialog_elm, '', url);
114+
}
102115

103116
/*
104117
* Create dialog box on the fly

web/templates/admin/list_services.html

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
<a href="/list/ip/" class="ui-button cancel" title="<?=__('IP')?>"><i class="fas fa-ethernet status-icon blue"></i> <?=__('IP')?></a>
77
<?php if ((isset($_SESSION['FIREWALL_SYSTEM'])) && (!empty($_SESSION['FIREWALL_SYSTEM']))) {?><a href="/list/firewall/" class="ui-button cancel" title="<?=__('Firewall')?>"><i class="fas fa-shield-alt status-icon red"></i> <?=__('Firewall')?></a><?php }?>
88
<a href="/list/updates/" class="ui-button cancel" title="<?=__('Updates')?>"><i class="fas fa-sync status-icon green"></i> <?=__('Updates')?></a>
9-
<a href="/restart/system/?hostname=<?php echo $sys['sysinfo']['HOSTNAME'] ?>&token=<?=$_SESSION['token']?>" class="ui-button danger cancel" title="<?=__('Restart')?>"><i class="fas fa-undo status-icon red"></i> <?=__('Restart')?></a>
9+
<div class="actions-panel display-inline-block" key-action="js">
10+
<a class="data-controls do_servicerestart ui-button danger cancel" title="<?=__('Restart')?>">
11+
<i class="do_servicerestart fas fa-undo status-icon red"></i>
12+
<?=__('Restart')?>
13+
<input type="hidden" name="servicerestart_url" value="/restart/system/?hostname=<?php echo $sys['sysinfo']['HOSTNAME'] ?>&token=<?=$_SESSION['token']?>" />
14+
<div class="confirmation-text-servicerestart hidden" title="<?=__('Confirmation')?>">
15+
<p class="confirmation"><?=__('RESTART_CONFIRMATION', 'Server')?></p>
16+
</div>
17+
</a>
18+
</div>
1019
</div>
1120
<div class="l-sort-toolbar clearfix">
1221
<table>
@@ -106,12 +115,30 @@
106115
</div>
107116
<div class="clearfix l-unit__stat-col--left wide-2"><b><a href="/edit/server/<? echo $key ?>/" title="<?=__('edit')?>"><?=$key?></a></b></div>
108117
<div class="clearfix l-unit__stat-col--left text-center compact-2">
118+
<div class="actions-panel clearfix">
109119
<div class="actions-panel__col actions-panel__edit shortcut-enter" key-action="href">
110120
<a href="/edit/server/<? echo $key ?>/" title="<?=__('edit')?>"><i class="fas fa-pencil-alt status-icon orange status-icon dim icon-large"></i></a>
111121
</div>
112-
<a href="/restart/service/?srv=<?=$key?>&token=<?=$_SESSION['token']?>" title="<?=__('restart')?>"><i class="data-controls fas fa-undo status-icon highlight status-icon dim icon-large"></i></a>
113-
<a href="/<?php echo $action ?>/service/?srv=<?=$key?>&token=<?=$_SESSION['token']?>" title="<?=__($action)?>"><i class="fas fa-pause status-icon red status-icon dim icon-large"></i></a>
122+
<div class="actions-panel__col actions-panel__stop shortcut-s" key-action="js">
123+
<a id="<?=$spnd_action ?>_link_<?=$i?>" class="data-controls do_servicerestart" title="<?=__('restart')?>">
124+
<i class="do_servicerestart data-controls fas fa-undo status-icon highlight status-icon dim icon-large"></i>
125+
<input type="hidden" name="servicerestart_url" value="/restart/service/?srv=<?=$key?>&token=<?=$_SESSION['token']?>" />
126+
<div id="<?=$spnd_action?>_dialog_<?=$i?>" class="confirmation-text-servicerestart hidden" title="<?=__('Confirmation')?>">
127+
<p class="confirmation"><?=__('RESTART_CONFIRMATION',$key)?></p>
128+
</div>
129+
</a>
130+
</div>
131+
<div class="actions-panel__col actions-panel__delete shortcut-delete" key-action="js">
132+
<a id="delete_link_<?=$i?>" class="data-controls do_servicestop" title="<?=__($action)?>">
133+
<i class="do_servicestop fas fa-pause status-icon red status-icon dim icon-large"></i>
134+
<input type="hidden" name="servicestop_url" value="/<?php echo $action ?>/service/?srv=<?=$key?>&token=<?=$_SESSION['token']?>" />
135+
<div id="delete_dialog_<?=$i?>" class="confirmation-text-servicestop hidden" title="<?=__('Confirmation')?>">
136+
<p class="confirmation"><?=__('Are you sure you want to stop service',$key)?></p>
137+
</div>
138+
</a>
139+
</div>
114140
</div>
141+
</div>
115142
<div class="clearfix l-unit__stat-col--left wide-3"><?=__($data[$key]['SYSTEM'])?></div>
116143
<div class="clearfix l-unit__stat-col--left text-center"><b><?=humanize_time($data[$key]['RTIME'])?></b></div>
117144
<div class="clearfix l-unit__stat-col--left text-center"><b><?=$cpu?></b></div>

0 commit comments

Comments
 (0)