mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-07 10:55:40 +00:00
Merge pull request #1200 from corubba/feature/modal-consolidation
enh: Consolidate generic modal code
This commit is contained in:
commit
259bd0a906
@ -12,13 +12,7 @@ function applyChanges(data, url, showResult, refreshPage) {
|
|||||||
console.log("Applied changes successfully.");
|
console.log("Applied changes successfully.");
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if (showResult) {
|
if (showResult) {
|
||||||
var modal = $("#modal_success");
|
showSuccessModal(data['msg'] || "Applied changes successfully");
|
||||||
if (data['msg']) {
|
|
||||||
modal.find('.modal-body p').text(data['msg']);
|
|
||||||
} else {
|
|
||||||
modal.find('.modal-body p').text("Applied changes successfully");
|
|
||||||
}
|
|
||||||
modal.modal('show');
|
|
||||||
}
|
}
|
||||||
if (refreshPage) {
|
if (refreshPage) {
|
||||||
location.reload(true);
|
location.reload(true);
|
||||||
@ -27,10 +21,8 @@ function applyChanges(data, url, showResult, refreshPage) {
|
|||||||
|
|
||||||
error : function(jqXHR, status) {
|
error : function(jqXHR, status) {
|
||||||
console.log(jqXHR);
|
console.log(jqXHR);
|
||||||
var modal = $("#modal_error");
|
|
||||||
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||||
modal.find('.modal-body p').text(responseJson['msg']);
|
showErrorModal(responseJson['msg']);
|
||||||
modal.modal('show');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -50,18 +42,14 @@ function applyRecordChanges(data, domain) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
console.log("Applied changes successfully.")
|
console.log("Applied changes successfully.")
|
||||||
var modal = $("#modal_success");
|
showSuccessModal("Applied changes successfully");
|
||||||
modal.find('.modal-body p').text("Applied changes successfully");
|
|
||||||
modal.modal('show');
|
|
||||||
setTimeout(() => {window.location.reload()}, 2000);
|
setTimeout(() => {window.location.reload()}, 2000);
|
||||||
},
|
},
|
||||||
|
|
||||||
error : function(jqXHR, status) {
|
error : function(jqXHR, status) {
|
||||||
console.log(jqXHR);
|
console.log(jqXHR);
|
||||||
var modal = $("#modal_error");
|
|
||||||
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
var responseJson = jQuery.parseJSON(jqXHR.responseText);
|
||||||
modal.find('.modal-body p').text(responseJson['msg']);
|
showErrorModal(responseJson['msg']);
|
||||||
modal.modal('show');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -446,9 +446,7 @@
|
|||||||
|
|
||||||
if(!canSearch)
|
if(!canSearch)
|
||||||
{
|
{
|
||||||
var modal = $("#modal_error");
|
showErrorModal("Please fill out the " + main_field + " field.");
|
||||||
modal.find('.modal-body p').text("Please fill out the " + main_field + " field.");
|
|
||||||
modal.modal('show');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -298,6 +298,18 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function showErrorModal(message) {
|
||||||
|
var modal = $('#modal_error');
|
||||||
|
modal.find('.modal-body p').text(message);
|
||||||
|
modal.modal('show');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSuccessModal(message) {
|
||||||
|
var modal = $("#modal_success");
|
||||||
|
modal.find('.modal-body p').text(message);
|
||||||
|
modal.modal('show');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endassets %}
|
{%- endassets %}
|
||||||
|
@ -251,9 +251,7 @@
|
|||||||
// handle apply changes button
|
// handle apply changes button
|
||||||
$(document.body).on("click",".button_apply_changes", function() {
|
$(document.body).on("click",".button_apply_changes", function() {
|
||||||
if (nNew || nEditing) {
|
if (nNew || nEditing) {
|
||||||
var modal = $("#modal_error");
|
showErrorModal("Previous record not saved. Please save it before applying the changes.");
|
||||||
modal.find('.modal-body p').text("Previous record not saved. Please save it before applying the changes.");
|
|
||||||
modal.modal('show');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,9 +275,7 @@
|
|||||||
// handle add record button
|
// handle add record button
|
||||||
$(document.body).on("click", ".button_add_record", function (e) {
|
$(document.body).on("click", ".button_add_record", function (e) {
|
||||||
if (nNew || nEditing) {
|
if (nNew || nEditing) {
|
||||||
var modal = $("#modal_error");
|
showErrorModal("Previous record not saved. Please save it before adding more record.");
|
||||||
modal.find('.modal-body p').text("Previous record not saved. Please save it before adding more record.");
|
|
||||||
modal.modal('show');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// clear search first
|
// clear search first
|
||||||
|
@ -73,9 +73,7 @@
|
|||||||
$(document.body).on("click", ".button_delete", function(e) {
|
$(document.body).on("click", ".button_delete", function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if ( $("#domainid").val() == 0 ){
|
if ( $("#domainid").val() == 0 ){
|
||||||
var modal = $("#modal_error");
|
showErrorModal("Please select domain to remove.");
|
||||||
modal.find('.modal-body p').text("Please select domain to remove.");
|
|
||||||
modal.modal('show');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,9 +192,7 @@
|
|||||||
// handle apply changes button
|
// handle apply changes button
|
||||||
$(document.body).on("click",".button_apply_changes", function() {
|
$(document.body).on("click",".button_apply_changes", function() {
|
||||||
if (nNew || nEditing) {
|
if (nNew || nEditing) {
|
||||||
var modal = $("#modal_error");
|
showErrorModal("Previous record not saved. Please save it before applying the changes.");
|
||||||
modal.find('.modal-body p').text("Previous record not saved. Please save it before applying the changes.");
|
|
||||||
modal.modal('show');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,9 +215,7 @@
|
|||||||
// handle add record button
|
// handle add record button
|
||||||
$(document.body).on("click", ".button_add_record", function (e) {
|
$(document.body).on("click", ".button_add_record", function (e) {
|
||||||
if (nNew || nEditing) {
|
if (nNew || nEditing) {
|
||||||
var modal = $("#modal_error");
|
showErrorModal("Previous record not saved. Please save it before adding more record.");
|
||||||
modal.find('.modal-body p').text("Previous record not saved. Please save it before adding more record.");
|
|
||||||
modal.modal('show');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// clear search first
|
// clear search first
|
||||||
|
Loading…
Reference in New Issue
Block a user