Cleanup + fadeOut deleted cfg

This commit is contained in:
billz 2021-02-07 18:51:21 +00:00
parent 361a37332a
commit c073d18133
2 changed files with 19 additions and 28 deletions

View file

@ -249,22 +249,14 @@ $('#configureClientModal').on('shown.bs.modal', function (e) {
}); });
$('#ovpn-confirm-delete').on('click', '.btn-delete', function (e) { $('#ovpn-confirm-delete').on('click', '.btn-delete', function (e) {
var modalDiv = $(e.delegateTarget);
var cfg_id = $(this).data('recordId'); var cfg_id = $(this).data('recordId');
console.log(cfg_id);
//console.log(modalDiv.parent().find('.js-remove-openvpn-client').attr('data-record-id'));
//console.log(modalDiv.parent().find(
$.post('ajax/openvpn/del_ovpncfg.php',{'cfg_id':cfg_id},function(data){ $.post('ajax/openvpn/del_ovpncfg.php',{'cfg_id':cfg_id},function(data){
jsonData = JSON.parse(data); jsonData = JSON.parse(data);
console.log(jsonData);
//$(this).closest('js-openvpn-client-row').fadeOut(300);
$("#ovpn-confirm-delete").modal('hide'); $("#ovpn-confirm-delete").modal('hide');
if(jsonData['return'] == 0) { var row = $(document.getElementById("openvpn-client-row-" + cfg_id));
// do something row.fadeOut( "slow", function() {
} else if(jsonData['return'] == 2) { row.remove();
// something else });
}
}); });
}); });

View file

@ -1,33 +1,32 @@
<div class="tab-pane fade" id="openvpnconfigs"> <div class="tab-pane fade" id="openvpnconfigs">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md">
<h4 class="mt-3 mb-3"><?php echo _("Configurations"); ?></h4> <h4 class="mt-3 mb-3"><?php echo _("Configurations"); ?></h4>
<p id="openvpnconfigs-description" class="mb-3"> <p id="openvpnconfigs-description" class="mb-3">
<small><?php echo _("Currently available OpenVPN client configurations are displayed below.") ?></small> <small><?php echo _("Currently available OpenVPN client configurations are displayed below.") ?></small>
<br><small class="text-muted"><?php echo _("Activating a configuraton will restart the <code>openvpn-client</code> service.") ?></small> <br><small class="text-muted"><?php echo _("Activating a configuraton will restart the <code>openvpn-client</code> service.") ?></small>
</p> </p>
<div class="openvpn-configs js-openvpn-configs-container"> <div class="openvpn-configs js-openvpn-configs-container">
<?php foreach ($clients as $client) : <?php foreach ($clients as $client) :
if ($client == "login.conf") { if ($client == "login.conf") {
$label = file_get_meta(RASPI_OPENVPN_CLIENT_LOGIN,'#\sfilename\s(.*)'); $label = file_get_meta(RASPI_OPENVPN_CLIENT_LOGIN,'#\sfilename\s(.*)');
$btn_class = "active"; $btn_class = "active";
} else { } else {
$label = trim(pathinfo($client, PATHINFO_FILENAME), "_login"); $label = trim(pathinfo($client, PATHINFO_FILENAME), "_login");
$client = $label; $client = $label;
$btn_class = "disabled"; $btn_class = "disabled";
} }?>
?> <div class="row mt-2" id="openvpn-client-row-<?php echo htmlspecialchars($client, ENT_QUOTES); ?>" >
<div class="row openvpn-client-row js-openvpn-client-row mt-2"> <div class="col-md-6 col-xs-4">
<div class="col-md-6 col-xs-5">
<label><?php echo htmlspecialchars($label, ENT_QUOTES); ?></label> <label><?php echo htmlspecialchars($label, ENT_QUOTES); ?></label>
</div> </div>
<div class="col-md-2 col-xs-2"> <div class="col-md-auto px-lg-3 col-xs-2">
<button type="button" class="btn btn-outline-success <?php echo $btn_class; ?> js-activate-openvpn-client" data-record-id="<?php echo htmlspecialchars($client, ENT_QUOTES); ?>" data-toggle="modal" data-target="#ovpn-confirm-activate" /><i class="far fa-check-circle"></i></button> <button type="button" class="btn btn-outline-success <?php echo $btn_class; ?> js-activate-openvpn-client" data-record-id="<?php echo htmlspecialchars($client, ENT_QUOTES); ?>" data-toggle="modal" data-target="#ovpn-confirm-activate" /><i class="far fa-check-circle"></i></button>
</div> </div>
<div class="col-md-2 col-xs-2"> <div class="col-md-auto col-xs-2">
<button type="button" class="btn btn-outline-danger js-remove-openvpn-client" data-record-id="<?php echo htmlspecialchars($client, ENT_QUOTES); ?>" data-toggle="modal" data-target="#ovpn-confirm-delete" /><i class="far fa-trash-alt"></i></button> <button type="button" class="btn btn-outline-danger js-remove-openvpn-client" data-record-id="<?php echo htmlspecialchars($client, ENT_QUOTES); ?>" data-toggle="modal" data-target="#ovpn-confirm-delete" /><i class="far fa-trash-alt"></i></button>
</div> </div>
</div><!-- ./row openvpn --> </div><!-- ./row openvpn-client -->
<?php endforeach ?> <?php endforeach ?>
</div><!-- /.openvpn-configs --> </div><!-- /.openvpn-configs -->
<div class="mb-3"></div> <div class="mb-3"></div>