Page 'groups/view', 'groups/remove', 'groups/edit', 'groups/members' DONE + les repos/modules utiles à leur fonctionnement DONE + les liens entre les pages DONE

This commit is contained in:
xdrm-brackets 2016-07-20 19:46:57 +02:00
parent 727e3c6a87
commit 15e59f55c4
2 changed files with 15 additions and 10 deletions

View File

@ -6,14 +6,14 @@ if(null!=section.view.element){1<pageManager.vars.length&&/^(u|m)\d+$/.test(page
function(a){pageManager.vars[1]=a.target.getData("cluster");autofill_edit();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");autofill_remove();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=a.target.getData("cluster")[0],d=a.target.getData("cluster").slice(1);
console.log(a.target);var c={};c.path="u"==b?"userDefault/unlink":"machineDefault/unlink";c.id_cluster=d;"u"==b?c.id_user=a.target.getData("member"):c.id_machine=a.target.getData("member");api.send(c,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();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))})},!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 b={path:"clusterDefault/create",name:section.create.input.name.value,"class":section.create.input["class"].value};api.send(b,function(a){0==a.ModuleError&&(console.log("Groupe cree!"),
pageManager.vars[1]=(0==b["class"]?"u":"m")+a.id_cluster,navSubMenu("view"),document.location="",section.create.input.submit.anim("active",1500))})},!1));
if(null!=section.remove.element){var autofill_remove=function(){var a={id_cluster:"","class":"",name:"",disable_input:!0};if(null==found_remove[searchindex_remove])searchindex_remove=section.remove.input.search.num.innerHTML=0;else{var b;found_remove[searchindex_remove].hasOwnProperty("id_user_cluster")?(a=found_remove[searchindex_remove].id_user_cluster,b=0):(a=found_remove[searchindex_remove].id_machine_cluster,b=1);a={id_cluster:a,"class":b,name:found_remove[searchindex_remove].name,disable_input:!1};
section.remove.input.search.num.innerHTML=searchindex_remove+1}section.remove.input.search.id.value=a.id_cluster;section.remove.input.name.value=a.name;section.remove.input["class"].value=0==a["class"]?"utilisateur":"machine";console.log(a);section.remove.input.submit.disabled=a.disable_input};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 b={path:"clusterDefault/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.clusters,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:"clusterDefault/delete",id_cluster:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Groupe supprimee!"),section.remove.input.submit.anim("active",1500),autofill_remove(null)):console.error("ModuleError::"+a.ModuleError)})},!1)}
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="",b="",d=!0;if(null==found_edit[searchindex_edit])searchindex_edit=section.edit.input.search.num.innerHTML=0;else{var c;found_edit[searchindex_remove].hasOwnProperty("id_user_cluster")?(a=found_edit[searchindex_remove].id_user_cluster,c=0):(a=found_edit[searchindex_remove].id_machine_cluster,c=1);b=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=b;section.edit.input["class"].value=0==c?"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])&&(console.log("bla"),prefix=pageManager.vars[1][0],cluster=pageManager.vars[1].slice(1),request={path:"clusterDefault/getById",id_cluster:cluster,"class":"u"==prefix?

View File

@ -214,9 +214,9 @@ if( section.create.element != null ){
console.log('Groupe cree!');
// On redirige sur le cluster
// pageManager.vars[1] = answer.id_cluster;
// navSubMenu('view');
// document.location = '';
pageManager.vars[1] = ((request.class==0)?'u':'m') + answer.id_cluster;
navSubMenu('view');
document.location = '';
section.create.input.submit.anim('active', 1500);
}
@ -418,10 +418,13 @@ if( section.remove.element != null ){
// Si l'id est defini
if( section.remove.input.search.id.value != '' ){
var clusterClass = (found_remove[searchindex_remove].hasOwnProperty('id_user_cluster')) ? 0 : 1;
/* (2) On supprime la cluster */
var request = {
path: 'clusterDefault/delete', // On veut supprimer cet utilisateur
id_cluster: section.remove.input.search.id.value
path: 'clusterDefault/delete', // On veut supprimer cet utilisateur
id_cluster: section.remove.input.search.id.value,
class: clusterClass
};
api.send(request, function(answer){
@ -429,8 +432,10 @@ if( section.remove.element != null ){
console.log('Groupe supprimee!');
section.remove.input.submit.anim('active', 1500);
// On vide le formulaire
autofill_remove(null);
pageManager.vars[1] = '';
navSubMenu('view');
document.location = '';
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);
});