diff --git a/ui/site/site.js b/ui/site/site.js index 71f935e..e6f82d7 100644 --- a/ui/site/site.js +++ b/ui/site/site.js @@ -135,3 +135,22 @@ function getUserStartPage() { return userMenu[0].file; } +function showSuccess(msg) { + const st = document.getElementById("status-message"); + if (st) { + st.innerHTML = `
`+ + ``+ + `Success! `+msg+`
`; + $("#success-alert").fadeTo(2000, 500).fadeOut(500); + } +} + +function showError(msg) { + const st = document.getElementById("status-message"); + if (st) { + st.innerHTML = `
`+ + ``+ + `Error! `+msg+`
`; + $("#success-alert").fadeTo(2000, 500).fadeOut(500); + } +} diff --git a/ui/site/user-profile.html b/ui/site/user-profile.html index c3dec26..3320177 100644 --- a/ui/site/user-profile.html +++ b/ui/site/user-profile.html @@ -61,7 +61,7 @@ if (conf["custom_css_link"]) {

Click on a field to edit, when finished click Save.

- +

 
@@ -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);
                     }
                 }
             }