From feb17e3f13416b50beb72f6b9926fe8690c4ba7d Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 23 Jan 2019 15:19:34 +0100 Subject: [PATCH] Automatically retrieve calls configuration --- assets/js/common/functionsSchema.js | 25 +++++++++++++ assets/js/common/system.js | 5 +++ assets/js/components/calls/controller.js | 47 ++++++++++++++++++++++++ assets/js/components/calls/interface.js | 19 ++++++++++ assets/js/user/userLogin.js | 10 ++++- system/config/dev.config.php | 4 ++ 6 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 assets/js/components/calls/controller.js create mode 100644 assets/js/components/calls/interface.js diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 012ebadd..a5cf4ab3 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -1144,6 +1144,31 @@ var ComunicWeb = { }, + /** + * Calls component + */ + calls: { + + /** + * Calls configuration + */ + __config: undefined, + + /** + * Calls interface + */ + interface: { + //TODO : implement + }, + + /** + * Calls controller + */ + controller: { + //TODO : implement + }, + }, + /** * Easter egg : pacman */ diff --git a/assets/js/common/system.js b/assets/js/common/system.js index 6f6c5a59..9caa9e30 100644 --- a/assets/js/common/system.js +++ b/assets/js/common/system.js @@ -58,6 +58,11 @@ ComunicWeb.common.system = { */ ComunicWeb.components.darkTheme.refresh(); + /** + * Initialize call system + */ + ComunicWeb.components.calls.controller.init(); + /** * What to do after login refresh */ diff --git a/assets/js/components/calls/controller.js b/assets/js/components/calls/controller.js new file mode 100644 index 00000000..06b9bbfc --- /dev/null +++ b/assets/js/components/calls/controller.js @@ -0,0 +1,47 @@ +/** + * Calls controller + * + * @author Pierre HUBERT + */ + +ComunicWeb.components.calls.controller = { + + /** + * This variable contains the initialization state + * of the call component + */ + _is_init: false, + + /** + * Initialize calls component + */ + init: function(){ + + //We init this component just once + if(this._is_init) + return; + + ComunicWeb.debug.logMessage("Initialize calls component"); + + //We wait the user to be connected before trying to get + // call configuration + document.addEventListener("got_user_id", function(){ + + //Check if we have already the call configuration + if(ComunicWeb.components.calls.__config !== undefined) + return; + + ComunicWeb.components.calls.interface.getConfig(function(config){ + + //Check if we could not get calls configuration + if(config.error) + return; + + //Save calls configuration + ComunicWeb.components.calls.__config = config; + }); + + }); + } + +} \ No newline at end of file diff --git a/assets/js/components/calls/interface.js b/assets/js/components/calls/interface.js new file mode 100644 index 00000000..590a0a23 --- /dev/null +++ b/assets/js/components/calls/interface.js @@ -0,0 +1,19 @@ +/** + * Calls interface + * + * @author Pierre HUBERT + */ + +ComunicWeb.components.calls.interface = { + + /** + * Get calls configuration + * + * @param {function} callback Function that will be called + * once the operation has completed + */ + getConfig: function(callback){ + ComunicWeb.common.api.makeAPIrequest("calls/config", {}, true, callback); + } + +} \ No newline at end of file diff --git a/assets/js/user/userLogin.js b/assets/js/user/userLogin.js index 6c922295..0026b5bb 100644 --- a/assets/js/user/userLogin.js +++ b/assets/js/user/userLogin.js @@ -77,12 +77,18 @@ ComunicWeb.user.userLogin = { //Perform next action afterGetCurrentUserID(0); } - else{ + else + { //Update user ID ComunicWeb.user.userLogin.__userID = result.userID; //Perform next action - afterGetCurrentUserID(result.userID) + afterGetCurrentUserID(result.userID); + + //Notify about the event + SendEvent("got_user_id", { + userID: result.userID + }); } }; diff --git a/system/config/dev.config.php b/system/config/dev.config.php index 12a5bbaf..1f5571a4 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -437,6 +437,10 @@ class Dev { "js/components/incognito/management.js", "js/components/incognito/keyboard.js", + //Calls compontent + "js/components/calls/interface.js", + "js/components/calls/controller.js", + //Pacman component (easter egg) "js/components/pacman.js",