@c8y/ng1-modules 1021.22.111 → 1021.22.113
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 t(t,n,e,i){var
|
|
1
|
+
(()=>{function t(t,n,s,e,i){var a,r=this;function c(){u(!0),s.getApplicationMO(n.applicationId).then(l).then(function(){a="/managedobjects/".concat(r.mo.id),e.addListener(t.$id,a,e.realtimeActions().UPDATE,function(t,n){return l(n)}),e.start(t.$id,a)}).finally(function(){return u(!1)})}function o(){e.stop(t.$id,a),e.removeSubscriber(t.$id,a)}function u(t){r.refreshingItems.appDetails=t}function l(t){r.mo=t,r.status=t.c8y_Status}_.assign(r,{status:"",realtime:!0,refreshingItems:{},tenantSubscriptions:{},$onInit:function(){c(),i.list(!0,!1).then(function(t){r.smartRulesMsExist=!!t}).catch(function(){r.smartRulesMsExist=!1})},$onDestroy:function(){o()},refresh:function(){o(),c(),t.$broadcast("alarmListRefresh"),t.$broadcast("eventListRefresh"),t.$broadcast("smartRulesListReload")},isRefreshing:function(){return _.includes(r.refreshingItems,!0)},statusVisible:function(){return!_.isEmpty(_.get(r.mo,"c8y_Status"))},subscriptionsVisible:function(){return!_.isEmpty(_.get(r.mo,"c8y_Subscriptions"))}}),t.$watch("vm.realtime",function(t,n){t!==n&&(t?c:o)()})}t.$inject=["$scope","$routeParams","c8yApplication","c8yRealtime","smartRuleTemplatesSvc"],angular.module("c8y.appStatus").component("c8yAppStatus",{bindings:{basePath:"@"},templateUrl:":::PLUGIN_PATH:::/app-status/app-status.html",controller:t,controllerAs:"vm"})})();
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
></c8y-app-alarms>
|
|
119
119
|
</div>
|
|
120
120
|
</div>
|
|
121
|
-
<div ng-if="vm.mo" class="inner-scroll--md">
|
|
121
|
+
<div ng-if="vm.mo && vm.smartRulesMsExist" class="inner-scroll--md">
|
|
122
122
|
<div class="card-header large-padding separator-top-bottom sticky-top">
|
|
123
123
|
<div class="card-title">
|
|
124
124
|
{{ 'Smart rules' | translate }}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,p=[],s=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=o.call(r)).done)&&(p.push(n.value),p.length!==t);s=!0);}catch(e){c=!0,i=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return p}}function _toArray(e){return _arrayWithHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_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 _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 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 _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 e(e,o,c,u,h,f,y,m,d){return new function r(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=n.tenantId,l=this,a="x-show-if-any-available",p="title";function i(e){var t=_.cloneDeep(e),e=u.when(t),r=_.find(l.ENTITIES.values(),{staticSchemaPath:l.propertiesCfg.static.path});return e=r?y.list().then(function(e){var t={appliesTo:{}};return t.appliesTo[r.value]=!0,_.filter(e,t)}).then(function(e){return _.map(e,function(e){return _.get(e,"c8y_JsonSchema")})}).then(function(e){return _.forEach(e,function(e){r===l.ENTITIES.TENANTS?_.merge(t.properties.customProperties.properties,e.properties):_.merge(t.properties,e.properties)}),t}):e}function s(e,t,r,n,i){if(r===p&&(r=_.has(i,"type"),i=!_.isUndefined(e),r)&&i)return e}this.ENTITIES=h.createEnum([{name:"MANAGED_OBJECTS",value:"MANAGED_OBJECTS",staticSchemaPath:h.dataFilePath("properties/managed-objects.json")},{name:"MEASUREMENTS",value:"MEASUREMENTS",staticSchemaPath:h.dataFilePath("properties/measurements.json")},{name:"ALARMS",value:"ALARMS",staticSchemaPath:h.dataFilePath("properties/alarms.json")},{name:"EVENTS",value:"EVENTS",staticSchemaPath:h.dataFilePath("properties/events.json")},{name:"TENANTS",value:"TENANTS",staticSchemaPath:h.dataFilePath("properties/tenants.json")}]),this.properties={},this.propertiesCfg={static:{path:e}},this.list=function(){return l.loadProperties().then(_.bind(l.getSimplifiedProperties,l))},this.getProperties=function(){return l.loadProperties().then(_.bind(l.getFullProperties,l))},this.getTenantDetails=function(){return t?d.detail(t).then(h.getResData):d.current()},this.removeKeysDependingOnAppsAvailability=function(t){return function e(t){for(var r=Object.keys(t),n=!1,i=0;i<r.length;i++){var o=r[i];_typeof(t[o])===_typeof({})&&null!==t[o]&&(n=o===a||n||e(t[o]))}return n}(t)?l.getTenantDetails().then(function(e){return e=_.flatMap(e.applications.references,"application"),function t(r,n){var e=Object.keys(r);return _.forEach(e,function(e){void 0===r[e][a]||_.some(r[e][a],function(e){return f.isAppOnTheList(n,e)})?_typeof(r[e])===_typeof({})&&null!==r[e]&&e!==a&&t(r[e],n):delete r[e]}),r}(t,e)}):t},this.loadProperties=_.throttle(function(){return l.loadStaticPropertiesSchema().then(i).then(l.removeKeysDependingOnAppsAvailability).then(_.bind(l.getPropertiesFromSchema,l)).then(_.bind(l.addProperties,l))},1e3,{leading:!0,trailing:!1}),this.loadStaticPropertiesSchema=function(){var e=l.propertiesCfg.static.path;return l.loadStaticPropertiesSchemaFromMemory()||o.get(e).then(h.getResData)},this.pathToKey=function(){var e=l.propertiesCfg.static.path;return _.last(e.split("/")).replace(/\.json$/,"")},this.loadStaticPropertiesSchemaFromMemory=function(){var e=l.pathToKey();return(e=(window.c8y&&window.c8y.collections&&window.c8y.collections.properties||{})[e])&&u.when(e)},this.getPropertiesFromSchema=function(e,t,r){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:["properties"],a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[],p=5<arguments.length&&void 0!==arguments[5]?arguments[5]:[],s=t||e.id||"c8yDefaultSchema",t=_.cloneDeep(r||{type:"object",properties:{}}),c=l.setObjValue(t,o,{});return _.has(e,"properties")&&_.forEach(e.properties,function(e,t){var r=_.cloneDeep(c),n=_.flattenDeep([o,t,"properties"]),i=_.flattenDeep([a,t]),r=l.setObjValue(r,o,_.cloneDeep(e),t),t=l.getNewPropertyObj(s,i,r,e);p.push(t),l.getPropertiesFromSchema(e,s,r,n,i,p)}),p},this.getNewPropertyObj=function(e,t,r,n){var i=t.join("."),e={id:"".concat(e,"!!").concat(i),keyPath:t,type:n.type,printFormat:n.printFormat,label:l.getDefaultPropertyLabel(t,n),schema:r};return n.config&&(e.configSchema=n.config),n.computed&&(e.computed=n.computed),e},this.getFragmentName=function(e){var e=e[e.length-1],t=/_\d{9,}$/;return e=t.test(e)?e.replace(t,""):e},this.getDefaultPropertyLabel=function(e,t){return t=(t=t.title)||(t=(t=l.getFragmentName(e)).replace(/^c8y_/i,"").replace(/([A-Z][a-z])/g," $1").replace(/([^0-9])([0-9])/g,"$1 $2").replace("_"," ").replace(/^\s*/,"").replace(/\s*$/,"")).charAt(0).toUpperCase()+t.slice(1)},this.setObjValue=function(e,t,r,n){for(var i=e,o=0;o<t.length-1;o++)i[t[o]]||(i[t[o]]={}),i=i[t[o]];return n?i[t[o]][n]=r:i[t[o]]=r,e},this.addProperties=function(e){_.forEach(e,function(e){l.properties[e.id]=e})},this.getSimplifiedProperties=function(){return _.map(l.properties,_.bind(l.simplifyProperty,l))},this.simplifyProperty=function(e){return _.pick(e,["id","keyPath","type","label","configSchema","computed","printFormat"])},this.getFullProperties=function(){return _.cloneDeep(l.properties)},this.getSchema=function(e){return l.loadProperties().then(_.bind(l.getSchemaForProperties,l,e)).catch(c.error)},this.getSchemaForProperties=function(o){var a={type:"object",properties:{}};return _.forEach(o,function(e){l.isCustomProperty(e)&&l.addCustomProperty(e),_.mergeWith(a.properties,l.properties[e.id].schema.properties,s);var t,r,n,i=l.findInSchema(a,e);i&&(i.id=e.id,i.title=e.label||l.properties[e.id].label,n=i,t=e,r=o,l.isComplexProperty(t)&&0<l.getChildren(t,r).length&&(n.properties={}),_.forEach(_.get(i,"properties"),function(e){_.set(e,p,m.getString(e.title))}),t=a,r=e,n=_.last(r.id.split("!!")),i=_.last(r.keyPath),r.computed)&&r.configSchema&&(n!==i&&(t.properties[i]=t.properties[n],delete t.properties[n]),r.config&&4===r.config.resultType&&(t.properties[i].type="object",t.properties[i].properties={value:{title:m.getString("Value"),type:"number"},unit:{title:m.getString("Unit"),type:"string"}}),r.config)&&1===r.config.resultType&&(t.properties[i].type="number")}),function r(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];e.properties&&_.forEach(e.properties,function(e,t){n(e,t,[].concat(_toConsumableArray(i),[t])),r(e,n,[].concat(_toConsumableArray(i),[t]))})}(a,function(e,t,r){_.isUndefined(e.title)&&(e.title=l.getDefaultPropertyLabel(r,e))}),a},this.findInSchema=function(e,t){var r=t.keyPath;return t.computed&&(r=[l.getFragmentName(r)]),l.findInSchemaByKeyPath(e,r)},this.findInSchemaById=function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return _.isObjectLike(e)&&_.forOwn(e,function(e){_.isObjectLike(e)&&e.id===t?r.push(e):l.findInSchemaById(e,t,r)}),r},this.findInSchemaByKeyPath=function(e,t){if(!t.length)return e;if(e.properties){var r=(t=_toArray(t))[0],t=t.slice(1);if(_.has(e.properties,r))return this.findInSchemaByKeyPath(e.properties[r],t)}},this.getForm=function(e,t){return l.loadProperties().then(_.bind(l.getFormForProperties,l,e,t))},this.getFormForProperties=function(e,n){var t=_(e).map(function(e){var t;return e.computed?e:(t=_slicedToArray(e.id.match(/^(.+)!!/),2)[1],t="".concat(t,"!!").concat(e.keyPath[0]),e=l.properties[t],_.pick(e,["id","keyPath"]))}).uniqBy("keyPath").value(),i=l.getSchemaForProperties(e);return t.map(function(e){return t=n,r=i,r=l.findInSchemaByKeyPath(r,e.keyPath),r=((e,t)=>(t.computed&&t.configSchema&&(e.key=_.last(t.keyPath)),e))(r={key:ObjectPath.stringify(l.properties[e.id].keyPath),title:r.title||e.label||l.properties[e.id].label},e),_.assign(r,t),r;var t,r})},this.isComplexProperty=function(e){return"object"===e.type||"array"===e.type},this.isCustomProperty=function(e){return"c8yCustom"===e.id.split("!!")[0]},this.getChildren=function(t,e){return _.filter(e||l.properties,function(e){return t.id!==e.id&&_.isEqual(_.take(e.keyPath,t.keyPath.length),t.keyPath)})},this.changeActiveProperty=function(e,t){return _.map(e,function(e){return _.assign(e,{__active:t})})},this.removeDuplication=function(e){var t,r=e;return _.map(e,function(e){l.isComplexProperty(e)&&(t=_.map(l.getChildren(e),"id"),r=_.reject(r,function(e){return _.includes(t,e.id)}))}),r},this.getParent=function(t){return _.filter(l.properties,function(e){return t.keyPath.length>e.keyPath.length&&_.isEqual(_.take(t.keyPath,e.keyPath.length),e.keyPath)})},this.addCustomProperty=function(e){l.properties[e.id]||(l.properties[e.id]={}),_.merge(l.properties[e.id],e)},this.another=function(e,t){return new r(e,void 0===t?n:t)},this.paths=_.reduce(this.ENTITIES.values(),function(e,t){return e[_.startCase(_.camelCase(t.value)).replace(" ","")]=t.staticSchemaPath,e},{})}(h.dataFilePath("properties/managed-objects.json"))}e.$inject=["$filter","$http","$log","$q","c8yBase","c8yApplication","c8yJsonSchemas","gettextCatalog","c8yTenant"],angular.module("c8y.ui").provider("c8yPropertiesLibrary",function(){return{$get:e}})})();
|
|
1
|
+
function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,p=[],s=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=o.call(r)).done)&&(p.push(n.value),p.length!==t);s=!0);}catch(e){c=!0,i=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return p}}function _toArray(e){return _arrayWithHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_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 _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 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 _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 e(e,o,c,l,h,f,y,m,d){return new function r(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=n.tenantId,u=this,a="x-show-if-any-available",p="title";function i(e){var t=_.cloneDeep(e),e=l.when(t),r=_.find(u.ENTITIES.values(),{staticSchemaPath:u.propertiesCfg.static.path});return e=r?y.list().then(function(e){var t={appliesTo:{}};return t.appliesTo[r.value]=!0,_.filter(e,t)}).then(function(e){return _.map(e,function(e){return _.get(e,"c8y_JsonSchema")})}).then(function(e){return _.forEach(e,function(e){r===u.ENTITIES.TENANTS?_.merge(t.properties.customProperties.properties,e.properties):_.merge(t.properties,e.properties)}),t}):e}function s(e,t,r,n,i){if(r===p&&(r=_.has(i,"type"),i=!_.isUndefined(e),r)&&i)return e}this.ENTITIES=h.createEnum([{name:"MANAGED_OBJECTS",value:"MANAGED_OBJECTS",staticSchemaPath:h.dataFilePath("properties/managed-objects.json")},{name:"MEASUREMENTS",value:"MEASUREMENTS",staticSchemaPath:h.dataFilePath("properties/measurements.json")},{name:"ALARMS",value:"ALARMS",staticSchemaPath:h.dataFilePath("properties/alarms.json")},{name:"EVENTS",value:"EVENTS",staticSchemaPath:h.dataFilePath("properties/events.json")},{name:"TENANTS",value:"TENANTS",staticSchemaPath:h.dataFilePath("properties/tenants.json")}]),this.properties={},this.propertiesCfg={static:{path:e}},this.list=function(){return u.loadProperties().then(_.bind(u.getSimplifiedProperties,u))},this.getProperties=function(){return u.loadProperties().then(_.bind(u.getFullProperties,u))},this.getTenantDetails=function(){return t?d.detail(t).then(h.getResData):d.current()},this.removeKeysDependingOnAppsAvailability=function(t){return function e(t){for(var r=Object.keys(t),n=!1,i=0;i<r.length;i++){var o=r[i];_typeof(t[o])===_typeof({})&&null!==t[o]&&(n=o===a||n||e(t[o]))}return n}(t)?u.getTenantDetails().then(function(e){return e=_.flatMap(e.applications.references,"application"),function t(r,n){var e=Object.keys(r);return _.forEach(e,function(e){void 0===r[e][a]||_.some(r[e][a],function(e){return f.isAppOnTheList(n,e)})?_typeof(r[e])===_typeof({})&&null!==r[e]&&e!==a&&t(r[e],n):delete r[e]}),r}(t,e)}):t},this.loadProperties=_.throttle(function(){return u.loadStaticPropertiesSchema().then(i).then(u.removeKeysDependingOnAppsAvailability).then(_.bind(u.getPropertiesFromSchema,u)).then(_.bind(u.addProperties,u))},1e3,{leading:!0,trailing:!1}),this.loadStaticPropertiesSchema=function(){var e=u.propertiesCfg.static.path;return u.loadStaticPropertiesSchemaFromMemory()||o.get(e).then(h.getResData)},this.pathToKey=function(){var e=u.propertiesCfg.static.path;return _.last(e.split("/")).replace(/\.json$/,"")},this.loadStaticPropertiesSchemaFromMemory=function(){var e=u.pathToKey();return(e=(window.c8y&&window.c8y.collections&&window.c8y.collections.properties||{})[e])&&l.when(e)},this.getPropertiesFromSchema=function(e,t,r){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:["properties"],a=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[],p=5<arguments.length&&void 0!==arguments[5]?arguments[5]:[],s=t||e.id||"c8yDefaultSchema",t=_.cloneDeep(r||{type:"object",properties:{}}),c=u.setObjValue(t,o,{});return _.has(e,"properties")&&_.forEach(e.properties,function(e,t){var r=_.cloneDeep(c),n=_.flattenDeep([o,t,"properties"]),i=_.flattenDeep([a,t]),r=u.setObjValue(r,o,_.cloneDeep(e),t),t=u.getNewPropertyObj(s,i,r,e);p.push(t),u.getPropertiesFromSchema(e,s,r,n,i,p)}),p},this.getNewPropertyObj=function(e,t,r,n){var i=t.join("."),e={id:"".concat(e,"!!").concat(i),keyPath:t,type:n.type,printFormat:n.printFormat,label:u.getDefaultPropertyLabel(t,n),schema:r};return n.config&&(e.configSchema=n.config),n.computed&&(e.computed=n.computed),e},this.getFragmentName=function(e){var e=e[e.length-1],t=/_\d{9,}$/;return e=t.test(e)?e.replace(t,""):e},this.getDefaultPropertyLabel=function(e,t){return t=(t=t.title)||(t=(t=u.getFragmentName(e)).replace(/^c8y_/i,"").replace(/([A-Z][a-z])/g," $1").replace(/([^0-9])([0-9])/g,"$1 $2").replace("_"," ").replace(/^\s*/,"").replace(/\s*$/,"")).charAt(0).toUpperCase()+t.slice(1)},this.setObjValue=function(e,t,r,n){for(var i=e,o=0;o<t.length-1;o++)i[t[o]]||(i[t[o]]={}),i=i[t[o]];return n?i[t[o]][n]=r:i[t[o]]=r,e},this.addProperties=function(e){_.forEach(e,function(e){u.properties[e.id]=e})},this.getSimplifiedProperties=function(){return _.map(u.properties,_.bind(u.simplifyProperty,u))},this.simplifyProperty=function(e){return _.pick(e,["id","keyPath","type","label","configSchema","computed","printFormat"])},this.getFullProperties=function(){return _.cloneDeep(u.properties)},this.getSchema=function(e){return u.loadProperties().then(_.bind(u.getSchemaForProperties,u,e)).catch(c.error)},this.getSchemaForProperties=function(o){var a={type:"object",properties:{}};return _.forEach(o,function(e){u.isCustomProperty(e)&&u.addCustomProperty(e),_.mergeWith(a.properties,u.properties[e.id].schema.properties,s);var t,r,n,i=u.findInSchema(a,e);i&&(i.id=e.id,i.title=e.label||u.properties[e.id].label,n=i,t=e,r=o,u.isComplexProperty(t)&&0<u.getChildren(t,r).length&&(n.properties={}),_.forEach(_.get(i,"properties"),function(e){_.set(e,p,m.getString(e.title))}),t=a,r=e,n=_.last(r.id.split("!!")),i=_.last(r.keyPath),r.computed)&&r.configSchema&&(n!==i&&(t.properties[i]=t.properties[n],delete t.properties[n]),r.config&&4===r.config.resultType&&(t.properties[i].type="object",t.properties[i].properties={value:{title:m.getString("Value"),type:"number"},unit:{title:m.getString("Unit"),type:"string"}}),r.config)&&1===r.config.resultType&&(t.properties[i].type="number")}),function r(e,n){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];e.properties&&_.forEach(e.properties,function(e,t){n(e,t,[].concat(_toConsumableArray(i),[t])),r(e,n,[].concat(_toConsumableArray(i),[t]))})}(a,function(e,t,r){_.isUndefined(e.title)&&(e.title=u.getDefaultPropertyLabel(r,e))}),a},this.findInSchema=function(e,t){var r=t.keyPath;return t.computed&&(r=[u.getFragmentName(r)]),u.findInSchemaByKeyPath(e,r)},this.findInSchemaById=function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[];return _.isObjectLike(e)&&_.forOwn(e,function(e){_.isObjectLike(e)&&e.id===t?r.push(e):u.findInSchemaById(e,t,r)}),r},this.findInSchemaByKeyPath=function(e,t){if(!t.length)return e;if(e.properties){var r=(t=_toArray(t))[0],t=t.slice(1);if(_.has(e.properties,r))return this.findInSchemaByKeyPath(e.properties[r],t)}},this.getForm=function(e,t){return u.loadProperties().then(_.bind(u.getFormForProperties,u,e,t))},this.getFormForProperties=function(e,n){var t=_(e).map(function(e){if(e.computed)return e;for(var t=_slicedToArray(e.id.match(/^(.+)!!/),2)[1],r=[],n=0;n<e.keyPath.length;n++){r.push(e.keyPath[n]);var i="".concat(t,"!!").concat(r.join("."));if(i=u.properties[i])return _.pick(i,["id","keyPath"])}return{}}).uniqBy("keyPath").value(),i=u.getSchemaForProperties(e);return t.map(function(e){return t=n,r=i,r=u.findInSchemaByKeyPath(r,e.keyPath),r=((e,t)=>(t.computed&&t.configSchema&&(e.key=_.last(t.keyPath)),e))(r={key:ObjectPath.stringify(u.properties[e.id].keyPath),title:r.title||e.label||u.properties[e.id].label},e),_.assign(r,t),r;var t,r})},this.isComplexProperty=function(e){return"object"===e.type||"array"===e.type},this.isCustomProperty=function(e){return"c8yCustom"===e.id.split("!!")[0]},this.getChildren=function(t,e){return _.filter(e||u.properties,function(e){return t.id!==e.id&&_.isEqual(_.take(e.keyPath,t.keyPath.length),t.keyPath)})},this.changeActiveProperty=function(e,t){return _.map(e,function(e){return _.assign(e,{__active:t})})},this.removeDuplication=function(e){var t,r=e;return _.map(e,function(e){u.isComplexProperty(e)&&(t=_.map(u.getChildren(e),"id"),r=_.reject(r,function(e){return _.includes(t,e.id)}))}),r},this.getParent=function(t){return _.filter(u.properties,function(e){return t.keyPath.length>e.keyPath.length&&_.isEqual(_.take(t.keyPath,e.keyPath.length),e.keyPath)})},this.addCustomProperty=function(e){u.properties[e.id]||(u.properties[e.id]={}),_.merge(u.properties[e.id],e)},this.another=function(e,t){return new r(e,void 0===t?n:t)},this.paths=_.reduce(this.ENTITIES.values(),function(e,t){return e[_.startCase(_.camelCase(t.value)).replace(" ","")]=t.staticSchemaPath,e},{})}(h.dataFilePath("properties/managed-objects.json"))}e.$inject=["$filter","$http","$log","$q","c8yBase","c8yApplication","c8yJsonSchemas","gettextCatalog","c8yTenant"],angular.module("c8y.ui").provider("c8yPropertiesLibrary",function(){return{$get:e}})})();
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_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,r){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,r):"Map"===(t="Object"===(t={}.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,r):void 0}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,a,i,l,o=[],u=!0,c=!1;try{if(i=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=i.call(t)).done)&&(o.push(n.value),o.length!==r);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=t.return&&(l=t.return(),Object(l)!==l))return}finally{if(c)throw a}}return o}}function _arrayWithHoles(e){if(Array.isArray(e))return e}(()=>{function e(e,r,
|
|
1
|
+
function _slicedToArray(e,r){return _arrayWithHoles(e)||_iterableToArrayLimit(e,r)||_unsupportedIterableToArray(e,r)||_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,r){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,r):"Map"===(t="Object"===(t={}.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,r):void 0}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function _iterableToArrayLimit(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,a,i,l,o=[],u=!0,c=!1;try{if(i=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=i.call(t)).done)&&(o.push(n.value),o.length!==r);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=t.return&&(l=t.return(),Object(l)!==l))return}finally{if(c)throw a}}return o}}function _arrayWithHoles(e){if(Array.isArray(e))return e}(()=>{function e(e,t,r,n,a,i,l,o){var u=a.url("service/smartrule/smartrules/configurations"),c=e("smartRuleTemplates"),s="list";return 0<_.get(window,"c8y.collections.smartrules",[]).length&&r.warn("In-memory definitions of smart rules are not supported right now."),{list:f,getTemplateForRule:function(r){return f().then(function(e){return _.find(e,{name:r.ruleTemplateName})})},getTemplateByName:function(r){return f().then(function(e){return _.find(e,{name:r})}).then(y)},mustBeAvailable:function(e){return h(e).then(function(e){return e?n.when():n.reject()})},isAvailable:h};function f(){var e={url:u,silentError:0<arguments.length&&void 0!==arguments[0]&&arguments[0]};if(!(1<arguments.length&&void 0!==arguments[1])||arguments[1]){var r=c.get(s);if(r)return n.when(r)}return t(e).then(a.getResData).then(function(e){return _.filter(e,function(e){return!_.includes(l.smartRules.exclude,e.name)})}).then(m).then(function(e){return c.put(s,e),e})}function m(e){var r=[];return e.forEach(function(e){r.push(y(e))}),n.all(r)}function y(r){return h(r.name).then(function(e){return r._active=e,n.when(r)})}function h(e){switch(e){case"sendDashboardsViaEmail":return n.all({systemOption:i.getSystemOptionValue({category:"reportMailer",key:"available"},!1),featureActive:o.isAvailable({name:"feature-dashboard-mailer"})}).then(_.every);case"onAlarmSendSms":return n.all([o.isAvailable({contextPath:"messaging"}),i.detailValue({category:"messaging",key:"provider"})]).then(function(e){var e=_slicedToArray(e,2),r=e[0];return Boolean(r&&e[1])});case"onAlarmEscalateAlarm":return h("onAlarmSendSms");default:return n.when(!0)}}}e.$inject=["$cacheFactory","$http","$log","$q","c8yBase","c8ySettings","c8yConfig","c8yApplication"],angular.module("c8y.smartRules").factory("smartRuleTemplatesSvc",e)})();
|