@c8y/ng1-modules 1018.320.0 → 1018.323.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _slicedToArray(n
|
|
1
|
+
"use strict";function _slicedToArray(r,n){return _arrayWithHoles(r)||_iterableToArrayLimit(r,n)||_unsupportedIterableToArray(r,n)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,n){if(r){if("string"==typeof r)return _arrayLikeToArray(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,n):void 0}}function _arrayLikeToArray(r,n){(null==n||n>r.length)&&(n=r.length);for(var t=0,e=new Array(n);t<n;t++)e[t]=r[t];return e}function _iterableToArrayLimit(r,n){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,u,o,a,c=[],i=!0,f=!1;try{if(o=(t=t.call(r)).next,0===n){if(Object(t)!==t)return;i=!1}else for(;!(i=(e=o.call(t)).done)&&(c.push(e.value),c.length!==n);i=!0);}catch(r){f=!0,u=r}finally{try{if(!i&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(f)throw u}}return c}}function _arrayWithHoles(r){if(Array.isArray(r))return r}!function(){function r(o,a,c,n){var i="user/";function f(){return n.current().then(function(r){var n=r.tenant;return c.url("".concat(i+n,"/groups"))})}function e(r){var t=r.id||r;return n.current().then(function(r){var n=r.tenant;return c.url("".concat(i+n,"/groups/").concat(t))})}function l(r,n){return e(r).then(function(r){return"".concat(r,"/users").concat(n?"/".concat(encodeURIComponent(n.id||n)):"")})}function s(r){return e(r).then(function(r){return"".concat(r,"/roles")})}function u(r){return e(r).then(function(r){return o.get(r)})}function t(n){var t={headers:c.contentHeaders("group")};return e(n).then(function(r){return o.put(r,n,t).then(function(){return n})})}function h(n){var t={headers:c.contentHeaders("group")};return f().then(function(r){return o.post(r,n,t).then(function(r){return u(_slicedToArray(r.headers("location").match(/\d+$/),1)[0]).then(function(r){return r.data})})})}function d(r,n){return function(r,n){var t=n.id||n;return s(r).then(function(r){return"".concat(r,"/").concat(t)})}(r,n).then(function(r){return o.delete(r)})}return{list:function r(n){var t=c.pageSizeFilter(n),e={params:t},u=c.cleanListCallback("groups",r,t);return f().then(function(r){return o.get(r,e).then(u)})},detail:u,remove:function(r){return e(r).then(function(r){return o.delete(r)})},create:h,update:t,save:function(r){return r.id?t(r):h(r)},listRoles:function r(n){var t=c.pageSizeFilter(n),e={params:t},u=c.cleanListCallback("roles",r,t);return a.when(c.url("".concat(i,"roles"))).then(function(r){return o.get(r,e).then(u)})},updateGroups:function(n,t){var e=_.get(n,"groups.references",[]).map(function(r){return r.group.id}),u=[];return t.forEach(function(r){-1===e.indexOf(r)&&u.push(function(r,n){var t={user:_.pick(n,["id","self"])};return l(r).then(function(r){return o.post(r,t)})}(r,n))}),e.forEach(function(r){-1===t.indexOf(r)&&u.push(function(r,n){return l(r,n).then(function(r){return o.delete(r)})}(r,n))}),a.all(u)},updateRoles:function(n,t){var e=n.roles.references.map(function(r){return r.role.id}),u=[];return t.forEach(function(r){-1===e.indexOf(r)&&u.push(function(r,n){var t={headers:c.contentHeaders("roleReference")};return s(r).then(function(r){return o.post(r,{role:n},t)})}(n,{self:c.url("user/roles/".concat(r))}))}),e.forEach(function(r){-1===t.indexOf(r)&&u.push(d(n,r))}),a.all(u)}}}r.$inject=["$http","$q","c8yBase","c8yUser"],angular.module("c8y.core").factory("c8yUserGroup",r)}();
|