Merge branch 'vvlladd28-feature/add_state_entityLabel'
This commit is contained in:
commit
ac7eec2f6e
@ -179,8 +179,7 @@ export default class Subscription {
|
||||
}
|
||||
|
||||
getFirstEntityInfo() {
|
||||
var entityId;
|
||||
var entityName;
|
||||
var entityId, entityName, entityLabel = null;
|
||||
if (this.type === this.ctx.types.widgetType.rpc.value) {
|
||||
if (this.targetDeviceId) {
|
||||
entityId = {
|
||||
@ -196,6 +195,7 @@ export default class Subscription {
|
||||
id: this.alarmSource.entityId
|
||||
};
|
||||
entityName = this.alarmSource.entityName;
|
||||
entityLabel = this.alarmSource.entityLabel;
|
||||
}
|
||||
} else {
|
||||
for (var i=0;i<this.datasources.length;i++) {
|
||||
@ -206,6 +206,7 @@ export default class Subscription {
|
||||
id: datasource.entityId
|
||||
};
|
||||
entityName = datasource.entityName;
|
||||
entityLabel = datasource.entityLabel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -213,7 +214,8 @@ export default class Subscription {
|
||||
if (entityId) {
|
||||
return {
|
||||
entityId: entityId,
|
||||
entityName: entityName
|
||||
entityName: entityName,
|
||||
entityLabel: entityLabel
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
|
||||
@ -152,7 +152,8 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
|
||||
var entityInfo = getActiveEntityInfo();
|
||||
var entityId = entityInfo ? entityInfo.entityId : null;
|
||||
var entityName = entityInfo ? entityInfo.entityName : null;
|
||||
handleWidgetAction($event, this.descriptor, entityId, entityName);
|
||||
var entityLabel = entityInfo && entityInfo.label ? entityInfo.label : null;
|
||||
handleWidgetAction($event, this.descriptor, entityId, entityName, null, entityLabel);
|
||||
}
|
||||
widgetContext.customHeaderActions.push(headerAction);
|
||||
}
|
||||
@ -458,14 +459,15 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
|
||||
var entityInfo = getActiveEntityInfo();
|
||||
var entityId = entityInfo ? entityInfo.entityId : null;
|
||||
var entityName = entityInfo ? entityInfo.entityName : null;
|
||||
handleWidgetAction(event, descriptors[i], entityId, entityName);
|
||||
var entityLabel = entityInfo && entityInfo.entityLabel ? entityInfo.entityLabel : null;
|
||||
handleWidgetAction(event, descriptors[i], entityId, entityName, null, entityLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateEntityParams(params, targetEntityParamName, targetEntityId, entityName) {
|
||||
function updateEntityParams(params, targetEntityParamName, targetEntityId, entityName, entityLabel) {
|
||||
if (targetEntityId) {
|
||||
var targetEntityParams;
|
||||
if (targetEntityParamName && targetEntityParamName.length) {
|
||||
@ -482,10 +484,13 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
|
||||
if (entityName) {
|
||||
targetEntityParams.entityName = entityName;
|
||||
}
|
||||
if (entityLabel) {
|
||||
targetEntityParams.entityLabel = entityLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleWidgetAction($event, descriptor, entityId, entityName, additionalParams) {
|
||||
function handleWidgetAction($event, descriptor, entityId, entityName, additionalParams, entityLabel) {
|
||||
var type = descriptor.type;
|
||||
var targetEntityParamName = descriptor.stateEntityParamName;
|
||||
var targetEntityId;
|
||||
@ -500,7 +505,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
updateEntityParams(params, targetEntityParamName, targetEntityId, entityName);
|
||||
updateEntityParams(params, targetEntityParamName, targetEntityId, entityName, entityLabel);
|
||||
if (type == types.widgetActionTypes.openDashboardState.value) {
|
||||
widgetContext.stateController.openState(targetDashboardStateId, params, descriptor.openRightLayout);
|
||||
} else {
|
||||
@ -512,7 +517,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL
|
||||
targetDashboardStateId = descriptor.targetDashboardStateId;
|
||||
var stateObject = {};
|
||||
stateObject.params = {};
|
||||
updateEntityParams(stateObject.params, targetEntityParamName, targetEntityId, entityName);
|
||||
updateEntityParams(stateObject.params, targetEntityParamName, targetEntityId, entityName, entityLabel);
|
||||
if (targetDashboardStateId) {
|
||||
stateObject.id = targetDashboardStateId;
|
||||
}
|
||||
|
||||
@ -159,22 +159,26 @@ export default function EntityStateController($scope, $timeout, $location, $stat
|
||||
}
|
||||
|
||||
function getStateName(index) {
|
||||
var result = '';
|
||||
let result = '';
|
||||
if (vm.stateObject[index]) {
|
||||
var stateName = vm.states[vm.stateObject[index].id].name;
|
||||
let stateName = vm.states[vm.stateObject[index].id].name;
|
||||
stateName = utils.customTranslation(stateName, stateName);
|
||||
var params = vm.stateObject[index].params;
|
||||
var entityName;
|
||||
if (params && params.targetEntityParamName && params[params.targetEntityParamName].entityName) {
|
||||
entityName = params[params.targetEntityParamName].entityName;
|
||||
} else {
|
||||
entityName = params && params.entityName ? params.entityName : '';
|
||||
}
|
||||
let targetParams = params && params.targetEntityParamName ? params[params.targetEntityParamName] : params;
|
||||
|
||||
let entityName, entityLabel;
|
||||
entityName =targetParams.entityName ? targetParams.entityName : '';
|
||||
entityLabel = targetParams.entityLabel ? targetParams.entityLabel : entityName;
|
||||
|
||||
result = utils.insertVariable(stateName, 'entityName', entityName);
|
||||
for (var prop in params) {
|
||||
result = utils.insertVariable(result, 'entityLabel', entityLabel);
|
||||
for (let prop in params) {
|
||||
if (params[prop] && params[prop].entityName) {
|
||||
result = utils.insertVariable(result, prop + ':entityName', params[prop].entityName);
|
||||
}
|
||||
if (params[prop] && params[prop].entityLabel) {
|
||||
result = utils.insertVariable(result, prop + ':entityLabel', params[prop].entityLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -195,6 +199,7 @@ export default function EntityStateController($scope, $timeout, $location, $stat
|
||||
}).then(
|
||||
function success(entity) {
|
||||
params.entityName = entity.name;
|
||||
params.entityLabel = entity.label;
|
||||
deferred.resolve();
|
||||
},
|
||||
function fail() {
|
||||
|
||||
@ -311,13 +311,13 @@ function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $mdP
|
||||
var actionSourceId = isDouble ? 'rowDoubleClick' : 'rowClick';
|
||||
var descriptors = vm.ctx.actionsApi.getActionDescriptors(actionSourceId);
|
||||
if (descriptors.length) {
|
||||
var entityId;
|
||||
var entityName;
|
||||
var entityId, entityName, entityLabel;
|
||||
if (vm.currentEntity) {
|
||||
entityId = vm.currentEntity.id;
|
||||
entityName = vm.currentEntity.entityName;
|
||||
entityLabel = vm.currentEntity.entityLabel;
|
||||
}
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName);
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, null, entityLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,13 +325,13 @@ function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $mdP
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
var entityId;
|
||||
var entityName;
|
||||
var entityId, entityName, entityLabel;
|
||||
if (entity) {
|
||||
entityId = entity.id;
|
||||
entityName = entity.entityName;
|
||||
entityLabel = entity.entityLabel;
|
||||
}
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName);
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, null, entityLabel);
|
||||
}
|
||||
|
||||
function isCurrent(entity) {
|
||||
|
||||
@ -1828,7 +1828,8 @@ export default class TbFlot {
|
||||
var entityInfo = this.ctx.actionsApi.getActiveEntityInfo();
|
||||
var entityId = entityInfo ? entityInfo.entityId : null;
|
||||
var entityName = entityInfo ? entityInfo.entityName : null;
|
||||
this.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, item);
|
||||
var entityLabel = entityInfo && entityInfo.entityLabel ? entityInfo.entityLabel : null;
|
||||
this.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, item, entityLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,8 @@ export default class TbMapWidgetV2 {
|
||||
entityId.id = datasource.entityId;
|
||||
entityId.entityType = datasource.entityType;
|
||||
var entityName = datasource.entityName;
|
||||
this.ctx.actionsApi.handleWidgetAction(event, descriptor, entityId, entityName);
|
||||
var entityLabel = datasource.entityLabel;
|
||||
this.ctx.actionsApi.handleWidgetAction(event, descriptor, entityId, entityName, null, entityLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -560,7 +561,8 @@ export default class TbMapWidgetV2 {
|
||||
entityId.id = datasource.entityId;
|
||||
entityId.entityType = datasource.entityType;
|
||||
var entityName = datasource.entityName;
|
||||
tbMap.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName);
|
||||
var entityLabel = datasource.entityLabel;
|
||||
tbMap.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, null, entityLabel);
|
||||
}
|
||||
}
|
||||
function locationPolygonClick($event, location) {
|
||||
@ -571,7 +573,8 @@ export default class TbMapWidgetV2 {
|
||||
entityId.id = datasource.entityId;
|
||||
entityId.entityType = datasource.entityType;
|
||||
var entityName = datasource.entityName;
|
||||
tbMap.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName);
|
||||
var entityLabel = datasource.entityLabel;
|
||||
tbMap.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, null, entityLabel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -192,7 +192,8 @@ function TimeseriesTableWidgetController($element, $scope, $filter, $timeout, ty
|
||||
if (descriptors.length) {
|
||||
var entityId = vm.ctx.activeEntityInfo.entityId;
|
||||
var entityName = vm.ctx.activeEntityInfo.entityName;
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, row);
|
||||
var entityLabel = vm.ctx.activeEntityInfo.entityLabel;
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, row, entityLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +203,8 @@ function TimeseriesTableWidgetController($element, $scope, $filter, $timeout, ty
|
||||
}
|
||||
var entityId = vm.ctx.activeEntityInfo.entityId;
|
||||
var entityName = vm.ctx.activeEntityInfo.entityName;
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, row);
|
||||
var entityLabel = vm.ctx.activeEntityInfo.entityLabel;
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, row, entityLabel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user