Browse Source

UI: Introduce additionalParams for custom widget actions.

pull/494/head
Igor Kulikov 9 years ago
parent
commit
84ed34d4f0
  1. 2
      ui/src/app/components/widget/action/widget-action-dialog.tpl.html
  2. 9
      ui/src/app/components/widget/widget.controller.js
  3. 4
      ui/src/app/widget/lib/alarms-table-widget.js

2
ui/src/app/components/widget/action/widget-action-dialog.tpl.html

@ -120,7 +120,7 @@
</div>
<tb-js-func ng-if="vm.action.type == vm.types.widgetActionTypes.custom.value"
ng-model="vm.action.customFunction"
function-args="{{ ['$event', 'widgetContext', 'entityId'] }}"
function-args="{{ ['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams'] }}"
validation-args="{{ [] }}">
</tb-js-func>
</fieldset>

9
ui/src/app/components/widget/widget.controller.js

@ -444,7 +444,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele
}
}
function handleWidgetAction($event, descriptor, entityId, entityName) {
function handleWidgetAction($event, descriptor, entityId, entityName, additionalParams) {
var type = descriptor.type;
var targetEntityParamName = descriptor.stateEntityParamName;
var targetEntityId;
@ -485,8 +485,11 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele
var customFunction = descriptor.customFunction;
if (angular.isDefined(customFunction) && customFunction.length > 0) {
try {
var customActionFunction = new Function('$event', 'widgetContext', 'entityId', 'entityName', customFunction);
customActionFunction($event, widgetContext, entityId, entityName);
if (!additionalParams) {
additionalParams = {};
}
var customActionFunction = new Function('$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', customFunction);
customActionFunction($event, widgetContext, entityId, entityName, additionalParams);
} catch (e) {
//
}

4
ui/src/app/widget/lib/alarms-table-widget.js

@ -298,7 +298,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia
entityId = vm.currentAlarm.originator;
entityName = vm.currentAlarm.originatorName;
}
vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName);
vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, { alarm: vm.currentAlarm });
}
}
@ -312,7 +312,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia
entityId = alarm.originator;
entityName = alarm.originatorName;
}
vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName);
vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, { alarm: vm.currentAlarm });
}
function isCurrent(alarm) {

Loading…
Cancel
Save