From 8367a769064ee65b0c150ec2d3e80ff9b1fdfb6f Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 29 Apr 2018 15:13:51 +0200 Subject: [PATCH] Get account image settings from the server --- .../pages/settings/sections/accountImage.css | 5 ++ assets/js/common/functionsSchema.js | 12 ++++ assets/js/common/messages.js | 18 ++++++ assets/js/components/settings/interface.js | 11 ++++ assets/js/pages/settings/navigationPane.js | 14 +++++ .../pages/settings/sections/accountImage.js | 63 +++++++++++++++++++ assets/js/pages/settings/sections/general.js | 2 +- assets/js/pages/settings/sectionsList.js | 8 +++ system/config/dev.config.php | 2 + 9 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 assets/css/pages/settings/sections/accountImage.css create mode 100644 assets/js/pages/settings/sections/accountImage.js diff --git a/assets/css/pages/settings/sections/accountImage.css b/assets/css/pages/settings/sections/accountImage.css new file mode 100644 index 00000000..3f268d75 --- /dev/null +++ b/assets/css/pages/settings/sections/accountImage.css @@ -0,0 +1,5 @@ +/** + * Account image settings section stylesheet + * + * @author Pierre HUBERT + */ \ No newline at end of file diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 9446d490..7f2c7b42 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -99,6 +99,11 @@ var ComunicWeb = { */ createCalloutElem: function(calloutTitle, calloutMessage, calloutType){}, + /** + * Create and return a callout element + */ + createLoadingCallout: function(target){}, + /** * Create and display a confirmation dialog */ @@ -1129,6 +1134,13 @@ var ComunicWeb = { password: { //TODO : implement }, + + /** + * Account image section + */ + accountImage: { + //TODO : implement + }, }, }, diff --git a/assets/js/common/messages.js b/assets/js/common/messages.js index 0ac3ed7c..0557a48a 100644 --- a/assets/js/common/messages.js +++ b/assets/js/common/messages.js @@ -37,6 +37,24 @@ ComunicWeb.common.messages.createCalloutElem = function(calloutTitle, calloutMes return calloutElem; } +/** + * Create loading callout element + * + * @param {HTMLElement} target Optionnal, the target of the callout element + * @return {HTMLElement} Generated loading callout element + */ +ComunicWeb.common.messages.createLoadingCallout = function(target){ + + var elem = this.createCalloutElem("Loading", "Please wait while this page is loading...", "info"); + + if(target) + target.appendChild(elem); + + return elem; + +} + + /** * Create a confirmation dialog * diff --git a/assets/js/components/settings/interface.js b/assets/js/components/settings/interface.js index 8b25f424..bff802a7 100644 --- a/assets/js/components/settings/interface.js +++ b/assets/js/components/settings/interface.js @@ -85,4 +85,15 @@ ComunicWeb.components.settings.interface = { }; ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); }, + + /** + * Get account image settings from the API + * + * @param {function} callback + */ + getAccountImage: function(callback){ + var apiURI = "settings/get_account_image"; + var params = {}; + ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); + } } \ No newline at end of file diff --git a/assets/js/pages/settings/navigationPane.js b/assets/js/pages/settings/navigationPane.js index 165f8f71..f7ef5280 100644 --- a/assets/js/pages/settings/navigationPane.js +++ b/assets/js/pages/settings/navigationPane.js @@ -77,6 +77,20 @@ ComunicWeb.pages.settings.navigationPane = { sectionSecurityLink.onclick = function(){ openPage("settings/security"); }; + + //Account image + var sectionSecurity = createElem2({ + appendTo: elemList, + type: "li", + }); + var sectionSecurityLink = createElem2({ + appendTo: sectionSecurity, + type: "a", + innerHTML: " Account image" + }); + sectionSecurityLink.onclick = function(){ + openPage("settings/account_image"); + }; } } \ No newline at end of file diff --git a/assets/js/pages/settings/sections/accountImage.js b/assets/js/pages/settings/sections/accountImage.js new file mode 100644 index 00000000..77d48de3 --- /dev/null +++ b/assets/js/pages/settings/sections/accountImage.js @@ -0,0 +1,63 @@ +/** + * Account image settings section + * + * @author Pierre HUBERT + */ + +ComunicWeb.pages.settings.sections.accountImage = { + + /** + * Open settings section + * + * @param {object} args Additionnal arguments + * @param {HTMLElement} target The target for the page + */ + open: function(args, target){ + + //Create a box + var box = createElem2({ + appendTo: target, + type: "div", + class: "box box-primary box-account-image-settings" + }); + + //Add box header + var boxHead = createElem2({ + appendTo: box, + type: "div", + class: "box-header", + }); + var boxTitle = createElem2({ + appendTo: boxHead, + type: "h3", + class: "box-title", + innerHTML: "Account image" + }); + + //Create box body + var boxBody = createElem2({ + appendTo: box, + type: "div", + class: "box-body" + }); + + //Add loading callout + var loadMsg = ComunicWeb.common.messages.createLoadingCallout(boxBody); + + //Fetch information about account image on the API + ComunicWeb.components.settings.interface.getAccountImage(function(result){ + + //Remove loading message + loadMsg.remove(); + + //Check for errors + if(result.error){ + notify("Could not get account image information !", "danger"); + return; + } + + //Apply account image settings + + }); + }, +} \ No newline at end of file diff --git a/assets/js/pages/settings/sections/general.js b/assets/js/pages/settings/sections/general.js index 386d4fb0..d0364a09 100644 --- a/assets/js/pages/settings/sections/general.js +++ b/assets/js/pages/settings/sections/general.js @@ -42,7 +42,7 @@ ComunicWeb.pages.settings.sections.general = { }); //Display loading message - var loadingMsg = ComunicWeb.common.messages.createCalloutElem("Loading", "Please wait while this page is loading...", "info"); + var loadingMsg = ComunicWeb.common.messages.createLoadingCallout(); boxBody.appendChild(loadingMsg); //Load general settings information diff --git a/assets/js/pages/settings/sectionsList.js b/assets/js/pages/settings/sectionsList.js index 07d33560..5a23a256 100644 --- a/assets/js/pages/settings/sectionsList.js +++ b/assets/js/pages/settings/sectionsList.js @@ -29,4 +29,12 @@ ComunicWeb.pages.settings.sectionsList = { title: "Password", handler: "ComunicWeb.pages.settings.sections.password.open", }, + + /** + * Account image + */ + account_image: { + title: "Account image", + handler: "ComunicWeb.pages.settings.sections.accountImage.open" + }, } \ No newline at end of file diff --git a/system/config/dev.config.php b/system/config/dev.config.php index ef74ab57..286de432 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -177,6 +177,7 @@ class Dev { "css/pages/settings/sections/general.css", "css/pages/settings/sections/security.css", "css/pages/settings/sections/password.css", + "css/pages/settings/sections/accountImage.css", //Latest post page stylesheet "css/pages/latestPosts/main.css", @@ -345,6 +346,7 @@ class Dev { "js/pages/settings/sections/general.js", "js/pages/settings/sections/security.js", "js/pages/settings/sections/password.js", + "js/pages/settings/sections/accountImage.js", //Login page "js/pages/login.js",