forked from v4l3n71n/covas-bo
update user
This commit is contained in:
parent
acd1b36eb0
commit
d4ef85c7aa
@ -150,7 +150,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="alert alert-danger alert-dismissible hidden" id="pseudoAlert" role="alert">
|
||||
<div class="alert alert-danger alert-dismissible hidden" id="usernameAlert" role="alert">
|
||||
<div>Champ pseudo vide</div>
|
||||
<button type="button" class="btn-close" aria-label="Close"></button>
|
||||
</div>
|
||||
@ -180,8 +180,8 @@
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="pseudoUpdate">Pseudo</span>
|
||||
<input id="pseudoUpdateInput" type="text" class="form-control" placeholder="Pseudo" aria-label="Pseudo" aria-describedby="pseudoUpdate">
|
||||
<span class="input-group-text" id="usernameUpdate">Pseudo</span>
|
||||
<input id="usernameUpdateInput" type="text" class="form-control" placeholder="Pseudo" aria-label="Pseudo" aria-describedby="usernameUpdate">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
|
@ -6,7 +6,7 @@ var id = getQuery("id");
|
||||
if(id.length > 0){
|
||||
instance.get("users/"+id, {withCredentials: true})
|
||||
.then(function(response){
|
||||
var listValue = [ "id", "pseudo", "name", "firstName", "email", "birth"];
|
||||
var listValue = [ "id", "username", "name", "firstName", "email", "birth"];
|
||||
var listTime = ["connected_at", "created_at", "updated_at", "deleted_at"];
|
||||
for (var i=0; i<listValue.length; i++){
|
||||
if(response.data[listValue[i]] != null){
|
||||
@ -64,7 +64,7 @@ if(id.length > 0){
|
||||
switch(e.currentTarget.id){
|
||||
case "disableUserButton":
|
||||
httpMethod = "delete";
|
||||
httpUrl = "users/disable/"+idInput;
|
||||
httpUrl = "users/"+idInput;
|
||||
break;
|
||||
case "removeUserButton":
|
||||
httpMethod = "delete";
|
||||
@ -101,7 +101,7 @@ if(id.length > 0){
|
||||
|
||||
|
||||
document.getElementById("updateUserButton").addEventListener("click", function(){
|
||||
var updateProfil = ["id", "pseudo", "email", "firstName", "birth"];
|
||||
var updateProfil = ["id", "username", "email", "firstName", "birth"];
|
||||
var updateOk = true;
|
||||
for (var i=0; i<updateProfil.length; i++){
|
||||
if(document.getElementById(updateProfil[i]+"UpdateInput").value.length == 0){
|
||||
@ -124,7 +124,7 @@ if(id.length > 0){
|
||||
dataPut = {
|
||||
|
||||
"id": id,
|
||||
"pseudo": document.getElementById("pseudoUpdateInput").value,
|
||||
"username": document.getElementById("usernameUpdateInput").value,
|
||||
"email": document.getElementById("emailUpdateInput").value,
|
||||
"name": document.getElementById("nameUpdateInput").value,
|
||||
"firstName": document.getElementById("firstNameUpdateInput").value,
|
||||
@ -139,8 +139,8 @@ if(id.length > 0){
|
||||
|
||||
}
|
||||
instance({
|
||||
method : "patch",
|
||||
url:"users/"+id,
|
||||
method : "put",
|
||||
url:"users",
|
||||
withCredentials: true,
|
||||
data: dataPut
|
||||
}).then(function(response){
|
||||
|
@ -97,7 +97,7 @@ instance.get("users", {withCredentials: true, params :param}).then(function(resp
|
||||
var trAll = document.querySelectorAll("#users tbody tr")
|
||||
td = trAll[i].querySelectorAll("td");
|
||||
td[0].textContent = listData[i].id;
|
||||
td[1].textContent = listData[i].pseudo;
|
||||
td[1].textContent = listData[i].username;
|
||||
td[2].textContent = listData[i].email;
|
||||
td[3].textContent = listData[i].roles;
|
||||
var classTd = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user