Suppression des retours vers la cible lors de 'création'/'modification' pour les pages 'users', 'machines', 'groups'

This commit is contained in:
xdrm-brackets 2016-07-24 00:03:02 +02:00
parent 2889114b28
commit 9977bcd695
8 changed files with 143 additions and 55 deletions

View File

@ -1,4 +1,4 @@
// TODO: Attendre que API soit chargée, sinon erreur, le CONTAINER prend comme contenu la dépendance JS
// TODO: Attendre que API soit chargée, sinon erreur: le CONTAINER prend comme contenu la dépendance JS
DOM = {
WRAPPER: $('WRAPPER'),
HEADER: $('HEADER'),

View File

@ -148,12 +148,13 @@
=========================================================*/
$deleted = Table::get('machine')
->whereId($id_machine)
->whereIdWarehouse($id_warehouse);
->whereIdWarehouse($id_warehouse)
->delete();
/* [2] On verifie que la machine est bien supprimée
=========================================================*/
return $delete->delete();
return $deleted;
}

13
view/js/groups-min.js vendored
View File

@ -6,20 +6,21 @@ if(null!=section.view.element){1<pageManager.vars.length&&/^(u|m)\d+$/.test(page
a[b].addClass("hidden")}})},!1);var i;for(i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("cluster");navSubMenu("edit");document.location=""},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("cluster");navSubMenu("remove");document.location=""},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",
function(a){var c=a.target.getData("cluster")[0],d=a.target.getData("cluster").slice(1);console.log(a.target);var b={};b.path="u"==c?"userDefault/unlink":"machineDefault/unlink";b.id_cluster=d;"u"==c?b.id_user=a.target.getData("member"):b.id_machine=a.target.getData("member");api.send(b,function(b){if(0!=b.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1);for(i=0;i<section.view.group.add.length;i++)section.view.group.add[i].addEventListener("click",function(a){pageManager.vars[1]=
a.target.getData("cluster");navSubMenu("members");document.location=""},!1)}
null!=section.create.element&&(section.create.input={name:document.querySelector(section.create.text+"#create_name"),"class":document.querySelector(section.create.text+"#create_class"),submit:document.querySelector(section.create.text+"#create_submit")},section.create.input.submit.addEventListener("click",function(a){a.preventDefault();var c={path:"clusterDefault/create",name:section.create.input.name.value,"class":section.create.input["class"].value};api.send(c,function(a){0==a.ModuleError&&(console.log("Groupe cree!"),
pageManager.vars[1]=(0==c["class"]?"u":"m")+a.id_cluster,navSubMenu("view"),document.location="",section.create.input.submit.anim("active",1500))})},!1));
null!=section.create.element&&(section.create.input={name:document.querySelector(section.create.text+"#create_name"),"class":document.querySelector(section.create.text+"#create_class"),submit:document.querySelector(section.create.text+"#create_submit")},section.create.input.submit.addEventListener("click",function(a){a.preventDefault();api.send({path:"clusterDefault/create",name:section.create.input.name.value,"class":section.create.input["class"].value},function(a){0==a.ModuleError&&(console.log("Groupe cree!"),
section.create.input.submit.anim("active",1500),section.create.input.name.value="",section.create.input["class"].children[0].selected="selected")})},!1));
if(null!=section.remove.element){var autofill_remove=function(){var a="",c="",d="",b=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(found_remove[searchindex_remove].hasOwnProperty("id_user_cluster")?(a=found_remove[searchindex_remove].id_user_cluster,c=0):(a=found_remove[searchindex_remove].id_machine_cluster,c=1),d=found_remove[searchindex_remove].name,b=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=
a;section.remove.input.name.value=d;section.remove.input["class"].value=0==c?"utilisateur":"machine";section.remove.input.submit.disabled=b};section.remove.input={search:{view:document.querySelector(section.remove.text+".remove_search_view"),num:document.querySelector(section.remove.text+".remove_search_num"),sum:document.querySelector(section.remove.text+".remove_search_sum"),keyword:document.querySelector(section.remove.text+"#remove_search_keyword"),id:document.querySelector(section.remove.text+
"#remove_search_id"),submit:document.querySelector(section.remove.text+"#remove_search_submit")},name:document.querySelector(section.remove.text+"#remove_name"),"class":document.querySelector(section.remove.text+"#remove_class"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastkeywords_remove="",found_remove=[],searchindex_remove=0;if(2<=pageManager.vars.length&&/^(u|m)\d+$/.test(pageManager.vars[1])){var prefix=pageManager.vars[1][0],cluster=pageManager.vars[1].slice(1),
request={path:"clusterDefault/getById",id_cluster:cluster,"class":"u"==prefix?0:1};api.send(request,function(a){0==a.ModuleError&&(found_remove=[a.cluster],searchindex_remove=0,autofill_remove())})}section.remove.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.remove.input.search.keyword.value)if(section.remove.input.search.keyword.value==lastkeywords_remove)searchindex_remove=(searchindex_remove+1)%found_remove.length,autofill_remove();else{var c={path:"clusterDefault/search",
keywords:section.remove.input.search.keyword.value};api.send(c,function(a){0==a.ModuleError&&(section.remove.input.search.submit.anim("active",1E3),searchindex_remove=0,found_remove=a.clusters,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove());lastkeywords_remove=c.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&(a=found_remove[searchindex_remove].hasOwnProperty("id_user_cluster")?
0:1,api.send({path:"clusterDefault/delete",id_cluster:section.remove.input.search.id.value,"class":a},function(a){0==a.ModuleError&&1==a.status?(console.log("Groupe supprimee!"),section.remove.input.submit.anim("active",1500),pageManager.vars[1]="",navSubMenu("view"),document.location=""):console.error("ModuleError::"+a.ModuleError)}))},!1)}
if(null!=section.edit.element){var autofill_edit=function(){var a="",c="",d=!0;if(null==found_edit[searchindex_edit])searchindex_edit=section.edit.input.search.num.innerHTML=0;else{var b;found_edit[searchindex_remove].hasOwnProperty("id_user_cluster")?(a=found_edit[searchindex_remove].id_user_cluster,b=0):(a=found_edit[searchindex_remove].id_machine_cluster,b=1);c=found_edit[searchindex_remove].name;d=!1;section.edit.input.search.num.innerHTML=searchindex_edit+1}section.edit.input.search.id.value=
a;section.edit.input.name.value=c;section.edit.input["class"].value=0==b?"utilisateur":"machine";section.edit.input.submit.disabled=d};section.edit.input={search:{view:document.querySelector(section.edit.text+".edit_search_view"),num:document.querySelector(section.edit.text+".edit_search_num"),sum:document.querySelector(section.edit.text+".edit_search_sum"),keyword:document.querySelector(section.edit.text+"#edit_search_keyword"),id:document.querySelector(section.edit.text+"#edit_search_id"),submit:document.querySelector(section.edit.text+
0:1,api.send({path:"clusterDefault/delete",id_cluster:section.remove.input.search.id.value,"class":a},function(a){0==a.ModuleError&&1==a.status?(console.log("Groupe supprimee!"),section.remove.input.submit.anim("active",1500),api.send({path:"clusterDefault/search",keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&(searchindex_remove=0,found_remove=a.clusters,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove())})):console.error("ModuleError::"+
a.ModuleError)}))},!1)}
if(null!=section.edit.element){var autofill_edit=function(){var a="",c="",d=!0;if(null==found_edit[searchindex_edit])searchindex_edit=section.edit.input.search.num.innerHTML=0;else{var b;found_edit[searchindex_remove].hasOwnProperty("id_user_cluster")?(a=found_edit[searchindex_remove].id_user_cluster,b=0):(a=found_edit[searchindex_remove].id_machine_cluster,b=1);c=found_edit[searchindex_remove].name;d=!1;section.edit.input.search.num.innerHTML=searchindex_edit+1}section.edit.input.search.id.value=a;
section.edit.input.name.value=c;section.edit.input["class"].value=0==b?"utilisateur":"machine";section.edit.input.submit.disabled=d};section.edit.input={search:{view:document.querySelector(section.edit.text+".edit_search_view"),num:document.querySelector(section.edit.text+".edit_search_num"),sum:document.querySelector(section.edit.text+".edit_search_sum"),keyword:document.querySelector(section.edit.text+"#edit_search_keyword"),id:document.querySelector(section.edit.text+"#edit_search_id"),submit:document.querySelector(section.edit.text+
"#edit_search_submit")},name:document.querySelector(section.edit.text+"#edit_name"),"class":document.querySelector(section.edit.text+"#edit_class"),submit:document.querySelector(section.edit.text+"#edit_submit")};var lastkeywords_edit="",found_edit=[],searchindex_edit=0;2<=pageManager.vars.length&&/^(u|m)\d+$/.test(pageManager.vars[1])&&(prefix=pageManager.vars[1][0],cluster=pageManager.vars[1].slice(1),request={path:"clusterDefault/getById",id_cluster:cluster,"class":"u"==prefix?0:1},api.send(request,
function(a){0==a.ModuleError&&(found_edit=[a.cluster],searchindex_edit=0,autofill_edit())}));section.edit.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.keyword.value)if(section.edit.input.search.keyword.value==lastkeywords_edit)searchindex_edit=(searchindex_edit+1)%found_edit.length,autofill_edit();else{var c={path:"clusterDefault/search",keywords:section.edit.input.search.keyword.value};api.send(c,function(a){0==a.ModuleError&&(section.edit.input.search.submit.anim("active",
1E3),searchindex_edit=0,found_edit=a.clusters,section.edit.input.search.sum.innerHTML=found_edit.length,autofill_edit());lastkeywords_edit=c.keywords})}},!1);section.edit.input.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.id.value){var c=found_edit[searchindex_edit].hasOwnProperty("id_user_cluster")?0:1,d={path:"clusterDefault/edit",id_cluster:section.edit.input.search.id.value,name:section.edit.input.name.value,"class":c};api.send(d,function(a){0==
a.ModuleError&&1==a.status?(console.log("Groupe modifiee!"),section.edit.input.submit.anim("active",1500),pageManager.vars[1]=(0==c?"u":"m")+d.id_cluster,navSubMenu("view"),document.location=""):console.error("ModuleError::"+a.ModuleError)})}},!1)}
a.ModuleError&&1==a.status?(console.log("Groupe modifiee!"),section.edit.input.submit.anim("active",1500),api.send({path:"clusterDefault/getById",id_cluster:d.id_cluster,"class":c},function(a){0==a.ModuleError&&(found_edit[searchindex_edit]=a.cluster,autofill_edit())})):console.error("ModuleError::"+a.ModuleError)})}},!1)}
null!=section.members.element&&null!=section.members.chooser.element&&(section.members.chooser.deflater=new FormDeflater(section.members.chooser.element,["select"],["data-name"]),section.members.chooser.submit=document.querySelector(section.members.chooser.text+"#choose-cluster"),section.members.chooser.submit.addEventListener("click",function(a){a.preventDefault();a=section.members.chooser.deflater.deflate().cluster;/^(u|m)\d+$/.test(a)&&(pageManager.vars[1]=a,pageManager.refresh(),document.location=
"")},!1));
null!=section.members.element&&null==section.members.chooser.element&&(section.members.deflater=new FormDeflater(section.members.element,["input"],["data-name"]),section.members.baseData=section.members.deflater.deflate().members,section.members["class"]=document.querySelector("#members-member-class").value,section.members.idcluster=document.querySelector("#members-member-idcluster").value,section.members.element.addEventListener("click",function(a){var c=[],d=[],b=section.members.deflater.deflate().members;b instanceof

View File

@ -216,12 +216,11 @@ if( section.create.element != null ){
if( answer.ModuleError == 0 ){ // Tout s'est bien deroule
console.log('Groupe cree!');
// On redirige sur le cluster
pageManager.vars[1] = ((request.class==0)?'u':'m') + answer.id_cluster;
navSubMenu('view');
document.location = '';
section.create.input.submit.anim('active', 1500);
// On vide les champs
section.create.input.name.value = '';
section.create.input.class.children[0].selected = 'selected';
}
});
@ -435,9 +434,29 @@ if( section.remove.element != null ){
section.remove.input.submit.anim('active', 1500);
pageManager.vars[1] = '';
navSubMenu('view');
document.location = '';
/* [1] On actualise la recherche
=========================================================*/
/* (1) Redaction de la requete */
var getClusters = {
path: 'clusterDefault/search',
keywords: section.remove.input.search.keyword.value
};
/* (2) On envoie la requête */
api.send(getClusters, function(getClustersResponse){
if( getClustersResponse.ModuleError == 0 ){ // si pas d'erreur
/* (3) On met à jour les données des users, et le compteur */
searchindex_remove = 0;
found_remove = getClustersResponse.clusters;
section.remove.input.search.sum.innerHTML = found_remove.length;
// On met à jour l'auto-remplissage
autofill_remove();
}
});
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);
});
@ -656,10 +675,24 @@ if( section.edit.element != null ){
section.edit.input.submit.anim('active', 1500);
/* (1) On actualise le groupe modifié
---------------------------------------------------------*/
// On met a jour le cluster
pageManager.vars[1] = ((clusterClass==0)?'u':'m') + request.id_cluster;
navSubMenu('view');
document.location = '';
var request2 = {
path: 'clusterDefault/getById',
id_cluster: request.id_cluster,
class: clusterClass
};
// On récupère la user d'uid donné dans l'URL
api.send(request2, function(response){
// Si aucune erreur et un résultat
if( response.ModuleError == 0 ){
found_edit[searchindex_edit] = response.cluster; // On récupère le résultat
autofill_edit(); // On auto-remplit
}
});
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);

