mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 13:59:23 +00:00
Fixed menubar issue with login management
This commit is contained in:
parent
a1ee1909dc
commit
633c4f9400
@ -168,6 +168,10 @@ ComunicWeb.common.page = {
|
|||||||
//Set wrapper class
|
//Set wrapper class
|
||||||
pageTarget.className = "content-wrapper";
|
pageTarget.className = "content-wrapper";
|
||||||
|
|
||||||
|
//Ask adminLTE to fix layout
|
||||||
|
if($.AdminLTE.layout)
|
||||||
|
$.AdminLTE.layout.fix();
|
||||||
|
|
||||||
//Set body class
|
//Set body class
|
||||||
document.body.className="hold-transition skin-blue layout-top-nav";
|
document.body.className="hold-transition skin-blue layout-top-nav";
|
||||||
|
|
||||||
|
@ -25,12 +25,33 @@ function createElem(nodeType, appendTo){
|
|||||||
* Get an HTML element specified by an ID
|
* Get an HTML element specified by an ID
|
||||||
*
|
*
|
||||||
* @param {String} nodeName The ID of the element
|
* @param {String} nodeName The ID of the element
|
||||||
* @return {HTMLElement} The elemnt / False for a failure
|
* @return {HTMLElement} The element / False for a failure
|
||||||
*/
|
*/
|
||||||
function byId(nodeName){
|
function byId(nodeName){
|
||||||
return document.getElementById(nodeName);
|
return document.getElementById(nodeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all nodes of a specified HTML element
|
||||||
|
*
|
||||||
|
* @param {HTMLElement} container The container to empty
|
||||||
|
* @return {Boolean} True for a success
|
||||||
|
*/
|
||||||
|
function emptyElem(container){
|
||||||
|
//Get children references
|
||||||
|
var children = container.childNodes;
|
||||||
|
|
||||||
|
//Process each child
|
||||||
|
for(i in children){
|
||||||
|
if(children[i].remove)
|
||||||
|
children[i].remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Success
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check a given email address
|
* Check a given email address
|
||||||
*
|
*
|
||||||
|
@ -19,8 +19,18 @@ ComunicWeb.components.menuBar.common = {
|
|||||||
|
|
||||||
//We check if the menubar is present or not on the page
|
//We check if the menubar is present or not on the page
|
||||||
if(menuBar){
|
if(menuBar){
|
||||||
ComunicWeb.debug.logMessage("Info: The menubar is already present on the page");
|
|
||||||
return true;
|
//We check if menubar is made for a logged user when not any is logged in or vice-versa
|
||||||
|
if(menuBar.getAttribute("forActiveUser") !== ComunicWeb.user.userLogin.getUserLoginState().toString()){
|
||||||
|
//Remove previously created menuBar
|
||||||
|
this.reset(menuBar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//Nothing to be done
|
||||||
|
ComunicWeb.debug.logMessage("Info: The menubar is already present on the page");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//So we have to initializate it
|
//So we have to initializate it
|
||||||
@ -84,6 +94,9 @@ ComunicWeb.components.menuBar.common = {
|
|||||||
//Now we need to know if user is logged in or not
|
//Now we need to know if user is logged in or not
|
||||||
var userLoggedIn = ComunicWeb.user.userLogin.getUserLoginState();
|
var userLoggedIn = ComunicWeb.user.userLogin.getUserLoginState();
|
||||||
|
|
||||||
|
//Save login information in menubar before continuing
|
||||||
|
menuContainer.setAttribute("forActiveUser", userLoggedIn);
|
||||||
|
|
||||||
//Call specific menu
|
//Call specific menu
|
||||||
if(userLoggedIn){
|
if(userLoggedIn){
|
||||||
//Not implemented yet
|
//Not implemented yet
|
||||||
@ -93,4 +106,20 @@ ComunicWeb.components.menuBar.common = {
|
|||||||
ComunicWeb.components.menuBar.notAuthenticated.addElements(containerElem);
|
ComunicWeb.components.menuBar.notAuthenticated.addElements(containerElem);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset a specified menubar
|
||||||
|
*
|
||||||
|
* @param {HTMLElement} menuBar The menuBar to reset
|
||||||
|
* @return {Boolean} True for a success
|
||||||
|
*/
|
||||||
|
reset: function(menuBar){
|
||||||
|
|
||||||
|
//Log action
|
||||||
|
ComunicWeb.debug.logMessage("Cleaning a menuBar element.");
|
||||||
|
|
||||||
|
//Perform action
|
||||||
|
return emptyElem(menuBar);
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
@ -21,10 +21,13 @@ ComunicWeb.pages.logout = {
|
|||||||
ComunicWeb.user.userLogin.logoutUser();
|
ComunicWeb.user.userLogin.logoutUser();
|
||||||
|
|
||||||
//Show a success notification
|
//Show a success notification
|
||||||
ComunicWeb.common.notificationSystem.showNotification("Good bye, you were sucessfully logouted !", "sucess", 5);
|
ComunicWeb.common.notificationSystem.showNotification("Good bye, you sucessfully terminated your session !", "sucess", 5);
|
||||||
|
|
||||||
//Open login page
|
//Open login page
|
||||||
ComunicWeb.common.page.openPage("login");
|
ComunicWeb.common.page.openPage("home");
|
||||||
|
|
||||||
|
//Remove overlay
|
||||||
|
screenOverlay.remove();
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user