From 5cfee77bb23941cc7f4c94c23ba19e3efb00c682 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 14 Jul 2018 11:48:59 +0200 Subject: [PATCH] Added a live notice to check the availability of a virtual directory for a group. --- assets/js/components/groups/interface.js | 17 +++++++++++++ assets/js/pages/groups/pages/settings.js | 31 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/assets/js/components/groups/interface.js b/assets/js/components/groups/interface.js index c313dd43..c51ef92b 100644 --- a/assets/js/components/groups/interface.js +++ b/assets/js/components/groups/interface.js @@ -109,6 +109,23 @@ ComunicWeb.components.groups.interface = { ComunicWeb.common.api.makeAPIrequest(apiURI, settings, true, callback); }, + /** + * Check the availability of a virtual directory for a group + * + * @param {String} directory The directory to check + * @param {Number} groupID The ID of the group to check + * @param {Function} callback + */ + checkVirtualDirectory: function(directory, groupID, callback){ + //Perform the request over the API + var apiURI = "groups/checkVirtualDirectory"; + var params = { + groupID: groupID, + directory: directory + }; + ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); + }, + /** * Upload a new group logo * diff --git a/assets/js/pages/groups/pages/settings.js b/assets/js/pages/groups/pages/settings.js index bd722283..bcd991b1 100644 --- a/assets/js/pages/groups/pages/settings.js +++ b/assets/js/pages/groups/pages/settings.js @@ -130,6 +130,37 @@ ComunicWeb.pages.groups.pages.settings = { value: settings.virtual_directory == "null" ? "" : settings.virtual_directory, }); + //Check message target + var checkVirtualDirectoryTarget = createElem2({ + appendTo: formContainer, + type: "small" + }); + + virtualDirectory.onkeyup = function(){ + + checkVirtualDirectoryTarget.innerHTML = "Checking availability..."; + + //Get the directory to check + var directory = virtualDirectory.value; + + //Check if the directory is empty + if(directory == ""){ + checkVirtualDirectoryTarget.innerHTML = ""; + return; + } + + //Perform a request on the API + ComunicWeb.components.groups.interface.checkVirtualDirectory(directory, settings.id, function(callback){ + + //Check if the directory is available or not + checkVirtualDirectoryTarget.innerHTML = + callback.error + ? "This directory is not available!" + : "This directory seems to be available!"; + + }) + } + //Group visibility var visibilityForm = createElem2({