mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: Stop service modal form disabling services for read-only admin (#4994)
This commit is contained in:
committed by
Tony Murray
parent
7061acf508
commit
1acd938fc1
@@ -10,66 +10,67 @@
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
if (is_admin() !== false) {
|
||||
?>
|
||||
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="Delete" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h5 class="modal-title" id="Delete">Confirm Delete</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Please confirm that you would like to delete this service.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<form role="form" class="remove_token_form">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-danger danger" id="service-removal" data-target="service-removal">Delete</button>
|
||||
<input type="hidden" name="service_id" id="service_id" value="">
|
||||
<input type="hidden" name="confirm" id="confirm" value="yes">
|
||||
</form>
|
||||
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="Delete" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h5 class="modal-title" id="Delete">Confirm Delete</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Please confirm that you would like to delete this service.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<form role="form" class="remove_token_form">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-danger danger" id="service-removal"
|
||||
data-target="service-removal">Delete
|
||||
</button>
|
||||
<input type="hidden" name="service_id" id="service_id" value="">
|
||||
<input type="hidden" name="confirm" id="confirm" value="yes">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#confirm-delete').on('show.bs.modal', function(e) {
|
||||
service_id = $(e.relatedTarget).data('service_id');
|
||||
$("#service_id").val(service_id);
|
||||
});
|
||||
<script>
|
||||
$('#confirm-delete').on('show.bs.modal', function (e) {
|
||||
service_id = $(e.relatedTarget).data('service_id');
|
||||
$("#service_id").val(service_id);
|
||||
});
|
||||
|
||||
$('#service-removal').click('', function(e) {
|
||||
e.preventDefault();
|
||||
var service_id = $("#service_id").val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: { type: "delete-service", service_id: service_id },
|
||||
success: function(result){
|
||||
if (result.status == 0) {
|
||||
// Yay.
|
||||
$('#message').html('<div class="alert alert-info">' + result.message + '</div>');
|
||||
$("#row_"+service_id).remove();
|
||||
$("#"+service_id).remove();
|
||||
$("#confirm-delete").modal('hide');
|
||||
}
|
||||
else {
|
||||
// Nay.
|
||||
$("#message").html('<div class="alert alert-danger">'+result.message+'</div>');
|
||||
$("#confirm-delete").modal('hide');
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
$("#message").html('<div class="alert alert-info">An error occurred deleting this service.</div>');
|
||||
$("#confirm-delete").modal('hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
$('#service-removal').click('', function (e) {
|
||||
e.preventDefault();
|
||||
var service_id = $("#service_id").val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax_form.php',
|
||||
data: {type: "delete-service", service_id: service_id},
|
||||
success: function (result) {
|
||||
if (result.status == 0) {
|
||||
// Yay.
|
||||
$('#message').html('<div class="alert alert-info">' + result.message + '</div>');
|
||||
$("#row_" + service_id).remove();
|
||||
$("#" + service_id).remove();
|
||||
$("#confirm-delete").modal('hide');
|
||||
}
|
||||
else {
|
||||
// Nay.
|
||||
$("#message").html('<div class="alert alert-danger">' + result.message + '</div>');
|
||||
$("#confirm-delete").modal('hide');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#message").html('<div class="alert alert-info">An error occurred deleting this service.</div>');
|
||||
$("#confirm-delete").modal('hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user