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