covas-bo/web/js/users.js

29 lines
994 B
JavaScript
Raw Normal View History

2022-08-04 00:03:57 +02:00
checkToken();
2022-08-05 21:20:14 +02:00
signOut();
2022-08-05 23:39:15 +02:00
var id = getQuery("id");
2022-08-05 21:20:14 +02:00
2022-08-05 23:39:15 +02:00
if(id.length > 0){
instance.get("users/"+id, {withCredentials: true})
.then(function(response){
2022-08-05 23:56:26 +02:00
var listValue = [ "id", "pseudo", "name", "firstName", "email", "birth"];
2022-08-05 23:39:15 +02:00
for (var i=0; i<listValue.length; i++){
document.getElementById(listValue[i]+"UpdateInput").value=response.data[listValue[i]];
}
2022-08-05 23:56:26 +02:00
var listSelector = ["roles", "status"];
for (var i=0; i<listSelector.length; i++){
var select = document.getElementById(listSelector[i]+"Selector").querySelectorAll("option");
for (var j=0; j<select.length; j++){
if(select[j].value == response.data[listSelector[i]]){
select[j].setAttribute("selected", true);
}
}
}
2022-08-05 23:39:15 +02:00
})
.catch(function(error){
console.log(error);
2022-08-05 21:20:14 +02:00
2022-08-05 23:39:15 +02:00
});
}