具有实体视图的Thingsboard仪表板实体表 [英] Thingsboard Dashboard Entities table with Entity Views

查看:1271
本文介绍了具有实体视图的Thingsboard仪表板实体表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与 Thingsboard仪表板自定义操作NullInjectorError

我使用来自实体别名(例如'power_sensor'类型的实体视图")的数据源设置实体表小部件.

I setup Entities table widget with Datasources from Entity alias like "Entity Views of type 'power_sensor'".

这个想法很简单:

  • 如果实体视图"的名称为"Powermeter1", -然后转到Dashboard状态1
  • 如果它被称为"Powermeter2",则不然. -转到控制台状态2
  • if Entity View's name is "Powermeter1" - then goto Dashboard state 1
  • else if it is called "Powermeter2" - goto Dashboard state 2

现在,我将为在行上单击"创建自定义操作,但是失败.我很愿意根据

Now I'm going to create Custom action for "On row click " but fail. I rty to modify @lee-sangjun's code according to entity.service API like this:

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

$injector.get(widgetContext.entityService.get('entityViewService')).getEntity(entityId.id).subscribe(function(entity) {
        if (entity.name == 'Powermeter1') {
            openDashboardState('energy_state_1')
        }
        else if(entity.name == 'Powermeter2') {
            openDashboardState('water_state_2')
        }
});

function openDashboardState(stateId) {
    var params = {
        entityId: entityId,
        entityName: entityName
    }

    widgetContext.stateController.openState(stateId, params,
        false);
}

但是什么也没发生.我需要做些什么才能使其正常工作?

But nothing happens. What I have to do to make it work?

推荐答案

我找到的有效解决方案:

Working solution I've found:

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

$injector.get(widgetContext.servicesMap.get('entityViewService')).getEntityView(entityId.id).subscribe(function(entity) {
    console.log(entity)
    if (entity.name == 'Powermeter1') {
        openDashboardState('energy_state_1')
    }
    else if(entity.name == 'Powermeter2') {
        openDashboardState('water_state_2')
    }
});

function openDashboardState(stateId) {
    var params = {
        entityId: entityId,
        entityName: entityName
    }

    widgetContext.stateController.openState(stateId, params,
        false);
}

其中"Powermeter1"和"Powermeter2"是实体视图的名称.希望对您有所帮助.

Where 'Powermeter1' and 'Powermeter2' are names of Entity Views. Hope it will be helpful.

这篇关于具有实体视图的Thingsboard仪表板实体表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