@c8y/ng1-modules 1019.6.10 → 1019.7.10
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/core/ui/navigation/breadcrumbsSet.component.js +1 -1
- package/package.json +1 -1
- package/smartRestEditor/views/preview.html +1 -1
- package/smartRestEditor/views/responses.html +19 -20
- package/smartRestEditorUI/index.js +1 -1
- package/smartRules/controllers/edit.js +1 -1
- package/smartRules/list/smartRulesList.component.js +1 -1
- package/smartRules/services/smartRules.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(){function e(e){var t=this;_.assign(t,{$onInit:function(){t.setController.addItem(t)},$onDestroy:function(){t.setController.removeItem(t)},getCrumb:function(){return _.pick(t,["icon","label","path","translate"])},$el:e})}function t(e,t){var n=this,r=[];_.assign(n,{$onInit:function(){e.hide(),t.addLiveBreadcrumbsController(n)},$onDestroy:function(){t.removeLiveBreadcrumbsController(n)},getBreadcrumbs:function(){var t=e.find("c8y-breadcrumbs-item");return _(n.paths).sortBy(function(e){return t.index(e.$el[0])}).reverse().map(function(e){return e.getCrumb()}).value()},paths:r,addItem:function(e){r.push(e),t.$emit("update")},removeItem:function(e){_.pull(r,e),t.$emit("update")}})}e.$inject=["$element"],t.$inject=["$element","c8yBreadcrumbs"],angular.module("c8y.ui").component("c8yBreadcrumbsSet",{template:"",controller:t}).component("c8yBreadcrumbsItem",{template:"",require:{setController:"^c8yBreadcrumbsSet"},controller:e,bindings:{icon:"@",label:"@",path:"@",translate:"@"}})}();
|
|
1
|
+
"use strict";!function(){function e(e){var t=this;_.assign(t,{$onInit:function(){t.setController.addItem(t)},$onChanges:function(e){_.forOwn(e,function(e){return!!e.isFirstChange()||(t.setController.emitUpdate(),!1)})},$onDestroy:function(){t.setController.removeItem(t)},getCrumb:function(){return _.pick(t,["icon","label","path","translate"])},$el:e})}function t(e,t){var n=this,r=[];_.assign(n,{$onInit:function(){e.hide(),t.addLiveBreadcrumbsController(n)},$onDestroy:function(){t.removeLiveBreadcrumbsController(n)},getBreadcrumbs:function(){var t=e.find("c8y-breadcrumbs-item");return _(n.paths).sortBy(function(e){return t.index(e.$el[0])}).reverse().map(function(e){return e.getCrumb()}).value()},paths:r,addItem:function(e){r.push(e),t.$emit("update")},removeItem:function(e){_.pull(r,e),t.$emit("update")},emitUpdate:function(){t.$emit("update")}})}e.$inject=["$element"],t.$inject=["$element","c8yBreadcrumbs"],angular.module("c8y.ui").component("c8yBreadcrumbsSet",{template:"",controller:t}).component("c8yBreadcrumbsItem",{template:"",require:{setController:"^c8yBreadcrumbsSet"},controller:e,bindings:{icon:"@",label:"@",path:"@",translate:"@"}})}();
|
package/package.json
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
<c8y-breadcrumbs-set>
|
|
2
|
-
<c8y-breadcrumbs-item
|
|
3
|
-
icon="c8y-smart-rest"
|
|
4
|
-
label="{{ 'Responses' | translate }}"
|
|
5
|
-
></c8y-breadcrumbs-item>
|
|
6
|
-
<c8y-breadcrumbs-item
|
|
7
|
-
icon="c8y-smart-rest"
|
|
8
|
-
label="{{ $ctrl.template.name }}"
|
|
9
|
-
></c8y-breadcrumbs-item>
|
|
10
|
-
<c8y-breadcrumbs-item
|
|
11
|
-
icon="c8y-smart-rest"
|
|
12
|
-
label="{{ 'SmartREST templates' | translate }}"
|
|
13
|
-
path="#smart-rest-templates"
|
|
14
|
-
></c8y-breadcrumbs-item>
|
|
15
|
-
<c8y-breadcrumbs-item
|
|
16
|
-
icon="c8y-device-protocols"
|
|
17
|
-
label="{{ 'Device types' | translate }}"
|
|
18
|
-
></c8y-breadcrumbs-item>
|
|
19
|
-
</c8y-breadcrumbs-set>
|
|
20
|
-
|
|
21
1
|
<div ng-controller="SmartRestTemplateDetailsCtrl as $ctrl">
|
|
2
|
+
<c8y-breadcrumbs-set>
|
|
3
|
+
<c8y-breadcrumbs-item
|
|
4
|
+
icon="c8y-smart-rest"
|
|
5
|
+
label="{{ 'Responses' | translate }}"
|
|
6
|
+
></c8y-breadcrumbs-item>
|
|
7
|
+
<c8y-breadcrumbs-item
|
|
8
|
+
icon="c8y-smart-rest"
|
|
9
|
+
label="{{ $ctrl.template.name }}"
|
|
10
|
+
></c8y-breadcrumbs-item>
|
|
11
|
+
<c8y-breadcrumbs-item
|
|
12
|
+
icon="c8y-smart-rest"
|
|
13
|
+
label="{{ 'SmartREST templates' | translate }}"
|
|
14
|
+
path="#smart-rest-templates"
|
|
15
|
+
></c8y-breadcrumbs-item>
|
|
16
|
+
<c8y-breadcrumbs-item
|
|
17
|
+
icon="c8y-device-protocols"
|
|
18
|
+
label="{{ 'Device types' | translate }}"
|
|
19
|
+
></c8y-breadcrumbs-item>
|
|
20
|
+
</c8y-breadcrumbs-set>
|
|
22
21
|
<div class="card content-fullpage split-view--5-7">
|
|
23
22
|
<div
|
|
24
23
|
class="card-block flex-no-shrink bg-level-1 large-padding p-t-24 p-b-24 separator-bottom grid__col--fullspan"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(){function t(t,
|
|
1
|
+
"use strict";!function(){function t(t,r,e,a,i,c){var n="smart-rest-templates",o="".concat(a,"/views"),a=c("SmartREST templates"),a={parent:c("Device types"),name:a,path:n,icon:"c8y-smart-rest",routerLinkExact:!1,priority:1e3},n="/".concat(n),s={templateUrl:"".concat(o,"/list.html")},l="".concat(n,"/:smartRestTemplateId"),c=[{name:c("Messages"),icon:"internal",templateUrl:"".concat(o,"/requests.html"),priority:3e3},{name:c("Responses"),icon:"external",templateUrl:"".concat(o,"/responses.html"),priority:2e3},{name:c("CSV preview"),icon:"file-code-o",templateUrl:"".concat(o,"/preview.html"),priority:1e3}],m={data:["$q",function(t){return t.when({templateUrl:"".concat(o,"/title.html")})}]},p={},n=(p[n]=[s],p[l]=c,{});n[l]=m,t.addNavigation(a),_.each(p,function(t,e){_.each(t,function(t){r.when(e,t)})}),_.each(n,function(t){e.addTitle(l,t)})}t.$inject=["c8yNavigatorProvider","c8yViewsProvider","c8yTitleProvider","smartRestEditorPluginPath","c8yBreadcrumbsProvider","gettext"],angular.module("c8y.smartRestEditorUI",["c8y.smartRestEditor"]).config(t)}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(){function e(t,e,n,s,i,a,l,r,u,o,c,d){var
|
|
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,
|
|
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)}();
|