View File

@ -4,18 +4,18 @@ if(null!=section.view.element){1<pageManager.vars.length&&!isNaN(pageManager.var
".add-group[data-machine]")};section.view.searchbar.addEventListener("keyup",function(a){api.send({path:"machineDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError){for(var d=[],c=0;c<a.machines.length;c++)d.push(a.machines[c].id_machine);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<d.indexOf(parseInt(a[c].id))?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",
function(a){pageManager.vars[1]=a.target.getData("machine");navSubMenu("edit");document.location=""},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("machine");navSubMenu("remove");document.location=""},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(a){var b={path:"machineDefault/unlink",id_machine:a.target.getData("machine"),id_cluster:a.target.getData("group")};
api.send(b,function(b){if(0!=b.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1)}
null!=section.create.element&&(section.create.input={name:document.querySelector(section.create.text+"#create_name"),submit:document.querySelector(section.create.text+"#create_submit")},section.create.input.submit.addEventListener("click",function(a){a.preventDefault();api.send({path:"machineDefault/create",name:section.create.input.name.value},function(a){0==a.ModuleError&&(console.log("Machine cree!"),pageManager.vars=["view",a.id_machine],pageManager.refresh(),document.location="",section.create.input.submit.anim("active",
1500))})},!1));
if(null!=section.remove.element){var autofill_remove=function(){var a="",b="",d=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(a=found_remove[searchindex_remove].id_machine,b=found_remove[searchindex_remove].name,d=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=a;section.remove.input.name.value=b;section.remove.input.submit.disabled=d};section.remove.input={search:{view:document.querySelector(section.remove.text+".remove_search_view"),
num:document.querySelector(section.remove.text+".remove_search_num"),sum:document.querySelector(section.remove.text+".remove_search_sum"),keyword:document.querySelector(section.remove.text+"#remove_search_keyword"),id:document.querySelector(section.remove.text+"#remove_search_id"),submit:document.querySelector(section.remove.text+"#remove_search_submit")},name:document.querySelector(section.remove.text+"#remove_name"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastkeywords_remove=
"",found_remove=[],searchindex_remove=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&api.send({path:"machineDefault/getById",id_machine:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_remove=[a.machine],searchindex_remove=0,autofill_remove())});section.remove.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.remove.input.search.keyword.value)if(section.remove.input.search.keyword.value==lastkeywords_remove)searchindex_remove=(searchindex_remove+
1)%found_remove.length,autofill_remove();else{var b={path:"machineDefault/search",keywords:section.remove.input.search.keyword.value};api.send(b,function(a){0==a.ModuleError&&(section.remove.input.search.submit.anim("active",1E3),searchindex_remove=0,found_remove=a.machines,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove());lastkeywords_remove=b.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&
api.send({path:"machineDefault/delete",id_machine:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Machine supprimee!"),section.remove.input.submit.anim("active",1500),pageManager.vars[1]="",navSubMenu("view"),document.location=""):console.error("ModuleError::"+a.ModuleError)})},!1)}
null!=section.create.element&&(section.create.input={name:document.querySelector(section.create.text+"#create_name"),submit:document.querySelector(section.create.text+"#create_submit")},section.create.input.submit.addEventListener("click",function(a){a.preventDefault();api.send({path:"machineDefault/create",name:section.create.input.name.value},function(a){0==a.ModuleError&&(console.log("Machine cree!"),section.create.input.name.value="",section.create.input.submit.anim("active",1500))})},!1));
if(null!=section.remove.element){var autofill_remove=function(){var a="",b="",d=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(a=found_remove[searchindex_remove].id_machine,b=found_remove[searchindex_remove].name,d=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=a;section.remove.input.name.value=b;section.remove.input.submit.disabled=d};section.remove.input={search:{view:document.querySelector(section.remove.text+
".remove_search_view"),num:document.querySelector(section.remove.text+".remove_search_num"),sum:document.querySelector(section.remove.text+".remove_search_sum"),keyword:document.querySelector(section.remove.text+"#remove_search_keyword"),id:document.querySelector(section.remove.text+"#remove_search_id"),submit:document.querySelector(section.remove.text+"#remove_search_submit")},name:document.querySelector(section.remove.text+"#remove_name"),submit:document.querySelector(section.remove.text+"#remove_submit")};
var lastkeywords_remove="",found_remove=[],searchindex_remove=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&api.send({path:"machineDefault/getById",id_machine:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_remove=[a.machine],searchindex_remove=0,autofill_remove())});section.remove.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.remove.input.search.keyword.value)if(section.remove.input.search.keyword.value==lastkeywords_remove)searchindex_remove=
(searchindex_remove+1)%found_remove.length,autofill_remove();else{var b={path:"machineDefault/search",keywords:section.remove.input.search.keyword.value};api.send(b,function(a){0==a.ModuleError&&(section.remove.input.search.submit.anim("active",1E3),searchindex_remove=0,found_remove=a.machines,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove());lastkeywords_remove=b.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=
section.remove.input.search.id.value&&api.send({path:"machineDefault/delete",id_machine:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Machine supprimee!"),section.remove.input.submit.anim("active",1500),api.send({path:"machineDefault/search",keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&(searchindex_remove=0,found_remove=a.machines,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove())})):
console.error("ModuleError::"+a.ModuleError)})},!1)}
if(null!=section.edit.element){var autofill_edit=function(){var a="",b="",d=!0;null==found_edit[searchindex_edit]?searchindex_edit=section.edit.input.search.num.innerHTML=0:(a=found_edit[searchindex_edit].id_machine,b=found_edit[searchindex_edit].name,d=!1,section.edit.input.search.num.innerHTML=searchindex_edit+1);section.edit.input.search.id.value=a;section.edit.input.name.value=b;section.edit.input.submit.disabled=d};section.edit.input={search:{view:document.querySelector(section.edit.text+".edit_search_view"),
num:document.querySelector(section.edit.text+".edit_search_num"),sum:document.querySelector(section.edit.text+".edit_search_sum"),keyword:document.querySelector(section.edit.text+"#edit_search_keyword"),id:document.querySelector(section.edit.text+"#edit_search_id"),submit:document.querySelector(section.edit.text+"#edit_search_submit")},name:document.querySelector(section.edit.text+"#edit_name"),submit:document.querySelector(section.edit.text+"#edit_submit")};var lastkeywords_edit="",found_edit=[],
searchindex_edit=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&api.send({path:"machineDefault/getById",id_machine:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_edit=[a.machine],searchindex_edit=0,autofill_edit())});section.edit.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.keyword.value)if(section.edit.input.search.keyword.value==lastkeywords_edit)searchindex_edit=(searchindex_edit+1)%found_edit.length,autofill_edit();
else{var b={path:"machineDefault/search",keywords:section.edit.input.search.keyword.value};api.send(b,function(a){0==a.ModuleError&&(section.edit.input.search.submit.anim("active",1E3),searchindex_edit=0,found_edit=a.machines,section.edit.input.search.sum.innerHTML=found_edit.length,autofill_edit());lastkeywords_edit=b.keywords})}},!1);section.edit.input.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.id.value){var b={path:"machineDefault/edit",id_machine:section.edit.input.search.id.value,
name:section.edit.input.name.value};api.send(b,function(a){0==a.ModuleError&&1==a.status?(console.log("Machine modifiee!"),section.edit.input.submit.anim("active",1500),pageManager.vars[1]=b.id_machine,navSubMenu("view"),document.location=""):console.error("ModuleError::"+a.ModuleError)})}},!1)}
name:section.edit.input.name.value};api.send(b,function(a){0==a.ModuleError&&1==a.status?(console.log("Machine modifiee!"),section.edit.input.submit.anim("active",1500),api.send({path:"machineDefault/getById",id_machine:b.id_machine},function(a){0==a.ModuleError&&(found_edit[searchindex_edit]=a.machine,autofill_edit())})):console.error("ModuleError::"+a.ModuleError)})}},!1)}
if(null!=section.groups.element){section.groups.link={remove:document.querySelectorAll(section.groups.text+".link_remove[data-cluster]"),edit:document.querySelectorAll(section.groups.text+".link_edit[data-cluster]")};section.groups.group={rem:document.querySelectorAll(section.groups.text+".rem-member[data-cluster][data-member]"),add:document.querySelectorAll(section.groups.text+".add-member[data-cluster]")};section.groups.searchbar.addEventListener("keyup",function(a){api.send({path:"clusterDefault/search",
keywords:section.groups.searchbar.value,"class":1},function(a){if(0==a.ModuleError){for(var d=[],c=0;c<a.clusters.length;c++)d.push(a.clusters[c].id_machine_cluster);a=document.querySelectorAll(section.groups.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<d.indexOf(parseInt(a[c].id))?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(i=0;i<section.groups.link.edit.length;i++)section.groups.link.edit[i].addEventListener("click",function(a){pageManager.vars[0]="edit";pageManager.vars[1]=
"m"+a.target.getData("cluster");navMenu("groups",!0)},!1);for(i=0;i<section.groups.link.remove.length;i++)section.groups.link.remove[i].addEventListener("click",function(a){pageManager.vars[0]="remove";pageManager.vars[1]="m"+a.target.getData("cluster");navMenu("groups",!0)},!1);for(i=0;i<section.groups.group.rem.length;i++)section.groups.group.rem[i].addEventListener("click",function(a){var b={path:"machineDefault/unlink",id_cluster:a.target.getData("cluster"),id_machine:a.target.getData("member")};

View File

@ -1,5 +1,3 @@
// TODO: Supprimer les retours vers la cible lors de 'création'/'modification'
// On referencie toutes les sections
var section = {
view: {
@ -184,10 +182,9 @@ if( section.create.element != null ){
if( answer.ModuleError == 0 ){ // Tout s'est bien deroule
console.log('Machine cree!');
// On redirige sur la machine
pageManager.vars = ['view', answer.id_machine];
pageManager.refresh();
document.location = '';
// On vide le champs
section.create.input.name.value = '';
section.create.input.submit.anim('active', 1500);
}
@ -378,9 +375,28 @@ if( section.remove.element != null ){
section.remove.input.submit.anim('active', 1500);
pageManager.vars[1] = '';
navSubMenu('view');
document.location = '';
/* (1) On actualise la recherche
---------------------------------------------------------*/
/* (1) Redaction de la requete */
var getMachines = {
path: 'machineDefault/search',
keywords: section.remove.input.search.keyword.value
};
/* (2) On envoie la requête */
api.send(getMachines, function(getMachinesResponse){
if( getMachinesResponse.ModuleError == 0 ){ // si pas d'erreur
/* (3) On met à jour les données des machines, et le compteur */
searchindex_remove = 0;
found_remove = getMachinesResponse.machines;
section.remove.input.search.sum.innerHTML = found_remove.length;
// On met à jour l'auto-remplissage
autofill_remove();
}
});
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);
@ -576,10 +592,16 @@ if( section.edit.element != null ){
section.edit.input.submit.anim('active', 1500);
// On met a jour la machine
pageManager.vars[1] = request.id_machine;
navSubMenu('view');
document.location = '';
/* [1] On met à jour les données machine
=========================================================*/
// On récupère la machine d'uid donné dans l'URL
api.send({path:'machineDefault/getById', id_machine:request.id_machine}, function(response){
// Si aucune erreur et un résultat
if( response.ModuleError == 0 ){
found_edit[searchindex_edit] = response.machine; // On récupère le résultat
autofill_edit(); // On auto-remplit
}
});
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);

View File

@ -6,19 +6,20 @@ function(a){pageManager.vars[1]=a.target.getData("user");navSubMenu("edit");docu
api.send(c,function(c){if(0!=c.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1)}
if(null!=section.create.element){section.create.input={code:document.querySelector(section.create.text+"#create_code"),username:document.querySelector(section.create.text+"#create_username"),firstname:document.querySelector(section.create.text+"#create_firstname"),lastname:document.querySelector(section.create.text+"#create_lastname"),mail:document.querySelector(section.create.text+"#create_mail"),submit:document.querySelector(section.create.text+"#create_submit")};var createChecker=new inputChecker;
createChecker.append(section.create.input.code,format_code,"01-AB-CD-23");section.create.input.code.addEventListener("keyup",function(a){a.target.value=a.target.value.toUpperCase();createChecker.check(a.target)||createChecker.correct(a.target,!1)},!1);section.create.input.submit.addEventListener("click",function(a){a.preventDefault();api.send({path:"userDefault/create",code:section.create.input.code.value,username:section.create.input.username.value,firstname:section.create.input.firstname.value,
lastname:section.create.input.lastname.value,mail:section.create.input.mail.value},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500),document.location=""):console.error("ModuleError::"+a.ModuleError)})},!1)}
lastname:section.create.input.lastname.value,mail:section.create.input.mail.value},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500),section.create.input.code.value="",section.create.input.username.value="",section.create.input.firstname.value="",section.create.input.lastname.value="",section.create.input.mail.value=""):console.error("ModuleError::"+a.ModuleError)})},!1)}
if(null!=section.remove.element){var autofill_remove=function(){var a="",c="",d="",b=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(a=found_remove[searchindex_remove].id_user,c=found_remove[searchindex_remove].username,d=found_remove[searchindex_remove].code,b=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=a;section.remove.input.username.value=c;section.remove.input.code.value=d;section.remove.input.submit.disabled=
b};section.remove.input={search:{view:document.querySelector(section.remove.text+".remove_search_view"),num:document.querySelector(section.remove.text+".remove_search_num"),sum:document.querySelector(section.remove.text+".remove_search_sum"),keyword:document.querySelector(section.remove.text+"#remove_search_keyword"),id:document.querySelector(section.remove.text+"#remove_search_id"),submit:document.querySelector(section.remove.text+"#remove_search_submit")},code:document.querySelector(section.remove.text+
"#remove_code"),username:document.querySelector(section.remove.text+"#remove_username"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastkeywords_remove="",found_remove=[],searchindex_remove=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&api.send({path:"userDefault/getById",id_user:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_remove=[a.user],searchindex_remove=0,autofill_remove())});section.remove.input.search.submit.addEventListener("click",function(a){a.preventDefault();
if(""!=section.remove.input.search.keyword.value)if(section.remove.input.search.keyword.value==lastkeywords_remove)searchindex_remove=(searchindex_remove+1)%found_remove.length,autofill_remove();else{var c={path:"userDefault/search",keywords:section.remove.input.search.keyword.value};api.send(c,function(a){0==a.ModuleError&&(section.remove.input.search.submit.anim("active",1E3),searchindex_remove=0,found_remove=a.users,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove());
lastkeywords_remove=c.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&api.send({path:"userDefault/delete",id_user:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Utilisateur supprime!"),section.remove.input.submit.anim("active",1500),pageManager.vars[1]="",navSubMenu("view"),document.location=""):console.error("ModuleError::"+a.ModuleError)})},!1)}
lastkeywords_remove=c.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&api.send({path:"userDefault/delete",id_user:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Utilisateur supprime!"),section.remove.input.submit.anim("active",1500),api.send({path:"userDefault/search",keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&(searchindex_remove=
0,found_remove=a.users,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove())})):console.error("ModuleError::"+a.ModuleError)})},!1)}
if(null!=section.edit.element){var autofill_edit=function(){var a="",c="",d="",b="",e="",f="",g=!0;null==found_edit[searchindex_edit]?searchindex_edit=section.edit.input.search.num.innerHTML=0:(a=found_edit[searchindex_edit].id_user,c=found_edit[searchindex_edit].code,d=found_edit[searchindex_edit].username,b=found_edit[searchindex_edit].firstname,e=found_edit[searchindex_edit].lastname,f=found_edit[searchindex_edit].mail,g=!1,section.edit.input.search.num.innerHTML=searchindex_edit+1);section.edit.input.search.id.value=
a;section.edit.input.code.value=c;section.edit.input.username.value=d;section.edit.input.firstname.value=b;section.edit.input.lastname.value=e;section.edit.input.mail.value=f;section.edit.input.submit.disabled=g};section.edit.input={search:{view:document.querySelector(section.edit.text+".edit_search_view"),num:document.querySelector(section.edit.text+".edit_search_num"),sum:document.querySelector(section.edit.text+".edit_search_sum"),keyword:document.querySelector(section.edit.text+"#edit_search_keyword"),
id:document.querySelector(section.edit.text+"#edit_search_id"),submit:document.querySelector(section.edit.text+"#edit_search_submit")},code:document.querySelector(section.edit.text+"#edit_code"),username:document.querySelector(section.edit.text+"#edit_username"),firstname:document.querySelector(section.edit.text+"#edit_firstname"),lastname:document.querySelector(section.edit.text+"#edit_lastname"),mail:document.querySelector(section.edit.text+"#edit_mail"),submit:document.querySelector(section.edit.text+
"#edit_submit")};var lastkeywords_edit="",found_edit=[],searchindex_edit=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&api.send({path:"userDefault/getById",id_user:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_edit=[a.user],searchindex_edit=0,autofill_edit())});section.edit.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.keyword.value)if(section.edit.input.search.keyword.value==lastkeywords_edit)searchindex_edit=
(searchindex_edit+1)%found_edit.length,autofill_edit();else{var c={path:"userDefault/search",keywords:section.edit.input.search.keyword.value};api.send(c,function(a){0==a.ModuleError&&(section.edit.input.search.submit.anim("active",1E3),searchindex_edit=0,found_edit=a.users,section.edit.input.search.sum.innerHTML=found_edit.length,autofill_edit());lastkeywords_edit=c.keywords})}},!1);section.edit.input.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.id.value){var c=
{path:"userDefault/edit",id_user:parseInt(section.edit.input.search.id.value),code:section.edit.input.code.value,username:section.edit.input.username.value,firstname:section.edit.input.firstname.value,lastname:section.edit.input.lastname.value,mail:section.edit.input.mail.value};api.send(c,function(a){console.log(a);0==a.ModuleError&&1==a.status?(console.log("Utilisateur modifie!"),section.edit.input.submit.anim("active",1500),pageManager.vars[1]=c.id_user,navSubMenu("view"),document.location=""):
console.error("ModuleError::"+a.ModuleError)})}},!1)}
{path:"userDefault/edit",id_user:parseInt(section.edit.input.search.id.value),code:section.edit.input.code.value,username:section.edit.input.username.value,firstname:section.edit.input.firstname.value,lastname:section.edit.input.lastname.value,mail:section.edit.input.mail.value};api.send(c,function(a){console.log(a);0==a.ModuleError&&1==a.status?(console.log("Utilisateur modifie!"),section.edit.input.submit.anim("active",1500),api.send({path:"userDefault/getById",id_user:c.id_user},function(a){0==
a.ModuleError&&(found_edit[searchindex_edit]=a.user,autofill_edit())})):console.error("ModuleError::"+a.ModuleError)})}},!1)}
if(null!=section.groups.element){section.groups.link={remove:document.querySelectorAll(section.groups.text+".link_remove[data-cluster]"),edit:document.querySelectorAll(section.groups.text+".link_edit[data-cluster]")};section.groups.group={rem:document.querySelectorAll(section.groups.text+".rem-member[data-cluster][data-member]"),add:document.querySelectorAll(section.groups.text+".add-member[data-cluster]")};section.groups.searchbar.addEventListener("keyup",function(a){api.send({path:"clusterDefault/search",
keywords:section.groups.searchbar.value,"class":0},function(a){if(0==a.ModuleError){for(var d=[],b=0;b<a.clusters.length;b++)d.push(a.clusters[b].id_user_cluster);a=document.querySelectorAll(section.groups.text+"> article.inline-box[id]");for(b=0;b<a.length;b++)-1<d.indexOf(parseInt(a[b].id))?a[b].remClass("hidden"):a[b].addClass("hidden")}})},!1);for(i=0;i<section.groups.link.edit.length;i++)section.groups.link.edit[i].addEventListener("click",function(a){pageManager.vars[0]="edit";pageManager.vars[1]=
"u"+a.target.getData("cluster");navMenu("groups",!0)},!1);for(i=0;i<section.groups.link.remove.length;i++)section.groups.link.remove[i].addEventListener("click",function(a){pageManager.vars[0]="remove";pageManager.vars[1]="u"+a.target.getData("cluster");navMenu("groups",!0)},!1);for(i=0;i<section.groups.group.rem.length;i++)section.groups.group.rem[i].addEventListener("click",function(a){var c={path:"userDefault/unlink",id_cluster:a.target.getData("cluster"),id_user:a.target.getData("member")};api.send(c,

View File

@ -1,5 +1,3 @@
// TODO: Supprimer les retours vers la cible lors de 'création'/'modification'
// On referencie toutes les sections
var section = {
view: {
@ -209,7 +207,12 @@ if( section.create.element != null ){
section.create.input.submit.anim('active', 1500);
document.location = '';
// on vide les champs
section.create.input.code.value = '';
section.create.input.username.value = '';
section.create.input.firstname.value = '';
section.create.input.lastname.value = '';
section.create.input.mail.value = '';
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);
@ -408,9 +411,29 @@ if( section.remove.element != null ){
section.remove.input.submit.anim('active', 1500);
pageManager.vars[1] = '';
navSubMenu('view');
document.location = '';
/* (1) On actualise la recherche
---------------------------------------------------------*/
/* (1) Redaction de la requete */
var getUsers = {
path: 'userDefault/search',
keywords: section.remove.input.search.keyword.value
};
/* (2) On envoie la requête */
api.send(getUsers, function(getUsersResponse){
if( getUsersResponse.ModuleError == 0 ){ // si pas d'erreur
/* (3) On met à jour les données des users, et le compteur */
searchindex_remove = 0;
found_remove = getUsersResponse.users;
section.remove.input.search.sum.innerHTML = found_remove.length;
// On met à jour l'auto-remplissage
autofill_remove();
}
});
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);
});
@ -620,10 +643,17 @@ if( section.edit.element != null ){
section.edit.input.submit.anim('active', 1500);
// On met a jour l'utilisateur
pageManager.vars[1] = request.id_user;
navSubMenu('view');
document.location = '';
/* (1) On met à jour les données utilisateur
---------------------------------------------------------*/
// On récupère la user d'uid donné dans l'URL
api.send({path:'userDefault/getById', id_user:request.id_user}, function(response){
// Si aucune erreur et un résultat
if( response.ModuleError == 0 ){
found_edit[searchindex_edit] = response.user; // On récupère le résultat
autofill_edit(); // On auto-remplit
}
});
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);