/** * Remove workspaces with given id or name * @param {String|RegExp} config.name name of the workspace * @param {String} config.id id of the workspace. id or name must be passed * @param {Funcion} callback success callback * @param {Function} errback error callback * @return {void} * 2017-01-05 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com> */functionremoveWorkspaces(config,callback,errback){$GP.user.workspaces.find({predicate:function(obj){console.log(obj);returnobj.id===config.id||(config.nameinstanceofRegExp?config.name.test(obj.name):obj.name===config.name);}},function(ret){varw=ret.workspaces;if(w.length===0){if(typeoferrback==="function")errback({success:false,message:"Error"});return;};for(vari=0,l=w.length;i<l;i++){w[i].remove();}if(typeofcallback==="function")callback({success:true});});}// usage:/*removeWorkspaces({ name: /workspace/i}, function() { console.log("Workspaces removed")})*/
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.