Add gettext strings to model data-message fields, error handling
This commit is contained in:
parent
2499c7a712
commit
13a113f717
|
@ -25,8 +25,9 @@ if (isset($_POST['csrf_token'])) {
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$return = $e->getCode();
|
$return = $e->getCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo json_encode($return);
|
$jsonData = ['return'=>$return];
|
||||||
|
echo json_encode($jsonData);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
handleInvalidCSRFToken();
|
handleInvalidCSRFToken();
|
||||||
|
|
|
@ -20,7 +20,6 @@ function createNetmaskAddr(bitCount) {
|
||||||
function loadSummary(strInterface) {
|
function loadSummary(strInterface) {
|
||||||
$.post('ajax/networking/get_ip_summary.php',{interface:strInterface},function(data){
|
$.post('ajax/networking/get_ip_summary.php',{interface:strInterface},function(data){
|
||||||
jsonData = JSON.parse(data);
|
jsonData = JSON.parse(data);
|
||||||
console.log(jsonData);
|
|
||||||
if(jsonData['return'] == 0) {
|
if(jsonData['return'] == 0) {
|
||||||
$('#'+strInterface+'-summary').html(jsonData['output'].join('<br />'));
|
$('#'+strInterface+'-summary').html(jsonData['output'].join('<br />'));
|
||||||
} else if(jsonData['return'] == 2) {
|
} else if(jsonData['return'] == 2) {
|
||||||
|
@ -323,18 +322,23 @@ $('#ovpn-userpw,#ovpn-certs').on('click', function (e) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#js-system-reset-confirm').on('click', function (e) {
|
$('#js-system-reset-confirm').on('click', function (e) {
|
||||||
var resetHtml = $('#js-system-reset-confirm').attr('data-message');
|
var progressHtml = $('#js-system-reset-confirm').attr('data-message');
|
||||||
var successHtml = $('#js-system-reset-message').attr('data-message');
|
var successHtml = $('#system-reset-message').attr('data-message');
|
||||||
|
var closeHtml = $('#js-system-reset-cancel').attr('data-message');
|
||||||
var csrfToken = $('meta[name=csrf_token]').attr('content');
|
var csrfToken = $('meta[name=csrf_token]').attr('content');
|
||||||
resetHtml += '<i class="fas fa-cog fa-spin ml-2"></i>';
|
progressHtml += '<i class="fas fa-cog fa-spin ml-2"></i>';
|
||||||
$('#system-reset-message').html(resetHtml);
|
$('#system-reset-message').html(progressHtml);
|
||||||
$.post('ajax/networking/do_sys_reset.php?',{'csrf_token':csrfToken},function(data){
|
$.post('ajax/networking/do_sys_reset.php?',{'csrf_token':csrfToken},function(data){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$('#system-reset-message').text('Reset complete. Restart the hotspot for the changes to take effect.');
|
jsonData = JSON.parse(data);
|
||||||
var response = JSON.parse(data);
|
if(jsonData['return'] == 0) {
|
||||||
console.log(response);
|
$('#system-reset-message').text(successHtml);
|
||||||
//$('#system-reset-message').text(responseText);
|
} else {
|
||||||
},1000);
|
$('#system-reset-message').text('Error occured: '+ jsonData['return']);
|
||||||
|
}
|
||||||
|
$("#js-system-reset-confirm").hide();
|
||||||
|
$("#js-system-reset-cancel").text(closeHtml);
|
||||||
|
},750);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -480,7 +484,6 @@ window.addEventListener('load', function() {
|
||||||
// Loop over them and prevent submission
|
// Loop over them and prevent submission
|
||||||
var validation = Array.prototype.filter.call(forms, function(form) {
|
var validation = Array.prototype.filter.call(forms, function(form) {
|
||||||
form.addEventListener('submit', function(event) {
|
form.addEventListener('submit', function(event) {
|
||||||
//console.log(event.submitter);
|
|
||||||
if (form.checkValidity() === false) {
|
if (form.checkValidity() === false) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
@ -42,10 +42,10 @@
|
||||||
<div class="modal-title" id="ModalLabel"><i class="fas fa-history mr-2"></i><?php echo _("System reset"); ?></div>
|
<div class="modal-title" id="ModalLabel"><i class="fas fa-history mr-2"></i><?php echo _("System reset"); ?></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="col-md-12 mb-3 mt-1" id="system-reset-message"><?php echo _("Reset RaspAP to its initial configuration? This action cannot be undone."); ?></div>
|
<div class="col-md-12 mb-3 mt-1" data-message="<?php echo _("Reset complete. Restart the hotspot for the changes to take effect."); ?>" id="system-reset-message"><?php echo _("Reset RaspAP to its initial configuration? This action cannot be undone."); ?></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" id="js-system-reset-cancel" class="btn btn-outline-secondary" data-dismiss="modal"><?php echo _("Cancel"); ?></button>
|
<button type="button" id="js-system-reset-cancel" data-message="<?php echo _("Close"); ?>" class="btn btn-outline-secondary" data-dismiss="modal"><?php echo _("Cancel"); ?></button>
|
||||||
<button type="button" id="js-system-reset-confirm" data-message="<?php echo _("System reset in progress..."); ?>" class="btn btn-outline-danger btn-delete"><?php echo _("Reset"); ?></button>
|
<button type="button" id="js-system-reset-confirm" data-message="<?php echo _("System reset in progress..."); ?>" class="btn btn-outline-danger btn-delete"><?php echo _("Reset"); ?></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue