Commit 481ff74c authored by Morten Nordseth's avatar Morten Nordseth
Browse files

add feedback on userprofile changes

parent d4a93ece
Pipeline #116522 passed with stages
in 2 minutes and 12 seconds
......@@ -151,11 +151,13 @@ async function getCurrentUser() {
return user;
}
function createAlert(header, data) {
function createAlert(header, data, type) {
let alertDiv = document.createElement("div");
alertDiv.className = "alert alert-warning alert-dismissible fade show"
//alertDiv.className = ""
if(type === "success") alertDiv.className = "alert alert-success alert-dismissible fade show"
else alertDiv.className = "alert alert-warning alert-dismissible fade show"
alertDiv.setAttribute("role", "alert");
let strong = document.createElement("strong");
strong.innerText = header;
alertDiv.appendChild(strong);
......
......@@ -40,8 +40,11 @@ async function updateUser(){
let currentUser = await getCurrentUser();
let response = await sendRequest("PATCH", `${HOST}/api/users/${currentUser.id}/`, userForm, "");
if (response.ok) {
//await fillForm();
window.location.replace("userprofile.html");
let alert = createAlert("Personal information updated!", {}, "success");
document.body.prepend(alert);
setTimeout(() => {
window.location.replace("userprofile.html");
}, 2000);
} else {
let data = await response.json();
let alert = createAlert("Could not update user!", data);
......
.workout {
}
.hide {
display: none !important;
display: none !important;
}
/* Adapted from https://bootsnipp.com/snippets/z8699 START */
.divider-text {
position: relative;
text-align: center;
margin-top: 15px;
margin-bottom: 15px;
position: relative;
text-align: center;
margin-top: 15px;
margin-bottom: 15px;
}
.divider-text span {
padding: 7px;
font-size: 12px;
position: relative;
z-index: 2;
padding: 7px;
font-size: 12px;
position: relative;
z-index: 2;
}
.divider-text:after {
content: "";
position: absolute;
width: 100%;
border-bottom: 1px solid #ddd;
top: 55%;
left: 0;
z-index: 1;
content: "";
position: absolute;
width: 100%;
border-bottom: 1px solid #ddd;
top: 55%;
left: 0;
z-index: 1;
}
.btn-facebook {
background-color: #405D9D;
color: #fff;
background-color: #405d9d;
color: #fff;
}
.btn-twitter {
background-color: #42AEEC;
color: #fff;
background-color: #42aeec;
color: #fff;
}
/* Adapted from https://bootsnipp.com/snippets/z8699 END */
.comment-wrapper .panel-body {
max-height:650px;
overflow:auto;
max-height: 650px;
overflow: auto;
}
.comment-wrapper .media-list .media img {
width:64px;
height:64px;
border:2px solid #e5e7e8;
width: 64px;
height: 64px;
border: 2px solid #e5e7e8;
}
.comment-wrapper .media-list .media {
border-bottom:1px dashed #efefef;
margin-bottom:25px;
border-bottom: 1px dashed #efefef;
margin-bottom: 25px;
}
.entry:not(:first-of-type)
{
.entry:not(:first-of-type) {
margin-top: 10px;
}
.link-block {
display: block;
display: block;
}
......@@ -27,7 +27,7 @@
<div class="col-lg-6"></div>
<div class="col-lg-6">
<label for="inputEmail" class="form-label">Email address</label>
<input type="text" class="form-control" id="inputEmail" name="email" readonly>
<input type="email" class="form-control" id="inputEmail" name="email" readonly>
</div>
<div class="col-lg-6"></div>
<div class="col-lg-6">
......@@ -56,6 +56,7 @@
<input type="button" class="btn btn-secondary hide" id="btn-cancel-profile" value="Cancel">
</div>
<div class="col-lg-6"></div>
<div class="col-lg-6"></div>
</form>
<script src="scripts/defaults.js"></script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment