mirror of
https://github.com/outbackdingo/databunker.git
synced 2026-01-27 18:18:43 +00:00
display operation status
This commit is contained in:
@@ -135,3 +135,22 @@ function getUserStartPage() {
|
||||
return userMenu[0].file;
|
||||
}
|
||||
|
||||
function showSuccess(msg) {
|
||||
const st = document.getElementById("status-message");
|
||||
if (st) {
|
||||
st.innerHTML = `<div class="alert alert-primary" id="success-alert">`+
|
||||
`<button type="button" class="close" data-dismiss="alert">x</button>`+
|
||||
`<strong>Success! </strong> `+msg+`</div>`;
|
||||
$("#success-alert").fadeTo(2000, 500).fadeOut(500);
|
||||
}
|
||||
}
|
||||
|
||||
function showError(msg) {
|
||||
const st = document.getElementById("status-message");
|
||||
if (st) {
|
||||
st.innerHTML = `<div class="alert alert-warning" id="error-alert">`+
|
||||
`<button type="button" class="close" data-dismiss="alert">x</button>`+
|
||||
`<strong>Error! </strong> `+msg+`</div>`;
|
||||
$("#success-alert").fadeTo(2000, 500).fadeOut(500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ if (conf["custom_css_link"]) {
|
||||
</div>
|
||||
</div>
|
||||
<p id="msg">Click on a field to edit, when finished click Save.</p>
|
||||
<div id="errordiv" class="alert alert-warning" role="alert" style="display:none;"></div>
|
||||
<div id='status-message'></div>
|
||||
<div id="jsoneditor" style="width:100%;height:300px;overflow:auto;"></div>
|
||||
<pre id="data"></pre>
|
||||
|
||||
@@ -153,21 +153,21 @@ if (conf["custom_css_link"]) {
|
||||
xhr0.setRequestHeader("X-Bunker-Token", xtoken)
|
||||
xhr0.setRequestHeader('Content-type', 'application/json');
|
||||
xhr0.onload = function () {
|
||||
$('#errordiv').hide();
|
||||
if (xhr0.status === 200) {
|
||||
var data = JSON.parse(xhr0.responseText);
|
||||
if (data.status == "ok" && data.result && data.result == "request-created") {
|
||||
showAlert("Admin request created to approve changes in your profile.");
|
||||
} else if (data.status == "ok" && data.result && data.result == "request-exists") {
|
||||
showAlert("Similar request already exists for Admin approval.");
|
||||
}
|
||||
} else {
|
||||
showSuccess('Record saved');
|
||||
}
|
||||
} else if (xhr0.status === 403) {
|
||||
document.location = "/";
|
||||
} else {
|
||||
var data = JSON.parse(xhr0.responseText);
|
||||
if (data.status == "error") {
|
||||
$('#errordiv').text(data.message);
|
||||
$('#errordiv').show();
|
||||
showError("Failed to save. "+data.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user