@c8y/ng1-modules 1018.505.8 → 1018.509.6

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.
Files changed (31) hide show
  1. package/administration-archivesEditor/views/index.html +1 -1
  2. package/binaryArtefactsManagement/index.js +1 -1
  3. package/binaryArtefactsManagement/views/list.html +1 -1
  4. package/cockpit-smartRulesUI/index.js +1 -1
  5. package/commandTemplates/controllers/commandTemplates.js +1 -1
  6. package/core/core/services/deviceShell.js +1 -1
  7. package/core/core/services/dynamicGroups.js +1 -1
  8. package/core/core/services/groups.js +1 -1
  9. package/core/core/services/permissions.js +1 -1
  10. package/core/core/services/userPreferences.js +1 -1
  11. package/core/locales/pl.po +301 -146
  12. package/core/ui/services/groupsHierarchySvc.js +1 -1
  13. package/core/ui/user/measurementUnitPreference.component.js +1 -1
  14. package/dashboard2/dashboard.service.js +1 -1
  15. package/device-protocol-lwm2m/lwm2mDetail.html +2 -2
  16. package/deviceDatabase4/device-database.service.js +1 -1
  17. package/deviceDatabase4/device-type-list.html +1 -1
  18. package/deviceDatabase4/modals/configure-register.component.js +1 -1
  19. package/deviceGroupAssignment/groupAssignment.component.js +1 -1
  20. package/deviceSelector/views/deviceSelectorCombo.html +1 -1
  21. package/devicemanagement-availability/index.js +1 -1
  22. package/devicemanagement-logViewer/views/index.html +1 -0
  23. package/enterpriseEdition/enterpriseEdition.module.js +1 -1
  24. package/export/directives/timespan.js +1 -1
  25. package/export/views/timespan.html +12 -27
  26. package/kpi/views/graphConfig.html +2 -2
  27. package/kpi/views/setup.html +1 -1
  28. package/package.json +1 -1
  29. package/smartRules/controllers/list.js +1 -1
  30. package/smartRules/list/smartRulesList.component.js +1 -1
  31. package/smartRules/services/smartRules.js +1 -1
