@c8y/ng1-modules 1022.9.6 → 1022.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
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 r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_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 r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}(()=>{function e(a,t,e,c,r,o,u,n){var i="c8y_IsDevice",s=["c8y_Dashboard","c8y_Report","c8y_Kpi","c8y_ExportConfiguration","c8y_IsBinary","c8y_NoDevice","c8y_IsDeviceGroup","c8y_Group","com_cumulocity_model_smartrest_SmartRestTemplate","com_cumulocity_model_devicesimulator_SensorTemplate","_attachments","c8y_IsDeviceType","c8y_objectmapping_ObjectMapping"],l=["c8y_ConfigurationDump","c8y_Firmware","c8y_SmartRule","c8y_Software","impact_object_mapping","c8y_UserPreference","c8y_TenantPolicy","c8y_PrivateSmartRule","c8y_SmartRest2Template","c8y_JsonSchema","c8y_DeviceShellTemplate","c8y_DemoStatus","c8y_DataBroker","c8y_Application_","brandingVariables","c8y_DeviceSimulator","c8y_CertificateMetadata","lwm2m_post_registration","c8y_microservice_manifest_"],y=["c8y_Network.c8y_LAN.ip","c8y_ModbusDevice.ipAddress"],d={},f={CONNECTED:{icon:"exchange",cls:"statusOk"},AVAILABLE:{icon:"check-circle",cls:"statusOk"},MAINTENANCE:{icon:"wrench",cls:"statusAlert"},UNAVAILABLE:{icon:"exclamation-circle",cls:"statusNok"},UNKNOWN:{icon:"circle",cls:"statusUnknown"},NOT_MONITORED:{icon:"circle",cls:"statusUnknown"}},p={true:{icon:"check-circle",color:"green",tooltipText:"Valid"},false:{icon:"exclamation-circle",color:"red",tooltipText:"Invalid"},null:{icon:"circle",color:"#f3f3f3",tooltipText:"Unknown"}};function v(e){return _.assign({skipChildrenNames:!0,fragmentType:i},e||{})}var h=c.createListFilter(m);function m(e){return!!e[i]}var g=c.createListFilter(A);function A(e){return m(e)||!((e=>{var t=_.get(e,"type","");return _.some(l,function(e){return t.includes(e)})})(e=e)||(t=>_.find(s,function(e){return!_.isUndefined(t[e])}))(e))}function b(e){e=_.cloneDeep(e);return e[i]=!0,u.create(e)}function D(e){var t=e&&e.c8y_RequiredAvailability,e=e&&e.c8y_Availability;return e&&e.status||(t?"UNKNOWN":"NOT_MONITORED")}function I(e){return e.c8y_Availability&&e.c8y_Availability.lastMessage&&e.c8y_RequiredAvailability&&e.c8y_RequiredAvailability.responseInterval?0<moment().valueOf()-moment(e.c8y_Availability.lastMessage).valueOf()-6e4*e.c8y_RequiredAvailability.responseInterval:null}function T(e){var t=e;return t=t&&(t.id||t),S.cache&&delete S.cache[t],u.update(e)}function C(e,t){t=_.assign(t||{},{withParents:!0}),t=u.detail(e,t);return S.cache&&S.cache.set(e&&(e.id||e),t),t}var S=_.memoize(C,function(e){e=e&&(e.id||e);return C(e),e});function w(e){return!_.isUndefined(e[i])}function O(e){return 0<e.deviceParents.references.length}function N(e){return e&&e.c8y_RequiredAvailability&&e.c8y_RequiredAvailability.responseInterval&&0!==parseInt(e.c8y_RequiredAvailability.responseInterval,10)}return _.assign(_.cloneDeep(u),{list:function(e){var e=v(e),t=u.list(e);return t=e.text?t.then(h):t},searchIncludingChildDevices:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=_.omit(v(e),["fragmentType","query"]);return(e.query?u.listQuery(e.query,t):u.list(t)).then(g)},save:function(e){return(e.id?T:b)(e)},update:T,detail:C,listChildren:function(e){return e=e&&(e.id||e),a.all([u.childDevices(e),u.childAssets(e)]).then(_.flattenDeep)},detailCached:S,create:b,removeWithUser:function(e){return C(e).then(function(e){var e=e.data,t=e.owner;e.c8y_IsDevice&&t&&t.match(/^device_/);return e}).then(function(){return u.remove(e)})},supportsOperation:function(e,t){return e=e&&e.c8y_SupportedOperations,!!(_.isArray(e)&&-1<e.indexOf(t))},getSupportedOperations:function(e){var t=[];return t=_.isArray(e.c8y_SupportedOperations)?e.c8y_SupportedOperations:t},getChildren:function(e){var t=e.childAssets?e.childAssets.references:[],e=e.childDevices?e.childDevices.references:[],t=_.map(_.uniqBy(_.union(t,e),"id"),function(e){return C(e.managedObject.id)});return a.all(t).then(function(e){return _.map(e,function(e){return e.data})})},statusIcon:function(e){return f[D(e)].icon},statusClass:function(e){return f[D(e)].cls},parseAvailability:D,getCount:function(e){return e=v(e),u.getCount(e)},getChildDevicesCount:function(e){return u.children(e,"childDevices",{skipDetail:!0,params:{pageSize:1,withTotalPages:!0,withChildren:!1}}).then(function(e){return e.data.statistics.totalPages})},isDevice:w,isChildDevice:O,isDeviceOrChildDevice:function(e){return w(e)||O(e)},model:function(e){return(e=e&&e.c8y_Hardware)&&e.model},serial:function(e){return(e=e&&e.c8y_Hardware)&&e.serialNumber},availabilityTooltip:function(e){return(e=(e=e.c8y_Availability)&&e.lastMessage&&t("absoluteDate")(e.lastMessage))?n.getString("Last message: {{date}}",{date:e}):n.getString("Connection not monitored")},properName:function(e){return"".concat(_.find(_.at(e,["name","id"]))||n.getString("<no name>"))},getIPAddress:function(e){return _.find(_.at(e,y))},canSwitchResponseInterval:N,switchResponseInterval:function(e){
|
|
1
|
+
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 r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_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 r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}(()=>{function e(a,t,e,c,r,o,u,n){var i="c8y_IsDevice",s=["c8y_Dashboard","c8y_Report","c8y_Kpi","c8y_ExportConfiguration","c8y_IsBinary","c8y_NoDevice","c8y_IsDeviceGroup","c8y_Group","com_cumulocity_model_smartrest_SmartRestTemplate","com_cumulocity_model_devicesimulator_SensorTemplate","_attachments","c8y_IsDeviceType","c8y_objectmapping_ObjectMapping"],l=["c8y_ConfigurationDump","c8y_Firmware","c8y_SmartRule","c8y_Software","impact_object_mapping","c8y_UserPreference","c8y_TenantPolicy","c8y_PrivateSmartRule","c8y_SmartRest2Template","c8y_JsonSchema","c8y_DeviceShellTemplate","c8y_DemoStatus","c8y_DataBroker","c8y_Application_","brandingVariables","c8y_DeviceSimulator","c8y_CertificateMetadata","lwm2m_post_registration","c8y_microservice_manifest_"],y=["c8y_Network.c8y_LAN.ip","c8y_ModbusDevice.ipAddress"],d={},f={CONNECTED:{icon:"exchange",cls:"statusOk"},AVAILABLE:{icon:"check-circle",cls:"statusOk"},MAINTENANCE:{icon:"wrench",cls:"statusAlert"},UNAVAILABLE:{icon:"exclamation-circle",cls:"statusNok"},UNKNOWN:{icon:"circle",cls:"statusUnknown"},NOT_MONITORED:{icon:"circle",cls:"statusUnknown"}},p={true:{icon:"check-circle",color:"green",tooltipText:"Valid"},false:{icon:"exclamation-circle",color:"red",tooltipText:"Invalid"},null:{icon:"circle",color:"#f3f3f3",tooltipText:"Unknown"}};function v(e){return _.assign({skipChildrenNames:!0,fragmentType:i},e||{})}var h=c.createListFilter(m);function m(e){return!!e[i]}var g=c.createListFilter(A);function A(e){return m(e)||!((e=>{var t=_.get(e,"type","");return _.some(l,function(e){return t.includes(e)})})(e=e)||(t=>_.find(s,function(e){return!_.isUndefined(t[e])}))(e))}function b(e){e=_.cloneDeep(e);return e[i]=!0,u.create(e)}function D(e){var t=e&&e.c8y_RequiredAvailability,e=e&&e.c8y_Availability;return e&&e.status||(t?"UNKNOWN":"NOT_MONITORED")}function I(e){return e.c8y_Availability&&e.c8y_Availability.lastMessage&&e.c8y_RequiredAvailability&&e.c8y_RequiredAvailability.responseInterval?0<moment().valueOf()-moment(e.c8y_Availability.lastMessage).valueOf()-6e4*e.c8y_RequiredAvailability.responseInterval:null}function T(e){var t=e;return t=t&&(t.id||t),S.cache&&delete S.cache[t],u.update(e)}function C(e,t){t=_.assign(t||{},{withParents:!0}),t=u.detail(e,t);return S.cache&&S.cache.set(e&&(e.id||e),t),t}var S=_.memoize(C,function(e){e=e&&(e.id||e);return C(e),e});function w(e){return!_.isUndefined(e[i])}function O(e){return 0<e.deviceParents.references.length}function N(e){return e&&e.c8y_RequiredAvailability&&e.c8y_RequiredAvailability.responseInterval&&0!==parseInt(e.c8y_RequiredAvailability.responseInterval,10)}return _.assign(_.cloneDeep(u),{list:function(e){var e=v(e),t=u.list(e);return t=e.text?t.then(h):t},searchIncludingChildDevices:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=_.omit(v(e),["fragmentType","query"]);return(e.query?u.listQuery(e.query,t):u.list(t)).then(g)},save:function(e){return(e.id?T:b)(e)},update:T,detail:C,listChildren:function(e){return e=e&&(e.id||e),a.all([u.childDevices(e),u.childAssets(e)]).then(_.flattenDeep)},detailCached:S,create:b,removeWithUser:function(e){return C(e).then(function(e){var e=e.data,t=e.owner;e.c8y_IsDevice&&t&&t.match(/^device_/);return e}).then(function(){return u.remove(e)})},supportsOperation:function(e,t){return e=e&&e.c8y_SupportedOperations,!!(_.isArray(e)&&-1<e.indexOf(t))},getSupportedOperations:function(e){var t=[];return t=_.isArray(e.c8y_SupportedOperations)?e.c8y_SupportedOperations:t},getChildren:function(e){var t=e.childAssets?e.childAssets.references:[],e=e.childDevices?e.childDevices.references:[],t=_.map(_.uniqBy(_.union(t,e),"id"),function(e){return C(e.managedObject.id)});return a.all(t).then(function(e){return _.map(e,function(e){return e.data})})},statusIcon:function(e){return f[D(e)].icon},statusClass:function(e){return f[D(e)].cls},parseAvailability:D,getCount:function(e){return e=v(e),u.getCount(e)},getChildDevicesCount:function(e){return u.children(e,"childDevices",{skipDetail:!0,params:{pageSize:1,withTotalPages:!0,withChildren:!1}}).then(function(e){return e.data.statistics.totalPages})},isDevice:w,isChildDevice:O,isDeviceOrChildDevice:function(e){return w(e)||O(e)},model:function(e){return(e=e&&e.c8y_Hardware)&&e.model},serial:function(e){return(e=e&&e.c8y_Hardware)&&e.serialNumber},availabilityTooltip:function(e){return(e=(e=e.c8y_Availability)&&e.lastMessage&&t("absoluteDate")(e.lastMessage))?n.getString("Last message: {{date}}",{date:e}):n.getString("Connection not monitored")},properName:function(e){return"".concat(_.find(_.at(e,["name","id"]))||n.getString("<no name>"))},getIPAddress:function(e){return _.find(_.at(e,y))},canSwitchResponseInterval:N,switchResponseInterval:function(e){return e=N(e)?{id:e.id,c8y_RequiredAvailability:{responseInterval:-e.c8y_RequiredAvailability.responseInterval}}:{id:e.id,c8y_RequiredAvailability:null},u.update(e)},isLastValidMessage:I,lastValidMessageColor:function(e){return p[I(e)].color},lastValidMessageTooltip:function(e){return p[I(e)].tooltipText},lastValidMessageIcon:function(e){return p[I(e)].icon},getBreadcrumbsData:function(e){function i(r,n,e){var t;return e?(n.unshift({label:(t=e).name||"Device ".concat(t.id),path:(e=>"#/".concat(o.isGroup(e)?"group":"device","/").concat(e.id))(t),icon:(e=>(e=_.compact([w(e)?"hdd-o":"",o.isGroup(e)?o.getIconSpecs(e).iconOpen:"","c8y-group-open"]),_.first(e)))(t),isDevice:w(t),isGroup:o.isGroup(t),id:t.id}),a.all([u.directParentDevices(e),u.directParentAssets(e)]).then(function(e){var t,e=[].concat(_toConsumableArray(e[0]),_toConsumableArray(e[1])).filter(function(e){var t=e.id;return!n.some(function(e){e=e.id;return t===e})});return 0===e.length?(r.push(n),a.when(r)):(t=[],_.forEach(e,function(e){t.push(u.detail(e.id,{withParents:!0}).then(c.getResData).then(function(e){return a.when(i(r,_.cloneDeep(n),e))}))}),a.all(t).then(function(){return r}))})):a.when(r)}var r,t=null;return c.hasId(e)&&(r=c.getId(e),d[r]&&(t=a.when(d[r])),e=S(r).then(c.getResData).then(function(e){return i([],[],e).then(function(e){var t=e,t=_.filter(e,function(e){return _.some(_.without(e,e[e.length-1]),function(e){return e.isDevice||e.isGroup})});return t=_.sortBy(t,function(e){return-1*e.length}),t=_.forEach(t,function(e){return e.pop()}),d[r]=t})}),t=t||e),t||a.when([])},isProbablyDevice:A,clearBreadcrumbsCache:function(e){e=c.getId(e),d[e]=null},isAsset:function(e){return!!e.c8y_IsAsset}})}e.$inject=["$q","$filter","$cacheFactory","c8yBase","c8yUser","c8yGroups","c8yInventory","gettextCatalog"],angular.module("c8y.core").factory("c8yDevices",e)})();
|