@c8y/ng1-modules 1019.6.10 → 1019.6.11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c8y/ng1-modules",
3
- "version": "1019.6.10",
3
+ "version": "1019.6.11",
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(t,e,n,s,i,a,l,r,u,o,c,d){var m=_.isEmpty(c)?null:c,g="smartRuleForm",h={parent:null,mo:null,withChildren:{assets:!0,devices:!1}},y={inProgres:!1};function p(e){o=e,t.ruleTemplate=o,t.rule.name||(t.rule.name=d.getString(t.ruleTemplate.description))}function v(e){t.enabledSources=_.sortBy(e,"name")}function C(e){t.disabledSources=_.sortBy(e,"name")}function S(){return b(),n.reject()}function f(){y.inProgress=!0}function b(){y.inProgress=!1}t.hasChildAssets=angular.bind(i,i.hasChildAssets),t.getChildAssetsCount=angular.bind(i,i.getChildAssetsCount),t.ruleTemplate=o,t.rule=c,t.save=function(){o.noTarget&&(h.withChildren={assets:!1,devices:!1}),n.when().then(f).then(angular.bind(r,r.save,c,o,h)).then(e.close,S).then(_.partial(_.unary(l.success),d.getString('Smart rule "{{name}}" saved.',{name:c.name}))).then(b)},t.savingStatus=y,t.cancel=e.dismiss,t.invalid=angular.bind(s,s.invalid,t,g);var R,T=t.$watch(g,function(e){m&&e.$setDirty(),e&&T()});c&&c.id||(c=_.assign(r.getEmpty(),c||{})),t.rule=c,g=r.getRuleModalTitle(t.rule),t.title=g,o?p(o):u.getTemplateForRule(c).then(p),t.initialActivationCfg=h,g=_.get(c,"c8y_Context",a.getContext()),i.detail(g.id).then(s.getResData).then(function(e){h.mo=e}),c&&c.id&&(_.isEmpty(c.enabledSources)||(R=c.enabledSources.join(","),i.list({ids:R}).then(v)),_.isEmpty(c.disabledSources)||(R=c.disabledSources.join(","),i.list({ids:R}).then(C)))}e.$inject=["$scope","$uibModalInstance","$q","c8yBase","c8yInventory","c8yUiUtil","c8yAlert","smartRulesSvc","smartRuleTemplatesSvc","ruleTemplate","rule","gettextCatalog"],angular.module("c8y.smartRules").controller("SmartRuleEditCtrl",e)}();
1
+ "use strict";!function(){function e(t,e,n,s,i,a,l,r,u,o,c,d,m){var g=_.isEmpty(c)?null:c,h="smartRuleForm",y={parent:null,mo:null,withChildren:{assets:!0,devices:!1}},p={inProgres:!1};function v(e){o=e,t.ruleTemplate=o,t.rule.name||(t.rule.name=m.getString(t.ruleTemplate.description))}function C(e){t.enabledSources=_.sortBy(e,"name")}function S(e){t.disabledSources=_.sortBy(e,"name")}function f(){return R(),n.reject()}function b(){p.inProgress=!0}function R(){p.inProgress=!1}t.hasChildAssets=angular.bind(i,i.hasChildAssets),t.getChildAssetsCount=angular.bind(i,i.getChildAssetsCount),t.ruleTemplate=o,t.rule=c,t.save=function(){o.noTarget&&(y.withChildren={assets:!1,devices:!1}),n.when().then(b).then(angular.bind(r,r.save,c,o,y)).then(e.close,f).then(_.partial(_.unary(l.success),m.getString('Smart rule "{{name}}" saved.',{name:c.name}))).then(R)},t.savingStatus=p,t.cancel=e.dismiss,t.invalid=angular.bind(s,s.invalid,t,h);var T,A=t.$watch(h,function(e){g&&e.$setDirty(),e&&A()});c&&c.id||(c=_.assign(r.getEmpty(),c||{})),t.rule=c,h=r.getRuleModalTitle(t.rule),t.title=h,o?v(o):u.getTemplateForRule(c).then(v),t.initialActivationCfg=y,h=_.get(c,"c8y_Context",d?{id:d}:a.getContext()),i.detail(h.id).then(s.getResData).then(function(e){y.mo=e}),c&&c.id&&(_.isEmpty(c.enabledSources)||(T=c.enabledSources.join(","),i.list({ids:T}).then(C)),_.isEmpty(c.disabledSources)||(T=c.disabledSources.join(","),i.list({ids:T}).then(S)))}e.$inject=["$scope","$uibModalInstance","$q","c8yBase","c8yInventory","c8yUiUtil","c8yAlert","smartRulesSvc","smartRuleTemplatesSvc","ruleTemplate","rule","contextMoId","gettextCatalog"],angular.module("c8y.smartRules").controller("SmartRuleEditCtrl",e)}();
@@ -1 +1 @@
1
- "use strict";!function(){function e(e,r,i,t,n,o,a,c,u,l,s,d,f,h){var m=this,v={},g={},p={done:!1,inProgress:!1},A={true:{text:f("Active`rule`"),icon:"check-circle",cls:"text-success"},false:{text:f("Inactive`rule`"),icon:"ban",cls:"text-warning"}};function S(){return i.when().then(R).then(C).then(I).then(N).then(b).catch(y)}function R(){p.inProgress=!0}function b(){p.inProgress=!1,p.done=!0,p.error=!1}function y(e){e.data&&e.data.message&&c.danger(e.data.message),p.inProgress=!1,p.done=!0,p.error=!0}function C(){return s.list().then(E)}function E(e){_.forEach(e,function(e){v[e.name]=e})}function I(){var e=m.mo?d.listByContext(m.mo):i.resolve([]),t=l.hasPermissions().then(function(e){return e?d.list():i.when([])});return i.all({listByContext:e,list:t}).then(function(e){m.rules=function(e){m.mo&&(e=_.reject(e,function(e){var n=new RegExp("".concat(e,"/dashboard"));return function(e){var t=_.get(e,"config.url","");return x(e)&&!n.test(t)}}(m.mo)));m.filter&&(e=_.filter(e,m.filter));return e}(_.concat(e.listByContext,e.list)),"function"==typeof m.onRules&&m.onRules()(m.rules)})}function x(e){return"sendDashboardsViaEmail"===e.ruleTemplateName}function w(e){return d.hasSource(e,m.mo)}function N(){var e,t;return Array.isArray(m.rules)&&0<m.rules.length&&(e=u.getContext(),t=function(e){e=e.id;return m.mo?_.get(m,"mo.id")||m.mo:e}(e),null!==e.context)?n.childAssets(t,{skipDetail:!0,params:{pageSize:2e3,withChildren:!1}}).then(function(e){m.children=e}).then(function(){m.ruleChildren={},_.forEach(m.rules,function(e){m.ruleChildren[e.id]=M(e)})}):i.resolve()}function M(t){return _.filter(m.children,function(e){return t.enabled&&d.hasSource(t,e)})}_.assign(m,{ruleTemplates:v,loadingStatus:p,isOpen:{},listClass:"interact-list",$onInit:function(){e.$on("smartRulesListReload",S),S()},add:function(){d.addNewWithUI().then(S)},edit:function(e){d.editWithUI(e).then(S)},clone:function(e){d.cloneWithUI(e).then(S)},remove:function(e){t({title:f("Delete smart rule"),body:h.getString('You are about to delete smart rule "{{name}}". Do you want to proceed?',e),status:"danger",labels:{ok:f("Delete")}}).then(d.remove.bind(d,e)).then(function(){return _.pull(m.rules,e)}).then(function(){return c.success(f("Smart rule deleted."))})},hasSource:w,getChildrenEnabledForSmartRule:M,toggleRuleActivationForContextMO:function(e){if(e.enabled&&w(e))return d.deactivate(e,m.mo,!1).then(function(){c.success(h.getString('Smart rule "{{name}}" deactivated.',e))});return d.activate(e,m.mo,!1).then(function(){c.success(h.getString('Smart rule "{{name}}" activated.',e))})},toggleRuleActivationForChildrenMOs:function(t,n){var r=[];return _.forEach(n,function(e){_.find(m.ruleChildren[t.id],{id:e.id})||r.push(d.activate(t,e,!1))}),_.forEach(m.ruleChildren[t.id],function(e){_.find(n,{id:e.id})||r.push(d.deactivate(t,e,!1))}),i.all(r).then(I).then(N).then(function(){c.success(h.getString('Smart rule "{{name}}" activated/deactivated for children.',t))})},tooltip:function(e){var t,n={activate:{"for group":f("Activate for this group."),"for device":f("Activate for this device."),"for object":f("Activate for this object.")},deactivate:{"for group":f("Deactivate for this group."),"for device":f("Deactivate for this device."),"for object":f("Deactivate for this object.")}},e=e.enabled&&w(e)?"deactivate":"activate";t=r.deviceId?"device":r.groupId?"group":"object";return n[e]["for ".concat(t)]},type:function(e){var t,e=v[e.ruleTemplateName];e&&(t=e.label.full?h.getString(e.label.full):"".concat(h.getString(e.label.input)," ").concat(h.getString(e.label.output)));return t},status:function(e){e=e.enabled&&w(e);return A[e].text},statusIcon:function(e){e=e.enabled&&w(e);return A[e].icon},statusClass:function(e){e=e.enabled&&w(e);return A[e].cls},context:u.getContext(),inputIcon:function(e){var t,e=v[e.ruleTemplateName];e&&(t=e.paramGroups.input.icon);return t},outputIcon:function(e){var t,e=v[e.ruleTemplateName];e&&(t=e.paramGroups.output.icon);return t},canAddRules:function(){var e,t=g.canAddRules;_.isUndefined(t)&&(e=m.context?a.isAllowed({adminMOs:[m.context.id]}):i.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}),g.canAddRules=e.then(function(e){return g.canAddRules=e,g.canAddRules}),t=!1);return t},canModify:function(t){g.rules=g.rules||{};var n=g.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!x(e)},canSeeSection:function(){var e=g.canSeeSection;_.isUndefined(e)&&(g.canSeeSection=l.shouldShowLocalSmartRules().then(function(e){return g.canSeeSection=e,g.canSeeSection}),e=!1);return e}}),_.assign(e,{refresh:S,paging:{refresh:S}})}e.$inject=["$scope","$routeParams","$q","c8yModal","c8yInventory","c8yApplication","c8yPermissions","c8yAlert","c8yUiUtil","c8ySmartRulesAvailability","smartRuleTemplatesSvc","smartRulesSvc","gettext","gettextCatalog"],angular.module("c8y.smartRules").component("smartRulesList",{bindings:{mo:"<?",filter:"<?",disableEditAndCreate:"<?",onRules:"&?"},templateUrl:":::PLUGIN_PATH:::/list/smartRulesList.html",controller:e,controllerAs:"vm"})}();
1
+ "use strict";!function(){function e(e,r,i,t,n,o,a,c,u,l,s,d,f,h){var m=this,v={},g={},p={done:!1,inProgress:!1},A={true:{text:f("Active`rule`"),icon:"check-circle",cls:"text-success"},false:{text:f("Inactive`rule`"),icon:"ban",cls:"text-warning"}};function S(){return i.when().then(R).then(C).then(I).then(N).then(b).catch(y)}function R(){p.inProgress=!0}function b(){p.inProgress=!1,p.done=!0,p.error=!1}function y(e){e.data&&e.data.message&&c.danger(e.data.message),p.inProgress=!1,p.done=!0,p.error=!0}function C(){return s.list().then(E)}function E(e){_.forEach(e,function(e){v[e.name]=e})}function I(){var e=m.mo?d.listByContext(m.mo):i.resolve([]),t=l.hasPermissions().then(function(e){return e?d.list():i.when([])});return i.all({listByContext:e,list:t}).then(function(e){m.rules=function(e){m.mo&&(e=_.reject(e,function(e){var n=new RegExp("".concat(e,"/dashboard"));return function(e){var t=_.get(e,"config.url","");return x(e)&&!n.test(t)}}(m.mo)));m.filter&&(e=_.filter(e,m.filter));return e}(_.concat(e.listByContext,e.list)),"function"==typeof m.onRules&&m.onRules()(m.rules)})}function x(e){return"sendDashboardsViaEmail"===e.ruleTemplateName}function w(e){return d.hasSource(e,m.mo)}function N(){var e,t;return Array.isArray(m.rules)&&0<m.rules.length&&(e=u.getContext(),t=function(e){e=e.id;return m.mo?_.get(m,"mo.id")||m.mo:e}(e),null!==e.context)?n.childAssets(t,{skipDetail:!0,params:{pageSize:2e3,withChildren:!1}}).then(function(e){m.children=e}).then(function(){m.ruleChildren={},_.forEach(m.rules,function(e){m.ruleChildren[e.id]=M(e)})}):i.resolve()}function M(t){return _.filter(m.children,function(e){return t.enabled&&d.hasSource(t,e)})}_.assign(m,{ruleTemplates:v,loadingStatus:p,isOpen:{},listClass:"interact-list",$onInit:function(){e.$on("smartRulesListReload",S),S()},add:function(){d.addNewWithUI().then(S)},edit:function(e){d.editWithUI(e,m.mo).then(S)},clone:function(e){d.cloneWithUI(e,m.mo).then(S)},remove:function(e){t({title:f("Delete smart rule"),body:h.getString('You are about to delete smart rule "{{name}}". Do you want to proceed?',e),status:"danger",labels:{ok:f("Delete")}}).then(d.remove.bind(d,e)).then(function(){return _.pull(m.rules,e)}).then(function(){return c.success(f("Smart rule deleted."))})},hasSource:w,getChildrenEnabledForSmartRule:M,toggleRuleActivationForContextMO:function(e){if(e.enabled&&w(e))return d.deactivate(e,m.mo,!1).then(function(){c.success(h.getString('Smart rule "{{name}}" deactivated.',e))});return d.activate(e,m.mo,!1).then(function(){c.success(h.getString('Smart rule "{{name}}" activated.',e))})},toggleRuleActivationForChildrenMOs:function(t,n){var r=[];return _.forEach(n,function(e){_.find(m.ruleChildren[t.id],{id:e.id})||r.push(d.activate(t,e,!1))}),_.forEach(m.ruleChildren[t.id],function(e){_.find(n,{id:e.id})||r.push(d.deactivate(t,e,!1))}),i.all(r).then(I).then(N).then(function(){c.success(h.getString('Smart rule "{{name}}" activated/deactivated for children.',t))})},tooltip:function(e){var t,n={activate:{"for group":f("Activate for this group."),"for device":f("Activate for this device."),"for object":f("Activate for this object.")},deactivate:{"for group":f("Deactivate for this group."),"for device":f("Deactivate for this device."),"for object":f("Deactivate for this object.")}},e=e.enabled&&w(e)?"deactivate":"activate";t=r.deviceId?"device":r.groupId?"group":"object";return n[e]["for ".concat(t)]},type:function(e){var t,e=v[e.ruleTemplateName];e&&(t=e.label.full?h.getString(e.label.full):"".concat(h.getString(e.label.input)," ").concat(h.getString(e.label.output)));return t},status:function(e){e=e.enabled&&w(e);return A[e].text},statusIcon:function(e){e=e.enabled&&w(e);return A[e].icon},statusClass:function(e){e=e.enabled&&w(e);return A[e].cls},context:u.getContext(),inputIcon:function(e){var t,e=v[e.ruleTemplateName];e&&(t=e.paramGroups.input.icon);return t},outputIcon:function(e){var t,e=v[e.ruleTemplateName];e&&(t=e.paramGroups.output.icon);return t},canAddRules:function(){var e,t=g.canAddRules;_.isUndefined(t)&&(e=m.context?a.isAllowed({adminMOs:[m.context.id]}):i.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}),g.canAddRules=e.then(function(e){return g.canAddRules=e,g.canAddRules}),t=!1);return t},canModify:function(t){g.rules=g.rules||{};var n=g.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!x(e)},canSeeSection:function(){var e=g.canSeeSection;_.isUndefined(e)&&(g.canSeeSection=l.shouldShowLocalSmartRules().then(function(e){return g.canSeeSection=e,g.canSeeSection}),e=!1);return e}}),_.assign(e,{refresh:S,paging:{refresh:S}})}e.$inject=["$scope","$routeParams","$q","c8yModal","c8yInventory","c8yApplication","c8yPermissions","c8yAlert","c8yUiUtil","c8ySmartRulesAvailability","smartRuleTemplatesSvc","smartRulesSvc","gettext","gettextCatalog"],angular.module("c8y.smartRules").component("smartRulesList",{bindings:{mo:"<?",filter:"<?",disableEditAndCreate:"<?",onRules:"&?"},templateUrl:":::PLUGIN_PATH:::/list/smartRulesList.html",controller:e,controllerAs:"vm"})}();
@@ -1 +1 @@
1
- "use strict";!function(){function e(i,u,o,r,n,a,t,c,l,d,s){var f=o.url("service/smartrule"),h="".concat(f,"/smartrules"),p=["id","self","cepModuleId","lastUpdated","creationTime"],m=["type","cepModuleId","creationTime","lastUpdated"];return{permissionsCfgs:{create:[{anyRole:["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE","ROLE_MANAGED_OBJECT_ADMIN","ROLE_MANAGED_OBJECT_CREATE"]},{anyRole:["ROLE_CEP_MANAGEMENT_ADMIN","ROLE_SMARTRULE_ADMIN"]}]},getEmpty:function(e){var e=e||n.getContext(),t={type:"c8y_SmartRule",name:"",enabled:!0,config:{}};e.context&&e.id&&(t.c8y_Context=e,t.type="c8y_PrivateSmartRule");return t},list:function(){return u.get(h).then(o.getResData).then(_.property("rules")).then(v)},listByContext:function(e){return u.get(g({moId:e})).then(o.getResData).then(_.property("rules")).then(v)},detail:function(e){e=S({id:e});return u.get(e).then(o.getResData)},save:function(e,t,n){e=e.id?y(e):function(e,t,n){var r=S(e,!0);return function(e,t,n){return e.ruleTemplateName=t.name,function(e,t){var n=i.when(e);e.c8y_Context||t.mo?(e.enabledSources=[],e.disabledSources=void 0,n=b(e,t.mo,t.withChildren)):(e.enabledSources=void 0,e.disabledSources=[]);return n}(e,n)}(e,t,n).then(_.partial(u.post,r)).then(o.getResData)}(e,t,n);return e},remove:function(e){e=S(e,!0);return u.delete(e)},hasSource:function(e,t){t=t&&t.id||t;if(!t)return!1;if(e.disabledSources)return!A(e.disabledSources,t);if(e.enabledSources)return A(e.enabledSources,t);return!0},activate:function(e,t,n){return b(e,t,n).then(y)},deactivate:function(e,t,n){return R(e,t,n).then(y)},updateSources:function(e,t,r,u){return function(e,t,n){return t.reduce(function(e,t){return e.then(function(e){return b(e,t,n)})},i.resolve(e))}(e,t,u).then(function(e){return n=u,r.reduce(function(e,t){return e.then(function(e){return R(e,t,n)})},i.resolve(e));var n}).then(y)},addNewWithUI:D,addNewForInputAlarmAndOutputUserWithUI:function(e,t){return D({inputAlarm:e,outputUser:t})},addNewForInputDataPointWithUI:function(e){return D({inputDataPoint:e})},addNewForOutputOperationWithUI:function(e){return D({outputOperation:{template:function(e){return o.cleanFields(e,["id","self","status","deviceId","creationTime","failureReason"])}(e)}})},createInstanceWithUI:N,createInstanceWithUIByName:function(e,t){return c.getTemplateByName(e).then(function(e){return N(e,t)})},editWithUI:function(e){return T(e,void 0)},cloneWithUI:function(e){return t.current().then(_.partial(U,e)).then(T)},getRuleModalTitle:E};function v(e){return i.all(_.map(e,function(t){return c.getTemplateForRule(t).then(function(e){return _.isUndefined(e)?null:t})})).then(_.flatten).then(_.filter)}function S(e,t){var n=_.get(e,"c8y_Context.id"),t=t&&n?g({moId:n}):h;return e.id&&(t+="/".concat(e.id)),t}function g(e){return"".concat(f,"/managedObjects/").concat(e.moId,"/smartrules")}function y(e){var t=S(e,!0),e=o.cleanFields(e,m);return u.put(t,e)}function b(n,e,t){return I(e,t).then(function(e){return _.forEach(e,function(t){_.isArray(n.enabledSources)&&!A(n.enabledSources,t)&&n.enabledSources.push(t),_.isArray(n.disabledSources)&&A(n.disabledSources,t)&&_.remove(n.disabledSources,function(e){return _.toString(e)===_.toString(t)})}),n})}function R(n,e,t){return I(e,t).then(function(e){return _.forEach(e,function(t){_.isArray(n.enabledSources)&&A(n.enabledSources,t)&&_.remove(n.enabledSources,function(e){return _.toString(e)===_.toString(t)}),_.isArray(n.disabledSources)&&!A(n.disabledSources,t)&&n.disabledSources.push(t)}),n})}function I(e,t){var e=e&&e.id||e,n=[];return e&&(n.push(i.when(e)),n.push(function(e,t){var n=[];!0!==t&&!0!==t.assets||n.push(r.childAssets(e));!0!==t&&!0!==t.devices||n.push(r.childDevices(e));return i.all(n).then(_.flattenDeep).then(_.partialRight(_.map,"id"))}(e,t))),i.all(n).then(_.flattenDeep)}function A(e,t){var n=t.id||t;return _.some(e,function(e){return _.toString(e)===_.toString(n)})}function E(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=e.id?"c8y_SmartRule"===e.type?l("Edit global smart rule"):l("Edit local smart rule"):"/rules"===s.path()?l("Add global smart rule"):l("Add local smart rule");return e}function D(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=1<arguments.length?arguments[1]:void 0,n=2<arguments.length?arguments[2]:void 0;return a({title:E(),templateUrl:":::PLUGIN_PATH:::/views/add.html",controller:"SmartRuleAddCtrl",ariaLabelledBy:"modal-title",ariaDescribedBy:"modal-body",size:"lg",keyboard:!1,resolve:{context:function(){return _.cloneDeep(e)},ruleInitialObj:function(){return _.cloneDeep(n)},ruleTemplatesFilterFn:function(){return t}}})}function N(e,t){return T(t,e)}function U(e,t){e=_.cloneDeep(e);return(e=o.cleanFields(e,p)).name=d.getString("Duplicate of {{name}}",e),t&&(e.owner=t.id),e}function T(e,t){return a({templateUrl:":::PLUGIN_PATH:::/views/edit.html",controller:"SmartRuleEditCtrl",size:"sm",keyboard:!1,resolve:{ruleTemplate:function(){return _.cloneDeep(t)},rule:function(){return _.cloneDeep(e)}}})}}e.$inject=["$q","$http","c8yBase","c8yInventory","c8yUiUtil","c8yModal","c8yUser","smartRuleTemplatesSvc","gettext","gettextCatalog","$location"],angular.module("c8y.smartRules").factory("smartRulesSvc",e)}();
1
+ "use strict";!function(){function e(i,u,o,r,n,a,c,l,t,d,s){var f=o.url("service/smartrule"),h="".concat(f,"/smartrules"),p=["id","self","cepModuleId","lastUpdated","creationTime"],m=["type","cepModuleId","creationTime","lastUpdated"];return{permissionsCfgs:{create:[{anyRole:["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE","ROLE_MANAGED_OBJECT_ADMIN","ROLE_MANAGED_OBJECT_CREATE"]},{anyRole:["ROLE_CEP_MANAGEMENT_ADMIN","ROLE_SMARTRULE_ADMIN"]}]},getEmpty:function(e){var e=e||n.getContext(),t={type:"c8y_SmartRule",name:"",enabled:!0,config:{}};e.context&&e.id&&(t.c8y_Context=e,t.type="c8y_PrivateSmartRule");return t},list:function(){return u.get(h).then(o.getResData).then(_.property("rules")).then(v)},listByContext:function(e){return u.get(g({moId:e})).then(o.getResData).then(_.property("rules")).then(v)},detail:function(e){e=S({id:e});return u.get(e).then(o.getResData)},save:function(e,t,n){e=e.id?y(e):function(e,t,n){var r=S(e,!0);return function(e,t,n){return e.ruleTemplateName=t.name,function(e,t){var n=i.when(e);e.c8y_Context||t.mo?(e.enabledSources=[],e.disabledSources=void 0,n=b(e,t.mo,t.withChildren)):(e.enabledSources=void 0,e.disabledSources=[]);return n}(e,n)}(e,t,n).then(_.partial(u.post,r)).then(o.getResData)}(e,t,n);return e},remove:function(e){e=S(e,!0);return u.delete(e)},hasSource:function(e,t){t=t&&t.id||t;if(!t)return!1;if(e.disabledSources)return!A(e.disabledSources,t);if(e.enabledSources)return A(e.enabledSources,t);return!0},activate:function(e,t,n){return b(e,t,n).then(y)},deactivate:function(e,t,n){return R(e,t,n).then(y)},updateSources:function(e,t,r,u){return function(e,t,n){return t.reduce(function(e,t){return e.then(function(e){return b(e,t,n)})},i.resolve(e))}(e,t,u).then(function(e){return n=u,r.reduce(function(e,t){return e.then(function(e){return R(e,t,n)})},i.resolve(e));var n}).then(y)},addNewWithUI:D,addNewForInputAlarmAndOutputUserWithUI:function(e,t){return D({inputAlarm:e,outputUser:t})},addNewForInputDataPointWithUI:function(e){return D({inputDataPoint:e})},addNewForOutputOperationWithUI:function(e){return D({outputOperation:{template:function(e){return o.cleanFields(e,["id","self","status","deviceId","creationTime","failureReason"])}(e)}})},createInstanceWithUI:N,createInstanceWithUIByName:function(e,t){return l.getTemplateByName(e).then(function(e){return N(e,t)})},editWithUI:function(e,t){return T(e,void 0,t)},cloneWithUI:function(e,t){return c.current().then(_.partial(U,e)).then(function(e){return T(e,void 0,t)})},getRuleModalTitle:E};function v(e){return i.all(_.map(e,function(t){return l.getTemplateForRule(t).then(function(e){return _.isUndefined(e)?null:t})})).then(_.flatten).then(_.filter)}function S(e,t){var n=_.get(e,"c8y_Context.id"),t=t&&n?g({moId:n}):h;return e.id&&(t+="/".concat(e.id)),t}function g(e){return"".concat(f,"/managedObjects/").concat(e.moId,"/smartrules")}function y(e){var t=S(e,!0),e=o.cleanFields(e,m);return u.put(t,e)}function b(n,e,t){return I(e,t).then(function(e){return _.forEach(e,function(t){_.isArray(n.enabledSources)&&!A(n.enabledSources,t)&&n.enabledSources.push(t),_.isArray(n.disabledSources)&&A(n.disabledSources,t)&&_.remove(n.disabledSources,function(e){return _.toString(e)===_.toString(t)})}),n})}function R(n,e,t){return I(e,t).then(function(e){return _.forEach(e,function(t){_.isArray(n.enabledSources)&&A(n.enabledSources,t)&&_.remove(n.enabledSources,function(e){return _.toString(e)===_.toString(t)}),_.isArray(n.disabledSources)&&!A(n.disabledSources,t)&&n.disabledSources.push(t)}),n})}function I(e,t){var e=e&&e.id||e,n=[];return e&&(n.push(i.when(e)),n.push(function(e,t){var n=[];!0!==t&&!0!==t.assets||n.push(r.childAssets(e));!0!==t&&!0!==t.devices||n.push(r.childDevices(e));return i.all(n).then(_.flattenDeep).then(_.partialRight(_.map,"id"))}(e,t))),i.all(n).then(_.flattenDeep)}function A(e,t){var n=t.id||t;return _.some(e,function(e){return _.toString(e)===_.toString(n)})}function E(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=e.id?"c8y_SmartRule"===e.type?t("Edit global smart rule"):t("Edit local smart rule"):"/rules"===s.path()?t("Add global smart rule"):t("Add local smart rule");return e}function D(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=1<arguments.length?arguments[1]:void 0,n=2<arguments.length?arguments[2]:void 0;return a({title:E(),templateUrl:":::PLUGIN_PATH:::/views/add.html",controller:"SmartRuleAddCtrl",ariaLabelledBy:"modal-title",ariaDescribedBy:"modal-body",size:"lg",keyboard:!1,resolve:{context:function(){return _.cloneDeep(e)},ruleInitialObj:function(){return _.cloneDeep(n)},ruleTemplatesFilterFn:function(){return t}}})}function N(e,t){return T(t,e)}function U(e,t){e=_.cloneDeep(e);return(e=o.cleanFields(e,p)).name=d.getString("Duplicate of {{name}}",e),t&&(e.owner=t.id),e}function T(e,t,n){return a({templateUrl:":::PLUGIN_PATH:::/views/edit.html",controller:"SmartRuleEditCtrl",size:"sm",keyboard:!1,resolve:{ruleTemplate:function(){return _.cloneDeep(t)},rule:function(){return _.cloneDeep(e)},contextMoId:function(){return _.cloneDeep(n)}}})}}e.$inject=["$q","$http","c8yBase","c8yInventory","c8yUiUtil","c8yModal","c8yUser","smartRuleTemplatesSvc","gettext","gettextCatalog","$location"],angular.module("c8y.smartRules").factory("smartRulesSvc",e)}();