@@ -1 +1 @@
1
- "use strict";!function(){function e(i,t,u,c,s,a,n,l,o,d,h,v,g,f,r,p){return{addAssetUI:function(){return r.open({component:"c8yGroupCreateAndAssignModal",ariaLabelledBy:"modal-title",ariaDescribedBy:"modal-body"}).result},editGroup:function(e){t.url("/group/".concat(e.id))},deleteGroup:function(e){return a.remove(e)},deleteGroupWithConfirmation:function(t){var n=0<_.get(t,"childAssets.references.length")||0<_.get(t,"childDevices.references.length"),e=o.isDynamicGroup(t),r=e&&!n?u.when():d.getItemsCount(t).then(function(e){n=0===e});return r.then(function(){return c({title:g("Delete group"),body:n||e?f.getString('You are about to delete group "{{name}}". This operation is irreversible. Do you want to proceed?',t):f.getString('You are about to delete group "{{name}}" and its subgroups recursively. This operation is irreversible. Do you want to proceed?',t),checkboxes:{cascade:{text:g("Also delete all devices inside this group and its subgroups."),checked:!1,showIf:function(){return!(n||e)}}},status:"danger",labels:{ok:g("Delete")}}).then(function(e){return o.isSmartGroupV2(t)?o.remove(t):a.remove(t,e)}).then(function(){return v.removeGroupNavigation(t)}).then(function(){return s.success(g("Group deleted."))})})},deleteDeviceWithConfirmation:function(n,e){var t=void 0===n.c8y_IsDevice,r=!_.isUndefined(n.childDevices)&&0<n.childDevices.references.length,o=function(){return!t&&!e&&r};return(r||e||t?u.when():h.getChildDevicesCount(n).then(function(e){r=0<e})).then(function(){return c({title:g("Delete device"),body:f.getString('You are about to delete device "{{name}}". This operation is irreversible. Do you want to proceed?',n),checkboxes:{cascade:{text:g("Also delete child devices of this device."),checked:o(),showIf:o},withDeviceUser:{text:f.getString('Also delete associated device owner "{{ owner }}".',n),checked:!1,showIf:function(){var e=n.c8y_IsDevice,t=n.owner&&l.isDeviceUser({id:n.owner});return Boolean(e&&t)}}},labels:{ok:g("Delete")},status:"danger"}).then(function(e){return a.remove(n,e)}).then(function(){return v.updateAllGroupsOfAChild(n)}).then(function(){return s.success(g("Device deleted."))})})},unassignDevice:function(r,o){var e={title:g("Unassign device"),body:f.getString('You are about to unassign device "{{name}}". Do you want to proceed?',o),status:"warning",size:"sm",labels:{ok:g("Unassign")}};return c(e).then(function(){return p.isApplicationAvailable().then(function(e){if(!e)return null;var e=r.id,t=o,n=u.when();try{return(n=i.get("smartRulesSvc")).listByContext(e).then(function(e){return u.all(e.map(function(e){return n.deactivate(e,t,!1)}))})}catch(e){return n}})}).then(function(){return a.removeChildAsset(r,o)}).then(function(){return v.updateGroupChildren(r)})},assignDevices:function(e){return r.open({component:"c8yGroupDeviceAssignmentModal",resolve:{currentGroup:function(){return e}}}).result.then(function(){return v.updateGroupChildren(e)})},getGroup:function(e){return a.detail(e).then(n.getResData)}}}e.$inject=["$injector","$location","$q","c8yModal","c8yAlert","c8yInventory","c8yBase","c8yUser","c8yDynamicGroups","c8yGroups","c8yDevices","groupTypesHierarchyNavigator","gettext","gettextCatalog","$uibModal","c8ySmartRulesAvailability"],angular.module("c8y.ui").factory("groupsHierarchySvc",e)}();
1
+ "use strict";!function(){function e(i,t,u,c,s,a,n,l,o,d,h,v,g,f,r,p){return{addAssetUI:function(){return r.open({component:"c8yGroupCreateAndAssignModal",ariaLabelledBy:"modal-title",ariaDescribedBy:"modal-body"}).result},editGroup:function(e){t.url("/group/".concat(e.id))},deleteGroup:function(e){return a.remove(e)},deleteGroupWithConfirmation:function(t){var n=0<_.get(t,"childAssets.references.length")||0<_.get(t,"childDevices.references.length"),e=o.isDynamicGroup(t),r=e&&!n?u.when():d.getItemsCount(t).then(function(e){n=0===e});return r.then(function(){return c({title:g("Delete group"),body:n||e?f.getString('You are about to delete group "{{name}}". This operation is irreversible. Do you want to proceed?',t):f.getString('You are about to delete group "{{name}}" and its subgroups recursively. This operation is irreversible. Do you want to proceed?',t),checkboxes:{cascade:{text:g("Also delete all devices inside this group and its subgroups."),checked:!1,showIf:function(){return!(n||e)}}},status:"danger",labels:{ok:g("Delete")}}).then(function(e){return a.remove(t,e)}).then(function(){return v.removeGroupNavigation(t)}).then(function(){return s.success(g("Group deleted."))})})},deleteDeviceWithConfirmation:function(n,e){var t=void 0===n.c8y_IsDevice,r=!_.isUndefined(n.childDevices)&&0<n.childDevices.references.length,o=function(){return!t&&!e&&r};return(r||e||t?u.when():h.getChildDevicesCount(n).then(function(e){r=0<e})).then(function(){return c({title:g("Delete device"),body:f.getString('You are about to delete device "{{name}}". This operation is irreversible. Do you want to proceed?',n),checkboxes:{cascade:{text:g("Also delete child devices of this device."),checked:o(),showIf:o},withDeviceUser:{text:f.getString('Also delete associated device owner "{{ owner }}".',n),checked:!1,showIf:function(){var e=n.c8y_IsDevice,t=n.owner&&l.isDeviceUser({id:n.owner});return Boolean(e&&t)}}},labels:{ok:g("Delete")},status:"danger"}).then(function(e){return a.remove(n,e)}).then(function(){return v.updateAllGroupsOfAChild(n)}).then(function(){return s.success(g("Device deleted."))})})},unassignDevice:function(r,o){var e={title:g("Unassign device"),body:f.getString('You are about to unassign device "{{name}}". Do you want to proceed?',o),status:"warning",size:"sm",labels:{ok:g("Unassign")}};return c(e).then(function(){return p.isApplicationAvailable().then(function(e){if(!e)return null;var e=r.id,t=o,n=u.when();try{return(n=i.get("smartRulesSvc")).listByContext(e).then(function(e){return u.all(e.map(function(e){return n.deactivate(e,t,!1)}))})}catch(e){return n}})}).then(function(){return a.removeChildAsset(r,o)}).then(function(){return v.updateGroupChildren(r)})},assignDevices:function(e){return r.open({component:"c8yGroupDeviceAssignmentModal",resolve:{currentGroup:function(){return e}}}).result.then(function(){return v.updateGroupChildren(e)})},getGroup:function(e){return a.detail(e).then(n.getResData)}}}e.$inject=["$injector","$location","$q","c8yModal","c8yAlert","c8yInventory","c8yBase","c8yUser","c8yDynamicGroups","c8yGroups","c8yDevices","groupTypesHierarchyNavigator","gettext","gettextCatalog","$uibModal","c8ySmartRulesAvailability"],angular.module("c8y.ui").factory("groupsHierarchySvc",e)}();
@@ -1 +1 @@
1
- "use strict";!function(){function e(t,e,n,i){var s,r=this,a=e.createEnum([{name:"NO_CONVERSION",label:i("No conversion"),value:""},{name:"IMPERIAL",label:i("Imperial"),value:"imperial"},{name:"METRIC",label:i("Metric"),value:"metric"}]);_.assign(r,{UNIT_TYPES:a.values(),$doCheck:function(){_.isEqual(r.user,s)||(r.loading=!0,t.current().then(function(e){var n=_.isEqual(e.userName,_.get(r,"user.userName"));_.set(r,"visible",(e=e,t.hasRole(e,"ROLE_INVENTORY_READ")&&t.hasRole(e,"ROLE_INVENTORY_ADMIN")&&n))}),n.get("unit",r.user).then(function(e){_.isUndefined(e)?_.set(r.user,"measurementUnit",a.NO_CONVERSION):_.set(r.user,"measurementUnit",_.find(a.values(),{value:e}))}).finally(function(){r.loading=!1}),s=r.user)},tooltip:i('Selected unit conversion will be used for displaying data. Select "No conversion" to see original units sent by devices.'),loading:!1})}e.$inject=["c8yUser","c8yBase","c8yUserPreferences","gettext"],angular.module("c8y.ui").component("c8yMeasurementUnitPreference",{controller:e,controllerAs:"vm",templateUrl:":::PLUGIN_PATH:::/ui/user/measurementUnitPreference.html",bindings:{user:"="}})}();
1
+ "use strict";!function(){function e(t,e,n,i){var s,r=this,a=e.createEnum([{name:"NO_CONVERSION",label:i("No conversion"),value:""},{name:"IMPERIAL",label:i("Imperial"),value:"imperial"},{name:"METRIC",label:i("Metric"),value:"metric"}]);_.assign(r,{UNIT_TYPES:a.values(),$doCheck:function(){_.isEqual(r.user,s)||(r.loading=!0,t.current().then(function(e){var n=_.isEqual(e.userName,_.get(r,"user.userName"));_.set(r,"visible",(e=e,(t.hasRole(e,"ROLE_INVENTORY_READ")&&t.hasRole(e,"ROLE_INVENTORY_ADMIN")||t.hasRole(e,"ROLE_MANAGED_OBJECT_READ")&&t.hasRole(e,"ROLE_MANAGED_OBJECT_ADMIN"))&&n))}),n.get("unit",r.user).then(function(e){_.isUndefined(e)?_.set(r.user,"measurementUnit",a.NO_CONVERSION):_.set(r.user,"measurementUnit",_.find(a.values(),{value:e}))}).finally(function(){r.loading=!1}),s=r.user)},tooltip:i('Selected unit conversion will be used for displaying data. Select "No conversion" to see original units sent by devices.'),loading:!1})}e.$inject=["c8yUser","c8yBase","c8yUserPreferences","gettext"],angular.module("c8y.ui").component("c8yMeasurementUnitPreference",{controller:e,controllerAs:"vm",templateUrl:":::PLUGIN_PATH:::/ui/user/measurementUnitPreference.html",bindings:{user:"="}})}();
@@ -1 +1 @@
1
- "use strict";function _slicedToArray(e,n){return _arrayWithHoles(e)||_iterableToArrayLimit(e,n)||_unsupportedIterableToArray(e,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(e,n){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,n):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,n):void 0}function _arrayLikeToArray(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function _iterableToArrayLimit(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i,a,c=[],u=!0,d=!1;try{if(i=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;u=!1}else for(;!(u=(r=i.call(t)).done)&&(c.push(r.value),c.length!==n);u=!0);}catch(e){d=!0,o=e}finally{try{if(!u&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw o}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}!function(){function ue(e,n,W,o,$,a,i,c,u,j,t,d,G,l,s,f){var h=e("dashboards"),p=e("dashboardLists"),g="c8y_Dashboard",M={welcome:{icon:"cloud",name:s.getString("Welcome")},home:{icon:"home",name:s.getString("Home")}};function z(e){return _.map(e,function(e){return _.assign(_.get(e,g,{}),{id:e.id})})}function m(e){var t,n,r,e=e||{},o=_.assign(_.get(e,g,{}),{id:e.id},(t=/^c8y_Dashboard!(.+)$/,_.pickBy(e,function(e,n){return t.test(n)})));return _.set(o,"global",!!_.get(e,"c8y_Global")),n=o,r=["templateUrl","configTemplateUrl"],e=_.map(n.children,function(e){return a.all(_.map(r,_.partial(K,e)))}),a.all(e).then(function(){return n}).then(H)}function H(n){return n.children?(e=n.children,t.list().then(function(n){return _(e).mapValues(function(e){return V(e,n,!1)}).value()}).then(function(e){return n.children=e,n})):n;var e}function V(e,n,t){var r,o=_.cloneDeep(e),e=_.find(n,function(e){var n=e.name&&e.name===o.name,e=e.templateUrl&&e.templateUrl===o.templateUrl;return n||e});return e?((r=e.replaceWith)&&(o.config=i.invoke(r.config,void 0,{oldConfig:o.config}),e=_.find(n,{name:r.component})),o.name=e.name,e.transformConfigWithContext&&(o.componentTransformConfigWithContext=e.transformConfigWithContext),e.widgetComponent?(o.widgetComponent=e.widgetComponent,delete o.templateUrl):o.templateUrl=e.templateUrl,e.configComponent?(o.configComponent=e.configComponent,delete o.configTemplateUrl):o.configTemplateUrl=e.configTemplateUrl,o):t?null:o}function F(n){return d.canAdminMOs([n]).then(function(e){return e||(n.isFrozen=!e),n.readOnly=!e,n})}function B(e){return _.get(e,"isFrozen")}function Y(e){return J(e,!0)}function q(e){return J(e,!1)}function J(e,n){return e.isFrozen=n,k.saveAndWait(e).then(ue.clearCacheList)}function K(n,t){var e=n[t];return G.verifyPluginViewPath(e).then(function(e){return n[t]=e,n})}function r(n){return function(e){e=_.isObjectLike(e)?e.id:e;return[g,n,e].join("!")}}var v=r("device"),e=r("group"),Q=r("name"),b=r("type");function X(e){return h.put(y(e),_.cloneDeep(e))}function y(e){return _.isObjectLike(e)?e.id:e}function C(e,n){var t,r=_.assign(e||{},{fragmentType:n||g}),r=u.list(r).then(z);return n&&!e&&(t=p.get(n),r.then(function(e){0<e.length&&p.put(n,e)})),t?a.when(t):r}function Z(){p.removeAll(),n.$emit("dashboard:refresh")}function x(e,n,t){var r=h.get(y(e)),t=!(t&&r)&&u.detail(e).then(c.getResData).then(m).then(F).then(X);return(r?a.when(r):t).then(re).then(ee(n))}function ee(t){return function(e){var n;return(e.deviceType||t)&&(n=_.cloneDeep(e),e=S().then(_.partial(ne,n))),e}}function ne(e,n){return a.all(_.map(e.children,function(e){return te(n,e.config)})).then(_.constant(e))}function te(n,e){function t(e){e.__target={id:n.id,name:n.name}}return e&&(e.device={id:n.id,name:n.name},e.datapoints&&_.forEach(e.datapoints,t),e.alarmsEventsConfigs&&_.forEach(e.alarmsEventsConfigs,t),e.options&&e.options.dataPoints&&_.forEach(e.options.dataPoints,t),e.datapointsGauge&&_.forEach(e.datapointsGauge,t),e.datapointsLabels)&&_.forEach(e.datapointsLabels,t),e}function re(t){return S().then(function(n){return a.all(_.map(t.children,function(e){return T(n,t,e)}))}).then(_.constant(t))}function T(t,r,n){var e=n.config||{},o=_.compact([n.transformConfigWithContext,n.componentTransformConfigWithContext]);return _.reduce(o,function(e,n){return e.then(function(e){return i.invoke(n,null,{config:e,context:t,dashboard:r})})},a.resolve(e)).then(function(e){return _.assign(n,{config:e})})}function R(e){return t.list().then(function(n){return _(e).map(function(e){return V(e,n,!0)}).compact().value()})}function oe(t,e){_.forEach(e,function(e,n){t[n]&&(t[n]=e(t[n]))})}function A(e,n,t){return _.forEach(e,function(e){e.__target=ie(e.__target,n,t)}),e}function ie(e,n,t){return e&&e.id===t.id&&_.assign(e,_.pick(n,["id","name"])),e}function D(e){var t=["id","creationContext","readOnly"],r=/^c8y_Dashboard!/,n=_.cloneDeep(e),o=(n.global=!!n.deviceType||n.global,n.id),i={id:o},o=o?"update":"createConfirm",a=(i[g]=_.pickBy(n,function(e,n){return!r.test(n)&&!_.includes(t,n)}),(a=i)[g].global&&_.assign(a,{c8y_Global:{}}),n.deviceType?{}:n.creationContext),n=u[o](i,a);return"update"==o&&(n=n.then(function(){return e})),(n="createConfirm"==o?n.then(c.getResData).then(m):n).then(X)}function I(e,n,t,r){t={id:t.id},e=e(n);return t[e]=r?null:{},h.get(e)&&h.remove(e),u.save(t)}function E(e,n){return C(null,e(n))}function O(){var t,r;return k.forcedContext||(r=t=null,_.forEach(["report","device","group"],function(e){var n=_.get(W,"".concat(e,"Id"));n&&(t=e,r=n)}),{context:t,id:r})}function ae(e,n){return o.open({templateUrl:":::PLUGIN_PATH:::/dashboardWidget/config.html",controller:"DashboardWidgetConfigController",size:"lg",resolve:{dashboard:function(){return n||{}},component:function(){return e||{}},hideTarget:function(){return n&&n.deviceType}}}).result}function ce(e,r){e={template:'<div ng-include="\':::PLUGIN_PATH:::/dashboard/new.html\'" ng-controller="DashboardEditCtrl"></div>',controller:["$scope","$uibModalInstance","config",function(e,n,t){e.dashboardId="new",e.modalInstance=n,e.config=t||{},e.creationContext=r}],size:"lg",resolve:{config:_.constant(e)}};return o.open(e).result}function L(e,n){var t,n=angular.extend({title:l("Select dashboard"),preventNew:!0,selectLabel:l("Select"),useReports:!0},n);return t=n,t={templateUrl:":::PLUGIN_PATH:::/dashboard/select.html",controller:"DashboardSelectController",size:"lg",resolve:{config:_.constant(n)}},o.open(t).result.then(function(n){return e.templateUrl?U(n,e):R([e]).then(function(e){e=_slicedToArray(e,1)[0];return U(n,e)})})}var w={};function U(e,n,t){var r=e.id||e,o=(w[r]=w[r]||{children:[]},w[r]),i=o.promise;return o.children.push({child:n,remove:t}),i||(o.promise=$(function(){return a.all({dashboard:x(e,!1,!0),contextObject:S()}).then(function(e){var t=e.dashboard,r=e.contextObject;return a.all(_.map(o.children,function(n){return(n.remove?a.resolve(n.child):T(r,t,n.child)).then(function(e){t.children=P(t.children||{},e,n.remove)})})).then(_.constant(t))}).then(D)}),(i=o.promise).finally(function(){delete w[r]})),i}function P(e,n,t){return n.id||(n.id=String(Math.random()).substr(2)),t?delete e[n.id]:e[n.id]=n,t=e,r=0,_(t).sortBy("position").forEach(function(e){e.position=r,r+=1}),_.cloneDeep(t);var r}function S(){var n=O();return n.id?j.detailCached(n.id,{withChildren:!1}).then(c.getResData).then(function(e){return e||{id:n.id}}):a.when({})}var N=[];var k={list:C,save:D,saveAndWait:_.partialRight(D,!0),detail:x,detailPredefinedReadOnly:function(e,n){var t={children:{},isFrozen:!0,readOnly:!0};return R(e).then(function(e){return _.forEach(e,function(e){P(t.children,e)}),t}).then(re).then(ee(n))},named:function(n,t,r){function o(e){return D(e).then(_.partial(I,Q,n)).then(c.getResData).then(function(e){return x(e,r)})}return C(null,Q(n)).then(function(e){var n;return e.length?x(_.head(e).id,r):(n={children:{}},R(t).then(function(e){return _.forEach(e,function(e){P(n.children,e)}),d.hasAnyRole(["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE"]).then(function(e){return!!e||a.reject()}).then(_.partial(o,n)).catch(_.partial(_.identity,n))}))})},isNamed:function(e){return _.some(_.keys(e),function(e){return/^c8y_Dashboard!name!/.test(e)})},remove:function(e){return h.remove(y(e)),n.$emit("dashboard:remove",y(e)),u.remove(e)},isLocked:B,toggleLock:function(e){return(B(e)?q:Y)(e)},lock:Y,unlock:q,deviceAdd:_.partial(I,v),deviceRemove:_.partialRight(_.partial(I,v),!0),deviceList:_.partial(E,v),deviceTypeAdd:_.partial(I,b),deviceTypeRemove:_.partialRight(_.partial(I,b),!0),deviceTypeList:function(e){return a.all([E(v,e.id),E(b,e.type)]).then(_.flattenDeep)},groupAdd:_.partial(I,e),groupRemove:_.partialRight(_.partial(I,e),!0),groupList:_.partial(E,e),getContextObject:S,transformChildWithContext:T,updateConfigTargetsWithContext:te,addDashboard:ce,copyDashboard:function(e){var n,t=function(e){var n=O(),t=n.id;function r(e){return e.__target.id!==t}if("device"!==n.context&&"group"!==n.context)return l("Only dashboards from devices or groups can be copied");if(!_.every(e.children,function(e){var e=e.config||{},n=!0;return e.device&&e.device.id!==t&&(n=!1),n=e.datapoints&&_.some(e.datapoints,r)?!1:n})){if("device"===n.context)return l("Only dashboards with widgets referencing the current device can be copied.");if("group"===n.context)return l("Only dashboards with widgets referencing the current group can be copied.")}return!1}(e);return t?(f.warning(t),!1):(N=[],t=O(),N.push({dashboard:_.cloneDeep(e),context:t}),"device"===t.context&&(n=l('Dashboard copied. Navigate to the desired device and select "Paste dashboard"')),"group"===t.context&&(n=l('Dashboard copied. Navigate to the desired group and select "Paste dashboard"')),f.success(n),!0)},pasteDashboard:function(){if(N&&N.length)return S().then(function(e){var n,t,r,o,i,a,c,u;return u=_.last(N),n=O(),u=u.context.context,(i=n.context!==u&&("device"===u&&(i=l("Device dashboards can only be copied into a device.")),"group"===u)?l("Group dashboards can only be copied into a group."):i)&&f.warning(i),!i&&(n=N.pop(),t=n.dashboard,(r=O()).name=e.name,o=k["".concat(r.context,"Add")],_.forEach(t,function(e,n){n.match(/!/)&&delete t[n]}),u=r.context,r.context===n.context.context&&["device","group"].includes(u)&&(i=t,a=r,c=n.context,e=_.reduce(i.children,function(e,n){var t=n.id,r=n.config,o={device:function(e){return ie(e,a,c)},datapoints:function(e){return A(e,a,c)},dataPoints:function(e){return A(e,a,c)},datapointsGauge:function(e){return A(e,a,c)},datapointsLabels:function(e){return A(e,a,c)}};return r&&(oe(r,o),r.options)&&oe(r.options,o),e[t]=n,e},{}),i.children=e,t=i),t.creationContext=r,delete t.id,(u=D(t)).then(function(e){return o(r.id,e)}).finally(Z),u)})},dashboardToPaste:function(){var e=N&&N[0];return e&&e.dashboard},selectDashboard:ce,editCurrentDashboard:function(t){return o.open({template:'<div ng-include="\':::PLUGIN_PATH:::/dashboard/new.html\'" ng-controller="DashboardEditCtrl"></div>',controller:["$scope","$uibModalInstance",function(e,n){e.modalInstance=n,e.dashboardId=_.get(t,"dashboardId")}],size:"lg"}).result},editChildUI:ae,addChildUI:_.partial(ae,null),restoreDefaultChildren:function(t,e,r){return R(e).then(function(e){var n=t.children;return _.forEach(_.keys(n),function(e){P(n,n[e],!0)}),_.forEach(e,function(e){P(n,e)}),D(t).then(function(e){return x(e,r)})})},getContext:O,getContextPath:function(){var e=O(),n="";return"group"===e.context&&(n="/group/".concat(e.id)),n="device"===e.context?"/device/".concat(e.id):n},appendChild:_.partialRight(U,!1),updateChild:_.partialRight(U,!1),removeChild:_.partialRight(U,!0),clearCacheList:Z,addWidgetToSelectedDashboard:L,addWidgetToSelectedDashboardInContext:function(e){return L(e,{inContext:!0,preventCreate:!0,useReports:!1})},addWidgetToSelectedReport:function(e){return L(e,{onlyReports:!0,useReports:!0,title:l("Select report"),preventCreate:!0})},getIconNameObj:function(e){var n,t={icon:e.icon||"th",name:e.name||s.getString("Dashboard")},r=function(e){var t=/^c8y_Dashboard!name!(.+?)[-_].+$/,e=_.pickBy(e,function(e,n){return t.test(n)}),e=_.keys(e);if(0<e.length)return e[0].match(t)[1];return null}(e),o=c.getPluginService("c8yReports");return r&&(n=M[r])&&(t.icon=n.icon||t.icon,t.name=n.name||t.name),"report"===r&&o&&(t=o.getReportFromDashboard(e).then(function(e){return _.pick(e,["icon","name"])})),a.resolve(t)},hasWritePermissions:function(e){return e=c.hasId(e)?d.canAdminMOs([e]):d.hasAnyRole(["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE"])},VERSION:2};return _.assign(k)}ue.$inject=["$cacheFactory","$rootScope","$routeParams","$uibModal","$timeout","$q","$injector","c8yBase","dashboardInventorySvc","c8yInventory","c8yComponents","c8yPermissions","c8yUiUtil","gettext","gettextCatalog","c8yAlert"],angular.module("c8y.parts.dashboard2").factory("dashboardSvc",ue)}();
1
+ "use strict";function _slicedToArray(e,n){return _arrayWithHoles(e)||_iterableToArrayLimit(e,n)||_unsupportedIterableToArray(e,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(e,n){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,n):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,n):void 0}function _arrayLikeToArray(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function _iterableToArrayLimit(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i,a,c=[],u=!0,d=!1;try{if(i=(t=t.call(e)).next,0===n){if(Object(t)!==t)return;u=!1}else for(;!(u=(r=i.call(t)).done)&&(c.push(r.value),c.length!==n);u=!0);}catch(e){d=!0,o=e}finally{try{if(!u&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw o}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}!function(){function ue(e,n,W,o,$,a,i,c,u,j,t,d,M,l,s,f){var h=e("dashboards"),p=e("dashboardLists"),g="c8y_Dashboard",G={welcome:{icon:"cloud",name:s.getString("Welcome")},home:{icon:"home",name:s.getString("Home")}};function B(e){return _.map(e,function(e){return _.assign(_.get(e,g,{}),{id:e.id})})}function m(e){var t,n,r,e=e||{},o=_.assign(_.get(e,g,{}),{id:e.id},(t=/^c8y_Dashboard!(.+)$/,_.pickBy(e,function(e,n){return t.test(n)})));return _.set(o,"global",!!_.get(e,"c8y_Global")),n=o,r=["templateUrl","configTemplateUrl"],e=_.map(n.children,function(e){return a.all(_.map(r,_.partial(K,e)))}),a.all(e).then(function(){return n}).then(z)}function z(n){return n.children?(e=n.children,t.list().then(function(n){return _(e).mapValues(function(e){return H(e,n,!1)}).value()}).then(function(e){return n.children=e,n})):n;var e}function H(e,n,t){var r,o=_.cloneDeep(e),e=_.find(n,function(e){var n=e.name&&e.name===o.name,e=e.templateUrl&&e.templateUrl===o.templateUrl;return n||e});return e?((r=e.replaceWith)&&(o.config=i.invoke(r.config,void 0,{oldConfig:o.config}),e=_.find(n,{name:r.component})),o.name=e.name,e.transformConfigWithContext&&(o.componentTransformConfigWithContext=e.transformConfigWithContext),e.widgetComponent?(o.widgetComponent=e.widgetComponent,delete o.templateUrl):o.templateUrl=e.templateUrl,e.configComponent?(o.configComponent=e.configComponent,delete o.configTemplateUrl):o.configTemplateUrl=e.configTemplateUrl,o):t?null:o}function V(n){return d.canAdminMOs([n]).then(function(e){return e||(n.isFrozen=!e),n.readOnly=!e,n})}function F(e){return _.get(e,"isFrozen")}function J(e){return q(e,!0)}function Y(e){return q(e,!1)}function q(e,n){return e.isFrozen=n,k.saveAndWait(e).then(ue.clearCacheList)}function K(n,t){var e=n[t];return M.verifyPluginViewPath(e).then(function(e){return n[t]=e,n})}function r(n){return function(e){e=_.isObjectLike(e)?e.id:e;return[g,n,e].join("!")}}var v=r("device"),e=r("group"),Q=r("name"),b=r("type");function X(e){return h.put(y(e),_.cloneDeep(e))}function y(e){return _.isObjectLike(e)?e.id:e}function C(e,n){var t,r=_.assign(e||{},{fragmentType:n||g}),r=u.list(r).then(B);return n&&!e&&(t=p.get(n),r.then(function(e){0<e.length&&p.put(n,e)})),t?a.when(t):r}function Z(){p.removeAll(),n.$emit("dashboard:refresh")}function E(e,n,t){var r=h.get(y(e)),t=!(t&&r)&&u.detail(e).then(c.getResData).then(m).then(V).then(X);return(r?a.when(r):t).then(re).then(ee(n))}function ee(t){return function(e){var n;return(e.deviceType||t)&&(n=_.cloneDeep(e),e=P().then(_.partial(ne,n))),e}}function ne(e,n){return a.all(_.map(e.children,function(e){return te(n,e.config)})).then(_.constant(e))}function te(n,e){function t(e){e.__target={id:n.id,name:n.name}}return e&&(e.device={id:n.id,name:n.name},e.datapoints&&_.forEach(e.datapoints,t),e.alarmsEventsConfigs&&_.forEach(e.alarmsEventsConfigs,t),e.options&&e.options.dataPoints&&_.forEach(e.options.dataPoints,t),e.datapointsGauge&&_.forEach(e.datapointsGauge,t),e.datapointsLabels)&&_.forEach(e.datapointsLabels,t),e}function re(t){return P().then(function(n){return a.all(_.map(t.children,function(e){return A(n,t,e)}))}).then(_.constant(t))}function A(t,r,n){var e=n.config||{},o=_.compact([n.transformConfigWithContext,n.componentTransformConfigWithContext]);return _.reduce(o,function(e,n){return e.then(function(e){return i.invoke(n,null,{config:e,context:t,dashboard:r})})},a.resolve(e)).then(function(e){return _.assign(n,{config:e})})}function T(e){return t.list().then(function(n){return _(e).map(function(e){return H(e,n,!0)}).compact().value()})}function oe(t,e){_.forEach(e,function(e,n){t[n]&&(t[n]=e(t[n]))})}function x(e,n,t){return _.forEach(e,function(e){e.__target=ie(e.__target,n,t)}),e}function ie(e,n,t){return e&&e.id===t.id&&_.assign(e,_.pick(n,["id","name"])),e}function R(e){var t=["id","creationContext","readOnly"],r=/^c8y_Dashboard!/,n=_.cloneDeep(e),o=(n.global=!!n.deviceType||n.global,n.id),i={id:o},o=o?"update":"createConfirm",a=(i[g]=_.pickBy(n,function(e,n){return!r.test(n)&&!_.includes(t,n)}),(a=i)[g].global&&_.assign(a,{c8y_Global:{}}),n.deviceType?{}:n.creationContext),n=u[o](i,a);return"update"==o&&(n=n.then(function(){return e})),(n="createConfirm"==o?n.then(c.getResData).then(m):n).then(X)}function D(e,n,t,r){t={id:t.id},e=e(n);return t[e]=r?null:{},h.get(e)&&h.remove(e),u.save(t)}function O(e,n){return C(null,e(n))}function I(){var t,r;return k.forcedContext||(r=t=null,_.forEach(["report","device","group"],function(e){var n=_.get(W,"".concat(e,"Id"));n&&(t=e,r=n)}),{context:t,id:r})}function ae(e,n){return o.open({templateUrl:":::PLUGIN_PATH:::/dashboardWidget/config.html",controller:"DashboardWidgetConfigController",size:"lg",resolve:{dashboard:function(){return n||{}},component:function(){return e||{}},hideTarget:function(){return n&&n.deviceType}}}).result}function ce(e,r){e={template:'<div ng-include="\':::PLUGIN_PATH:::/dashboard/new.html\'" ng-controller="DashboardEditCtrl"></div>',controller:["$scope","$uibModalInstance","config",function(e,n,t){e.dashboardId="new",e.modalInstance=n,e.config=t||{},e.creationContext=r}],size:"lg",resolve:{config:_.constant(e)}};return o.open(e).result}function L(e,n){var t,n=angular.extend({title:l("Select dashboard"),preventNew:!0,selectLabel:l("Select"),useReports:!0},n);return t=n,t={templateUrl:":::PLUGIN_PATH:::/dashboard/select.html",controller:"DashboardSelectController",size:"lg",resolve:{config:_.constant(n)}},o.open(t).result.then(function(n){return e.templateUrl?w(n,e):T([e]).then(function(e){e=_slicedToArray(e,1)[0];return w(n,e)})})}var N={};function w(e,n,t){var r=e.id||e,o=(N[r]=N[r]||{children:[]},N[r]),i=o.promise;return o.children.push({child:n,remove:t}),i||(o.promise=$(function(){return a.all({dashboard:E(e,!1,!0),contextObject:P()}).then(function(e){var t=e.dashboard,r=e.contextObject;return a.all(_.map(o.children,function(n){return(n.remove?a.resolve(n.child):A(r,t,n.child)).then(function(e){t.children=U(t.children||{},e,n.remove)})})).then(_.constant(t))}).then(R)}),(i=o.promise).finally(function(){delete N[r]})),i}function U(e,n,t){return n.id||(n.id=String(Math.random()).substr(2)),t?delete e[n.id]:e[n.id]=n,t=e,r=0,_(t).sortBy("position").forEach(function(e){e.position=r,r+=1}),_.cloneDeep(t);var r}function P(){var n=I();return n.id?j.detailCached(n.id,{withChildren:!1}).then(c.getResData).then(function(e){return e||{id:n.id}}):a.when({})}var S=[];var k={list:C,save:R,saveAndWait:_.partialRight(R,!0),detail:E,detailPredefinedReadOnly:function(e,n){var t={children:{},isFrozen:!0,readOnly:!0};return T(e).then(function(e){return _.forEach(e,function(e){U(t.children,e)}),t}).then(re).then(ee(n))},named:function(n,t,r){function o(e){return R(e).then(_.partial(D,Q,n)).then(c.getResData).then(function(e){return E(e,r)})}return C(null,Q(n)).then(function(e){var n;return e.length?E(_.head(e).id,r):(n={children:{}},T(t).then(function(e){return _.forEach(e,function(e){U(n.children,e)}),d.hasAnyRole(["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE","ROLE_MANAGED_OBJECT_ADMIN","ROLE_MANAGED_OBJECT_CREATE"]).then(function(e){return!!e||a.reject()}).then(_.partial(o,n)).catch(_.partial(_.identity,n))}))})},isNamed:function(e){return _.some(_.keys(e),function(e){return/^c8y_Dashboard!name!/.test(e)})},remove:function(e){return h.remove(y(e)),n.$emit("dashboard:remove",y(e)),u.remove(e)},isLocked:F,toggleLock:function(e){return(F(e)?Y:J)(e)},lock:J,unlock:Y,deviceAdd:_.partial(D,v),deviceRemove:_.partialRight(_.partial(D,v),!0),deviceList:_.partial(O,v),deviceTypeAdd:_.partial(D,b),deviceTypeRemove:_.partialRight(_.partial(D,b),!0),deviceTypeList:function(e){return a.all([O(v,e.id),O(b,e.type)]).then(_.flattenDeep)},groupAdd:_.partial(D,e),groupRemove:_.partialRight(_.partial(D,e),!0),groupList:_.partial(O,e),getContextObject:P,transformChildWithContext:A,updateConfigTargetsWithContext:te,addDashboard:ce,copyDashboard:function(e){var n,t=function(e){var n=I(),t=n.id;function r(e){return e.__target.id!==t}if("device"!==n.context&&"group"!==n.context)return l("Only dashboards from devices or groups can be copied");if(!_.every(e.children,function(e){var e=e.config||{},n=!0;return e.device&&e.device.id!==t&&(n=!1),n=e.datapoints&&_.some(e.datapoints,r)?!1:n})){if("device"===n.context)return l("Only dashboards with widgets referencing the current device can be copied.");if("group"===n.context)return l("Only dashboards with widgets referencing the current group can be copied.")}return!1}(e);return t?(f.warning(t),!1):(S=[],t=I(),S.push({dashboard:_.cloneDeep(e),context:t}),"device"===t.context&&(n=l('Dashboard copied. Navigate to the desired device and select "Paste dashboard"')),"group"===t.context&&(n=l('Dashboard copied. Navigate to the desired group and select "Paste dashboard"')),f.success(n),!0)},pasteDashboard:function(){if(S&&S.length)return P().then(function(e){var n,t,r,o,i,a,c,u;return u=_.last(S),n=I(),u=u.context.context,(i=n.context!==u&&("device"===u&&(i=l("Device dashboards can only be copied into a device.")),"group"===u)?l("Group dashboards can only be copied into a group."):i)&&f.warning(i),!i&&(n=S.pop(),t=n.dashboard,(r=I()).name=e.name,o=k["".concat(r.context,"Add")],_.forEach(t,function(e,n){n.match(/!/)&&delete t[n]}),u=r.context,r.context===n.context.context&&["device","group"].includes(u)&&(i=t,a=r,c=n.context,e=_.reduce(i.children,function(e,n){var t=n.id,r=n.config,o={device:function(e){return ie(e,a,c)},datapoints:function(e){return x(e,a,c)},dataPoints:function(e){return x(e,a,c)},datapointsGauge:function(e){return x(e,a,c)},datapointsLabels:function(e){return x(e,a,c)}};return r&&(oe(r,o),r.options)&&oe(r.options,o),e[t]=n,e},{}),i.children=e,t=i),t.creationContext=r,delete t.id,(u=R(t)).then(function(e){return o(r.id,e)}).finally(Z),u)})},dashboardToPaste:function(){var e=S&&S[0];return e&&e.dashboard},selectDashboard:ce,editCurrentDashboard:function(t){return o.open({template:'<div ng-include="\':::PLUGIN_PATH:::/dashboard/new.html\'" ng-controller="DashboardEditCtrl"></div>',controller:["$scope","$uibModalInstance",function(e,n){e.modalInstance=n,e.dashboardId=_.get(t,"dashboardId")}],size:"lg"}).result},editChildUI:ae,addChildUI:_.partial(ae,null),restoreDefaultChildren:function(t,e,r){return T(e).then(function(e){var n=t.children;return _.forEach(_.keys(n),function(e){U(n,n[e],!0)}),_.forEach(e,function(e){U(n,e)}),R(t).then(function(e){return E(e,r)})})},getContext:I,getContextPath:function(){var e=I(),n="";return"group"===e.context&&(n="/group/".concat(e.id)),n="device"===e.context?"/device/".concat(e.id):n},appendChild:_.partialRight(w,!1),updateChild:_.partialRight(w,!1),removeChild:_.partialRight(w,!0),clearCacheList:Z,addWidgetToSelectedDashboard:L,addWidgetToSelectedDashboardInContext:function(e){return L(e,{inContext:!0,preventCreate:!0,useReports:!1})},addWidgetToSelectedReport:function(e){return L(e,{onlyReports:!0,useReports:!0,title:l("Select report"),preventCreate:!0})},getIconNameObj:function(e){var n,t={icon:e.icon||"th",name:e.name||s.getString("Dashboard")},r=function(e){var t=/^c8y_Dashboard!name!(.+?)[-_].+$/,e=_.pickBy(e,function(e,n){return t.test(n)}),e=_.keys(e);if(0<e.length)return e[0].match(t)[1];return null}(e),o=c.getPluginService("c8yReports");return r&&(n=G[r])&&(t.icon=n.icon||t.icon,t.name=n.name||t.name),"report"===r&&o&&(t=o.getReportFromDashboard(e).then(function(e){return _.pick(e,["icon","name"])})),a.resolve(t)},hasWritePermissions:function(e){return e=c.hasId(e)?d.canAdminMOs([e]):d.hasAnyRole(["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE","ROLE_MANAGED_OBJECT_ADMIN","ROLE_MANAGED_OBJECT_CREATE"])},VERSION:2};return _.assign(k)}ue.$inject=["$cacheFactory","$rootScope","$routeParams","$uibModal","$timeout","$q","$injector","c8yBase","dashboardInventorySvc","c8yInventory","c8yComponents","c8yPermissions","c8yUiUtil","gettext","gettextCatalog","c8yAlert"],angular.module("c8y.parts.dashboard2").factory("dashboardSvc",ue)}();
@@ -112,7 +112,7 @@
112
112
  />
113
113
  <span></span>
114
114
  <span class="sr-only">
115
- {{ 'If selected it ignores empty values on all resources below.' | translate }}
115
+ {{ 'If selected, it ignores empty values on all resources below.' | translate }}
116
116
  </span>
117
117
  </label>
118
118
  </div>
@@ -123,7 +123,7 @@
123
123
  class="btn-help btn-help--sm"
124
124
  aria-label="{{ 'Help' | translate }}"
125
125
  type="button"
126
- uib-popover="{{ 'If selected it ignores empty values on all resources below.' | translate }}"
126
+ uib-popover="{{ 'If selected, it ignores empty values on all resources below.' | translate }}"
127
127
  popover-placement="right"
128
128
  popover-trigger="'focus'"
129
129
  popover-append-to-body="true"
@@ -1 +1 @@
1
- "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return o};var o={},e=Object.prototype,s=e.hasOwnProperty,c=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",a=t.toStringTag||"@@toStringTag";function i(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(e){i=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a,i,o,u,t=t&&t.prototype instanceof m?t:m,t=Object.create(t.prototype),r=new S(r||[]);return c(t,"_invoke",{value:(a=e,i=n,o=r,u="suspendedStart",function(e,t){if("executing"===u)throw new Error("Generator is already running");if("completed"===u){if("throw"===e)throw t;return M()}for(o.method=e,o.arg=t;;){var n=o.delegate;if(n){n=function e(t,n){var r=n.method,a=t.iterator[r];if(void 0===a)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=void 0,e(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;r=p(a,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,l;a=r.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,l):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,l)}(n,o);if(n){if(n===l)continue;return n}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if("suspendedStart"===u)throw u="completed",o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);u="executing";n=p(a,i,o);if("normal"===n.type){if(u=o.done?"completed":"suspendedYield",n.arg===l)continue;return{value:n.arg,done:o.done}}"throw"===n.type&&(u="completed",o.method="throw",o.arg=n.arg)}})}),t}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}o.wrap=u;var l={};function m(){}function d(){}function f(){}var t={},y=(i(t,r,function(){return this}),Object.getPrototypeOf),y=y&&y(y(T([]))),g=(y&&y!==e&&s.call(y,r)&&(t=y),f.prototype=m.prototype=Object.create(t));function _(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function v(o,u){var t;c(this,"_invoke",{value:function(n,r){function e(){return new u(function(e,t){!function t(e,n,r,a){var i,e=p(o[e],o,n);if("throw"!==e.type)return(n=(i=e.arg).value)&&"object"==_typeof(n)&&s.call(n,"__await")?u.resolve(n.__await).then(function(e){t("next",e,r,a)},function(e){t("throw",e,r,a)}):u.resolve(n).then(function(e){i.value=e,r(i)},function(e){return t("throw",e,r,a)});a(e.arg)}(n,r,e,t)})}return t=t?t.then(e,e):e()}})}function h(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(h,this),this.reset(!0)}function T(t){if(t){var n,e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(s.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:M}}function M(){return{value:void 0,done:!0}}return c(g,"constructor",{value:d.prototype=f,configurable:!0}),c(f,"constructor",{value:d,configurable:!0}),d.displayName=i(f,a,"GeneratorFunction"),o.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,i(e,a,"GeneratorFunction")),e.prototype=Object.create(g),e},o.awrap=function(e){return{__await:e}},_(v.prototype),i(v.prototype,n,function(){return this}),o.AsyncIterator=v,o.async=function(e,t,n,r,a){void 0===a&&(a=Promise);var i=new v(u(e,t,n,r),a);return o.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},_(g),i(g,a,"Generator"),i(g,r,function(){return this}),i(g,"toString",function(){return"[object Generator]"}),o.keys=function(e){var t,n=Object(e),r=[];for(t in n)r.push(t);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},o.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return i.type="throw",i.arg=n,r.next=e,t&&(r.method="next",r.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var a=this.tryEntries[t],i=a.completion;if("root"===a.tryLoc)return e("end");if(a.tryLoc<=this.prev){var o=s.call(a,"catchLoc"),u=s.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return e(a.catchLoc,!0);if(this.prev<a.finallyLoc)return e(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return e(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return e(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var a=r;break}}var i=(a=a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc?null:a)?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),b(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,r,a=this.tryEntries[t];if(a.tryLoc===e)return"throw"===(n=a.completion).type&&(r=n.arg,b(a)),r}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},o}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_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 _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,u=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw a}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function asyncGeneratorStep(e,t,n,r,a,i,o){try{var u=e[i](o),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,a)}function _asyncToGenerator(u){return function(){var e=this,o=arguments;return new Promise(function(t,n){var r=u.apply(e,o);function a(e){asyncGeneratorStep(r,t,n,a,i,"next",e)}function i(e){asyncGeneratorStep(r,t,n,a,i,"throw",e)}a(void 0)})}}function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function e(r,o,e,u,P,s,L,V,a,i,c){var B={name:"feature-fieldbus4"},n=e.has("FIELDBUS_UI_VERSION")?e.get("FIELDBUS_UI_VERSION"):4,p="c8y_IsDeviceType",l="c8y_ModbusDeviceType",m="%%",d=u.createEnum(["DISCRETE_IO","REGISTER"]),e=u.createEnum([{name:"FPORT",label:"FPort"},{name:"PAYLOAD",label:"Payload"}]),f=u.dataFilePath("devicetypes"),y={common:{name:null},deviceType:{c8y_Coils:[],c8y_Registers:[]},element:{number:null},discreteIO:{},discreteOutput:{input:!1},discreteInput:{input:!0},register:{multiplier:1,divisor:1,offset:0,decimalPlaces:0,startBit:0,noBits:16,unit:"",signed:!1},canbusRegister:{noBits:64,offset:0},canopenRegister:{},holdingRegister:{input:!1},inputRegister:{input:!0}},t=[],g=[];return{ElementType:d,MessageIdSources:e,metaDefaults:{discreteIO:{enumValues:[{value:0,label:"0"},{value:1,label:"1"}]}},registerFeaturesManifest:function(e){e=r.resolve(e);t.push(e),e.then(function(e){e&&g.push(e)})},areAnyFeaturesManifestsRegistered:function(){return v().then(function(e){return 0<e.length})},getFeaturesManifestsAsync:v,getFeaturesManifests:function(){return g},getDeviceTypeFeatures:k,getElementTypeLabel:function(e,t){var n,r=_.get(e,"meta.type");r&&(e=_.get(e,"input"),r===d.DISCRETE_IO?n=i(e?"Discrete input":"Coil (discrete output)"):r===d.REGISTER&&(n=e?i("Input register"):(r=k(t),_.get(r,"holdingRegisters.elementTypeLabel",i("Holding register")))));return n},getFieldbusVersion:Q,getEmptyDeviceType:function(){var e=y.common,t=y.deviceType;return _.cloneDeep(_objectSpread(_objectSpread({},e),t))},getAvailableDeviceTypes:function(e){return h.apply(this,arguments)},getDeviceTypeFromDevice:function(e){var t=_.flatten(_.map(g,"deviceFragments")),e=_.head(_.compact(_.at(e,t))),t=_.get(e,"type"),e=t&&t.match(/\/inventory\/managedObjects\/(\d+)/),t=_.nth(e,1);if(t)return b(t);return r.resolve(null)},getFieldbusVersionFromDevice:function(e){var t=_.map(g,"deviceConfiguration.fragment"),e=_.head(_.compact(_.at(e,t)));return _.get(e,"maxFieldbusVersion",4)},getDeviceType:b,save:H,exportDeviceTypeAndSaveAs:function(e){var t="".concat(e.name,".json"),e=JSON.stringify(function(e){return e.c8y_ModbusDeviceTypeInfo=function(e){return _.omit(_objectSpread(_objectSpread({},_.get(e,"c8y_ModbusDeviceTypeInfo",{})),{},{name:e.name,minFieldbusUI:n,fieldbusType:e.fieldbusType}),["id","category","description"])}(e),e.c8y_Coils=_.map(e.c8y_Coils,pe),e.c8y_Registers=_.map(e.c8y_Registers,pe),_.pick(e,["c8y_ModbusDeviceTypeInfo","c8y_Coils","c8y_Registers","c8y_useServerTime","c8y_MessageIdConfiguration"])}(e),null,2),e=new Blob([e],{type:"application/json"});window.saveAs(e,t)},importDeviceTypeWithUI:function(){return a({component:"c8yImportDeviceTypeModal"}).then(H)},getPredefinedDeviceTypeInfos:function(){return le.apply(this,arguments)},isDeviceTypeSupported:fe,isDeviceTypeSupportedAsync:function(n){return v().then(function(e){return _.map(e,"fieldbusType")}).then(function(e){var t=N(n);return _.includes(e,t)})},getPredefinedDeviceType:Qe,downloadPredefinedDeviceTypeAndSaveAs:function(e){return ye.apply(this,arguments)},upgradeDeviceType:S,getElementsWithMeta:function(t){var e=_.get(t,"c8y_Coils",[]),n=_.get(t,"c8y_Registers",[]);return _.union(_.map(e,O),_.map(n,function(e){return D(e,t)}))},addDiscreteIOsMeta:function(e){if(e)return e.c8y_Coils=_.map(e.c8y_Coils,O),e;return},addDiscreteIOMeta:O,removeDiscreteIOMeta:function(e){e.meta&&(e=_.flow([Se,Te,Me,we,Re])(e),_.unset(e,"meta"));return e},addRegistersMeta:function(t){if(t)return t.c8y_Registers=_.map(t.c8y_Registers,function(e){return D(e,t)}),t;return},addRegisterMeta:D,removeRegisterMeta:function(e){var t=e;e.meta&&(t=_.flow([Ne,Pe,Le,Ve,Be,Fe,Ge,$e,We,He])(e),_.unset(t,"meta"));return t},removeAllElements:function(e){e.c8y_Registers=[],e.c8y_Coils=[]},getElementRefId:function(e){e=_.compact(Je(e));return _.head(e)},findElementBestMatchingRefId:function(e,i,o){return _(e).chain().map(function(e){return{score:(n=i,r=o,r=(t=e).meta.type.value===o,t=Je(t),a=_.findIndex(t,_.negate(_.isUndefined)),t=_.indexOf(t,n),r&&0<=t?a-t:void 0),element:e};var t,n,r,a}).reject(function(e){return _.isUndefined(e.score)}).orderBy("score").head().get("element").value()},getDiscreteOutputsCategorized:function(e){return _(e.c8y_Coils).reject("input").groupBy(U).value()},getDiscreteInputsCategorized:function(e){return _(e.c8y_Coils).filter("input").groupBy(U).value()},getHoldingRegistersCategorized:function(e){return _(e.c8y_Registers).reject("input").groupBy(U).value()},getInputRegistersCategorized:function(e){return _(e.c8y_Registers).filter("input").groupBy(U).value()},getEmptyDiscreteOutput:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.discreteIO),y.discreteOutput))},getEmptyDiscreteInput:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.discreteIO),y.discreteInput))},getEmptyHoldingRegister:function(e){return"canbus"!==e.fieldbusType?"canopen"!==e.fieldbusType?_.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.holdingRegister)):_.cloneDeep(_objectSpread(_objectSpread({},y.common),y.canopenRegister)):_.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.canbusRegister),y.holdingRegister))},getEmptyInputRegister:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.inputRegister))},editDiscreteIOWithUI:function(e,t){return a({component:"c8yConfigureDiscreteIOModal",title:ze(e),resolve:_objectSpread({title:function(){return ze(e)}},Ke(e,t.c8y_Coils,t))})},editRegisterWithUI:function(n,r){return a({component:"c8yConfigureRegisterModal",resolve:_objectSpread({title:function(){var e=n,t=r;return t=k(t),e.input?e.name?c.getString('Edit input register: "{{name}}"',e):i("New input register"):e.name?c.getString(_.get(t,"holdingRegisters.editRegisterModalTitle",i('Edit holding register: "{{name}}"')),e):_.get(t,"holdingRegisters.newRegisterModalTitle",i("New holding register"))}},Ke(n,r.c8y_Registers,r))})},addEmptyEnumValue:function(e){e.meta.enumValues=e.meta.enumValues||[],e.meta.enumValues.push({value:null,label:null})},removeEnumValue:function(e,t){e.meta.enumValues=_.without(e.meta.enumValues,t)},areOverlappingRegisters:function(e,t,n){e=qe(e,n),t=qe(t,n),n=Math.max(e.start,t.start),e=Math.min(e.end,t.end);return n<=e},getValuesRange:ke,openFieldbusSelector:function(e){return a({component:"c8ySelectFieldbusPropertyModal",resolve:{modalParams:function(){return _.defaults(e,{})}}})},downloadPredefinedDeviceTypeHref:function(e){return Ye.apply(this,arguments)},predefinedDeviceTypeHrefFilename:function(e){return"".concat(e.id,".json")},isFieldbusDevice:function(t){return _.some(g,function(e){return _.some(e.deviceFragments,function(e){return _.has(t,e)})})},isFeatureFieldbus4Available:function(){return P.isSubscribed(B)},addElementId:T};function v(){return r.all(t).then(_.compact)}function h(){return(h=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r,a,i,o=arguments;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=1<o.length&&void 0!==o[1]?o[1]:{},r=2<o.length?o[2]:void 0,i={__and:[{__or:[{__has:p},{type:l}]},{fieldbusType:{__in:_.map(g,"fieldbusType")}}]},_.isEmpty(t)||(i.__and=[].concat(_toConsumableArray(i.__and),[t])),a=u.createListMapper(S),e.next=8,s.listQuery(i,n,!0,r).then(a);case 8:return i=e.sent,e.abrupt("return",i);case 10:case"end":return e.stop()}},e)}))).apply(this,arguments)}function b(e){return F.apply(this,arguments)}function F(){return(F=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=u,e.next=3,s.detail(t);case 3:return e.t1=e.sent,n=e.t0.getResData.call(e.t0,e.t1),e.abrupt("return",S(n));case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}function S(e){return _.flow([G,$,W,q,Y])(e)}function G(e){return _.forEach(e.c8y_Coils,function(e){!e.enumValues&&e.statusMapping&&_.isArray(e.statusMapping.enumValues)&&(e.enumValues={0:e.statusMapping.enumValues[0],1:e.statusMapping.enumValues[1]},_.unset(e,"statusMapping.enumValues")),_.isUndefined(e.input)&&(e.input=y.discreteOutput.input)}),e}function $(e){var n=k(e);return _.forEach(e.c8y_Registers,function(e){var t=e.input?"inputRegisters":"holdingRegisters",t=_.get(n,t,{});_.get(t,"startBit")&&_.defaults(e,{startBit:y.register.startBit}),_.get(t,"noBits")&&_.defaults(e,{noBits:y.register.noBits}),_.get(t,"options.signed")&&_.defaults(e,{signed:y.register.signed}),!e.unit&&e.measurementMapping&&e.measurementMapping.unit&&(e.unit=e.measurementMapping.unit,_.unset(e,"measurementMapping.unit")),_.isUndefined(e.input)&&(e.input=y.holdingRegister.input)}),e}function W(e){return e.fieldbusType=N(e),e}function H(e){return J.apply(this,arguments)}function J(){return(J=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=_.flow([K,q,X,Z,ee,te,Y,z])(t),e.abrupt("return",s.save(n).then(u.getResData).then(function(e){return t.id?e:function(){return ce.apply(this,arguments)}(e).then(function(){return e})}));case 2:case"end":return e.stop()}},e)}))).apply(this,arguments)}function z(e){return s.addGlobalFlag(e,!0)}function K(e){var t;return e.type||(t=k(e),e.type=_.get(t,"type",l)),e}function q(e){return _.set(e,p,{})}function Y(e){return _.set(e,"fieldbusVersion",Q(e))}function Q(t){var e=k(t).versions,e=_.findLast(e,function(e){return _.some(e.checks,function(e){return e(t)})});return _.get(e,"number",4)}function X(e){return e.c8y_Coils=_.map(e.c8y_Coils,T),e.c8y_Registers=_.map(e.c8y_Registers,T),e}function T(e){return e.id||(e.id=String(Math.random()).substr(2)),e}function Z(e){return e.c8y_Coils=_.orderBy(e.c8y_Coils,["input","number"]),e.c8y_Registers=_.orderBy(e.c8y_Registers,["input","number","startBit","index","subIndex"]),e}function ee(e){var a,t=k(e);return!!_.get(t,"configuration.messageIdConfiguration.length")&&(e.c8y_MessageTypes=(a=e,_.reduce(["c8y_Registers","c8y_Coils"],function(e,t){return _.merge(e,(n=a,r=t,e=_.groupBy(n[r],"messageTypeId"),e=_.mapValues(e,function(e){return _.map(e,function(e){return _.indexOf(n[r],e)})}),_.reduce(e,function(e,t,n){return e[n]={},e[n][r]=t,e},{})));var n,r},{}))),e}function te(e){r=k(t=e).customizeSmartRestTemplates||_.identity,n={requestTemplates:_.flattenDeep([function(e){return{msgId:100,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.managedObject+json",placeholder:m,resourceUri:"/inventory/managedObjects/".concat(m),templateString:E([{key:"c8y_CoilStatus",value:new j(M(e.c8y_Coils).map(function(e){return{key:e.name,value:m,raw:!0}}).value())}]),values:["UNSIGNED"].concat(_toConsumableArray(M(e.c8y_Coils).map(function(){return"UNSIGNED"}).value()))}}(t),function(e){return{msgId:101,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.managedObject+json",placeholder:m,resourceUri:"/inventory/managedObjects/".concat(m),templateString:E([{key:"c8y_RegisterStatus",value:new j(M(e.c8y_Registers).map(function(e){return{key:e.name,value:m,raw:!0}}).value())}]),values:["UNSIGNED"].concat(_toConsumableArray(M(e.c8y_Registers).map(function(){return"NUMBER"}).value()))}}(t),[w(102,"EXECUTING"),w(103,"SUCCESSFUL"),w(104,"FAILED")],function(e){return _.flow([ne,oe,ue])({deviceType:e,msgId:300,templates:[]}).templates}(t)]),responseTemplates:_.flattenDeep([{msgId:200,condition:"$.c8y_SetCoil",pattern:["$.id","$.c8y_SetCoil.address","$.c8y_SetCoil.input","$.c8y_SetCoil.coil","$.c8y_SetCoil.value"]},{msgId:201,condition:"$.c8y_SetRegister",pattern:["$.id","$.c8y_SetRegister.ipAddress","$.c8y_SetRegister.address","$.c8y_SetRegister.input","$.c8y_SetRegister.register","$.c8y_SetRegister.startBit","$.c8y_SetRegister.noBits","$.c8y_SetRegister.value"]},{msgId:202,condition:"$.c8y_ModbusDevice",pattern:["$.id","$.deviceId","$.c8y_ModbusDevice.id","$.c8y_ModbusDevice.address","$.c8y_ModbusDevice.type","$.c8y_ModbusDevice.protocol"]},{msgId:203,condition:"$.c8y_ModbusSource",pattern:["$.id"]}])};var t,n,r=r(n,t);return _.set(e,"com_cumulocity_model_smartrest_SmartRestTemplate",r)}function M(e){return _(e).filter("statusMapping.status")}function w(e,t){return{msgId:e,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.operation+json",placeholder:m,resourceUri:"/devicecontrol/operations/".concat(m),templateString:E({status:t}),values:["UNSIGNED"]}}function ne(e){var t=e.deviceType,n=e.msgId,r=e.templates,e=_.filter(t.c8y_Coils,"alarmMapping"),a=_.filter(t.c8y_Registers,"alarmMapping"),i=k(t),o=i.getCoilSource||ae,u=i.getRegisterSource||ie,s=n;return _.forEach(e,function(e){r.push(re(s,t,e.alarmMapping,o(e))),e.alarmMapping.raiseAlarmTemplate=s,s+=1}),_.forEach(a,function(e){r.push(re(s,t,e.alarmMapping,u(e))),e.alarmMapping.raiseAlarmTemplate=s,s+=1}),{deviceType:t,templates:r,msgId:s}}function re(e,t,n,r){return{msgId:e,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.alarm+json",accept:"application/vnd.com.nsn.cumulocity.alarm+json",placeholder:m,resourceUri:"/alarm/alarms",templateString:E([{key:"source",value:{id:m}},{key:"type",value:n.type},{key:"status",value:L.status.ACTIVE},{key:"severity",value:n.severity},{key:"time",value:m},{key:"text",value:n.text},{key:r.key,value:r.value}]),values:["UNSIGNED",R(t)]}}function ae(e){return{key:"c8y_ModbusSource",value:{coil:_.pick(e,"input","number")}}}function ie(e){return{key:"c8y_ModbusSource",value:{register:_.pick(e,["input","number","startBit","noBits"])}}}function oe(e){var r=e.deviceType,t=e.msgId,o=e.templates,e=_([].concat(_toConsumableArray(r.c8y_Coils),_toConsumableArray(r.c8y_Registers))).filter("measurementMapping").groupBy("measurementMapping.type").value(),u=t;return _.forEach(e,function(e,t){var n,a,i,e=_.map(e,function(e){return _.set(e.measurementMapping,"unit",e.unit||e.measurementMapping.unit)});o.push((n=r,a=t,i=e,{msgId:u,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.measurement+json",placeholder:m,resourceUri:"/measurement/measurements",templateString:E(function(){var n=a,r=_defineProperty({source:{id:m},time:m,type:n},n,{});return _.forEach(i,function(e){var t=e.series,e=e.unit;r[n][t]={value:"%n",unit:e}}),r}()),values:["UNSIGNED",R(n)].concat(_toConsumableArray(_.map(i,function(){return"NUMBER"})))})),_.forEach(e,function(e){e.sendMeasurementTemplate=u,_.unset(e,"unit")}),u+=1}),{deviceType:r,templates:o,msgId:u}}function ue(e){var a=e.deviceType,t=e.msgId,i=e.templates,e=[].concat(_toConsumableArray(a.c8y_Coils),_toConsumableArray(a.c8y_Registers)),o=t;return _.forEach(e,function(e){var t,n,r;_.isUndefined(e.eventMapping)||(i.push((t=o,n=a,r=e.eventMapping,{msgId:t,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.event+json",placeholder:m,resourceUri:"/event/events",templateString:E([{key:"source",value:{id:m}},{key:"time",value:m},{key:"type",value:r.type},{key:"text",value:r.text},{key:e.name,value:m,raw:!0}]),values:["UNSIGNED",R(n),"NUMBER"]})),e.eventMapping.eventTemplate=o,o+=1)}),{deviceType:a,templates:i,msgId:o}}function R(e){return e.c8y_useServerTime?"NOW":"DATE"}function E(e,t){var n;return e instanceof j?n=I(e.kvObj):_.isArray(e)?n=I(e):_.isObjectLike(e)&&(n=angular.toJson(e)),n=n.replace(/"%n"/g,t||m)}function I(e){e=_.map(e,se);return"{".concat(e.join(","),"}")}function se(e){var t=e.key,n=e.value,e=e.raw,r={},e=n instanceof j?(r[t]=":::INNER_OBJECT_STRING:::",JSON.stringify(r).replace('":::INNER_OBJECT_STRING:::"',I(n.kvObj))):e?(r[t]=":::RAW_VALUE:::",JSON.stringify(r).replace('":::RAW_VALUE:::"',n)):(r[t]=n,JSON.stringify(r));return e.substr(1,e.length-2)}function j(e){this.kvObj=e}function ce(){return(ce=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,V.createIdentity(t,{type:"c8y_SmartRestDeviceIdentifier",externalId:t.name},{silentError:!0});case 3:return e.abrupt("return",e.sent);case 6:return e.prev=6,e.t0=e.catch(0),n=r.reject.bind(r,{errorMessage:e.t0.data.message}),e.abrupt("return",s.remove(t).then(n,n));case 10:case"end":return e.stop()}},e,null,[[0,6]])}))).apply(this,arguments)}function pe(e){return e.eventMapping&&(e.eventMapping=_.omit(e.eventMapping,["eventTemplate"])),e.alarmMapping&&(e.alarmMapping=_.omit(e.alarmMapping,["raiseAlarmTemplate"])),e.measurementMapping&&(e.measurementMapping=_.omit(e.measurementMapping,["sendMeasurementTemplate"])),_.omit(e,["id","originalName","originalNumber","originalStartBit","meta"])}function le(){return(le=_asyncToGenerator(_regeneratorRuntime().mark(function e(){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,t=Ze(),n=t&&_.map(t)){e.next=8;break}return r="".concat(f,"/index.json"),e.t0=u,e.next=6,o.get(r);case 6:e.t1=e.sent,n=e.t0.getResData.call(e.t0,e.t1);case 8:return e.abrupt("return",_.flow([me,de])(n));case 9:case"end":return e.stop()}var t},e)}))).apply(this,arguments)}function me(e){return _.filter(e,fe)}function de(e){return _.filter(e,function(e){return e.minFieldbusUI<=n})}function fe(e){var t=_.map(g,"fieldbusType"),e=N(e);return _.includes(t,e)}function ye(){return(ye=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r,a,i;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n="".concat(t,".json"),r="predefinedDeviceTypesUrl/".concat(n),e.next=4,o.get(r);case 4:r=e.sent,i=JSON.stringify(r.data,null,2),a=r.headers("Content-Type"),i=new Blob([i],{type:a}),window.saveAs(i,n);case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function O(e){return e.meta=e.meta||{},_.flow([ge,_e,ve,he,be])(e)}function ge(e){return e.meta.type=e.meta.type||d.DISCRETE_IO,e}function _e(e){return e.meta.enumType=e.meta.enumType||!!e.enumValues,e.meta.enumValues=e.meta.enumValues||e.enumValues&&_.map(e.enumValues,je),e}function ve(e){var t=_.get(e,"statusMapping.status");return e.meta.showStatus=e.meta.showStatus||"read"===t||"write"===t,e.meta.updateStatus=e.meta.updateStatus||"write"===t,e}function he(e){var t=_.get(e,"alarmMapping.raiseAlarmTemplate");return e.meta.raiseAlarm=e.meta.raiseAlarm||!_.isUndefined(t),e}function be(e){var t=_.get(e,"eventMapping.eventTemplate");return e.meta.sendEvent=e.meta.sendEvent||!_.isUndefined(t),e}function Se(e){return e.meta.type=void 0,e}function Te(n){return n.meta.enumType?(n.enumValues={},_.forEach(n.meta.enumValues,function(e){var t=e.value,e=e.label;n.enumValues[t]=e})):n.enumValues=void 0,n}function Me(e){return e.meta.showStatus||e.meta.updateStatus?(e.statusMapping=e.statusMapping||{},e.meta.showStatus&&(e.statusMapping.status="read"),e.meta.updateStatus&&(e.statusMapping.status="write")):e.statusMapping=void 0,e}function we(e){return e.meta.raiseAlarm?(e.alarmMapping=e.alarmMapping||{},e.alarmMapping.raiseAlarmTemplate=null):e.alarmMapping=void 0,e}function Re(e){return e.meta.sendEvent?(e.eventMapping=e.eventMapping||{},e.eventMapping.eventTemplate=null):e.eventMapping=void 0,e}function D(e,n){return e.meta=e.meta||{},_.flow([Ee,Ie,Oe,De,Ae,xe,Ce,function(e){var t=n;return t=k(t)[e.input?"inputRegisters":"holdingRegisters"],t=_.get(t,"dataType.choices",[]),e.meta.dataType=e.meta.dataType||_.find(t.values(),{value:e.dataType}),e},function(e){var t=n;return t=k(t)[e.input?"inputRegisters":"holdingRegisters"],t=_.get(t,"accessType.choices",[]),e.meta.accessType=e.meta.accessType||_.find(t.values(),{value:e.accessType}),e},Ue])(e)}function Ee(e){return e.meta.type=e.meta.type||d.REGISTER,e}function Ie(e){return e.meta.enumType=e.meta.enumType||!!e.enumValues,e.meta.enumValues=e.meta.enumValues||e.enumValues&&_.map(e.enumValues,je),e}function je(e,t){return{label:e,value:parseFloat(t)}}function Oe(e){var t=_.get(e,"statusMapping.status");return e.meta.showStatus=e.meta.showStatus||"read"===t||"write"===t,e.meta.updateStatus=e.meta.updateStatus||"write"===t,e}function De(e){var t=_.get(e,"measurementMapping.sendMeasurementTemplate");return e.meta.sendMeasurement=e.meta.sendMeasurement||!_.isUndefined(t),e}function Ae(e){var t=_.get(e,"alarmMapping.raiseAlarmTemplate");return e.meta.raiseAlarm=e.meta.raiseAlarm||!_.isUndefined(t),e}function xe(e){var t=_.get(e,"eventMapping.eventTemplate");return e.meta.sendEvent=e.meta.sendEvent||!_.isUndefined(t),e}function Ce(e){return e.meta.sendManagedObjectUpdate=e.meta.sendManagedObjectUpdate||!!e.managedObjectMapping,e}function Ue(e){return e.meta.valuesRange=e.meta.valuesRange||ke(e),e}function ke(e){var t,n=_.get(e.meta,"dataType",{}),r=_.get(n,"baseValuesRange",{}),a=A([n.divisor,e.divisor,1]),i=A([n.multiplier,e.multiplier,1]),o=A([n.decimalPlaces,e.decimalPlaces,0]),u=A([n.noBits,e.noBits]),n=A([n.signed,e.signed,!1]),s=r.min,r=r.max;return _.isUndefined(o)||null===o||_.isUndefined(i)||_.isUndefined(a)||(t=x(i*Math.pow(10,-o)/a)),_.isUndefined(n)||_.isUndefined(u)||_.isUndefined(t)||(_.isUndefined(s)&&(s=x((n?-Math.pow(2,u-1):0)*t)),_.isUndefined(r)&&(r=x((n?Math.pow(2,u-1)-1:Math.pow(2,u)-1)*t))),{base:{decimalPlaces:_.isNull(o)?void 0:o,step:t,min:s,max:r},custom:{decimalPlaces:_.isNull(o)?void 0:o,step:t,min:Math.max(s,e.min||s),max:Math.min(r,e.max||r)},mask:{min:0,max:Math.pow(2,u)},possiblePrecisionLoss:function(e,t){e=53<e,t=!_.isUndefined(t)&&10<=function(e){if(Math.floor(e)===e)return 0;return(_slicedToArray(e.toString().split("."),2)[1]||"").length}(t);return e||t}(u,t)}}function A(e){return _.head(_.reject(e,_.isUndefined))}function x(e){var t=Math.pow(10,10);return Math.round(e*t)/t}function Ne(e){return e.meta.type=void 0,e}function Pe(n){return n.meta.enumType?(n.enumValues={},_.forEach(n.meta.enumValues,function(e){var t=e.value,e=e.label;n.enumValues[t]=e})):n.enumValues=void 0,n}function Le(e){return e.meta.showStatus||e.meta.updateStatus?(e.statusMapping=e.statusMapping||{},e.meta.showStatus&&(e.statusMapping.status="read"),e.meta.updateStatus&&(e.statusMapping.status="write")):e.statusMapping=void 0,e}function Ve(e){return e.meta.sendMeasurement?(e.measurementMapping=e.measurementMapping||{},e.measurementMapping.sendMeasurementTemplate=null):e.measurementMapping=void 0,e}function Be(e){return e.meta.raiseAlarm?(e.alarmMapping=e.alarmMapping||{},e.alarmMapping.raiseAlarmTemplate=null):e.alarmMapping=void 0,e}function Fe(e){return e.meta.sendEvent?(e.eventMapping=e.eventMapping||{},e.eventMapping.eventTemplate=null):e.eventMapping=void 0,e}function Ge(e){return e.meta.sendManagedObjectUpdate?e.managedObjectMapping=e.managedObjectMapping||{}:e.managedObjectMapping=void 0,e}function $e(e){return e.meta.dataType?e.dataType=e.meta.dataType.value:e.dataType=void 0,e}function We(e){return e.meta.accessType?e.accessType=e.meta.accessType.value:e.accessType=void 0,e}function He(e){return e.meta.valuesRange=void 0,e}function Je(e){return[_.get(e,"id"),C(e,["input","number","startBit"]),C(e,["input","number"]),C(e,["number"])]}function C(e,t){t=_.map(t,_.propertyOf(e));if(_.every(t,_.negate(_.isUndefined)))return t.join(",")}function U(e){return e.category||""}function ze(e){return e.input?e.name?c.getString('Edit discrete input: "{{name}}"',e):i("New discrete input"):e.name?c.getString('Edit coil: "{{name}}"',e):i("New coil")}function Ke(e,t,n){return{element:function(){return _.cloneDeep(function(e){if(e)return _objectSpread(_objectSpread({},e),{},{meta:{original:_.cloneDeep(e)}});return}(e))},existingElements:function(){return _.cloneDeep(t)},existingCategories:function(){return _.cloneDeep((e=n,_([].concat(_toConsumableArray(_.get(e,"c8y_Coils",[])),_toConsumableArray(_.get(e,"c8y_Registers",[])))).filter("category").map("category").uniq().map(function(e){return{name:e}}).value()));var e},deviceType:function(){return _.cloneDeep(n)},fieldbusType:function(){return N(n)},features:function(){return k(n)}}}function k(e){return _.find(g,{fieldbusType:N(e)})||{}}function N(e){return e.fieldbusType||"modbus"}function qe(e,t){var n=e.number,r=e.startBit,e=e.noBits,n=n*_.get(t,"noBits.base",_.get(t,"noBits.max"))+r;return{start:n,end:n+e-1}}function Ye(){return(Ye=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id||t,e.next=3,Qe(n);case 3:return n=e.sent,e.abrupt("return",window.btoa(unescape(encodeURIComponent(JSON.stringify(n,null,2)))));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Qe(e){return Xe.apply(this,arguments)}function Xe(){return(Xe=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=function(e){e=(Ze()||{})[e];return e&&_.clone(e._item)}(t)){e.next=8;break}return r="".concat(f,"/").concat(t,".json"),e.t0=u,e.next=6,o.get(r);case 6:return e.t1=e.sent,e.abrupt("return",e.t0.getResData.call(e.t0,e.t1));case 8:return e.abrupt("return",n);case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Ze(){return _.get(window,"c8y.collections.devicetypes")}}e.$inject=["$q","$http","$injector","c8yBase","c8yTenant","c8yInventory","c8yAlarms","c8yIdentity","c8yModal","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").factory("c8yDeviceDatabase",e)}();
1
+ "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return o};var o={},e=Object.prototype,s=e.hasOwnProperty,c=Object.defineProperty||function(e,t,n){e[t]=n.value},t="function"==typeof Symbol?Symbol:{},r=t.iterator||"@@iterator",n=t.asyncIterator||"@@asyncIterator",a=t.toStringTag||"@@toStringTag";function i(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{i({},"")}catch(e){i=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var a,i,o,u,t=t&&t.prototype instanceof m?t:m,t=Object.create(t.prototype),r=new S(r||[]);return c(t,"_invoke",{value:(a=e,i=n,o=r,u="suspendedStart",function(e,t){if("executing"===u)throw new Error("Generator is already running");if("completed"===u){if("throw"===e)throw t;return M()}for(o.method=e,o.arg=t;;){var n=o.delegate;if(n){n=function e(t,n){var r=n.method,a=t.iterator[r];if(void 0===a)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=void 0,e(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;r=p(a,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,l;a=r.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,l):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,l)}(n,o);if(n){if(n===l)continue;return n}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if("suspendedStart"===u)throw u="completed",o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);u="executing";n=p(a,i,o);if("normal"===n.type){if(u=o.done?"completed":"suspendedYield",n.arg===l)continue;return{value:n.arg,done:o.done}}"throw"===n.type&&(u="completed",o.method="throw",o.arg=n.arg)}})}),t}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}o.wrap=u;var l={};function m(){}function f(){}function d(){}var t={},y=(i(t,r,function(){return this}),Object.getPrototypeOf),y=y&&y(y(T([]))),g=(y&&y!==e&&s.call(y,r)&&(t=y),d.prototype=m.prototype=Object.create(t));function _(e){["next","throw","return"].forEach(function(t){i(e,t,function(e){return this._invoke(t,e)})})}function v(o,u){var t;c(this,"_invoke",{value:function(n,r){function e(){return new u(function(e,t){!function t(e,n,r,a){var i,e=p(o[e],o,n);if("throw"!==e.type)return(n=(i=e.arg).value)&&"object"==_typeof(n)&&s.call(n,"__await")?u.resolve(n.__await).then(function(e){t("next",e,r,a)},function(e){t("throw",e,r,a)}):u.resolve(n).then(function(e){i.value=e,r(i)},function(e){return t("throw",e,r,a)});a(e.arg)}(n,r,e,t)})}return t=t?t.then(e,e):e()}})}function h(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(h,this),this.reset(!0)}function T(t){if(t){var n,e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return n=-1,(e=function e(){for(;++n<t.length;)if(s.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e}).next=e}return{next:M}}function M(){return{value:void 0,done:!0}}return c(g,"constructor",{value:f.prototype=d,configurable:!0}),c(d,"constructor",{value:f,configurable:!0}),f.displayName=i(d,a,"GeneratorFunction"),o.isGeneratorFunction=function(e){e="function"==typeof e&&e.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,i(e,a,"GeneratorFunction")),e.prototype=Object.create(g),e},o.awrap=function(e){return{__await:e}},_(v.prototype),i(v.prototype,n,function(){return this}),o.AsyncIterator=v,o.async=function(e,t,n,r,a){void 0===a&&(a=Promise);var i=new v(u(e,t,n,r),a);return o.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},_(g),i(g,a,"Generator"),i(g,r,function(){return this}),i(g,"toString",function(){return"[object Generator]"}),o.keys=function(e){var t,n=Object(e),r=[];for(t in n)r.push(t);return r.reverse(),function e(){for(;r.length;){var t=r.pop();if(t in n)return e.value=t,e.done=!1,e}return e.done=!0,e}},o.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var r=this;function e(e,t){return i.type="throw",i.arg=n,r.next=e,t&&(r.method="next",r.arg=void 0),!!t}for(var t=this.tryEntries.length-1;0<=t;--t){var a=this.tryEntries[t],i=a.completion;if("root"===a.tryLoc)return e("end");if(a.tryLoc<=this.prev){var o=s.call(a,"catchLoc"),u=s.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return e(a.catchLoc,!0);if(this.prev<a.finallyLoc)return e(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return e(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return e(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;0<=n;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var a=r;break}}var i=(a=a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc?null:a)?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),b(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;0<=t;--t){var n,r,a=this.tryEntries[t];if(a.tryLoc===e)return"throw"===(n=a.completion).type&&(r=n.arg,b(a)),r}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},o}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_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 _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,u=[],s=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(u.push(r.value),u.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw a}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function asyncGeneratorStep(e,t,n,r,a,i,o){try{var u=e[i](o),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,a)}function _asyncToGenerator(u){return function(){var e=this,o=arguments;return new Promise(function(t,n){var r=u.apply(e,o);function a(e){asyncGeneratorStep(r,t,n,a,i,"next",e)}function i(e){asyncGeneratorStep(r,t,n,a,i,"throw",e)}a(void 0)})}}function ownKeys(t,e){var n,r=Object.keys(t);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(t),e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)),r}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function e(r,o,e,u,N,s,L,V,B,a,i,c){var G={name:"feature-fieldbus4"},n=e.has("FIELDBUS_UI_VERSION")?e.get("FIELDBUS_UI_VERSION"):4,p="c8y_IsDeviceType",l="c8y_ModbusDeviceType",m="%%",f=u.createEnum(["DISCRETE_IO","REGISTER"]),e=u.createEnum([{name:"FPORT",label:"FPort"},{name:"PAYLOAD",label:"Payload"}]),d=u.dataFilePath("devicetypes"),y={common:{name:null},deviceType:{c8y_Coils:[],c8y_Registers:[]},element:{number:null},discreteIO:{},discreteOutput:{input:!1},discreteInput:{input:!0},register:{multiplier:1,divisor:1,offset:0,decimalPlaces:0,startBit:0,noBits:16,unit:"",signed:!1},canbusRegister:{noBits:64,offset:0},canopenRegister:{},holdingRegister:{input:!1},inputRegister:{input:!0}},t=[],g=[];return{ElementType:f,MessageIdSources:e,metaDefaults:{discreteIO:{enumValues:[{value:0,label:"0"},{value:1,label:"1"}]}},registerFeaturesManifest:function(e){e=r.resolve(e);t.push(e),e.then(function(e){e&&g.push(e)})},areAnyFeaturesManifestsRegistered:function(){return v().then(function(e){return 0<e.length})},getFeaturesManifestsAsync:v,getFeaturesManifests:function(){return g},getDeviceTypeFeatures:k,getElementTypeLabel:function(e,t){var n,r=_.get(e,"meta.type");r&&(e=_.get(e,"input"),r===f.DISCRETE_IO?n=i(e?"Discrete input":"Coil (discrete output)"):r===f.REGISTER&&(n=e?i("Input register"):(r=k(t),_.get(r,"holdingRegisters.elementTypeLabel",i("Holding register")))));return n},getFieldbusVersion:X,getEmptyDeviceType:function(){var e=y.common,t=y.deviceType;return _.cloneDeep(_objectSpread(_objectSpread({},e),t))},getAvailableDeviceTypes:function(e){return h.apply(this,arguments)},getDeviceTypeFromDevice:function(e){var t=_.flatten(_.map(g,"deviceFragments")),e=_.head(_.compact(_.at(e,t))),t=_.get(e,"type"),e=t&&t.match(/\/inventory\/managedObjects\/(\d+)/),t=_.nth(e,1);if(t)return b(t);return r.resolve(null)},getFieldbusVersionFromDevice:function(e){var t=_.map(g,"deviceConfiguration.fragment"),e=_.head(_.compact(_.at(e,t)));return _.get(e,"maxFieldbusVersion",4)},getDeviceType:b,save:J,exportDeviceTypeAndSaveAs:function(e){var t="".concat(e.name,".json"),e=JSON.stringify(function(e){return e.c8y_ModbusDeviceTypeInfo=function(e){return _.omit(_objectSpread(_objectSpread({},_.get(e,"c8y_ModbusDeviceTypeInfo",{})),{},{name:e.name,minFieldbusUI:n,fieldbusType:e.fieldbusType}),["id","category","description"])}(e),e.c8y_Coils=_.map(e.c8y_Coils,le),e.c8y_Registers=_.map(e.c8y_Registers,le),_.pick(e,["c8y_ModbusDeviceTypeInfo","c8y_Coils","c8y_Registers","c8y_useServerTime","c8y_MessageIdConfiguration"])}(e),null,2),e=new Blob([e],{type:"application/json"});window.saveAs(e,t)},importDeviceTypeWithUI:function(){return a({component:"c8yImportDeviceTypeModal"}).then(J)},getPredefinedDeviceTypeInfos:function(){return me.apply(this,arguments)},isDeviceTypeSupported:ye,isDeviceTypeSupportedAsync:function(n){return v().then(function(e){return _.map(e,"fieldbusType")}).then(function(e){var t=P(n);return _.includes(e,t)})},getPredefinedDeviceType:Xe,downloadPredefinedDeviceTypeAndSaveAs:function(e){return ge.apply(this,arguments)},upgradeDeviceType:S,getElementsWithMeta:function(t){var e=_.get(t,"c8y_Coils",[]),n=_.get(t,"c8y_Registers",[]);return _.union(_.map(e,O),_.map(n,function(e){return D(e,t)}))},addDiscreteIOsMeta:function(e){if(e)return e.c8y_Coils=_.map(e.c8y_Coils,O),e;return},addDiscreteIOMeta:O,removeDiscreteIOMeta:function(e){e.meta&&(e=_.flow([Te,Me,we,Re,Ee])(e),_.unset(e,"meta"));return e},addRegistersMeta:function(t){if(t)return t.c8y_Registers=_.map(t.c8y_Registers,function(e){return D(e,t)}),t;return},addRegisterMeta:D,removeRegisterMeta:function(e){var t=e;e.meta&&(t=_.flow([Ne,Le,Ve,Be,Ge,Fe,$e,We,He,Je])(e),_.unset(t,"meta"));return t},removeAllElements:function(e){e.c8y_Registers=[],e.c8y_Coils=[]},getElementRefId:function(e){e=_.compact(ze(e));return _.head(e)},findElementBestMatchingRefId:function(e,i,o){return _(e).chain().map(function(e){return{score:(n=i,r=o,r=(t=e).meta.type.value===o,t=ze(t),a=_.findIndex(t,_.negate(_.isUndefined)),t=_.indexOf(t,n),r&&0<=t?a-t:void 0),element:e};var t,n,r,a}).reject(function(e){return _.isUndefined(e.score)}).orderBy("score").head().get("element").value()},getDiscreteOutputsCategorized:function(e){return _(e.c8y_Coils).reject("input").groupBy(U).value()},getDiscreteInputsCategorized:function(e){return _(e.c8y_Coils).filter("input").groupBy(U).value()},getHoldingRegistersCategorized:function(e){return _(e.c8y_Registers).reject("input").groupBy(U).value()},getInputRegistersCategorized:function(e){return _(e.c8y_Registers).filter("input").groupBy(U).value()},getEmptyDiscreteOutput:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.discreteIO),y.discreteOutput))},getEmptyDiscreteInput:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.discreteIO),y.discreteInput))},getEmptyHoldingRegister:function(e){return"canbus"!==e.fieldbusType?"canopen"!==e.fieldbusType?_.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.holdingRegister)):_.cloneDeep(_objectSpread(_objectSpread({},y.common),y.canopenRegister)):_.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.canbusRegister),y.holdingRegister))},getEmptyInputRegister:function(){return _.cloneDeep(_objectSpread(_objectSpread(_objectSpread(_objectSpread({},y.common),y.element),y.register),y.inputRegister))},editDiscreteIOWithUI:function(e,t){return a({component:"c8yConfigureDiscreteIOModal",title:Ke(e),resolve:_objectSpread({title:function(){return Ke(e)}},qe(e,t.c8y_Coils,t))})},editRegisterWithUI:function(n,r){return a({component:"c8yConfigureRegisterModal",resolve:_objectSpread({title:function(){var e=n,t=r;return t=k(t),e.input?e.name?c.getString('Edit input register: "{{name}}"',e):i("New input register"):e.name?c.getString(_.get(t,"holdingRegisters.editRegisterModalTitle",i('Edit holding register: "{{name}}"')),e):_.get(t,"holdingRegisters.newRegisterModalTitle",i("New holding register"))}},qe(n,r.c8y_Registers,r))})},addEmptyEnumValue:function(e){e.meta.enumValues=e.meta.enumValues||[],e.meta.enumValues.push({value:null,label:null})},removeEnumValue:function(e,t){e.meta.enumValues=_.without(e.meta.enumValues,t)},areOverlappingRegisters:function(e,t,n){e=Ye(e,n),t=Ye(t,n),n=Math.max(e.start,t.start),e=Math.min(e.end,t.end);return n<=e},getValuesRange:Pe,openFieldbusSelector:function(e){return a({component:"c8ySelectFieldbusPropertyModal",resolve:{modalParams:function(){return _.defaults(e,{})}}})},downloadPredefinedDeviceTypeHref:function(e){return Qe.apply(this,arguments)},predefinedDeviceTypeHrefFilename:function(e){return"".concat(e.id,".json")},isFieldbusDevice:function(t){return _.some(g,function(e){return _.some(e.deviceFragments,function(e){return _.has(t,e)})})},isFeatureFieldbus4Available:function(){return N.isSubscribed(G)},addElementId:T};function v(){return r.all(t).then(_.compact)}function h(){return(h=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r,a,i,o=arguments;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=1<o.length&&void 0!==o[1]?o[1]:{},r=2<o.length?o[2]:void 0,i={__and:[{__or:[{__has:p},{type:l}]},{fieldbusType:{__in:_.map(g,"fieldbusType")}}]},_.isEmpty(t)||(i.__and=[].concat(_toConsumableArray(i.__and),[t])),a=u.createListMapper(S),e.next=8,s.listQuery(i,n,!0,r).then(a);case 8:return i=e.sent,e.abrupt("return",i);case 10:case"end":return e.stop()}},e)}))).apply(this,arguments)}function b(e){return F.apply(this,arguments)}function F(){return(F=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=u,e.next=3,s.detail(t);case 3:return e.t1=e.sent,n=e.t0.getResData.call(e.t0,e.t1),e.abrupt("return",S(n));case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}function S(e){return _.flow([$,W,H,Y,Q])(e)}function $(e){return _.forEach(e.c8y_Coils,function(e){!e.enumValues&&e.statusMapping&&_.isArray(e.statusMapping.enumValues)&&(e.enumValues={0:e.statusMapping.enumValues[0],1:e.statusMapping.enumValues[1]},_.unset(e,"statusMapping.enumValues")),_.isUndefined(e.input)&&(e.input=y.discreteOutput.input)}),e}function W(e){var n=k(e);return _.forEach(e.c8y_Registers,function(e){var t=e.input?"inputRegisters":"holdingRegisters",t=_.get(n,t,{});_.get(t,"startBit")&&_.defaults(e,{startBit:y.register.startBit}),_.get(t,"noBits")&&_.defaults(e,{noBits:y.register.noBits}),_.get(t,"options.signed")&&_.defaults(e,{signed:y.register.signed}),!e.unit&&e.measurementMapping&&e.measurementMapping.unit&&(e.unit=e.measurementMapping.unit,_.unset(e,"measurementMapping.unit")),_.isUndefined(e.input)&&(e.input=y.holdingRegister.input)}),e}function H(e){return e.fieldbusType=P(e),e}function J(e){return z.apply(this,arguments)}function z(){return(z=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=_.flow([q,Y,Z,ee,te,ne,Q])(t),e.next=3,function(){return K.apply(this,arguments)}(n);case 3:return n=e.sent,e.abrupt("return",s.save(n).then(u.getResData).then(function(e){return t.id?e:function(){return pe.apply(this,arguments)}(e).then(function(){return e})}));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function K(){return(K=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=s,e.t1=t,e.next=4,B.getGlobalParam(t.type);case 4:return e.t2=e.sent,e.abrupt("return",e.t0.addGlobalFlag.call(e.t0,e.t1,e.t2));case 6:case"end":return e.stop()}},e)}))).apply(this,arguments)}function q(e){var t;return e.type||(t=k(e),e.type=_.get(t,"type",l)),e}function Y(e){return _.set(e,p,{})}function Q(e){return _.set(e,"fieldbusVersion",X(e))}function X(t){var e=k(t).versions,e=_.findLast(e,function(e){return _.some(e.checks,function(e){return e(t)})});return _.get(e,"number",4)}function Z(e){return e.c8y_Coils=_.map(e.c8y_Coils,T),e.c8y_Registers=_.map(e.c8y_Registers,T),e}function T(e){return e.id||(e.id=String(Math.random()).substr(2)),e}function ee(e){return e.c8y_Coils=_.orderBy(e.c8y_Coils,["input","number"]),e.c8y_Registers=_.orderBy(e.c8y_Registers,["input","number","startBit","index","subIndex"]),e}function te(e){var a,t=k(e);return!!_.get(t,"configuration.messageIdConfiguration.length")&&(e.c8y_MessageTypes=(a=e,_.reduce(["c8y_Registers","c8y_Coils"],function(e,t){return _.merge(e,(n=a,r=t,e=_.groupBy(n[r],"messageTypeId"),e=_.mapValues(e,function(e){return _.map(e,function(e){return _.indexOf(n[r],e)})}),_.reduce(e,function(e,t,n){return e[n]={},e[n][r]=t,e},{})));var n,r},{}))),e}function ne(e){r=k(t=e).customizeSmartRestTemplates||_.identity,n={requestTemplates:_.flattenDeep([function(e){return{msgId:100,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.managedObject+json",placeholder:m,resourceUri:"/inventory/managedObjects/".concat(m),templateString:E([{key:"c8y_CoilStatus",value:new j(M(e.c8y_Coils).map(function(e){return{key:e.name,value:m,raw:!0}}).value())}]),values:["UNSIGNED"].concat(_toConsumableArray(M(e.c8y_Coils).map(function(){return"UNSIGNED"}).value()))}}(t),function(e){return{msgId:101,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.managedObject+json",placeholder:m,resourceUri:"/inventory/managedObjects/".concat(m),templateString:E([{key:"c8y_RegisterStatus",value:new j(M(e.c8y_Registers).map(function(e){return{key:e.name,value:m,raw:!0}}).value())}]),values:["UNSIGNED"].concat(_toConsumableArray(M(e.c8y_Registers).map(function(){return"NUMBER"}).value()))}}(t),[w(102,"EXECUTING"),w(103,"SUCCESSFUL"),w(104,"FAILED")],function(e){return _.flow([re,ue,se])({deviceType:e,msgId:300,templates:[]}).templates}(t)]),responseTemplates:_.flattenDeep([{msgId:200,condition:"$.c8y_SetCoil",pattern:["$.id","$.c8y_SetCoil.address","$.c8y_SetCoil.input","$.c8y_SetCoil.coil","$.c8y_SetCoil.value"]},{msgId:201,condition:"$.c8y_SetRegister",pattern:["$.id","$.c8y_SetRegister.ipAddress","$.c8y_SetRegister.address","$.c8y_SetRegister.input","$.c8y_SetRegister.register","$.c8y_SetRegister.startBit","$.c8y_SetRegister.noBits","$.c8y_SetRegister.value"]},{msgId:202,condition:"$.c8y_ModbusDevice",pattern:["$.id","$.deviceId","$.c8y_ModbusDevice.id","$.c8y_ModbusDevice.address","$.c8y_ModbusDevice.type","$.c8y_ModbusDevice.protocol"]},{msgId:203,condition:"$.c8y_ModbusSource",pattern:["$.id"]}])};var t,n,r=r(n,t);return _.set(e,"com_cumulocity_model_smartrest_SmartRestTemplate",r)}function M(e){return _(e).filter("statusMapping.status")}function w(e,t){return{msgId:e,method:"PUT",contentType:"application/vnd.com.nsn.cumulocity.operation+json",placeholder:m,resourceUri:"/devicecontrol/operations/".concat(m),templateString:E({status:t}),values:["UNSIGNED"]}}function re(e){var t=e.deviceType,n=e.msgId,r=e.templates,e=_.filter(t.c8y_Coils,"alarmMapping"),a=_.filter(t.c8y_Registers,"alarmMapping"),i=k(t),o=i.getCoilSource||ie,u=i.getRegisterSource||oe,s=n;return _.forEach(e,function(e){r.push(ae(s,t,e.alarmMapping,o(e))),e.alarmMapping.raiseAlarmTemplate=s,s+=1}),_.forEach(a,function(e){r.push(ae(s,t,e.alarmMapping,u(e))),e.alarmMapping.raiseAlarmTemplate=s,s+=1}),{deviceType:t,templates:r,msgId:s}}function ae(e,t,n,r){return{msgId:e,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.alarm+json",accept:"application/vnd.com.nsn.cumulocity.alarm+json",placeholder:m,resourceUri:"/alarm/alarms",templateString:E([{key:"source",value:{id:m}},{key:"type",value:n.type},{key:"status",value:L.status.ACTIVE},{key:"severity",value:n.severity},{key:"time",value:m},{key:"text",value:n.text},{key:r.key,value:r.value}]),values:["UNSIGNED",R(t)]}}function ie(e){return{key:"c8y_ModbusSource",value:{coil:_.pick(e,"input","number")}}}function oe(e){return{key:"c8y_ModbusSource",value:{register:_.pick(e,["input","number","startBit","noBits"])}}}function ue(e){var r=e.deviceType,t=e.msgId,o=e.templates,e=_([].concat(_toConsumableArray(r.c8y_Coils),_toConsumableArray(r.c8y_Registers))).filter("measurementMapping").groupBy("measurementMapping.type").value(),u=t;return _.forEach(e,function(e,t){var n,a,i,e=_.map(e,function(e){return _.set(e.measurementMapping,"unit",e.unit||e.measurementMapping.unit)});o.push((n=r,a=t,i=e,{msgId:u,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.measurement+json",placeholder:m,resourceUri:"/measurement/measurements",templateString:E(function(){var n=a,r=_defineProperty({source:{id:m},time:m,type:n},n,{});return _.forEach(i,function(e){var t=e.series,e=e.unit;r[n][t]={value:"%n",unit:e}}),r}()),values:["UNSIGNED",R(n)].concat(_toConsumableArray(_.map(i,function(){return"NUMBER"})))})),_.forEach(e,function(e){e.sendMeasurementTemplate=u,_.unset(e,"unit")}),u+=1}),{deviceType:r,templates:o,msgId:u}}function se(e){var a=e.deviceType,t=e.msgId,i=e.templates,e=[].concat(_toConsumableArray(a.c8y_Coils),_toConsumableArray(a.c8y_Registers)),o=t;return _.forEach(e,function(e){var t,n,r;_.isUndefined(e.eventMapping)||(i.push((t=o,n=a,r=e.eventMapping,{msgId:t,method:"POST",contentType:"application/vnd.com.nsn.cumulocity.event+json",placeholder:m,resourceUri:"/event/events",templateString:E([{key:"source",value:{id:m}},{key:"time",value:m},{key:"type",value:r.type},{key:"text",value:r.text},{key:e.name,value:m,raw:!0}]),values:["UNSIGNED",R(n),"NUMBER"]})),e.eventMapping.eventTemplate=o,o+=1)}),{deviceType:a,templates:i,msgId:o}}function R(e){return e.c8y_useServerTime?"NOW":"DATE"}function E(e,t){var n;return e instanceof j?n=I(e.kvObj):_.isArray(e)?n=I(e):_.isObjectLike(e)&&(n=angular.toJson(e)),n=n.replace(/"%n"/g,t||m)}function I(e){e=_.map(e,ce);return"{".concat(e.join(","),"}")}function ce(e){var t=e.key,n=e.value,e=e.raw,r={},e=n instanceof j?(r[t]=":::INNER_OBJECT_STRING:::",JSON.stringify(r).replace('":::INNER_OBJECT_STRING:::"',I(n.kvObj))):e?(r[t]=":::RAW_VALUE:::",JSON.stringify(r).replace('":::RAW_VALUE:::"',n)):(r[t]=n,JSON.stringify(r));return e.substr(1,e.length-2)}function j(e){this.kvObj=e}function pe(){return(pe=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,V.createIdentity(t,{type:"c8y_SmartRestDeviceIdentifier",externalId:t.name},{silentError:!0});case 3:return e.abrupt("return",e.sent);case 6:return e.prev=6,e.t0=e.catch(0),n=r.reject.bind(r,{errorMessage:e.t0.data.message}),e.abrupt("return",s.remove(t).then(n,n));case 10:case"end":return e.stop()}},e,null,[[0,6]])}))).apply(this,arguments)}function le(e){return e.eventMapping&&(e.eventMapping=_.omit(e.eventMapping,["eventTemplate"])),e.alarmMapping&&(e.alarmMapping=_.omit(e.alarmMapping,["raiseAlarmTemplate"])),e.measurementMapping&&(e.measurementMapping=_.omit(e.measurementMapping,["sendMeasurementTemplate"])),_.omit(e,["id","originalName","originalNumber","originalStartBit","meta"])}function me(){return(me=_asyncToGenerator(_regeneratorRuntime().mark(function e(){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=void 0,t=et(),n=t&&_.map(t)){e.next=8;break}return r="".concat(d,"/index.json"),e.t0=u,e.next=6,o.get(r);case 6:e.t1=e.sent,n=e.t0.getResData.call(e.t0,e.t1);case 8:return e.abrupt("return",_.flow([fe,de])(n));case 9:case"end":return e.stop()}var t},e)}))).apply(this,arguments)}function fe(e){return _.filter(e,ye)}function de(e){return _.filter(e,function(e){return e.minFieldbusUI<=n})}function ye(e){var t=_.map(g,"fieldbusType"),e=P(e);return _.includes(t,e)}function ge(){return(ge=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r,a,i;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n="".concat(t,".json"),r="predefinedDeviceTypesUrl/".concat(n),e.next=4,o.get(r);case 4:r=e.sent,i=JSON.stringify(r.data,null,2),a=r.headers("Content-Type"),i=new Blob([i],{type:a}),window.saveAs(i,n);case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function O(e){return e.meta=e.meta||{},_.flow([_e,ve,he,be,Se])(e)}function _e(e){return e.meta.type=e.meta.type||f.DISCRETE_IO,e}function ve(e){return e.meta.enumType=e.meta.enumType||!!e.enumValues,e.meta.enumValues=e.meta.enumValues||e.enumValues&&_.map(e.enumValues,Oe),e}function he(e){var t=_.get(e,"statusMapping.status");return e.meta.showStatus=e.meta.showStatus||"read"===t||"write"===t,e.meta.updateStatus=e.meta.updateStatus||"write"===t,e}function be(e){var t=_.get(e,"alarmMapping.raiseAlarmTemplate");return e.meta.raiseAlarm=e.meta.raiseAlarm||!_.isUndefined(t),e}function Se(e){var t=_.get(e,"eventMapping.eventTemplate");return e.meta.sendEvent=e.meta.sendEvent||!_.isUndefined(t),e}function Te(e){return e.meta.type=void 0,e}function Me(n){return n.meta.enumType?(n.enumValues={},_.forEach(n.meta.enumValues,function(e){var t=e.value,e=e.label;n.enumValues[t]=e})):n.enumValues=void 0,n}function we(e){return e.meta.showStatus||e.meta.updateStatus?(e.statusMapping=e.statusMapping||{},e.meta.showStatus&&(e.statusMapping.status="read"),e.meta.updateStatus&&(e.statusMapping.status="write")):e.statusMapping=void 0,e}function Re(e){return e.meta.raiseAlarm?(e.alarmMapping=e.alarmMapping||{},e.alarmMapping.raiseAlarmTemplate=null):e.alarmMapping=void 0,e}function Ee(e){return e.meta.sendEvent?(e.eventMapping=e.eventMapping||{},e.eventMapping.eventTemplate=null):e.eventMapping=void 0,e}function D(e,n){return e.meta=e.meta||{},_.flow([Ie,je,De,xe,Ae,Ce,Ue,function(e){var t=n;return t=k(t)[e.input?"inputRegisters":"holdingRegisters"],t=_.get(t,"dataType.choices",[]),e.meta.dataType=e.meta.dataType||_.find(t.values(),{value:e.dataType}),e},function(e){var t=n;return t=k(t)[e.input?"inputRegisters":"holdingRegisters"],t=_.get(t,"accessType.choices",[]),e.meta.accessType=e.meta.accessType||_.find(t.values(),{value:e.accessType}),e},ke])(e)}function Ie(e){return e.meta.type=e.meta.type||f.REGISTER,e}function je(e){return e.meta.enumType=e.meta.enumType||!!e.enumValues,e.meta.enumValues=e.meta.enumValues||e.enumValues&&_.map(e.enumValues,Oe),e}function Oe(e,t){return{label:e,value:parseFloat(t)}}function De(e){var t=_.get(e,"statusMapping.status");return e.meta.showStatus=e.meta.showStatus||"read"===t||"write"===t,e.meta.updateStatus=e.meta.updateStatus||"write"===t,e}function xe(e){var t=_.get(e,"measurementMapping.sendMeasurementTemplate");return e.meta.sendMeasurement=e.meta.sendMeasurement||!_.isUndefined(t),e}function Ae(e){var t=_.get(e,"alarmMapping.raiseAlarmTemplate");return e.meta.raiseAlarm=e.meta.raiseAlarm||!_.isUndefined(t),e}function Ce(e){var t=_.get(e,"eventMapping.eventTemplate");return e.meta.sendEvent=e.meta.sendEvent||!_.isUndefined(t),e}function Ue(e){return e.meta.sendManagedObjectUpdate=e.meta.sendManagedObjectUpdate||!!e.managedObjectMapping,e}function ke(e){return e.meta.valuesRange=e.meta.valuesRange||Pe(e),e}function Pe(e){var t,n=_.get(e.meta,"dataType",{}),r=_.get(n,"baseValuesRange",{}),a=x([n.divisor,e.divisor,1]),i=x([n.multiplier,e.multiplier,1]),o=x([n.decimalPlaces,e.decimalPlaces,0]),u=x([n.noBits,e.noBits]),n=x([n.signed,e.signed,!1]),s=r.min,r=r.max;return _.isUndefined(o)||null===o||_.isUndefined(i)||_.isUndefined(a)||(t=A(i*Math.pow(10,-o)/a)),_.isUndefined(n)||_.isUndefined(u)||_.isUndefined(t)||(_.isUndefined(s)&&(s=A((n?-Math.pow(2,u-1):0)*t)),_.isUndefined(r)&&(r=A((n?Math.pow(2,u-1)-1:Math.pow(2,u)-1)*t))),{base:{decimalPlaces:_.isNull(o)?void 0:o,step:t,min:s,max:r},custom:{decimalPlaces:_.isNull(o)?void 0:o,step:t,min:Math.max(s,e.min||s),max:Math.min(r,e.max||r)},mask:{min:0,max:Math.pow(2,u)},possiblePrecisionLoss:function(e,t){e=53<e,t=!_.isUndefined(t)&&10<=function(e){if(Math.floor(e)===e)return 0;return(_slicedToArray(e.toString().split("."),2)[1]||"").length}(t);return e||t}(u,t)}}function x(e){return _.head(_.reject(e,_.isUndefined))}function A(e){var t=Math.pow(10,10);return Math.round(e*t)/t}function Ne(e){return e.meta.type=void 0,e}function Le(n){return n.meta.enumType?(n.enumValues={},_.forEach(n.meta.enumValues,function(e){var t=e.value,e=e.label;n.enumValues[t]=e})):n.enumValues=void 0,n}function Ve(e){return e.meta.showStatus||e.meta.updateStatus?(e.statusMapping=e.statusMapping||{},e.meta.showStatus&&(e.statusMapping.status="read"),e.meta.updateStatus&&(e.statusMapping.status="write")):e.statusMapping=void 0,e}function Be(e){return e.meta.sendMeasurement?(e.measurementMapping=e.measurementMapping||{},e.measurementMapping.sendMeasurementTemplate=null):e.measurementMapping=void 0,e}function Ge(e){return e.meta.raiseAlarm?(e.alarmMapping=e.alarmMapping||{},e.alarmMapping.raiseAlarmTemplate=null):e.alarmMapping=void 0,e}function Fe(e){return e.meta.sendEvent?(e.eventMapping=e.eventMapping||{},e.eventMapping.eventTemplate=null):e.eventMapping=void 0,e}function $e(e){return e.meta.sendManagedObjectUpdate?e.managedObjectMapping=e.managedObjectMapping||{}:e.managedObjectMapping=void 0,e}function We(e){return e.meta.dataType?e.dataType=e.meta.dataType.value:e.dataType=void 0,e}function He(e){return e.meta.accessType?e.accessType=e.meta.accessType.value:e.accessType=void 0,e}function Je(e){return e.meta.valuesRange=void 0,e}function ze(e){return[_.get(e,"id"),C(e,["input","number","startBit"]),C(e,["input","number"]),C(e,["number"])]}function C(e,t){t=_.map(t,_.propertyOf(e));if(_.every(t,_.negate(_.isUndefined)))return t.join(",")}function U(e){return e.category||""}function Ke(e){return e.input?e.name?c.getString('Edit discrete input: "{{name}}"',e):i("New discrete input"):e.name?c.getString('Edit coil: "{{name}}"',e):i("New coil")}function qe(e,t,n){return{element:function(){return _.cloneDeep(function(e){if(e)return _objectSpread(_objectSpread({},e),{},{meta:{original:_.cloneDeep(e)}});return}(e))},existingElements:function(){return _.cloneDeep(t)},existingCategories:function(){return _.cloneDeep((e=n,_([].concat(_toConsumableArray(_.get(e,"c8y_Coils",[])),_toConsumableArray(_.get(e,"c8y_Registers",[])))).filter("category").map("category").uniq().map(function(e){return{name:e}}).value()));var e},deviceType:function(){return _.cloneDeep(n)},fieldbusType:function(){return P(n)},features:function(){return k(n)}}}function k(e){return _.find(g,{fieldbusType:P(e)})||{}}function P(e){return e.fieldbusType||"modbus"}function Ye(e,t){var n=e.number,r=e.startBit,e=e.noBits,n=n*_.get(t,"noBits.base",_.get(t,"noBits.max"))+r;return{start:n,end:n+e-1}}function Qe(){return(Qe=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id||t,e.next=3,Xe(n);case 3:return n=e.sent,e.abrupt("return",window.btoa(unescape(encodeURIComponent(JSON.stringify(n,null,2)))));case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Xe(e){return Ze.apply(this,arguments)}function Ze(){return(Ze=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var n,r;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=function(e){e=(et()||{})[e];return e&&_.clone(e._item)}(t)){e.next=8;break}return r="".concat(d,"/").concat(t,".json"),e.t0=u,e.next=6,o.get(r);case 6:return e.t1=e.sent,e.abrupt("return",e.t0.getResData.call(e.t0,e.t1));case 8:return e.abrupt("return",n);case 9:case"end":return e.stop()}},e)}))).apply(this,arguments)}function et(){return _.get(window,"c8y.collections.devicetypes")}}e.$inject=["$q","$http","$injector","c8yBase","c8yTenant","c8yInventory","c8yAlarms","c8yIdentity","c8yGlobalConfigService","c8yModal","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").factory("c8yDeviceDatabase",e)}();
@@ -1,5 +1,5 @@
1
1
  <c8y-ui-action-bar-set>
2
- <c8y-if-allowed any-role="['ROLE_INVENTORY_ADMIN', 'ROLE_INVENTORY_CREATE']">
2
+ <c8y-if-allowed any-role="['ROLE_INVENTORY_ADMIN', 'ROLE_INVENTORY_CREATE', 'ROLE_MANAGED_OBJECT_ADMIN', 'ROLE_MANAGED_OBJECT_CREATE']">
3
3
  <button
4
4
  title="{{ 'Import' | translate }}"
5
5
  class="btn btn-link"
@@ -1 +1 @@
1
- "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function e(e,t,a,o,n,i,r){var u,l,d,s,m,c,g,S=this,f="elementForm",I={IS_REQUIRED:"required",IS_VALID_NAME:"valid-name",IS_VALID_BIT_RANGE:"valid-bit-range",IS_VALID_MEASUREMENT:"valid-measurement",IS_VALUE_IN_REGISTER_RANGE:"value-in-register-range",IS_VALID_NO_BITS_FOR_SIGNED_REGISTER:"no-bits-for-signed-register",IS_VALID_MESSAGEID:"valid-messageID",IS_VALID_BROWSEPATH:"valid-browsePath",IS_VALID_OID:"valid-oid",IS_MIN:"min",IS_MAX:"max",IS_UNIQUE:"unique",PATTERN:"pattern",HEXNUMBER:"hexnumber",MEASUREMENT_FRAGMENT:"measurement-fragment"},p=i("Value out of range. Allowed values from {{min | number}} to {{max | number}}."),v=i('This will be matched with the message ID extracted from the protocol\'s data according to the "Source" setting.');function y(){"read"===S.readWriteMutexValue?(l.meta.showStatus=!0,l.meta.updateStatus=!1):(l.meta.showStatus=!1,l.meta.updateStatus=!0)}function E(e){e=S.features.functionalities[e];return e&&(!e.showIf||e.showIf(S.element))}function h(){return _.get(u,"number.min",1)}function V(){return _.get(u,"number.max",65536)}function b(e){var t=_.get(u,"noBits.max");return _.isNumber(t)&&_.isNumber(e)?t-e:t}_.assign(S,{$onInit:function(){var e=S.resolve;l=e.element,d=e.existingElements,s=e.existingCategories,m=e.deviceType,c=e.fieldbusType,function(){var e=l.input?"input":"holding";u=S.resolve.features["".concat(e,"Registers")],_.assign(S,{features:u,dataTypes:_.get(u,"dataType.choices"),accessTypes:_.get(u,"accessType.choices")})}(),S.element=o.addRegisterMeta(l,m),S.categories=s,S.deviceType=m,S.fieldbusType=c,function(){var e;_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(e={},I.IS_REQUIRED,i("This field is required.")),I.IS_VALID_NAME,_.get(u,"validation.invalidName",i("Name must be unique among registers."))),I.IS_VALID_BIT_RANGE,i("Selected number, start bit or number of bits overlap with another register.")),I.IS_VALID_MEASUREMENT,_.get(u,"validation.invalidMeasurement",i("Selected measurement type and series are already used by another register."))),I.IS_MIN,i("Value cannot be lower than minimum.")),I.IS_MAX,i("Value cannot be greater than maximum.")),I.IS_UNIQUE,i("Value cannot be used more than once.")),I.IS_VALID_NO_BITS_FOR_SIGNED_REGISTER,i("At least two bits needed for signed register.")),I.IS_VALID_MESSAGEID,i("Invalid hexadecimal number.")),I.IS_VALID_BROWSEPATH,i("Invalid browse path.")),g=_defineProperty(_defineProperty(_defineProperty(_defineProperty(e,I.IS_VALID_OID,_.get(u,"validation.invalidOid",i("OID must be unique among components."))),I.PATTERN,i("Must be a valid number.")),I.HEXNUMBER,i("Must be a valid hexadecimal number.")),I.MEASUREMENT_FRAGMENT,i("Must not contain whitespaces nor the special characters .,*[]()@$"))}(),u.functionalities.readWriteMutex&&(S.readWriteMutexValue="read",l.meta.updateStatus&&(S.readWriteMutexValue="write"),y())},PATTERN_VALIDATE_FRAGMENT_SERIES:"^[^.]*$",alarmSeverities:n.severityList,getValuePlaceholder:function(e){var t=r.getString("no value");_.isUndefined(e)||_.isNaN(e)||(t=e);return"(".concat(t,")")},addEnumValue:o.addEmptyEnumValue,removeEnumValue:o.removeEnumValue,invalid:function(e){return function(e){{var t,n;"number"===e&&_.get(u,"number.useHex")&&(e=_.get(S,"".concat(f,".number")),(n=_.get(e,"$modelValue"))?(n.startsWith("0x")&&(n=n.substring(2)),t=parseInt(n,16),n=t.toString(16)===n.toLowerCase(),e.$setValidity(I.IS_VALID_MESSAGEID,n),e.$setValidity(I.IS_MIN,!n||t>=h()),e.$setValidity(I.IS_MAX,!n||t<=V())):e.$setValidity(I.IS_VALID_MESSAGEID,!0))}}(e),function(e){var t=S[f];"browsePath"===e&&(e=t.browsePath.$viewValue,t.browsePath.$setValidity(I.IS_VALID_BROWSEPATH,/^|((\d)+:[^/]+)([/](\d)+:[^/]+)*$/.test(e)))}(e),function(){var t=S[f].name,n=_.get(l,"meta"),e=_.isUndefined(t.$modelValue)||_.every(d,function(e){return e.name===_.get(n,"original.name")||e.name!==t.$modelValue});t.$setValidity(I.IS_VALID_NAME,e)}(),function(){var e=S[f],n=e.number,a=e.startBit,i=e.noBits,r=_.get(l,"meta"),e=!n||_.isUndefined(n.$modelValue)||_.isUndefined(a.$modelValue)||_.isUndefined(i.$modelValue)||!_.some(d,function(e){var t=n.$modelValue;_.get(u,"number.useHex")&&t&&-1===t.indexOf("0x")&&(t="0x".concat(t));return(!r||!(_.get(r,"original.number")===e.number&&r.original.startBit===e.startBit))&&e.input===l.input&&o.areOverlappingRegisters(e,{number:t,startBit:a.$modelValue,noBits:i.$modelValue},u)});n&&n.$setValidity(I.IS_VALID_BIT_RANGE,e);a&&a.$setValidity(I.IS_VALID_BIT_RANGE,e);i&&i.$setValidity(I.IS_VALID_BIT_RANGE,e)}(),function(){var e=S[f],i=_.get(e,"messageTypeId.$modelValue"),t=e.measurementType,r=_.get(t,"$modelValue"),e=e.measurementSeries,o=_.get(e,"$modelValue"),s=_.get(l,"meta"),n=!_.get(s,"sendMeasurement")||_.isUndefined(r)||_.isUndefined(o)||!_.some(d,function(e){var t=!1,n=_.get(l,"id")===_.get(e,"id"),a=u.number&&_.get(s,"original.number")===e.number&&_.get(s,"original.startBit")===e.startBit&&_.get(s,"original.input")===e.input;return t=n||a?t:(!u.messageTypeId||_.get(e,"messageTypeId")===i)&&_.get(e,"measurementMapping.type")===r&&_.get(e,"measurementMapping.series")===o});t&&t.$setValidity(I.IS_VALID_MEASUREMENT,n);e&&e.$setValidity(I.IS_VALID_MEASUREMENT,n)}(),function(){var e=_.get(S,"".concat(f,".noBits"));{var t;e&&(t=!l.signed||l.signed&&!_.isUndefined(e.$modelValue)&&1<e.$modelValue,e.$setValidity(I.IS_VALID_NO_BITS_FOR_SIGNED_REGISTER,t))}}(),function(e){var t=S[f];{var n,a;"oid"===e&&(n=t.oid,a=_.get(l,"meta"),e=_.isUndefined(n.$modelValue)||_.every(d,function(e){return e.oid===_.get(a,"original.oid")||e.oid!==n.$modelValue}),n.$setValidity(I.IS_VALID_OID,e))}}(e),a.invalid(S,f,e)},validationHints:function(e,t){var n=_.cloneDeep(g),t=_.get(t,"validateValueInRegisterRange");t&&(n[I.IS_VALUE_IN_REGISTER_RANGE]=r.getString(p,t));return a.validationHints(e,n)},onAccessTypeChange:function(){E("showStatus")||(S.element.meta.showStatus=!1);!S.element.input&&E("updateStatus")||(S.element.meta.updateStatus=!1);S.shouldEnableShowStatusStandardFunctionalities()&&E("sendMeasurement")||(S.element.meta.sendMeasurement=!1);S.shouldEnableShowStatusStandardFunctionalities()&&E("raiseAlarm")||(S.element.meta.raiseAlarm=!1);S.shouldEnableShowStatusStandardFunctionalities()&&E("sendEvent")||(S.element.meta.sendEvent=!1)},onUpdateStatusCheckboxChange:function(){l.meta.updateStatus&&(l.meta.showStatus=!0)},onStatusMappingRadiosChange:y,save:function(){(function(){var e=[];S.features.functionalities.readWriteMutex&&(e=["measurementMapping","eventMapping","alarmMapping"],"read"===S.readWriteMutexValue)&&(e=["min","max"]);l.noBits<=8&&e.push("littleEndian");_.forEach(e,function(e){return _.unset(l,e)})})(),S.close({$value:o.removeRegisterMeta(l)})},messageTypeIdMax:function(){var e=void 0;return _.get(m,"c8y_MessageIdConfiguration.source")!==o.MessageIdSources.PAYLOAD.value?e:(e=_.get(m,"c8y_MessageIdConfiguration.messageIdMapping.noBits"),Math.pow(2,e)-1)},startBitMax:function(){return _.get(u,"startBit.max")},noBitsMax:b,getNumberMin:h,getNumberMax:V,shouldShowOptions:function(){return _.some(S.features.options,Boolean)},shouldShowNormalisationSection:function(){return _.some([S.features.multiplier,S.features.divisor,S.features.offset,S.features.decimalPlaces,S.features.unit,_.get(S.element,"meta.updateStatus",!1)],Boolean)},shouldShowFunctionalities:function(){var e=S.features.functionalities,t=e.readWriteMutex,n=e.showStatus&&S.shouldShowFunctionality("showStatus"),a=e.updateStatus&&!S.element.input&&S.shouldShowFunctionality("updateStatus"),i=S.shouldEnableShowStatusStandardFunctionalities()&&(S.shouldShowFunctionality("sendMeasurement")||S.shouldShowFunctionality("raiseAlarm")||S.shouldShowFunctionality("sendEvent")),e=e.sendManagedObjectUpdate;return t||n||a||i||e},shouldEnableShowStatusStandardFunctionalities:function(){return!(S.features.functionalities.readWriteMutex&&"write"===S.readWriteMutexValue)},shouldShowFunctionality:E,messageIdTooltip:v}),e.$watch("vm.element.startBit",function(){var e=b(l.startBit);l.noBits>e&&(l.noBits=e)}),e.$watchGroup(["vm.element.min","vm.element.max","vm.element.noBits","vm.element.multiplier","vm.element.divisor","vm.element.decimalPlaces","vm.element.signed","vm.element.meta.dataType"],function(){var e=l.meta;e&&(e.valuesRange=o.getValuesRange(l))})}e.$inject=["$scope","$q","c8yBase","c8yDeviceDatabase","c8yAlarms","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").component("c8yConfigureRegisterModal",{templateUrl:":::PLUGIN_PATH:::/modals/configure-register.html",bindings:{resolve:"<",close:"&",dismiss:"&"},controllerAs:"vm",controller:e})}();
1
+ "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);n=n.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}!function(){function e(e,t,a,o,n,i,r){var u,l,d,s,m,c,g,S=this,f="elementForm",I={IS_REQUIRED:"required",IS_VALID_NAME:"valid-name",IS_VALID_BIT_RANGE:"valid-bit-range",IS_VALID_MEASUREMENT:"valid-measurement",IS_VALUE_IN_REGISTER_RANGE:"value-in-register-range",IS_VALID_NO_BITS_FOR_SIGNED_REGISTER:"no-bits-for-signed-register",IS_VALID_MESSAGEID:"valid-messageID",IS_VALID_BROWSEPATH:"valid-browsePath",IS_VALID_OID:"valid-oid",IS_MIN:"min",IS_MAX:"max",IS_UNIQUE:"unique",PATTERN:"pattern",HEXNUMBER:"hexnumber",MEASUREMENT_FRAGMENT:"measurement-fragment"},p=i("Value out of range. Allowed values from {{min | number}} to {{max | number}}."),v=i('This will be matched with the message ID extracted from the protocol\'s data according to the "Source" setting.');function y(){"read"===S.readWriteMutexValue?(l.meta.showStatus=!0,l.meta.updateStatus=!1):(l.meta.showStatus=!1,l.meta.updateStatus=!0)}function E(e){e=S.features.functionalities[e];return e&&(!e.showIf||e.showIf(S.element))}function h(){return _.get(u,"number.min",1)}function V(){return _.get(u,"number.max",65536)}function b(e){var t=_.get(u,"noBits.max");return _.isNumber(t)&&_.isNumber(e)?t-e:t}_.assign(S,{$onInit:function(){var e=S.resolve;l=e.element,d=e.existingElements,s=e.existingCategories,m=e.deviceType,c=e.fieldbusType,function(){var e=l.input?"input":"holding";u=S.resolve.features["".concat(e,"Registers")],_.assign(S,{features:u,dataTypes:_.get(u,"dataType.choices"),accessTypes:_.get(u,"accessType.choices")})}(),S.element=o.addRegisterMeta(l,m),S.categories=s,S.deviceType=m,S.fieldbusType=c,function(){var e;_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(e={},I.IS_REQUIRED,i("This field is required.")),I.IS_VALID_NAME,_.get(u,"validation.invalidName",i("Name must be unique among registers."))),I.IS_VALID_BIT_RANGE,i("Selected number, start bit or number of bits overlap with another register.")),I.IS_VALID_MEASUREMENT,_.get(u,"validation.invalidMeasurement",i("Selected measurement type and series are already used by another register."))),I.IS_MIN,i("Value cannot be lower than minimum.")),I.IS_MAX,i("Value cannot be greater than maximum.")),I.IS_UNIQUE,i("Value cannot be used more than once.")),I.IS_VALID_NO_BITS_FOR_SIGNED_REGISTER,i("At least two bits needed for signed register.")),I.IS_VALID_MESSAGEID,i("Invalid hexadecimal number.")),I.IS_VALID_BROWSEPATH,i("Invalid browse path.")),g=_defineProperty(_defineProperty(_defineProperty(_defineProperty(e,I.IS_VALID_OID,_.get(u,"validation.invalidOid",i("OID must be unique among components."))),I.PATTERN,i("Must be a valid number.")),I.HEXNUMBER,i("Must be a valid hexadecimal number.")),I.MEASUREMENT_FRAGMENT,r.getString("Must not contain whitespaces nor the following special characters {{ specialCharactersList }}",{specialCharactersList:".,*[]()@$"}))}(),u.functionalities.readWriteMutex&&(S.readWriteMutexValue="read",l.meta.updateStatus&&(S.readWriteMutexValue="write"),y())},PATTERN_VALIDATE_FRAGMENT_SERIES:"^[^.]*$",alarmSeverities:n.severityList,getValuePlaceholder:function(e){var t=r.getString("no value");_.isUndefined(e)||_.isNaN(e)||(t=e);return"(".concat(t,")")},addEnumValue:o.addEmptyEnumValue,removeEnumValue:o.removeEnumValue,invalid:function(e){return function(e){{var t,n;"number"===e&&_.get(u,"number.useHex")&&(e=_.get(S,"".concat(f,".number")),(n=_.get(e,"$modelValue"))?(n.startsWith("0x")&&(n=n.substring(2)),t=parseInt(n,16),n=t.toString(16)===n.toLowerCase(),e.$setValidity(I.IS_VALID_MESSAGEID,n),e.$setValidity(I.IS_MIN,!n||t>=h()),e.$setValidity(I.IS_MAX,!n||t<=V())):e.$setValidity(I.IS_VALID_MESSAGEID,!0))}}(e),function(e){var t=S[f];"browsePath"===e&&(e=t.browsePath.$viewValue,t.browsePath.$setValidity(I.IS_VALID_BROWSEPATH,/^|((\d)+:[^/]+)([/](\d)+:[^/]+)*$/.test(e)))}(e),function(){var t=S[f].name,n=_.get(l,"meta"),e=_.isUndefined(t.$modelValue)||_.every(d,function(e){return e.name===_.get(n,"original.name")||e.name!==t.$modelValue});t.$setValidity(I.IS_VALID_NAME,e)}(),function(){var e=S[f],n=e.number,a=e.startBit,i=e.noBits,r=_.get(l,"meta"),e=!n||_.isUndefined(n.$modelValue)||_.isUndefined(a.$modelValue)||_.isUndefined(i.$modelValue)||!_.some(d,function(e){var t=n.$modelValue;_.get(u,"number.useHex")&&t&&-1===t.indexOf("0x")&&(t="0x".concat(t));return(!r||!(_.get(r,"original.number")===e.number&&r.original.startBit===e.startBit))&&e.input===l.input&&o.areOverlappingRegisters(e,{number:t,startBit:a.$modelValue,noBits:i.$modelValue},u)});n&&n.$setValidity(I.IS_VALID_BIT_RANGE,e);a&&a.$setValidity(I.IS_VALID_BIT_RANGE,e);i&&i.$setValidity(I.IS_VALID_BIT_RANGE,e)}(),function(){var e=S[f],i=_.get(e,"messageTypeId.$modelValue"),t=e.measurementType,r=_.get(t,"$modelValue"),e=e.measurementSeries,o=_.get(e,"$modelValue"),s=_.get(l,"meta"),n=!_.get(s,"sendMeasurement")||_.isUndefined(r)||_.isUndefined(o)||!_.some(d,function(e){var t=!1,n=_.get(l,"id")===_.get(e,"id"),a=u.number&&_.get(s,"original.number")===e.number&&_.get(s,"original.startBit")===e.startBit&&_.get(s,"original.input")===e.input;return t=n||a?t:(!u.messageTypeId||_.get(e,"messageTypeId")===i)&&_.get(e,"measurementMapping.type")===r&&_.get(e,"measurementMapping.series")===o});t&&t.$setValidity(I.IS_VALID_MEASUREMENT,n);e&&e.$setValidity(I.IS_VALID_MEASUREMENT,n)}(),function(){var e=_.get(S,"".concat(f,".noBits"));{var t;e&&(t=!l.signed||l.signed&&!_.isUndefined(e.$modelValue)&&1<e.$modelValue,e.$setValidity(I.IS_VALID_NO_BITS_FOR_SIGNED_REGISTER,t))}}(),function(e){var t=S[f];{var n,a;"oid"===e&&(n=t.oid,a=_.get(l,"meta"),e=_.isUndefined(n.$modelValue)||_.every(d,function(e){return e.oid===_.get(a,"original.oid")||e.oid!==n.$modelValue}),n.$setValidity(I.IS_VALID_OID,e))}}(e),a.invalid(S,f,e)},validationHints:function(e,t){var n=_.cloneDeep(g),t=_.get(t,"validateValueInRegisterRange");t&&(n[I.IS_VALUE_IN_REGISTER_RANGE]=r.getString(p,t));return a.validationHints(e,n)},onAccessTypeChange:function(){E("showStatus")||(S.element.meta.showStatus=!1);!S.element.input&&E("updateStatus")||(S.element.meta.updateStatus=!1);S.shouldEnableShowStatusStandardFunctionalities()&&E("sendMeasurement")||(S.element.meta.sendMeasurement=!1);S.shouldEnableShowStatusStandardFunctionalities()&&E("raiseAlarm")||(S.element.meta.raiseAlarm=!1);S.shouldEnableShowStatusStandardFunctionalities()&&E("sendEvent")||(S.element.meta.sendEvent=!1)},onUpdateStatusCheckboxChange:function(){l.meta.updateStatus&&(l.meta.showStatus=!0)},onStatusMappingRadiosChange:y,save:function(){(function(){var e=[];S.features.functionalities.readWriteMutex&&(e=["measurementMapping","eventMapping","alarmMapping"],"read"===S.readWriteMutexValue)&&(e=["min","max"]);l.noBits<=8&&e.push("littleEndian");_.forEach(e,function(e){return _.unset(l,e)})})(),S.close({$value:o.removeRegisterMeta(l)})},messageTypeIdMax:function(){var e=void 0;return _.get(m,"c8y_MessageIdConfiguration.source")!==o.MessageIdSources.PAYLOAD.value?e:(e=_.get(m,"c8y_MessageIdConfiguration.messageIdMapping.noBits"),Math.pow(2,e)-1)},startBitMax:function(){return _.get(u,"startBit.max")},noBitsMax:b,getNumberMin:h,getNumberMax:V,shouldShowOptions:function(){return _.some(S.features.options,Boolean)},shouldShowNormalisationSection:function(){return _.some([S.features.multiplier,S.features.divisor,S.features.offset,S.features.decimalPlaces,S.features.unit,_.get(S.element,"meta.updateStatus",!1)],Boolean)},shouldShowFunctionalities:function(){var e=S.features.functionalities,t=e.readWriteMutex,n=e.showStatus&&S.shouldShowFunctionality("showStatus"),a=e.updateStatus&&!S.element.input&&S.shouldShowFunctionality("updateStatus"),i=S.shouldEnableShowStatusStandardFunctionalities()&&(S.shouldShowFunctionality("sendMeasurement")||S.shouldShowFunctionality("raiseAlarm")||S.shouldShowFunctionality("sendEvent")),e=e.sendManagedObjectUpdate;return t||n||a||i||e},shouldEnableShowStatusStandardFunctionalities:function(){return!(S.features.functionalities.readWriteMutex&&"write"===S.readWriteMutexValue)},shouldShowFunctionality:E,messageIdTooltip:v}),e.$watch("vm.element.startBit",function(){var e=b(l.startBit);l.noBits>e&&(l.noBits=e)}),e.$watchGroup(["vm.element.min","vm.element.max","vm.element.noBits","vm.element.multiplier","vm.element.divisor","vm.element.decimalPlaces","vm.element.signed","vm.element.meta.dataType"],function(){var e=l.meta;e&&(e.valuesRange=o.getValuesRange(l))})}e.$inject=["$scope","$q","c8yBase","c8yDeviceDatabase","c8yAlarms","gettext","gettextCatalog"],angular.module("c8y.deviceDatabase4").component("c8yConfigureRegisterModal",{templateUrl:":::PLUGIN_PATH:::/modals/configure-register.html",bindings:{resolve:"<",close:"&",dismiss:"&"},controllerAs:"vm",controller:e})}();
@@ -1 +1 @@
1
- "use strict";!function(){function e(e,n,t,r,o,i,c,u,s,a,d,p,l,g){var f,h=this,m="c8y_DeviceGroup",v="c8y_IsDeviceGroup";function y(){return o.directParentAssets(f,m,v,{withChildren:!1}).then(G)}function G(e){h.currentGroups=e,o.clearBreadcrumbsCache(f),i.$emit("update")}function A(){return y().then(function(){return c.success(a("Device added to group"))})}_.assign(h,{group:{},$onInit:function(){_.get(h.config,"device.id")&&(f=_.get(h.config,"device.id"),y(),d.hasAnyRole(["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE"]).then(function(e){h.isCreateNewGroupAllowed=e}))},addToGroup:function(e){return function(e){return function(e){return!_.isUndefined(e.newGroup)}(e)?function(n){return t({title:a("Create new group and assign device"),body:l.getString('You are about to create a new group "{{name}}" and assign the device to it. Do you want to proceed?',{name:n}),labels:{ok:a("Create and assign")},status:"warning",size:"sm"}).then(function(){return e={name:n},p.create(e).then(u.getResData);var e}).then(function(e){return g.addGroupNavigation(e),e})}(e.name):n.resolve(e)}(e).then(function(e){return n=e,o.detailCached(f).then(function(e){e=e.data;return r.addChildAsset(n,e)});var n}).then(A)},removeFromGroup:function(n){return o.detailCached(f).then(function(e){e=e.data;return s.unassignDevice(n,e)}).then(y).then(function(){return c.success(a("Device removed from group."))})},isCreateNewGroupAllowed:!1})}function n(t,e,n,r,o){var i=[];function c(e){return n.detail(e).then(function(e){var n=e.data;return r.getGroupItems(n).then(function(e){t.items=e,i.push(n)})})}t.title=o("Select group"),t.drillDown=c,t.upToGroup=function(e){for(;i[i.length-1]!==e;)i.pop();i.pop(),c(e.id)},t.select=e.close,t.dismiss=e.dismiss,t.isGroup=r.isGroup,r.getTopLevelGroups().then(function(e){t.items=e}),t.breadcrumbs=i,t.currentManagedObjectId=t.device.id}e.$inject=["$scope","$q","c8yModal","c8yInventory","c8yDevices","c8yBreadcrumbs","c8yAlert","c8yBase","groupsHierarchySvc","gettext","c8yPermissions","c8yDeviceGroup","gettextCatalog","groupTypesHierarchyNavigator"],n.$inject=["$scope","$uibModalInstance","c8yInventory","c8yGroups","gettext"],angular.module("c8y.deviceGroupAssignment").controller("GroupSelectModalCtrl",n).component("groupAssignment",{controller:e,controllerAs:"vm",templateUrl:":::PLUGIN_PATH:::/groupAssignment.component.html",bindings:{config:"<"}})}();
1
+ "use strict";!function(){function e(e,n,t,r,o,i,c,u,s,a,d,p,l,g){var f,h=this,m="c8y_DeviceGroup",v="c8y_IsDeviceGroup";function y(){return o.directParentAssets(f,m,v,{withChildren:!1}).then(G)}function G(e){h.currentGroups=e,o.clearBreadcrumbsCache(f),i.$emit("update")}function A(){return y().then(function(){return c.success(a("Device added to group"))})}_.assign(h,{group:{},$onInit:function(){_.get(h.config,"device.id")&&(f=_.get(h.config,"device.id"),y(),d.hasAnyRole(["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE","ROLE_MANAGED_OBJECT_ADMIN","ROLE_MANAGED_OBJECT_CREATE"]).then(function(e){h.isCreateNewGroupAllowed=e}))},addToGroup:function(e){return function(e){return function(e){return!_.isUndefined(e.newGroup)}(e)?function(n){return t({title:a("Create new group and assign device"),body:l.getString('You are about to create a new group "{{name}}" and assign the device to it. Do you want to proceed?',{name:n}),labels:{ok:a("Create and assign")},status:"warning",size:"sm"}).then(function(){return e={name:n},p.create(e).then(u.getResData);var e}).then(function(e){return g.addGroupNavigation(e),e})}(e.name):n.resolve(e)}(e).then(function(e){return n=e,o.detailCached(f).then(function(e){e=e.data;return r.addChildAsset(n,e)});var n}).then(A)},removeFromGroup:function(n){return o.detailCached(f).then(function(e){e=e.data;return s.unassignDevice(n,e)}).then(y).then(function(){return c.success(a("Device removed from group."))})},isCreateNewGroupAllowed:!1})}function n(t,e,n,r,o){var i=[];function c(e){return n.detail(e).then(function(e){var n=e.data;return r.getGroupItems(n).then(function(e){t.items=e,i.push(n)})})}t.title=o("Select group"),t.drillDown=c,t.upToGroup=function(e){for(;i[i.length-1]!==e;)i.pop();i.pop(),c(e.id)},t.select=e.close,t.dismiss=e.dismiss,t.isGroup=r.isGroup,r.getTopLevelGroups().then(function(e){t.items=e}),t.breadcrumbs=i,t.currentManagedObjectId=t.device.id}e.$inject=["$scope","$q","c8yModal","c8yInventory","c8yDevices","c8yBreadcrumbs","c8yAlert","c8yBase","groupsHierarchySvc","gettext","c8yPermissions","c8yDeviceGroup","gettextCatalog","groupTypesHierarchyNavigator"],n.$inject=["$scope","$uibModalInstance","c8yInventory","c8yGroups","gettext"],angular.module("c8y.deviceGroupAssignment").controller("GroupSelectModalCtrl",n).component("groupAssignment",{controller:e,controllerAs:"vm",templateUrl:":::PLUGIN_PATH:::/groupAssignment.component.html",bindings:{config:"<"}})}();
@@ -95,7 +95,7 @@
95
95
  </button>
96
96
  </div>
97
97
  <div
98
- class="device deviceRow text-truncate"
98
+ class="device deviceRow text-truncate p-l-24"
99
99
  ng-repeat="child in children"
100
100
  c8y-device-selector-combo-devices
101
101
  >
@@ -1 +1 @@
1
- "use strict";angular.module("c8y.parts.availability",["nvd3ChartDirectives"]).config(["c8yViewsProvider","c8yNavigatorProvider","c8yTitleProvider","gettext",function(i,e,a,t){var l="signal",n={name:t("Availability"),icon:l,templateUrl:"".concat(":::PLUGIN_PATH:::/views/","detail.html"),controller:"availabilityReportCtrl",showIfPermissions:{allRoles:["ROLE_ALARM_READ","ROLE_INVENTORY_READ"]}},o="availability";e.addNavigation({parent:t("Devices"),name:t("Availability"),icon:l,path:o,showIfPermissions:{allRoles:["ROLE_ALARM_READ","ROLE_INVENTORY_READ"]}}),i.when("/device/:deviceId",_.cloneDeep(n)),i.when("/".concat(o),_.cloneDeep(n)),a.addTitle("/".concat(o),{data:function(){return{title:t("Availability")}}})}]);
1
+ "use strict";angular.module("c8y.parts.availability",["nvd3ChartDirectives"]).config(["c8yViewsProvider","c8yNavigatorProvider","c8yTitleProvider","gettext",function(i,e,a,t){var l="signal",n={name:t("Availability"),icon:l,templateUrl:"".concat(":::PLUGIN_PATH:::/views/","detail.html"),controller:"availabilityReportCtrl",showIfPermissions:{allRoles:["ROLE_ALARM_READ"],anyRole:["ROLE_INVENTORY_READ","ROLE_MANAGED_OBJECT_READ"]}},o="availability";e.addNavigation({parent:t("Devices"),name:t("Availability"),icon:l,path:o,showIfPermissions:{allRoles:["ROLE_ALARM_READ"],anyRole:["ROLE_INVENTORY_READ","ROLE_MANAGED_OBJECT_READ"]}}),i.when("/device/:deviceId",_.cloneDeep(n)),i.when("/".concat(o),_.cloneDeep(n)),a.addTitle("/".concat(o),{data:function(){return{title:t("Availability")}}})}]);
@@ -256,6 +256,7 @@
256
256
  >
257
257
  <button
258
258
  class="dropdown-toggle c8y-dropdown btn-link"
259
+ data-cy="index--dropdown-toggle--Action"
259
260
  title="{{ 'Actions' | translate }}"
260
261
  aria-haspopup="true"
261
262
  type="button"
@@ -1 +1 @@
1
- "use strict";!function(){function n(t,n,e){c.$inject=["manageCertificateSvc"],s.$inject=["c8yEnterpriseEditionAvailability"],a.$inject=["$scope"];var i=["ROLE_INVENTORY_ADMIN","ROLE_OPTION_MANAGEMENT_ADMIN","ROLE_APPLICATION_MANAGEMENT_ADMIN","ROLE_APPLICATION_MANAGEMENT_READ"];function r(i){return["c8yTenant",function(n){var t=this;n.isEnterpriseEditionTenant().then(function(n){t.title=n?e("Enterprise tenant"):i})}]}function o(i){return["c8yTenant","c8yApplication",function(n,t){return n.isEnterpriseEditionTenant().then(function(n){return!n&&t.isAnyAvailable(i)})}]}function a(n){n.optionsGroups=["twoFactorAuthenticationOptions","supportLinkOptions","passwordResetOptions","emailServerOptions","dataExportOptions","storageLimitOptions","suspendingTenantsOptions"]}function s(n){return n.isAvailable()}function c(n){return n.hasCustomLoadBalancer().then(function(n){return!n})}_.each(["/enterprise","/branding"],function(n){return t.when(n,{template:'\n <c8y-ui-title-set title="vm.title"></c8y-ui-title-set>\n <c8y-branding-configuration-form></c8y-branding-configuration-form>\n ',name:n=e("Branding"),icon:"paint-brush",controller:r(n),controllerAs:"vm"})}),_.each(["/enterprise","/domain_name"],function(n){return t.when(n,{template:'\n <c8y-ui-title-set title="vm.title"></c8y-ui-title-set>\n <c8y-manage-certificate-form></c8y-manage-certificate-form>\n ',name:n=e("Domain name"),icon:"certificate",controller:r(n),controllerAs:"vm",showIf:c})}),n.addNavigation({name:e("Enterprise tenant"),parent:e("Settings"),icon:"enterprise-resource-planning",priority:1e3,path:"enterprise",routerLinkExact:!1,showIf:s,showIfPermissions:{allRoles:i}}),n.addNavigation({name:e("Branding"),parent:e("Settings"),icon:"paint-brush",priority:1e3,path:"branding",showIf:o([{name:"branding"},{name:"feature-branding"}]),showIfPermissions:{allRoles:i}}),n.addNavigation({name:e("Domain name"),parent:e("Settings"),icon:"certificate",priority:1e3,path:"domain_name",showIf:o([{name:"sslmanagement"}]),showIfPermissions:{allRoles:i}}),t.when("/enterprise",{template:'<c8y-platform-configuration options-groups="optionsGroups"></c8y-platform-configuration>',name:e("Configuration"),icon:"cog",controller:a})}n.$inject=["c8yViewsProvider","c8yNavigatorProvider","gettext"],angular.module("c8y.enterpriseEdition",["c8y.custom-branding"]).config(n)}();
1
+ "use strict";!function(){function n(t,n,i){l.$inject=["manageCertificateSvc"],c.$inject=["c8yEnterpriseEditionAvailability"],s.$inject=["$scope"];var e=["ROLE_OPTION_MANAGEMENT_ADMIN","ROLE_APPLICATION_MANAGEMENT_ADMIN","ROLE_APPLICATION_MANAGEMENT_READ"],r=["ROLE_INVENTORY_ADMIN","ROLE_MANAGED_OBJECT_ADMIN"];function o(e){return["c8yTenant",function(n){var t=this;n.isEnterpriseEditionTenant().then(function(n){t.title=n?i("Enterprise tenant"):e})}]}function a(e){return["c8yTenant","c8yApplication",function(n,t){return n.isEnterpriseEditionTenant().then(function(n){return!n&&t.isAnyAvailable(e)})}]}function s(n){n.optionsGroups=["twoFactorAuthenticationOptions","supportLinkOptions","passwordResetOptions","emailServerOptions","dataExportOptions","storageLimitOptions","suspendingTenantsOptions"]}function c(n){return n.isAvailable()}function l(n){return n.hasCustomLoadBalancer().then(function(n){return!n})}_.each(["/enterprise","/branding"],function(n){return t.when(n,{template:'\n <c8y-ui-title-set title="vm.title"></c8y-ui-title-set>\n <c8y-branding-configuration-form></c8y-branding-configuration-form>\n ',name:n=i("Branding"),icon:"paint-brush",controller:o(n),controllerAs:"vm"})}),_.each(["/enterprise","/domain_name"],function(n){return t.when(n,{template:'\n <c8y-ui-title-set title="vm.title"></c8y-ui-title-set>\n <c8y-manage-certificate-form></c8y-manage-certificate-form>\n ',name:n=i("Domain name"),icon:"certificate",controller:o(n),controllerAs:"vm",showIf:l})}),n.addNavigation({name:i("Enterprise tenant"),parent:i("Settings"),icon:"enterprise-resource-planning",priority:1e3,path:"enterprise",routerLinkExact:!1,showIf:c,showIfPermissions:{allRoles:e,anyRole:r}}),n.addNavigation({name:i("Branding"),parent:i("Settings"),icon:"paint-brush",priority:1e3,path:"branding",showIf:a([{name:"branding"},{name:"feature-branding"}]),showIfPermissions:{allRoles:e,anyRole:r}}),n.addNavigation({name:i("Domain name"),parent:i("Settings"),icon:"certificate",priority:1e3,path:"domain_name",showIf:a([{name:"sslmanagement"}]),showIfPermissions:{allRoles:e,anyRole:r}}),t.when("/enterprise",{template:'<c8y-platform-configuration options-groups="optionsGroups"></c8y-platform-configuration>',name:i("Configuration"),icon:"cog",controller:s})}n.$inject=["c8yViewsProvider","c8yNavigatorProvider","gettext"],angular.module("c8y.enterpriseEdition",["c8y.custom-branding"]).config(n)}();
@@ -1 +1 @@
1
- "use strict";angular.module("c8y.cockpit.export").directive("c8yExportTimespan",["gettext",function(e){return{restrict:"AE",link:function(t){t.types={LAST_24HOURS:e("Last 24 hours"),LAST_7DAYS:e("Last 7 days"),LAST_30DAYS:e("Last 30 days"),LAST_WEEK:e("Last week"),LAST_MONTH:e("Last month"),LAST_YEAR:e("Last year"),CUSTOM:e("Custom")}},scope:{timespan:"=c8yExportTimespan"},templateUrl:":::PLUGIN_PATH:::/views/timespan.html"}}]);
1
+ "use strict";!function(){function t(e,s){return{restrict:"AE",link:function(t){t.types={LAST_24HOURS:s("Last 24 hours"),LAST_7DAYS:s("Last 7 days"),LAST_30DAYS:s("Last 30 days"),LAST_WEEK:s("Last week"),LAST_MONTH:s("Last month"),LAST_YEAR:s("Last year"),CUSTOM:s("Custom")},t.helpLink=e.getUserGuideLink("/docs/cockpit/managing-exports/#to-add-an-export")},scope:{timespan:"=c8yExportTimespan"},templateUrl:":::PLUGIN_PATH:::/views/timespan.html"}}t.$inject=["c8yDocs","gettext"],angular.module("c8y.cockpit.export").directive("c8yExportTimespan",t)}();
@@ -12,38 +12,23 @@
12
12
  </div>
13
13
  </div>
14
14
  <button
15
- ng-show="timespan.dateType === 'LAST_MONTH'"
16
- class="btn-help btn-help--sm"
15
+ data-cy="c8y-export-details--timerange-help-btn"
16
+ class="btn-help btn-help--sm m-t-8"
17
17
  type="button"
18
18
  aria-label="{{ 'Help' | translate }}"
19
- uib-popover="{{
20
- 'From midnight last month to now. For details refer to the user documentation.' | translate
21
- }}"
22
- popover-placement="right"
23
- popover-trigger="'focus'"
24
- ></button>
25
- <button
26
- ng-show="timespan.dateType === 'LAST_WEEK'"
27
- class="btn-help btn-help--sm"
28
- type="button"
29
- aria-label="{{ 'Help' | translate }}"
30
- uib-popover="{{
31
- 'From midnight last week to now. For details refer to the user documentation.' | translate
32
- }}"
33
- popover-placement="right"
34
- popover-trigger="'focus'"
35
- ></button>
36
- <button
37
- ng-show="timespan.dateType === 'LAST_YEAR'"
38
- class="btn-help btn-help--sm"
39
- type="button"
40
- aria-label="{{ 'Help' | translate }}"
41
- uib-popover="{{
42
- 'From midnight last year to now. For details refer to the user documentation.' | translate
43
- }}"
19
+ uib-popover-template="'helpContent.html'"
44
20
  popover-placement="right"
45
21
  popover-trigger="'focus'"
46
22
  ></button>
23
+ <script
24
+ id="helpContent.html"
25
+ type="text/ng-template"
26
+ >
27
+ <div translate>
28
+ Find out more about each option in the
29
+ <a ng-href="{{ ::helpLink }}" target="_blank" rel="noopener noreferrer">user documentation</a>.
30
+ </div>
31
+ </script>
47
32
  </div>
48
33
  <div
49
34
  class="col-xs-12"
@@ -16,7 +16,7 @@
16
16
 
17
17
  <div ng-repeat="m in measurementsByFragment[measurement]">
18
18
  {{m.fragment}} <span class="text-muted">{{m.series}}</span>
19
- <c8y-if-allowed any-role="['ROLE_INVENTORY_ADMIN']">
19
+ <c8y-if-allowed any-role="['ROLE_INVENTORY_ADMIN', 'ROLE_MANAGED_OBJECT_ADMIN']">
20
20
  <a class="btn btn-link btn-xs" ng-href="/apps/administration/#kpi/new?fragment={{m.fragment}}&series={{m.series}}">
21
21
  <i c8y-icon="plus"></i>
22
22
  <translate>Create KPI</translate>
@@ -35,7 +35,7 @@
35
35
  <translate>Edit KPI</translate>
36
36
  </a>
37
37
  </c8y-if-allowed>
38
- <c8y-if-allowed any-role="['ROLE_INVENTORY_ADMIN']">
38
+ <c8y-if-allowed any-role="['ROLE_INVENTORY_ADMIN', 'ROLE_MANAGED_OBJECT_ADMIN']">
39
39
  <a class="btn btn-link btn-xs" ng-href="/apps/administration/#kpi/new?fragment={{kpi.c8y_Kpi.fragment}}&series={{kpi.c8y_Kpi.series}}">
40
40
  <i c8y-icon="plus"></i>
41
41
  <translate>Create new KPI</translate>
@@ -1,7 +1,7 @@
1
1
  <div ng-controller="kpiSetupCtrl">
2
2
  <div class="nav">
3
3
  <div class="navbar-right">
4
- <c8y-if-allowed any-role="['ROLE_INVENTORY_ADMIN']">
4
+ <c8y-if-allowed any-role="['ROLE_INVENTORY_ADMIN', 'ROLE_MANAGED_OBJECT_ADMIN']">
5
5
  <button
6
6
  title="{{ 'Add KPI' | translate }}"
7
7
  ng-if="false"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c8y/ng1-modules",
3
- "version": "1018.505.8",
3
+ "version": "1018.509.6",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Cumulocity",
6
6
  "description": "AngularJS modules for Cumulocity IoT applications.",
@@ -1 +1 @@
1
- "use strict";!function(){function e(i,r,e,n,t,o,c,j,a,u,l,s,d,f,h,g,v,m){var p,S=r.deviceId||r.groupId,x={},A={},b={done:!1,inProgress:!1},R={true:{text:v("Active"),icon:"check-circle",cls:"text-success"},false:{text:v("Inactive"),icon:"ban",cls:"text-danger"}},y=s.getContext(),C=v("Global smart rules");function I(){return n.when().then(T).then(M).then(w).then(L).then(D).catch(E)}function T(){b.inProgress=!0}function D(){b.inProgress=!1,b.done=!0,b.error=!1}function E(e){e.data&&e.data.message&&l.danger(e.data.message),b.inProgress=!1,b.done=!0,b.error=!0}function M(){return h.list().then(N)}function N(e){_.forEach(e||[],function(e){x[e.name]=e})}function w(){var e=S?g.listByContext(S):n.resolve([]),t=f.hasPermissions().then(function(e){return e?g.list():n.when([])});return n.all({listByContext:e,list:t}).then(function(e){i.rules=function(e){var t=e;S&&(t=_.reject(e,function(e){var n=new RegExp("".concat(e,"/dashboard"));return function(e){var t=_.get(e,"config.url","");return O(e)&&!n.test(t)}}(S)));return t}(_.concat(e.listByContext,e.list))})}function O(e){return"sendDashboardsViaEmail"===e.ruleTemplateName}function U(e){return g.hasSource(e,S)}function L(){var e;return Array.isArray(i.rules)&&0<i.rules.length&&null!==(e=s.getContext()).context?c.childAssets(e.id,{skipDetail:!0,params:{pageSize:2e3,withChildren:!1}}).then(function(e){i.children=e}).then(function(){i.ruleChildren={},_.forEach(i.rules,function(e){i.ruleChildren[e.id]=P(e)})}):n.resolve()}function P(t){return _.filter(i.children,function(e){return g.hasSource(t,e)})}_.assign(i,{isOpen:{},moId:S,loadingStatus:b,refresh:I,paging:{refresh:I},ruleTemplates:x,getLinkToDM:function(){var e={deviceId:S};return t(p||"")(e)},add:function(){g.addNewWithUI().then(I)},edit:function(e){g.editWithUI(e).then(I)},clone:function(e){g.cloneWithUI(e).then(I)},remove:function(e){u({title:v("Delete smart rule"),body:m.getString('You are about to delete smart rule "{{name}}". Do you want to proceed?',e),labels:{ok:v("Delete")},status:"danger"}).then(angular.bind(g,g.remove,e)).then(function(){return _.pull(i.rules,e)}).then(function(){return l.success(v("Smart rule deleted."))})},hasSource:U,getChildrenEnabledForSmartRule:P,toggleRuleActivationForContextMO:function(e){if(U(e))return g.deactivate(e,S,!1).then(function(){l.success(m.getString('Smart rule "{{name}}" deactivated.',e))});return g.activate(e,S,!1).then(function(){l.success(m.getString('Smart rule "{{name}}" activated.',e))})},toggleRuleActivationForChildrenMOs:function(e,n){var t=_.filter(n,function(t){return!_.find(i.ruleChildren[e.id],function(e){return e.id===t.id})}),r=_.filter(i.ruleChildren[e.id],function(t){return!_.find(n,function(e){return t.id===e.id})});return g.updateSources(e,t,r,!1).then(w).then(L).then(function(){l.success(m.getString('Smart rule "{{name}}" activated/deactivated for children.',e))})},tooltip:function(e){var t={activate:{"for group":v("Activate for this group"),"for device":v("Activate for this device"),"for object":v("Activate for this object")},deactivate:{"for group":v("Deactivate for this group"),"for device":v("Deactivate for this device"),"for object":v("Deactivate for this object")}},e=e.enabled&&U(e)?"deactivate":"activate",n=r.groupId?"group":"object";return n=r.deviceId?"device":n,t[e]["for ".concat(n)]},type:function(e){var t,e=x[e.ruleTemplateName];e&&(t=e.label.full?m.getString(e.label.full):"".concat(m.getString(e.label.input)," ").concat(m.getString(e.label.output)));return t},status:function(e){return R[e.enabled].text},statusIcon:function(e){return R[e.enabled].icon},statusClass:function(e){return R[e.enabled].cls},showTitle:function(){return null!==s.getContext().context},title:C,context:y,inputIcon:function(e){var t,e=x[e.ruleTemplateName];e&&(t=e.paramGroups.input.icon);return t},outputIcon:function(e){var t,e=x[e.ruleTemplateName];e&&(t=e.paramGroups.output.icon);return t},canAddRules:function(e){var t=_.get(x,"".concat(_.get(e,"ruleTemplateName"),"._active")),n=A.canAddRules;e&&!t&&(n=!1);_.isUndefined(n)&&(e=i.context?{adminMOs:[i.context.id]}:{allRoles:["ROLE_INVENTORY_ADMIN"],anyRole:["ROLE_SMARTRULE_ADMIN","ROLE_CEP_MANAGEMENT_ADMIN"]},A.canAddRules=a.isAllowed(e).then(function(e){return A.canAddRules=e,A.canAddRules}),n=!1);return n},canModify:function(t){A.rules=A.rules||{};var n=A.rules,e=n[t.id];_.isUndefined(e)&&(n[t.id]=a.isAllowed({adminMOs:[t.id]}).then(function(e){return n[t.id]=e,n[t.id]}),e=!1);return e},canApplyOnChildren:function(e){return!O(e)},canSeeSection:function(){var e=A.canSeeSection;_.isUndefined(e)&&(A.canSeeSection=(o.checkIfModulesExist(["c8y.cockpit.config"])?f.shouldShowLocalSmartRules():n.when(!1)).then(function(e){return A.canSeeSection=e,A.canSeeSection}),e=!1);return e},isConfigurationGlobalSmartRulesContext:void 0}),i.isConfigurationGlobalSmartRulesContext=e.path().includes("/rules"),I(),null===s.getContext().context&&d.changeTitle({title:C}),"device"===y.context&&o.getStaticLinkTemplate("devicemanagementDeviceDetails").then(function(e){p=e})}e.$inject=["$scope","$routeParams","$location","$q","$interpolate","c8yBase","c8yInventory","c8yApplication","c8yPermissions","c8yModal","c8yAlert","c8yUiUtil","c8yTitle","c8ySmartRulesAvailability","smartRuleTemplatesSvc","smartRulesSvc","gettext","gettextCatalog"],angular.module("c8y.smartRules").controller("SmartRulesListCtrl",e)}();
1
+ "use strict";!function(){function e(i,r,e,o,t,n,c,j,a,u,l,s,d,f,h,g,v,m){var p,S=r.deviceId||r.groupId,A={},R={},y={done:!1,inProgress:!1},x={true:{text:v("Active"),icon:"check-circle",cls:"text-success"},false:{text:v("Inactive"),icon:"ban",cls:"text-danger"}},b=s.getContext(),C=v("Global smart rules");function I(){return o.when().then(w).then(M).then(N).then(U).then(E).catch(D)}function w(){y.inProgress=!0}function E(){y.inProgress=!1,y.done=!0,y.error=!1}function D(e){e.data&&e.data.message&&l.danger(e.data.message),y.inProgress=!1,y.done=!0,y.error=!0}function M(){return h.list().then(T)}function T(e){_.forEach(e||[],function(e){A[e.name]=e})}function N(){var e=S?g.listByContext(S):o.resolve([]),t=f.hasPermissions().then(function(e){return e?g.list():o.when([])});return o.all({listByContext:e,list:t}).then(function(e){i.rules=function(e){var t=e;S&&(t=_.reject(e,function(e){var n=new RegExp("".concat(e,"/dashboard"));return function(e){var t=_.get(e,"config.url","");return O(e)&&!n.test(t)}}(S)));return t}(_.concat(e.listByContext,e.list))})}function O(e){return"sendDashboardsViaEmail"===e.ruleTemplateName}function L(e){return g.hasSource(e,S)}function U(){var e;return Array.isArray(i.rules)&&0<i.rules.length&&null!==(e=s.getContext()).context?c.childAssets(e.id,{skipDetail:!0,params:{pageSize:2e3,withChildren:!1}}).then(function(e){i.children=e}).then(function(){i.ruleChildren={},_.forEach(i.rules,function(e){i.ruleChildren[e.id]=P(e)})}):o.resolve()}function P(t){return _.filter(i.children,function(e){return g.hasSource(t,e)})}_.assign(i,{isOpen:{},moId:S,loadingStatus:y,refresh:I,paging:{refresh:I},ruleTemplates:A,getLinkToDM:function(){var e={deviceId:S};return t(p||"")(e)},add:function(){g.addNewWithUI().then(I)},edit:function(e){g.editWithUI(e).then(I)},clone:function(e){g.cloneWithUI(e).then(I)},remove:function(e){u({title:v("Delete smart rule"),body:m.getString('You are about to delete smart rule "{{name}}". Do you want to proceed?',e),labels:{ok:v("Delete")},status:"danger"}).then(angular.bind(g,g.remove,e)).then(function(){return _.pull(i.rules,e)}).then(function(){return l.success(v("Smart rule deleted."))})},hasSource:L,getChildrenEnabledForSmartRule:P,toggleRuleActivationForContextMO:function(e){if(L(e))return g.deactivate(e,S,!1).then(function(){l.success(m.getString('Smart rule "{{name}}" deactivated.',e))});return g.activate(e,S,!1).then(function(){l.success(m.getString('Smart rule "{{name}}" activated.',e))})},toggleRuleActivationForChildrenMOs:function(e,n){var t=_.filter(n,function(t){return!_.find(i.ruleChildren[e.id],function(e){return e.id===t.id})}),r=_.filter(i.ruleChildren[e.id],function(t){return!_.find(n,function(e){return t.id===e.id})});return g.updateSources(e,t,r,!1).then(N).then(U).then(function(){l.success(m.getString('Smart rule "{{name}}" activated/deactivated for children.',e))})},tooltip:function(e){var t={activate:{"for group":v("Activate for this group"),"for device":v("Activate for this device"),"for object":v("Activate for this object")},deactivate:{"for group":v("Deactivate for this group"),"for device":v("Deactivate for this device"),"for object":v("Deactivate for this object")}},e=e.enabled&&L(e)?"deactivate":"activate",n=r.groupId?"group":"object";return n=r.deviceId?"device":n,t[e]["for ".concat(n)]},type:function(e){var t,e=A[e.ruleTemplateName];e&&(t=e.label.full?m.getString(e.label.full):"".concat(m.getString(e.label.input)," ").concat(m.getString(e.label.output)));return t},status:function(e){return x[e.enabled].text},statusIcon:function(e){return x[e.enabled].icon},statusClass:function(e){return x[e.enabled].cls},showTitle:function(){return null!==s.getContext().context},title:C,context:b,inputIcon:function(e){var t,e=A[e.ruleTemplateName];e&&(t=e.paramGroups.input.icon);return t},outputIcon:function(e){var t,e=A[e.ruleTemplateName];e&&(t=e.paramGroups.output.icon);return t},canAddRules:function(e){var t=_.get(A,"".concat(_.get(e,"ruleTemplateName"),"._active")),n=R.canAddRules;e&&!t&&(n=!1);_.isUndefined(n)&&(e=i.context?a.isAllowed({adminMOs:[i.context.id]}):o.all({isAllowedInventory:a.isAllowed({anyRole:["ROLE_INVENTORY_ADMIN","ROLE_MANAGED_OBJECT_ADMIN"]}),isAllowedSmartRules:a.isAllowed({anyRole:["ROLE_SMARTRULE_ADMIN","ROLE_CEP_MANAGEMENT_ADMIN"]})}).then(function(e){var t=e.isAllowedInventory,e=e.isAllowedSmartRules;return t&&e}),R.canAddRules=e.then(function(e){return R.canAddRules=e,R.canAddRules}),n=!1);return n},canModify:function(t){R.rules=R.rules||{};var n=R.rules,e=n[t.id];_.isUndefined(e)&&(n[t.id]=a.isAllowed({adminMOs:[t.id]}).then(function(e){return n[t.id]=e,n[t.id]}),e=!1);return e},canApplyOnChildren:function(e){return!O(e)},canSeeSection:function(){var e=R.canSeeSection;_.isUndefined(e)&&(R.canSeeSection=(n.checkIfModulesExist(["c8y.cockpit.config"])?f.shouldShowLocalSmartRules():o.when(!1)).then(function(e){return R.canSeeSection=e,R.canSeeSection}),e=!1);return e},isConfigurationGlobalSmartRulesContext:void 0}),i.isConfigurationGlobalSmartRulesContext=e.path().includes("/rules"),I(),null===s.getContext().context&&d.changeTitle({title:C}),"device"===b.context&&n.getStaticLinkTemplate("devicemanagementDeviceDetails").then(function(e){p=e})}e.$inject=["$scope","$routeParams","$location","$q","$interpolate","c8yBase","c8yInventory","c8yApplication","c8yPermissions","c8yModal","c8yAlert","c8yUiUtil","c8yTitle","c8ySmartRulesAvailability","smartRuleTemplatesSvc","smartRulesSvc","gettext","gettextCatalog"],angular.module("c8y.smartRules").controller("SmartRulesListCtrl",e)}();