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({