Solutions ISA7
Solutions ISA7

Reputation: 1

Thingsboard Alarm Widget - Custom Action for "On row click "

I have an alarm widget in a higher level dashboard state concentrating alarms coming from many different devices. I need to implement the following: when clicking in the alarm row it is necessary to open a new dashboard state with the details of the alarm originator device. For that I am using the widget "On row click" action of the type "Custom Action". Below the code I am using:

var $injector = widgetContext.$scope.$injector;

$injector.get('deviceService').getDevice (entityId.id).then(function(device)
{
var params = {
entityId: entityId,
entityName: entityName
};

Widgetcontext.statecontroller.openState('operacao', params, false);
});

However, when a row is clicked in the widget, nothing happens.

Could someone please help understand what I am doing wrong here?

Thanks.

Upvotes: 0

Views: 1415

Answers (1)

Nathan Almeida
Nathan Almeida

Reputation: 199

this may help you:

so the code I use to move from one dash to another is:

ctx.stateController.updateState(page, params, false);

Where page here is a var with the name of the page you set up on your dashboard

params needs normally to pass entityId and entityName:

var params = {
    entityId: entityId,
    entityName: entityName,
    rowIndex: rowIndex
}  

and that's pretty much it, rowIndex here is a value you can pass over to the next page.

 $scope.doSomething = function($event) {
    if ($event) {
        $event.stopPropagation();
    }

    var rowIndex = $event.currentTarget.rowIndex;
    entity = self.ctx.defaultSubscription.data[0].datasource;


    var entityId = entity.entityId;
    var entityName = entity.entityName;
    var params = {
        entityId: entityId,
        entityName: entityName,
        rowIndex: rowIndex
    };


    var page = 'sets';
    ctx.stateController.updateState(page, params, false);
}

and this is an example of how I use this

Upvotes: 0

Related Questions