@c8y/ng1-modules 1017.0.249 → 1017.0.251

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";!function(){function e(o,n,i,e,s,t,a,l,r,u,c,f,d){var g=this,m="YYYY-MM-DDTHH:mm:ssZZ";function p(){o.filters={dateFrom:moment().subtract(1,"day"),dateTo:moment(),logFile:o.logTypes[0]&&o.logTypes[0].name||null,maximumLines:1e3},g.filters=o.filters}function y(e){var t=_.assign({deviceId:n.deviceId,fragmentType:"c8y_LogfileRequest",dateFrom:new Date(0).toISOString(),revert:!0,withTotalPages:!0},e);return a.list(t).then(h)}function h(e,t){o.operations&&!t||(o.operations=[]),e.forEach(function(e){o.operations.push(e)}),o.paging=e.paging}function L(){_.get(o.paging,"refresh")&&(o.realtimeAnimation=!1,o.refreshLoading=!0,o.paging.refresh().then(_.partialRight(h,!0)).finally(function(){o.refreshLoading=!1}),o.paging=null)}function v(e){if(e.c8y_LogfileRequest.file){var t=s.getIdFromUrl(e.c8y_LogfileRequest.file);if(t)return s.removeBinary(t)}return!1}function C(e){var t={id:e.id,status:e.status,c8y_LogfileRequest:null};return a.save(t)}function R(e){F(e)?o.selectedLog=e:o.selectedLog=void 0}function F(e){return e.c8y_LogfileRequest&&e.c8y_LogfileRequest.file}function q(e){return e&&"SUCCESSFUL"===e.status}function T(e){return e&&"FAILED"===e.status}function D(e,t){t&&!e?(g.shouldClose="disabled",i(function(){g.shouldClose="outsideClick"})):g.shouldClose="outsideClick"}o.requestLogfile=function(e){var t={deviceId:n.deviceId,description:c("Log file request"),c8y_LogfileRequest:{dateFrom:moment(e.dateFrom).format(m),dateTo:moment(e.dateTo).format(m),logFile:e.logFile,searchText:e.searchText||"",maximumLines:e.maximumLines}};a.createWithNotifications(t).then(function(e){e.created.then(L),e.completed.then(function(e){e.status===a.status.SUCCESSFUL?(_.assign(t,e),R(t)):e.status===a.status.FAILED&&"Operation cancelled by user."!==e.failureReason&&(e.failureReason?u.danger(f('Could not load file: "{{failureReason | translate}}".',e)):u.danger(c("Could not load file.")))},_.noop,function(e){_.assign(t,e),R(t)}).then(L)})},o.hasLogFile=F,o.selectLogfile=R,o.isBinary=function(e){return e&&e.c8y_LogfileRequest&&e.c8y_LogfileRequest.file&&!!s.getIdFromUrl(e.c8y_LogfileRequest.file)},o.download=d.download,o.cancel=function(e){return"PENDING"===e.status&&a.cancel(e).then(function(){return u.success(c("Log file request cancelled."))}).then(L)},o.remove=function(e){return r({title:c("Delete log file"),body:c("You are about to delete this log file. Do you want to proceed?"),status:"danger",labels:{ok:c("Delete")}}).then(_.partial(v,e)).then(_.partial(C,e)).then(function(){return u.success(c("Log file deleted."))}).then(L)},o.statusIcon=function(e){return a.getStyle(e).icon},o.statusClass=function(e){return a.getStyle(e).cls},o.isSuccessful=q,o.isPending=function(e){return e&&"PENDING"===e.status},o.isFailed=T,o.isCompleted=function(e){return q(e)||T(e)},o.refresh=L,o.loadNext=function(e){o.paging.loading=!0,(e?y({pageSize:e}):o.paging.next().then(h)).finally(function(){o.paging.loading=!1})},o.getOperationDesc=function(e){return e.description||c("no description available")},o.$watch("vm.datePickerToOpen",D),o.$watch("vm.datePickerFromOpen",D),o.$watch("vm.logtypeSelect.open",function(e){e||(g.shouldClose="disabled",i(function(){g.shouldClose="outsideClick"}))}),g.shouldClose="outsideClick",g.datePickerToOpen=!1,g.datePickerFromOpen=!1,t.detail(n.deviceId).then(e.getResData).then(function(e){o.logTypes=_.map(e.c8y_SupportedLogs,function(e){return{name:e}}),g.logTypes=o.logTypes}).then(p),y();var S=o.$id,I="/operations/".concat(n.deviceId),w=l.realtimeActions();_.forOwn(w,function(e){l.addListener(S,I,e,function(e,t){if(_.has(t,"c8y_LogfileRequest")){L();var n=o.selectedLog;n&&n.id===t.id&&e===w.UPDATE&&(n.c8y_LogfileRequest=t.c8y_LogfileRequest)}})}),l.start(S,I),o.$on("$destroy",function(){l.stop(S,I),l.destroySubscription(S,I)})}e.$inject=["$scope","$routeParams","$timeout","c8yBase","c8yBinary","c8yDevices","c8yDeviceControl","c8yRealtime","c8yModal","c8yAlert","gettext","gettextCatalog","logViewer"],angular.module("c8y.logViewer").controller("logViewerCtrl",e)}();
1
+ "use strict";!function(){function e(i,n,o,e,t,s,a,l,r,c,u,f,d,g){var m=this,y="YYYY-MM-DDTHH:mm:ssZZ";function p(){i.filters={dateFrom:moment().subtract(1,"day"),dateTo:moment(),logFile:i.logTypes[0]&&i.logTypes[0].name||null,maximumLines:1e3},m.filters=i.filters}function h(e){var t=_.assign({deviceId:n.deviceId,fragmentType:"c8y_LogfileRequest",dateFrom:new Date(0).toISOString(),revert:!0,withTotalPages:!0},e);return l.list(t).then(L)}function L(e,t){i.operations&&!t||(i.operations=[]),e.forEach(function(e){i.operations.push(e)}),i.paging=e.paging}function v(){_.get(i.paging,"refresh")&&(i.realtimeAnimation=!1,i.refreshLoading=!0,i.paging.refresh().then(_.partialRight(L,!0)).finally(function(){i.refreshLoading=!1}),i.paging=null)}function C(e){if(e.c8y_LogfileRequest.file){var t=s.getIdFromUrl(e.c8y_LogfileRequest.file);if(t)return s.removeBinary(t)}return!1}function R(e){var t={id:e.id,status:e.status,c8y_LogfileRequest:null};return l.save(t)}function q(e){F(e)?i.selectedLog=e:i.selectedLog=void 0}function F(e){return e.c8y_LogfileRequest&&e.c8y_LogfileRequest.file}function T(e){return e&&"SUCCESSFUL"===e.status}function D(e){return e&&"FAILED"===e.status}function S(e,t){t&&!e?(m.shouldClose="disabled",o(function(){m.shouldClose="outsideClick"})):m.shouldClose="outsideClick"}i.requestLogfile=function(e){var t={deviceId:n.deviceId,description:f("Log file request"),c8y_LogfileRequest:{dateFrom:moment(e.dateFrom).format(y),dateTo:moment(e.dateTo).format(y),logFile:e.logFile,searchText:e.searchText||"",maximumLines:e.maximumLines}};l.createWithNotifications(t).then(function(e){e.created.then(v),e.completed.then(function(e){e.status===l.status.SUCCESSFUL?(_.assign(t,e),q(t)):e.status===l.status.FAILED&&"Operation cancelled by user."!==e.failureReason&&(e.failureReason?u.danger(d('Could not load file: "{{failureReason | translate}}".',e)):u.danger(f("Could not load file.")))},_.noop,function(e){_.assign(t,e),q(t)}).then(v)})},i.hasLogFile=F,i.selectLogfile=q,i.isBinary=function(e){return e&&e.c8y_LogfileRequest&&e.c8y_LogfileRequest.file&&(!!s.getIdFromUrl(e.c8y_LogfileRequest.file)||t.isEventBinary(e.c8y_LogfileRequest.file))},i.download=g.download,i.cancel=function(e){return"PENDING"===e.status&&l.cancel(e).then(function(){return u.success(f("Log file request cancelled."))}).then(v)},i.remove=function(e){return c({title:f("Delete log file"),body:f("You are about to delete this log file. Do you want to proceed?"),status:"danger",labels:{ok:f("Delete")}}).then(_.partial(C,e)).then(_.partial(R,e)).then(function(){return u.success(f("Log file deleted."))}).then(v)},i.statusIcon=function(e){return l.getStyle(e).icon},i.statusClass=function(e){return l.getStyle(e).cls},i.isSuccessful=T,i.isPending=function(e){return e&&"PENDING"===e.status},i.isFailed=D,i.isCompleted=function(e){return T(e)||D(e)},i.refresh=v,i.loadNext=function(e){i.paging.loading=!0,(e?h({pageSize:e}):i.paging.next().then(L)).finally(function(){i.paging.loading=!1})},i.getOperationDesc=function(e){return e.description||f("no description available")},i.$watch("vm.datePickerToOpen",S),i.$watch("vm.datePickerFromOpen",S),i.$watch("vm.logtypeSelect.open",function(e){e||(m.shouldClose="disabled",o(function(){m.shouldClose="outsideClick"}))}),m.shouldClose="outsideClick",m.datePickerToOpen=!1,m.datePickerFromOpen=!1,a.detail(n.deviceId).then(e.getResData).then(function(e){i.logTypes=_.map(e.c8y_SupportedLogs,function(e){return{name:e}}),m.logTypes=i.logTypes}).then(p),h();var I=i.$id,w="/operations/".concat(n.deviceId),E=r.realtimeActions();_.forOwn(E,function(e){r.addListener(I,w,e,function(e,t){if(_.has(t,"c8y_LogfileRequest")){v();var n=i.selectedLog;n&&n.id===t.id&&e===E.UPDATE&&(n.c8y_LogfileRequest=t.c8y_LogfileRequest)}})}),r.start(I,w),i.$on("$destroy",function(){r.stop(I,w),r.destroySubscription(I,w)})}e.$inject=["$scope","$routeParams","$timeout","c8yBase","c8yEvents","c8yBinary","c8yDevices","c8yDeviceControl","c8yRealtime","c8yModal","c8yAlert","gettext","gettextCatalog","logViewer"],angular.module("c8y.logViewer").controller("logViewerCtrl",e)}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c8y/ng1-modules",
3
- "version": "1017.0.249",
3
+ "version": "1017.0.251",
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,c,a,t,n,r,o,u,s,l,d,e,f,h,g,v,m){var p,A=c.deviceId||c.groupId,S={},E={},R={done:!1,inProgress:!1},b={true:{text:v("Active"),icon:"check-circle",cls:"text-success"},false:{text:v("Inactive"),icon:"ban",cls:"text-danger"}},y=d.getContext(),x=v("Global smart rules");function I(){return a.when().then(C).then(T).then(P).then(U).then(M).catch(N)}function C(){R.inProgress=!0}function M(){R.inProgress=!1,R.done=!0,R.error=!1}function N(e){e.data&&e.data.message&&l.danger(e.data.message),R.inProgress=!1,R.done=!0,R.error=!0}function T(){return h.list().then(D)}function D(e){_.forEach(e||[],function(e){S[e.name]=e})}function P(){var e=A?g.listByContext(A):a.resolve([]),t=f.hasPermissions().then(function(e){return e?g.list():a.when([])});return a.all({listByContext:e,list:t}).then(function(e){i.rules=function(e){var t=e;A&&(t=_.reject(e,function(e){var n=new RegExp("".concat(e,"/dashboard"));return function(e){var t=_.get(e,"config.url","");return w(e)&&!n.test(t)}}(A)));return t}(_.concat(e.listByContext,e.list))})}function w(e){return"sendDashboardsViaEmail"===e.ruleTemplateName}function O(e){return g.hasSource(e,A)}function U(){return Array.isArray(i.rules)&&0<i.rules.length?function(){var e=d.getContext();return null!==e.context?r.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]=L(e)})}):a.resolve()}():a.resolve()}function L(t){return _.filter(i.children,function(e){return g.hasSource(t,e)})}_.assign(i,{isOpen:{},moId:A,loadingStatus:R,refresh:I,paging:{refresh:I},ruleTemplates:S,getLinkToDM:function(){var e={deviceId:A};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){s({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:O,getChildrenEnabledForSmartRule:L,toggleRuleActivationForContextMO:function(e){if(O(e))return g.deactivate(e,A,!1).then(function(){l.success(m.getString('Smart rule "{{name}}" deactivated.',e))});return g.activate(e,A,!1).then(function(){l.success(m.getString('Smart rule "{{name}}" activated.',e))})},toggleRuleActivationForChildrenMOs:function(e,n){var r=[];return _.forEach(n,function(t){!_.find(i.ruleChildren[e.id],function(e){return e.id===t.id})&&r.push(g.activate(e,t,!1))}),_.forEach(i.ruleChildren[e.id],function(t){!_.find(n,function(e){return t.id===e.id})&&r.push(g.deactivate(e,t,!1))}),a.all(r).then(P).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")}},n=e.enabled&&O(e)?"deactivate":"activate",r=c.groupId?"group":"object";return r=c.deviceId?"device":r,t[n]["for ".concat(r)]},type:function(e){var t,n=S[e.ruleTemplateName];n&&(t=n.label.full?m.getString(n.label.full):"".concat(m.getString(n.label.input)," ").concat(m.getString(n.label.output)));return t},status:function(e){return b[e.enabled].text},statusIcon:function(e){return b[e.enabled].icon},statusClass:function(e){return b[e.enabled].cls},showTitle:function(){return null!==d.getContext().context},title:x,context:y,inputIcon:function(e){var t,n=S[e.ruleTemplateName];n&&(t=n.paramGroups.input.icon);return t},outputIcon:function(e){var t,n=S[e.ruleTemplateName];n&&(t=n.paramGroups.output.icon);return t},canAddRules:function(e){var t=_.get(S,"".concat(_.get(e,"ruleTemplateName"),"._active")),n=E.canAddRules;e&&!t&&(n=!1);if(_.isUndefined(n)){var r;r=i.context?{adminMOs:[i.context.id]}:{allRoles:["ROLE_INVENTORY_ADMIN"],anyRole:["ROLE_SMARTRULE_ADMIN","ROLE_CEP_MANAGEMENT_ADMIN"]},E.canAddRules=u.isAllowed(r).then(function(e){return E.canAddRules=e,E.canAddRules}),n=!1}return n},canModify:function(t){E.rules=E.rules||{};var n=E.rules,e=n[t.id];_.isUndefined(e)&&(n[t.id]=u.isAllowed({adminMOs:[t.id]}).then(function(e){return n[t.id]=e,n[t.id]}),e=!1);return e},canInspect:function(){var e=E.canInspect;_.isUndefined(e)&&(E.canInspect=a.all({administrationAccess:o.listByUser().then(function(e){return!!_.find(e,{contextPath:"administration"})}),eventProcessingAccess:u.isAllowed({anyRole:["ROLE_CEP_MANAGEMENT_READ","ROLE_CEP_MANAGEMENT_ADMIN"]}),eventProcessingEnabled:g.eventProcessingEnabled()}).then(function(e){return E.canInspect=e.administrationAccess&&e.eventProcessingAccess&&e.eventProcessingEnabled,E.canInspect}),e=!1);return e},canApplyOnChildren:function(e){return!w(e)},canSeeSection:function(){var e=E.canSeeSection;_.isUndefined(e)&&(E.canSeeSection=(n.checkIfModulesExist(["c8y.cockpit.config"])?f.shouldShowLocalSmartRules():a.when(!1)).then(function(e){return E.canSeeSection=e,E.canSeeSection}),e=!1);return e}}),I(),null===d.getContext().context&&e.changeTitle({title:x}),"device"===y.context&&n.getStaticLinkTemplate("devicemanagementDeviceDetails").then(function(e){p=e})}e.$inject=["$scope","$routeParams","$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,c,n,t,r,o,a,u,l,s,d,e,f,h,g,v,m){var p,A=c.deviceId||c.groupId,S={},R={},b={done:!1,inProgress:!1},y={true:{text:v("Active"),icon:"check-circle",cls:"text-success"},false:{text:v("Inactive"),icon:"ban",cls:"text-danger"}},E=d.getContext(),x=v("Global smart rules");function I(){return n.when().then(C).then(T).then(P).then(U).then(M).catch(N)}function C(){b.inProgress=!0}function M(){b.inProgress=!1,b.done=!0,b.error=!1}function N(e){e.data&&e.data.message&&s.danger(e.data.message),b.inProgress=!1,b.done=!0,b.error=!0}function T(){return h.list().then(D)}function D(e){_.forEach(e||[],function(e){S[e.name]=e})}function P(){var e=A?g.listByContext(A):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;A&&(t=_.reject(e,function(e){var n=new RegExp("".concat(e,"/dashboard"));return function(e){var t=_.get(e,"config.url","");return w(e)&&!n.test(t)}}(A)));return t}(_.concat(e.listByContext,e.list))})}function w(e){return"sendDashboardsViaEmail"===e.ruleTemplateName}function O(e){return g.hasSource(e,A)}function U(){return Array.isArray(i.rules)&&0<i.rules.length?function(){var e=d.getContext();return null!==e.context?o.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]=L(e)})}):n.resolve()}():n.resolve()}function L(t){return _.filter(i.children,function(e){return g.hasSource(t,e)})}_.assign(i,{isOpen:{},moId:A,loadingStatus:b,refresh:I,paging:{refresh:I},ruleTemplates:S,getLinkToDM:function(){var e={deviceId:A};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){l({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 s.success(v("Smart rule deleted."))})},hasSource:O,getChildrenEnabledForSmartRule:L,toggleRuleActivationForContextMO:function(e){if(O(e))return g.deactivate(e,A,!1).then(function(){s.success(m.getString('Smart rule "{{name}}" deactivated.',e))});return g.activate(e,A,!1).then(function(){s.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(P).then(U).then(function(){s.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")}},n=e.enabled&&O(e)?"deactivate":"activate",r=c.groupId?"group":"object";return r=c.deviceId?"device":r,t[n]["for ".concat(r)]},type:function(e){var t,n=S[e.ruleTemplateName];n&&(t=n.label.full?m.getString(n.label.full):"".concat(m.getString(n.label.input)," ").concat(m.getString(n.label.output)));return t},status:function(e){return y[e.enabled].text},statusIcon:function(e){return y[e.enabled].icon},statusClass:function(e){return y[e.enabled].cls},showTitle:function(){return null!==d.getContext().context},title:x,context:E,inputIcon:function(e){var t,n=S[e.ruleTemplateName];n&&(t=n.paramGroups.input.icon);return t},outputIcon:function(e){var t,n=S[e.ruleTemplateName];n&&(t=n.paramGroups.output.icon);return t},canAddRules:function(e){var t=_.get(S,"".concat(_.get(e,"ruleTemplateName"),"._active")),n=R.canAddRules;e&&!t&&(n=!1);if(_.isUndefined(n)){var r;r=i.context?{adminMOs:[i.context.id]}:{allRoles:["ROLE_INVENTORY_ADMIN"],anyRole:["ROLE_SMARTRULE_ADMIN","ROLE_CEP_MANAGEMENT_ADMIN"]},R.canAddRules=u.isAllowed(r).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]=u.isAllowed({adminMOs:[t.id]}).then(function(e){return n[t.id]=e,n[t.id]}),e=!1);return e},canInspect:function(){var e=R.canInspect;_.isUndefined(e)&&(R.canInspect=n.all({administrationAccess:a.listByUser().then(function(e){return!!_.find(e,{contextPath:"administration"})}),eventProcessingAccess:u.isAllowed({anyRole:["ROLE_CEP_MANAGEMENT_READ","ROLE_CEP_MANAGEMENT_ADMIN"]}),eventProcessingEnabled:g.eventProcessingEnabled()}).then(function(e){return R.canInspect=e.administrationAccess&&e.eventProcessingAccess&&e.eventProcessingEnabled,R.canInspect}),e=!1);return e},canApplyOnChildren:function(e){return!w(e)},canSeeSection:function(){var e=R.canSeeSection;_.isUndefined(e)&&(R.canSeeSection=(r.checkIfModulesExist(["c8y.cockpit.config"])?f.shouldShowLocalSmartRules():n.when(!1)).then(function(e){return R.canSeeSection=e,R.canSeeSection}),e=!1);return e}}),I(),null===d.getContext().context&&e.changeTitle({title:x}),"device"===E.context&&r.getStaticLinkTemplate("devicemanagementDeviceDetails").then(function(e){p=e})}e.$inject=["$scope","$routeParams","$q","$interpolate","c8yBase","c8yInventory","c8yApplication","c8yPermissions","c8yModal","c8yAlert","c8yUiUtil","c8yTitle","c8ySmartRulesAvailability","smartRuleTemplatesSvc","smartRulesSvc","gettext","gettextCatalog"],angular.module("c8y.smartRules").controller("SmartRulesListCtrl",e)}();
@@ -1 +1 @@
1
- "use strict";!function(){function e(u,i,a,o,r,c,t,n,l,s){var d=a.url("service/smartrule"),f="".concat(d,"/smartrules"),h=["id","self","cepModuleId","lastUpdated","creationTime"],p=["type","cepModuleId","creationTime","lastUpdated"];return{eventProcessingEnabled:r.shouldShowEventProcessing,permissionsCfgs:{create:[{anyRole:["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE"]},{anyRole:["ROLE_CEP_MANAGEMENT_ADMIN","ROLE_SMARTRULE_ADMIN"]}]},getEmpty:function(e){var t=e||r.getContext(),n={type:"c8y_SmartRule",name:"",enabled:!0,config:{}};t.context&&t.id&&(n.c8y_Context=t,n.type="c8y_PrivateSmartRule");return n},list:function(){return i.get(f).then(a.getResData).then(_.property("rules")).then(m)},listByContext:function(e){return i.get(S({moId:e})).then(a.getResData).then(_.property("rules")).then(m)},detail:function(e){var t=v({id:e});return i.get(t).then(a.getResData)},save:function(e,t,n){var r;r=e.id?g(e):function(e,t,n){var r=v(e,!0);return function(e,t,n){return e.ruleTemplateName=t.name,function(e,t){var n=u.when(e);return e.c8y_Context||t.mo?(e.enabledSources=[],e.disabledSources=void 0,n=y(e,t.mo,t.withChildren)):(e.enabledSources=void 0,e.disabledSources=[]),n}(e,n)}(e,t,n).then(_.partial(i.post,r)).then(a.getResData)}(e,t,n);return r},remove:function(e){var t=v(e,!0);return i.delete(t)},hasSource:function(e,t){var n=t&&t.id||t;if(!n)return!1;if(e.disabledSources)return!I(e.disabledSources,n);if(e.enabledSources)return I(e.enabledSources,n);return!0},activate:function(e,t,n){return y(e,t,n).then(g)},deactivate:function(e,t,n){return function(n,e,t){return b(e,t).then(function(e){return _.forEach(e,function(t){_.isArray(n.enabledSources)&&I(n.enabledSources,t)&&_.remove(n.enabledSources,function(e){return _.toString(e)===_.toString(t)}),_.isArray(n.disabledSources)&&!I(n.disabledSources,t)&&n.disabledSources.push(t)}),n})}(e,t,n).then(g)},addNewWithUI:R,addNewForInputAlarmAndOutputUserWithUI:function(e,t){return R({inputAlarm:e,outputUser:t})},addNewForInputDataPointWithUI:function(e){return R({inputDataPoint:e})},addNewForOutputOperationWithUI:function(e){return R({outputOperation:{template:function(e){return a.cleanFields(e,["id","self","status","deviceId","creationTime","failureReason"])}(e)}})},createInstanceWithUI:U,createInstanceWithUIByName:function(e,t){return n.getTemplateByName(e).then(function(e){return U(e,t)})},editWithUI:function(e){return D(e,void 0)},cloneWithUI:function(e){return t.current().then(_.partial(A,e)).then(D)}};function m(e){return u.all(_.map(e,function(t){return n.getTemplateForRule(t).then(function(e){return _.isUndefined(e)?null:t})})).then(_.flatten).then(_.filter)}function v(e,t){var n=_.get(e,"c8y_Context.id"),r=t&&n?S({moId:n}):f;return e.id&&(r+="/".concat(e.id)),r}function S(e){return"".concat(d,"/managedObjects/").concat(e.moId,"/smartrules")}function g(e){var t=v(e,!0),n=a.cleanFields(e,p);return i.put(t,n)}function y(n,e,t){return b(e,t).then(function(e){return _.forEach(e,function(t){_.isArray(n.enabledSources)&&!I(n.enabledSources,t)&&n.enabledSources.push(t),_.isArray(n.disabledSources)&&I(n.disabledSources,t)&&_.remove(n.disabledSources,function(e){return _.toString(e)===_.toString(t)})}),n})}function b(e,t){var n=e&&e.id||e,r=[];return n&&(r.push(u.when(n)),r.push(function(e,t){var n=[];!0!==t&&!0!==t.assets||n.push(o.childAssets(e));!0!==t&&!0!==t.devices||n.push(o.childDevices(e));return u.all(n).then(_.flattenDeep).then(_.partialRight(_.map,"id"))}(n,t))),u.all(r).then(_.flattenDeep)}function I(e,t){var n=t.id||t;return _.some(e,function(e){return _.toString(e)===_.toString(n)})}function R(){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 c({title:l("Add global smart rule"),templateUrl:":::PLUGIN_PATH:::/views/add.html",controller:"SmartRuleAddCtrl",ariaLabelledBy:"modal-title",ariaDescribedBy:"modal-body",size:"lg",resolve:{context:function(){return _.cloneDeep(e)},ruleInitialObj:function(){return _.cloneDeep(n)},ruleTemplatesFilterFn:function(){return t}}})}function U(e,t){return D(t,e)}function A(e,t){var n=_.cloneDeep(e);return(n=a.cleanFields(n,h)).name=s.getString("Duplicate of {{name}}",n),t&&(n.owner=t.id),n}function D(e,t){return c({templateUrl:":::PLUGIN_PATH:::/views/edit.html",controller:"SmartRuleEditCtrl",size:"sm",resolve:{ruleTemplate:function(){return _.cloneDeep(t)},rule:function(){return _.cloneDeep(e)}}})}}e.$inject=["$q","$http","c8yBase","c8yInventory","c8yUiUtil","c8yModal","c8yUser","smartRuleTemplatesSvc","gettext","gettextCatalog"],angular.module("c8y.smartRules").factory("smartRulesSvc",e)}();
1
+ "use strict";!function(){function e(u,i,o,a,r,c,t,n,l,s){var d=o.url("service/smartrule"),f="".concat(d,"/smartrules"),h=["id","self","cepModuleId","lastUpdated","creationTime"],p=["type","cepModuleId","creationTime","lastUpdated"];return{eventProcessingEnabled:r.shouldShowEventProcessing,permissionsCfgs:{create:[{anyRole:["ROLE_INVENTORY_ADMIN","ROLE_INVENTORY_CREATE"]},{anyRole:["ROLE_CEP_MANAGEMENT_ADMIN","ROLE_SMARTRULE_ADMIN"]}]},getEmpty:function(e){var t=e||r.getContext(),n={type:"c8y_SmartRule",name:"",enabled:!0,config:{}};t.context&&t.id&&(n.c8y_Context=t,n.type="c8y_PrivateSmartRule");return n},list:function(){return i.get(f).then(o.getResData).then(_.property("rules")).then(m)},listByContext:function(e){return i.get(S({moId:e})).then(o.getResData).then(_.property("rules")).then(m)},detail:function(e){var t=v({id:e});return i.get(t).then(o.getResData)},save:function(e,t,n){var r;r=e.id?g(e):function(e,t,n){var r=v(e,!0);return function(e,t,n){return e.ruleTemplateName=t.name,function(e,t){var n=u.when(e);return e.c8y_Context||t.mo?(e.enabledSources=[],e.disabledSources=void 0,n=y(e,t.mo,t.withChildren)):(e.enabledSources=void 0,e.disabledSources=[]),n}(e,n)}(e,t,n).then(_.partial(i.post,r)).then(o.getResData)}(e,t,n);return r},remove:function(e){var t=v(e,!0);return i.delete(t)},hasSource:function(e,t){var n=t&&t.id||t;if(!n)return!1;if(e.disabledSources)return!R(e.disabledSources,n);if(e.enabledSources)return R(e.enabledSources,n);return!0},activate:function(e,t,n){return y(e,t,n).then(g)},deactivate:function(e,t,n){return b(e,t,n).then(g)},updateSources:function(e,t,n,r){return function(e,t,n){return t.reduce(function(e,t){return e.then(function(e){return y(e,t,n)})},u.resolve(e))}(e,t,r).then(function(e){return function(e,t,n){return t.reduce(function(e,t){return e.then(function(e){return b(e,t,n)})},u.resolve(e))}(e,n,r)}).then(g)},addNewWithUI:U,addNewForInputAlarmAndOutputUserWithUI:function(e,t){return U({inputAlarm:e,outputUser:t})},addNewForInputDataPointWithUI:function(e){return U({inputDataPoint:e})},addNewForOutputOperationWithUI:function(e){return U({outputOperation:{template:function(e){return o.cleanFields(e,["id","self","status","deviceId","creationTime","failureReason"])}(e)}})},createInstanceWithUI:A,createInstanceWithUIByName:function(e,t){return n.getTemplateByName(e).then(function(e){return A(e,t)})},editWithUI:function(e){return E(e,void 0)},cloneWithUI:function(e){return t.current().then(_.partial(D,e)).then(E)}};function m(e){return u.all(_.map(e,function(t){return n.getTemplateForRule(t).then(function(e){return _.isUndefined(e)?null:t})})).then(_.flatten).then(_.filter)}function v(e,t){var n=_.get(e,"c8y_Context.id"),r=t&&n?S({moId:n}):f;return e.id&&(r+="/".concat(e.id)),r}function S(e){return"".concat(d,"/managedObjects/").concat(e.moId,"/smartrules")}function g(e){var t=v(e,!0),n=o.cleanFields(e,p);return i.put(t,n)}function y(n,e,t){return I(e,t).then(function(e){return _.forEach(e,function(t){_.isArray(n.enabledSources)&&!R(n.enabledSources,t)&&n.enabledSources.push(t),_.isArray(n.disabledSources)&&R(n.disabledSources,t)&&_.remove(n.disabledSources,function(e){return _.toString(e)===_.toString(t)})}),n})}function b(n,e,t){return I(e,t).then(function(e){return _.forEach(e,function(t){_.isArray(n.enabledSources)&&R(n.enabledSources,t)&&_.remove(n.enabledSources,function(e){return _.toString(e)===_.toString(t)}),_.isArray(n.disabledSources)&&!R(n.disabledSources,t)&&n.disabledSources.push(t)}),n})}function I(e,t){var n=e&&e.id||e,r=[];return n&&(r.push(u.when(n)),r.push(function(e,t){var n=[];!0!==t&&!0!==t.assets||n.push(a.childAssets(e));!0!==t&&!0!==t.devices||n.push(a.childDevices(e));return u.all(n).then(_.flattenDeep).then(_.partialRight(_.map,"id"))}(n,t))),u.all(r).then(_.flattenDeep)}function R(e,t){var n=t.id||t;return _.some(e,function(e){return _.toString(e)===_.toString(n)})}function U(){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 c({title:l("Add global smart rule"),templateUrl:":::PLUGIN_PATH:::/views/add.html",controller:"SmartRuleAddCtrl",ariaLabelledBy:"modal-title",ariaDescribedBy:"modal-body",size:"lg",resolve:{context:function(){return _.cloneDeep(e)},ruleInitialObj:function(){return _.cloneDeep(n)},ruleTemplatesFilterFn:function(){return t}}})}function A(e,t){return E(t,e)}function D(e,t){var n=_.cloneDeep(e);return(n=o.cleanFields(n,h)).name=s.getString("Duplicate of {{name}}",n),t&&(n.owner=t.id),n}function E(e,t){return c({templateUrl:":::PLUGIN_PATH:::/views/edit.html",controller:"SmartRuleEditCtrl",size:"sm",resolve:{ruleTemplate:function(){return _.cloneDeep(t)},rule:function(){return _.cloneDeep(e)}}})}}e.$inject=["$q","$http","c8yBase","c8yInventory","c8yUiUtil","c8yModal","c8yUser","smartRuleTemplatesSvc","gettext","gettextCatalog"],angular.module("c8y.smartRules").factory("smartRulesSvc",e)}();