Liens des pages 'users/groups' et 'machines/groups' vers les pages 'groups/...' DONE (excepté certains pb à régler)
This commit is contained in:
parent
8744cf9577
commit
2f3e00d99f
|
@ -1,6 +1,6 @@
|
|||
DOM={WRAPPER:$("WRAPPER"),HEADER:$("HEADER"),MENUSIDE:$("MENU-SIDE"),CONTAINER:$("CONTAINER")};var pageManager=new pageManagerClass;pageManager.setPage(null,"/view",DOM.CONTAINER,"profile dashboard machines users groups analytics settings".split(" "));var api=new APIClass("/api/");
|
||||
function navSubMenu(a){var c=document.querySelector('#CONTAINER > .sub-menu-side > span[data-sublink="'+pageManager.vars[0]+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?document.querySelector('#CONTAINER > .sub-menu-side > span[data-sublink="'+a+'"]'):b,b=null==b?document.querySelector("#CONTAINER > .sub-menu-side > span[data-sublink]"):b;if(null==b)return!1;null!=c&&c.remClass("active");a=document.querySelectorAll("#CONTAINER > section[data-sublink].active");for(c=0;c<a.length;c++)a[c].remClass("active");
|
||||
function navSubMenu(a){var d=document.querySelector('#CONTAINER > .sub-menu-side > span[data-sublink="'+pageManager.vars[0]+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?document.querySelector('#CONTAINER > .sub-menu-side > span[data-sublink="'+a+'"]'):b,b=null==b?document.querySelector("#CONTAINER > .sub-menu-side > span[data-sublink]"):b;if(null==b)return!1;null!=d&&d.remClass("active");a=document.querySelectorAll("#CONTAINER > section[data-sublink].active");for(d=0;d<a.length;d++)a[d].remClass("active");
|
||||
null!=b&&(b.addClass("active"),a=document.querySelector('#CONTAINER > section[data-sublink="'+b.getData("sublink")+'"]'),null!=a&&a.addClass("active"));if(!b.getData("sublink"))return!1;a=pageManager.vars[0]!=b.getData("sublink");pageManager.vars[0]=b.getData("sublink");a&&pageManager.updateURL()}
|
||||
function navMenu(a){var c=document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.page+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+a+'"]'):b,b=null==b?document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]'):b;if(null==b)return!1;null!=c&&c.remClass("active");null!=b&&b.addClass("active");c!=b&&(pageManager.vars=[]);b.getData("link")&&(DOM.HEADER.addClass("loading"),
|
||||
pageManager.setPage(b.getData("link")),pageManager.activeXHR.addEventListener("loadend",function(){DOM.HEADER.remClass("loading");1<=pageManager.vars.length&&null!=document.querySelector('#CONTAINER > .sub-menu-side > [data-sublink="'+pageManager.vars[0]+'"]')?navSubMenu(pageManager.vars[0]):navSubMenu(null);document.querySelector("#CONTAINER > .sub-menu-side").addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("sublink");)a=a.parentNode;a.getData("sublink")&&navSubMenu(a)},
|
||||
!1)},!1))}navMenu(pageManager.page);DOM.MENUSIDE.addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("link");)a=a.parentNode;a.getData("link")&&navMenu(a.getData("link"))},!1);
|
||||
function navMenu(a,d){var b=document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.page+'"]'),c=null,c=a instanceof Element?a:null,c="string"==typeof a?document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+a+'"]'):c,c=null==c?document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]'):c;if(null==c)return!1;d=!0===d?!0:!1;null!=b&&b.remClass("active");null!=c&&c.addClass("active");d||b==c||(pageManager.vars=[]);c.getData("link")&&
|
||||
(DOM.HEADER.addClass("loading"),pageManager.setPage(c.getData("link")),pageManager.activeXHR.addEventListener("loadend",function(){DOM.HEADER.remClass("loading");0<pageManager.vars.length&&null!=document.querySelector('#CONTAINER > .sub-menu-side > [data-sublink="'+pageManager.vars[0]+'"]')?navSubMenu(pageManager.vars[0]):navSubMenu(null);document.querySelector("#CONTAINER > .sub-menu-side").addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("sublink");)a=a.parentNode;
|
||||
a.getData("sublink")&&navSubMenu(a)},!1)},!1))}navMenu(pageManager.page);DOM.MENUSIDE.addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("link");)a=a.parentNode;a.getData("link")&&navMenu(a.getData("link"))},!1);
|
||||
|
|
|
@ -85,7 +85,7 @@ function navSubMenu(subsection){
|
|||
|
||||
/* [2] Toggle du side-menu <-> navigation
|
||||
===========================================*/
|
||||
function navMenu(section){
|
||||
function navMenu(section, persistence){
|
||||
|
||||
/* [1] Format du param
|
||||
------------------------------------------------*/
|
||||
|
@ -107,6 +107,9 @@ function navMenu(section){
|
|||
// Si le param n'est toujours pas bon, on retourne une erreur
|
||||
if( target == null ) return false;
|
||||
|
||||
// Persistence de pageManager.vars (OPTIONNEL)
|
||||
persistence = (persistence===true) ? true : false;
|
||||
|
||||
/* [2] Gestion de l'affichage de l'element
|
||||
------------------------------------------------*/
|
||||
// On desactive l'element courant
|
||||
|
@ -122,7 +125,7 @@ function navMenu(section){
|
|||
var page = null;
|
||||
|
||||
// SI on change de menu, on efface les données URL
|
||||
if( current != target )
|
||||
if( !persistence && current != target )
|
||||
pageManager.vars = [];
|
||||
|
||||
|
||||
|
@ -138,7 +141,7 @@ function navMenu(section){
|
|||
DOM.HEADER.remClass('loading');
|
||||
|
||||
// On gere la navigation du sous-menu (si defini, utilise)
|
||||
var subSectionExists = pageManager.vars.length >= 1 && document.querySelector('#CONTAINER > .sub-menu-side > [data-sublink="'+pageManager.vars[0]+'"]') != null;
|
||||
var subSectionExists = pageManager.vars.length > 0 && document.querySelector('#CONTAINER > .sub-menu-side > [data-sublink="'+pageManager.vars[0]+'"]') != null;
|
||||
if( subSectionExists ) // Si le lien du menu associe existe
|
||||
navSubMenu(pageManager.vars[0]); // on charge la page associee
|
||||
else // sinon
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
case 'user': return "
|
||||
<span>
|
||||
@username
|
||||
<span class='rem-member' data-member='@id_user' data-cluster='@id_user_cluster'></span>
|
||||
<span class='rem-member' data-member='@id_user' data-cluster='@id_cluster'></span>
|
||||
</span>";
|
||||
break;
|
||||
|
||||
|
@ -80,7 +80,7 @@
|
|||
$CLUSTERLIST[$c]['users'] = View::replaceMultiple(
|
||||
self::template('user'),
|
||||
$users,
|
||||
[ 'id_user_cluster' => $cluster['id_user_cluster'] ]
|
||||
[ 'id_cluster' => $cluster['id_user_cluster'] ]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ function(a){pageManager.vars[1]=a.target.getData("cluster");navSubMenu("edit");d
|
|||
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();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&&(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.remove.element){var autofill_remove=function(){var a="",b="",d="",c=!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,b=0):(a=found_remove[searchindex_remove].id_machine_cluster,b=1),d=found_remove[searchindex_remove].name,c=!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==b?"utilisateur":"machine";section.remove.input.submit.disabled=c};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&&(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?
|
||||
|
@ -21,6 +21,6 @@ a.ModuleError&&(section.edit.input.search.submit.anim("active",1E3),searchindex_
|
|||
"class":b};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==b?"u":"m")+d.id_cluster,navSubMenu("view"),document.location=""):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 b=[],d=[],c=section.members.deflater.deflate().members;c instanceof
|
||||
Array||(c=[c]);for(a=0;a<c.length;a++)-1==section.members.baseData.indexOf(c[a])&&b.push(c[a]);for(a=0;a<section.members.baseData.length;a++)-1==c.indexOf(section.members.baseData[a])&&d.push(section.members.baseData[a]);for(a=0;a<b.length;a++){var e={};e.path=0==section.members["class"]?"userDefault/link":"machineDefault/link";e.id_cluster=section.members.idcluster;0==section.members["class"]?e.id_user=b[a]:e.id_machine=b[a];api.send(e,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")})}for(a=
|
||||
0;a<d.length;a++)b={},b.path=0==section.members["class"]?"userDefault/unlink":"machineDefault/unlink",b.id_cluster=section.members.idcluster,0==section.members["class"]?b.id_user=d[a]:b.id_machine=d[a],api.send(b,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")});section.members.baseData=c},!1));
|
||||
null!=section.members.element&&null==section.members.chooser.element&&(2<=pageManager.vars.length&&/^(u|m)\d+$/.test(pageManager.vars[1]),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 b=
|
||||
[],d=[],c=section.members.deflater.deflate().members;c instanceof Array||(c=[c]);for(a=0;a<c.length;a++)-1==section.members.baseData.indexOf(c[a])&&b.push(c[a]);for(a=0;a<section.members.baseData.length;a++)-1==c.indexOf(section.members.baseData[a])&&d.push(section.members.baseData[a]);for(a=0;a<b.length;a++){var e={};e.path=0==section.members["class"]?"userDefault/link":"machineDefault/link";e.id_cluster=section.members.idcluster;0==section.members["class"]?e.id_user=b[a]:e.id_machine=b[a];api.send(e,
|
||||
function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")})}for(a=0;a<d.length;a++)b={},b.path=0==section.members["class"]?"userDefault/unlink":"machineDefault/unlink",b.id_cluster=section.members.idcluster,0==section.members["class"]?b.id_user=d[a]:b.id_machine=d[a],api.send(b,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")});section.members.baseData=c},!1));
|
||||
|
|
|
@ -319,7 +319,6 @@ if( section.remove.element != null ){
|
|||
// Auto-remplissage du formulaire
|
||||
section.remove.input.name.value = cluster_data.name;
|
||||
section.remove.input.class.value = cluster_data.class == 0 ? 'utilisateur' : 'machine';
|
||||
console.log(cluster_data);
|
||||
|
||||
// On gere le caractere "inactif" du submit
|
||||
section.remove.input.submit.disabled = cluster_data.disable_input;
|
||||
|
@ -746,6 +745,13 @@ if( section.members.element != null && section.members.chooser.element != null )
|
|||
*/
|
||||
if( section.members.element != null && section.members.chooser.element == null ){
|
||||
|
||||
|
||||
// Gestion automatique au chargement de la page si ID_CLUSTER dans url "/users/remove/:id_cluster:"
|
||||
if( pageManager.vars.length >= 2 && /^(u|m)\d+$/.test(pageManager.vars[1]) ){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (1) On initialise le Deflater() */
|
||||
section.members.deflater = new FormDeflater(
|
||||
section.members.element,
|
||||
|
|
|
@ -1,21 +1,24 @@
|
|||
var section={view:{text:'#CONTAINER > section[data-sublink="view"] ',element:document.querySelector('#CONTAINER > section[data-sublink="view"]'),searchbar:document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar')},create:{text:'#CONTAINER > section[data-sublink="create"] ',element:document.querySelector('#CONTAINER > section[data-sublink="create"]')},remove:{text:'#CONTAINER > section[data-sublink="remove"] ',element:document.querySelector('#CONTAINER > section[data-sublink="remove"]')},
|
||||
edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')}};
|
||||
edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')},groups:{text:'#CONTAINER > section[data-sublink="groups"] ',element:document.querySelector('#CONTAINER > section[data-sublink="groups"]'),searchbar:document.querySelector('#CONTAINER > section[data-sublink="groups"] > .searchbar')}};
|
||||
if(null!=section.view.element){1<pageManager.vars.length&&!isNaN(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1],document.getElementById(pageManager.vars[1]).addClass("selected"));section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-user]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-user]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-group[data-user][data-group]"),add:document.querySelectorAll(section.view.text+
|
||||
".add-group[data-user]")};section.view.searchbar.addEventListener("keyup",function(a){api.send({path:"userDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError&&(console.log(a.users.length),0==a.ModuleError)){for(var d=[],c=0;c<a.users.length;c++)d.push(a.users[c].id_user);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<d.indexOf(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("user");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("user");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:"userDefault/unlink",id_user:a.target.getData("user"),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)}
|
||||
".add-group[data-user]")};section.view.searchbar.addEventListener("keyup",function(a){api.send({path:"userDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError&&(console.log(a.users.length),0==a.ModuleError)){for(var d=[],b=0;b<a.users.length;b++)d.push(a.users[b].id_user);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(b=0;b<a.length;b++)-1<d.indexOf(a[b].id)?a[b].remClass("hidden"):a[b].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("user");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("user");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={path:"userDefault/unlink",id_user:a.target.getData("user"),id_cluster:a.target.getData("group")};
|
||||
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)):console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||
if(null!=section.remove.element){var autofill_remove=function(){var a="",b="",d="",c=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(a=found_remove[searchindex_remove].id_user,b=found_remove[searchindex_remove].username,d=found_remove[searchindex_remove].code,c=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=a;section.remove.input.username.value=b;section.remove.input.code.value=d;section.remove.input.submit.disabled=
|
||||
c};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+
|
||||
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 b={path:"userDefault/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.users,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:"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)}
|
||||
if(null!=section.edit.element){var autofill_edit=function(){var a="",b="",d="",c="",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,b=found_edit[searchindex_edit].code,d=found_edit[searchindex_edit].username,c=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=b;section.edit.input.username.value=d;section.edit.input.firstname.value=c;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"),
|
||||
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)}
|
||||
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 b={path:"userDefault/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.users,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:"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(b,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]=b.id_user,navSubMenu("view"),document.location=""):
|
||||
console.error("ModuleError::"+a.ModuleError)})}},!1)};
|
||||
(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)}
|
||||
if(null!=section.groups.element){section.groups.link={remove:document.querySelectorAll(section.groups.text+".link_remove[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_cluster);a=document.querySelectorAll(section.groups.text+"> article.inline-box[id]");for(b=0;b<a.length;b++)-1<d.indexOf(a[b].id)?a[b].remClass("hidden"):a[b].addClass("hidden")}})},!1);for(i=0;i<section.groups.link.remove.length;i++)section.groups.link.remove[i].addEventListener("click",function(a){navMenu("groups","remove");pageManager.vars[1]="u"+a.target.getData("cluster")},!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,function(c){if(0!=c.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1);for(i=0;i<section.groups.group.add.length;i++)section.groups.group.add[i].addEventListener("click",function(a){pageManager.vars[0]="members";pageManager.vars[1]="u"+a.target.getData("cluster");navMenu("groups",!0)},!1)};
|
||||
|
|
135
view/js/users.js
135
view/js/users.js
|
@ -19,6 +19,12 @@ var section = {
|
|||
edit: {
|
||||
text: '#CONTAINER > section[data-sublink="edit"] ',
|
||||
element: document.querySelector('#CONTAINER > section[data-sublink="edit"]')
|
||||
},
|
||||
|
||||
groups: {
|
||||
text: '#CONTAINER > section[data-sublink="groups"] ',
|
||||
element: document.querySelector('#CONTAINER > section[data-sublink="groups"]'),
|
||||
searchbar: document.querySelector('#CONTAINER > section[data-sublink="groups"] > .searchbar')
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -623,3 +629,132 @@ if( section.edit.element != null ){
|
|||
}, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [5] groups -> Groupes d'utilisateurs
|
||||
=========================================================*/
|
||||
if( section.groups.element != null ){
|
||||
|
||||
/* (1) On recupere tous les liens vers des sous-sections */
|
||||
section.groups.link = {
|
||||
remove: document.querySelectorAll(section.groups.text + '.link_remove[data-cluster]')
|
||||
};
|
||||
|
||||
/* (2) On récupère toutes les actions de groupes */
|
||||
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]')
|
||||
};
|
||||
|
||||
|
||||
/* (3) Gestion de la recherche instantannee */
|
||||
section.groups.searchbar.addEventListener('keyup', function(e){
|
||||
|
||||
var search = {
|
||||
path: 'clusterDefault/search',
|
||||
keywords: section.groups.searchbar.value,
|
||||
class: 0
|
||||
};
|
||||
|
||||
// On envoie la requete
|
||||
api.send(search, function(result){
|
||||
if( result.ModuleError == 0 ){ // si aucune erreur
|
||||
|
||||
// On enregistre tous les UID dans un tableau
|
||||
var uid_list = [];
|
||||
for( var i = 0 ; i < result.clusters.length ; i++ )
|
||||
uid_list.push( result.clusters[i].id_cluster);
|
||||
|
||||
// On recupere la liste des elements correspondants aux utilisateurs
|
||||
var cluster_list = document.querySelectorAll(section.groups.text + '> article.inline-box[id]');
|
||||
|
||||
// Pour chaque cluster
|
||||
for( var i = 0 ; i < cluster_list.length ; i++ ){
|
||||
// Si doit etre visible
|
||||
if( uid_list.indexOf(cluster_list[i].id) > -1 )
|
||||
cluster_list[i].remClass('hidden');
|
||||
// Si ne doit pas etre visible
|
||||
else
|
||||
cluster_list[i].addClass('hidden');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}, false);
|
||||
|
||||
var i;
|
||||
|
||||
|
||||
/* (4) On gere la "redirection" vers la modification */
|
||||
// for( i = 0 ; i < section.groups.link.edit.length ; i++ ){
|
||||
//
|
||||
// section.groups.link.edit[i].addEventListener('click', function(e){
|
||||
// pageManager.vars[1] = e.target.getData('cluster');
|
||||
// navSubMenu('edit');
|
||||
// document.location = '';
|
||||
// }, false);
|
||||
//
|
||||
// }
|
||||
|
||||
/* (5) On gere la "redirection" vers la suppression */
|
||||
for( i = 0 ; i < section.groups.link.remove.length ; i++ ){
|
||||
|
||||
section.groups.link.remove[i].addEventListener('click', function(e){
|
||||
navMenu('groups', 'remove');
|
||||
pageManager.vars[1] = 'u'+e.target.getData('cluster');
|
||||
}, false);
|
||||
|
||||
}
|
||||
|
||||
/* (6) On gere la "suppression" d'un groupe */
|
||||
for( i = 0 ; i < section.groups.group.rem.length ; i++ ){
|
||||
|
||||
section.groups.group.rem[i].addEventListener('click', function(e){
|
||||
// {1} On rédige la requête //
|
||||
var request = {
|
||||
path: 'userDefault/unlink',
|
||||
id_cluster: e.target.getData('cluster'),
|
||||
id_user: e.target.getData('member')
|
||||
};
|
||||
|
||||
|
||||
// {2} On envoie la requête //
|
||||
api.send(request, function(response){
|
||||
|
||||
// {3} Si erreur, on ne fait rien //
|
||||
if( response.ModuleError != 0 )
|
||||
return false;
|
||||
|
||||
|
||||
// {4} Si tout s'est bien passé //
|
||||
e.target.parentNode.parentNode.removeChild( e.target.parentNode );
|
||||
});
|
||||
|
||||
}, false);
|
||||
|
||||
}
|
||||
|
||||
/* (7) On gere la "modification" des membres d'un groupe */
|
||||
for( i = 0 ; i < section.groups.group.add.length ; i++ ){
|
||||
|
||||
section.groups.group.add[i].addEventListener('click', function(e){
|
||||
pageManager.vars[0] = 'members';
|
||||
pageManager.vars[1] = 'u'+e.target.getData('cluster');
|
||||
navMenu('groups', true);
|
||||
}, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue