mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Retrieve group settings on the API
This commit is contained in:
parent
30696174f2
commit
218e9b6fbe
16
assets/css/pages/groups/pages/settings.css
Normal file
16
assets/css/pages/groups/pages/settings.css
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Group settings stylesheet
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
|
||||||
|
.group-settings-container {
|
||||||
|
float: none;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-settings-container .title {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
@ -1219,6 +1219,13 @@ var ComunicWeb = {
|
|||||||
//TODO : implement
|
//TODO : implement
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings page
|
||||||
|
*/
|
||||||
|
settings: {
|
||||||
|
//TODO : implement
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +50,21 @@ ComunicWeb.components.groups.interface = {
|
|||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the settings of a group
|
||||||
|
*
|
||||||
|
* @param {Number} id The ID of the target group
|
||||||
|
* @param {Function} callback
|
||||||
|
*/
|
||||||
|
getSettings: function(id, callback){
|
||||||
|
//Perform the request over the API
|
||||||
|
var apiURI = "groups/get_settings";
|
||||||
|
var params = {
|
||||||
|
id: id
|
||||||
|
};
|
||||||
|
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
@ -54,9 +54,12 @@ ComunicWeb.pages.groups.main = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Check which page to open
|
//Check which page to open
|
||||||
if(page == "group"){
|
if(page == "group")
|
||||||
ComunicWeb.pages.groups.pages.group.open(groupID, target);
|
ComunicWeb.pages.groups.pages.group.open(groupID, target);
|
||||||
}
|
|
||||||
|
else if(page == "settings")
|
||||||
|
ComunicWeb.pages.groups.pages.settings.open(groupID, target);
|
||||||
|
|
||||||
|
|
||||||
//Unrecognized page
|
//Unrecognized page
|
||||||
else
|
else
|
||||||
|
@ -21,7 +21,7 @@ ComunicWeb.pages.groups.pages.group = {
|
|||||||
if(result.error){
|
if(result.error){
|
||||||
|
|
||||||
//Check the code of the error
|
//Check the code of the error
|
||||||
if(result.error.code == 404){
|
if(result.error.code == 401){
|
||||||
need_auth;//TODO : implement
|
need_auth;//TODO : implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
87
assets/js/pages/groups/pages/settings.js
Normal file
87
assets/js/pages/groups/pages/settings.js
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
* Page settings
|
||||||
|
*
|
||||||
|
* @author Pierre HUBERT
|
||||||
|
*/
|
||||||
|
|
||||||
|
ComunicWeb.pages.groups.pages.settings = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open group settings page
|
||||||
|
*
|
||||||
|
* @param {Number} id The ID of the settings page
|
||||||
|
* @param {HTMLElement} target The target of the page
|
||||||
|
*/
|
||||||
|
open: function(id, target){
|
||||||
|
|
||||||
|
//Create settings container
|
||||||
|
var settingsContainer = createElem2({
|
||||||
|
appendTo: target,
|
||||||
|
type: "div",
|
||||||
|
class: "group-settings-container col-md-6"
|
||||||
|
});
|
||||||
|
|
||||||
|
//Add title
|
||||||
|
createElem2({
|
||||||
|
appendTo: settingsContainer,
|
||||||
|
type: "h2",
|
||||||
|
class: "title",
|
||||||
|
innerHTML: "Group settings"
|
||||||
|
});
|
||||||
|
|
||||||
|
//Display loading message
|
||||||
|
var loadingMsg = ComunicWeb.common.messages.createCalloutElem(
|
||||||
|
"Loading",
|
||||||
|
"Please wait while we retrieve the settings of the page...",
|
||||||
|
"info");
|
||||||
|
settingsContainer.appendChild(loadingMsg);
|
||||||
|
|
||||||
|
//Get the settings of the page
|
||||||
|
ComunicWeb.components.groups.interface.getSettings(id, function(result){
|
||||||
|
|
||||||
|
//Remove loading message
|
||||||
|
loadingMsg.remove();
|
||||||
|
|
||||||
|
//Check for error
|
||||||
|
if(result.error){
|
||||||
|
|
||||||
|
//Check if the user is not authorized to access the page
|
||||||
|
if(result.error.code == 401){
|
||||||
|
//The user is not authorized to see this page
|
||||||
|
settingsContainer.appendChild(ComunicWeb.common.messages.createCalloutElem(
|
||||||
|
"Access forbidden",
|
||||||
|
"You are not authorized to access these information !",
|
||||||
|
"danger"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Else the page was not found
|
||||||
|
else {
|
||||||
|
settingsContainer.remove();
|
||||||
|
ComunicWeb.common.error.pageNotFound({}, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
//Display settings pages
|
||||||
|
ComunicWeb.pages.groups.pages.settings.display(id, result, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display page settings
|
||||||
|
*
|
||||||
|
* @param {Number} id The ID of the target page
|
||||||
|
* @param {Object} settings The settings of the page
|
||||||
|
* @param {HTMLElement} target The target of the page
|
||||||
|
*/
|
||||||
|
display: function(id, settings, target){
|
||||||
|
|
||||||
|
alert(settings);
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
@ -71,6 +71,20 @@ ComunicWeb.pages.groups.sections.header = {
|
|||||||
type: "div",
|
type: "div",
|
||||||
innerHTML: '<i class="fa fa-group"></i> '+ info.number_members+' members'
|
innerHTML: '<i class="fa fa-group"></i> '+ info.number_members+' members'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//If the user is an admin, add a link to configure the page
|
||||||
|
if(signed_in() && info.membership == "administrator"){
|
||||||
|
|
||||||
|
var settingsLink = createElem2({
|
||||||
|
appendTo: secondColumn,
|
||||||
|
type: "div",
|
||||||
|
class: "a",
|
||||||
|
innerHTML: " <i class='fa fa-gear'></i>Settings"
|
||||||
|
});
|
||||||
|
settingsLink.addEventListener("click", function(e){
|
||||||
|
openPage("groups/" + info.id + "/settings");
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
@ -221,6 +221,7 @@ class Dev {
|
|||||||
"css/pages/groups/pages/main.css",
|
"css/pages/groups/pages/main.css",
|
||||||
"css/pages/groups/pages/create.css",
|
"css/pages/groups/pages/create.css",
|
||||||
"css/pages/groups/pages/group.css",
|
"css/pages/groups/pages/group.css",
|
||||||
|
"css/pages/groups/pages/settings.css",
|
||||||
|
|
||||||
//Groups sections
|
//Groups sections
|
||||||
"css/pages/groups/sections/header.css",
|
"css/pages/groups/sections/header.css",
|
||||||
@ -425,6 +426,7 @@ class Dev {
|
|||||||
"js/pages/groups/pages/main.js",
|
"js/pages/groups/pages/main.js",
|
||||||
"js/pages/groups/pages/create.js",
|
"js/pages/groups/pages/create.js",
|
||||||
"js/pages/groups/pages/group.js",
|
"js/pages/groups/pages/group.js",
|
||||||
|
"js/pages/groups/pages/settings.js",
|
||||||
|
|
||||||
//Groups sections
|
//Groups sections
|
||||||
"js/pages/groups/sections/header.js",
|
"js/pages/groups/sections/header.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user