Commit ac7eec2f6e0f32253c9cfada17f6f5097bef72f9
Merge branch 'vvlladd28-feature/add_state_entityLabel'
Showing
7 changed files
with
50 additions
and
32 deletions
@@ -179,8 +179,7 @@ export default class Subscription { | @@ -179,8 +179,7 @@ export default class Subscription { | ||
179 | } | 179 | } |
180 | 180 | ||
181 | getFirstEntityInfo() { | 181 | getFirstEntityInfo() { |
182 | - var entityId; | ||
183 | - var entityName; | 182 | + var entityId, entityName, entityLabel = null; |
184 | if (this.type === this.ctx.types.widgetType.rpc.value) { | 183 | if (this.type === this.ctx.types.widgetType.rpc.value) { |
185 | if (this.targetDeviceId) { | 184 | if (this.targetDeviceId) { |
186 | entityId = { | 185 | entityId = { |
@@ -196,6 +195,7 @@ export default class Subscription { | @@ -196,6 +195,7 @@ export default class Subscription { | ||
196 | id: this.alarmSource.entityId | 195 | id: this.alarmSource.entityId |
197 | }; | 196 | }; |
198 | entityName = this.alarmSource.entityName; | 197 | entityName = this.alarmSource.entityName; |
198 | + entityLabel = this.alarmSource.entityLabel; | ||
199 | } | 199 | } |
200 | } else { | 200 | } else { |
201 | for (var i=0;i<this.datasources.length;i++) { | 201 | for (var i=0;i<this.datasources.length;i++) { |
@@ -206,6 +206,7 @@ export default class Subscription { | @@ -206,6 +206,7 @@ export default class Subscription { | ||
206 | id: datasource.entityId | 206 | id: datasource.entityId |
207 | }; | 207 | }; |
208 | entityName = datasource.entityName; | 208 | entityName = datasource.entityName; |
209 | + entityLabel = datasource.entityLabel; | ||
209 | break; | 210 | break; |
210 | } | 211 | } |
211 | } | 212 | } |
@@ -213,7 +214,8 @@ export default class Subscription { | @@ -213,7 +214,8 @@ export default class Subscription { | ||
213 | if (entityId) { | 214 | if (entityId) { |
214 | return { | 215 | return { |
215 | entityId: entityId, | 216 | entityId: entityId, |
216 | - entityName: entityName | 217 | + entityName: entityName, |
218 | + entityLabel: entityLabel | ||
217 | }; | 219 | }; |
218 | } else { | 220 | } else { |
219 | return null; | 221 | return null; |
@@ -152,7 +152,8 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | @@ -152,7 +152,8 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | ||
152 | var entityInfo = getActiveEntityInfo(); | 152 | var entityInfo = getActiveEntityInfo(); |
153 | var entityId = entityInfo ? entityInfo.entityId : null; | 153 | var entityId = entityInfo ? entityInfo.entityId : null; |
154 | var entityName = entityInfo ? entityInfo.entityName : null; | 154 | var entityName = entityInfo ? entityInfo.entityName : null; |
155 | - handleWidgetAction($event, this.descriptor, entityId, entityName); | 155 | + var entityLabel = entityInfo && entityInfo.label ? entityInfo.label : null; |
156 | + handleWidgetAction($event, this.descriptor, entityId, entityName, null, entityLabel); | ||
156 | } | 157 | } |
157 | widgetContext.customHeaderActions.push(headerAction); | 158 | widgetContext.customHeaderActions.push(headerAction); |
158 | } | 159 | } |
@@ -458,14 +459,15 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | @@ -458,14 +459,15 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | ||
458 | var entityInfo = getActiveEntityInfo(); | 459 | var entityInfo = getActiveEntityInfo(); |
459 | var entityId = entityInfo ? entityInfo.entityId : null; | 460 | var entityId = entityInfo ? entityInfo.entityId : null; |
460 | var entityName = entityInfo ? entityInfo.entityName : null; | 461 | var entityName = entityInfo ? entityInfo.entityName : null; |
461 | - handleWidgetAction(event, descriptors[i], entityId, entityName); | 462 | + var entityLabel = entityInfo && entityInfo.entityLabel ? entityInfo.entityLabel : null; |
463 | + handleWidgetAction(event, descriptors[i], entityId, entityName, null, entityLabel); | ||
462 | } | 464 | } |
463 | } | 465 | } |
464 | } | 466 | } |
465 | } | 467 | } |
466 | } | 468 | } |
467 | 469 | ||
468 | - function updateEntityParams(params, targetEntityParamName, targetEntityId, entityName) { | 470 | + function updateEntityParams(params, targetEntityParamName, targetEntityId, entityName, entityLabel) { |
469 | if (targetEntityId) { | 471 | if (targetEntityId) { |
470 | var targetEntityParams; | 472 | var targetEntityParams; |
471 | if (targetEntityParamName && targetEntityParamName.length) { | 473 | if (targetEntityParamName && targetEntityParamName.length) { |
@@ -482,10 +484,13 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | @@ -482,10 +484,13 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | ||
482 | if (entityName) { | 484 | if (entityName) { |
483 | targetEntityParams.entityName = entityName; | 485 | targetEntityParams.entityName = entityName; |
484 | } | 486 | } |
487 | + if (entityLabel) { | ||
488 | + targetEntityParams.entityLabel = entityLabel; | ||
489 | + } | ||
485 | } | 490 | } |
486 | } | 491 | } |
487 | 492 | ||
488 | - function handleWidgetAction($event, descriptor, entityId, entityName, additionalParams) { | 493 | + function handleWidgetAction($event, descriptor, entityId, entityName, additionalParams, entityLabel) { |
489 | var type = descriptor.type; | 494 | var type = descriptor.type; |
490 | var targetEntityParamName = descriptor.stateEntityParamName; | 495 | var targetEntityParamName = descriptor.stateEntityParamName; |
491 | var targetEntityId; | 496 | var targetEntityId; |
@@ -500,7 +505,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | @@ -500,7 +505,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | ||
500 | if (!params) { | 505 | if (!params) { |
501 | params = {}; | 506 | params = {}; |
502 | } | 507 | } |
503 | - updateEntityParams(params, targetEntityParamName, targetEntityId, entityName); | 508 | + updateEntityParams(params, targetEntityParamName, targetEntityId, entityName, entityLabel); |
504 | if (type == types.widgetActionTypes.openDashboardState.value) { | 509 | if (type == types.widgetActionTypes.openDashboardState.value) { |
505 | widgetContext.stateController.openState(targetDashboardStateId, params, descriptor.openRightLayout); | 510 | widgetContext.stateController.openState(targetDashboardStateId, params, descriptor.openRightLayout); |
506 | } else { | 511 | } else { |
@@ -512,7 +517,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | @@ -512,7 +517,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ocL | ||
512 | targetDashboardStateId = descriptor.targetDashboardStateId; | 517 | targetDashboardStateId = descriptor.targetDashboardStateId; |
513 | var stateObject = {}; | 518 | var stateObject = {}; |
514 | stateObject.params = {}; | 519 | stateObject.params = {}; |
515 | - updateEntityParams(stateObject.params, targetEntityParamName, targetEntityId, entityName); | 520 | + updateEntityParams(stateObject.params, targetEntityParamName, targetEntityId, entityName, entityLabel); |
516 | if (targetDashboardStateId) { | 521 | if (targetDashboardStateId) { |
517 | stateObject.id = targetDashboardStateId; | 522 | stateObject.id = targetDashboardStateId; |
518 | } | 523 | } |
@@ -159,22 +159,26 @@ export default function EntityStateController($scope, $timeout, $location, $stat | @@ -159,22 +159,26 @@ export default function EntityStateController($scope, $timeout, $location, $stat | ||
159 | } | 159 | } |
160 | 160 | ||
161 | function getStateName(index) { | 161 | function getStateName(index) { |
162 | - var result = ''; | 162 | + let result = ''; |
163 | if (vm.stateObject[index]) { | 163 | if (vm.stateObject[index]) { |
164 | - var stateName = vm.states[vm.stateObject[index].id].name; | 164 | + let stateName = vm.states[vm.stateObject[index].id].name; |
165 | stateName = utils.customTranslation(stateName, stateName); | 165 | stateName = utils.customTranslation(stateName, stateName); |
166 | var params = vm.stateObject[index].params; | 166 | var params = vm.stateObject[index].params; |
167 | - var entityName; | ||
168 | - if (params && params.targetEntityParamName && params[params.targetEntityParamName].entityName) { | ||
169 | - entityName = params[params.targetEntityParamName].entityName; | ||
170 | - } else { | ||
171 | - entityName = params && params.entityName ? params.entityName : ''; | ||
172 | - } | 167 | + let targetParams = params && params.targetEntityParamName ? params[params.targetEntityParamName] : params; |
168 | + | ||
169 | + let entityName, entityLabel; | ||
170 | + entityName =targetParams.entityName ? targetParams.entityName : ''; | ||
171 | + entityLabel = targetParams.entityLabel ? targetParams.entityLabel : entityName; | ||
172 | + | ||
173 | result = utils.insertVariable(stateName, 'entityName', entityName); | 173 | result = utils.insertVariable(stateName, 'entityName', entityName); |
174 | - for (var prop in params) { | 174 | + result = utils.insertVariable(result, 'entityLabel', entityLabel); |
175 | + for (let prop in params) { | ||
175 | if (params[prop] && params[prop].entityName) { | 176 | if (params[prop] && params[prop].entityName) { |
176 | result = utils.insertVariable(result, prop + ':entityName', params[prop].entityName); | 177 | result = utils.insertVariable(result, prop + ':entityName', params[prop].entityName); |
177 | } | 178 | } |
179 | + if (params[prop] && params[prop].entityLabel) { | ||
180 | + result = utils.insertVariable(result, prop + ':entityLabel', params[prop].entityLabel); | ||
181 | + } | ||
178 | } | 182 | } |
179 | } | 183 | } |
180 | return result; | 184 | return result; |
@@ -195,6 +199,7 @@ export default function EntityStateController($scope, $timeout, $location, $stat | @@ -195,6 +199,7 @@ export default function EntityStateController($scope, $timeout, $location, $stat | ||
195 | }).then( | 199 | }).then( |
196 | function success(entity) { | 200 | function success(entity) { |
197 | params.entityName = entity.name; | 201 | params.entityName = entity.name; |
202 | + params.entityLabel = entity.label; | ||
198 | deferred.resolve(); | 203 | deferred.resolve(); |
199 | }, | 204 | }, |
200 | function fail() { | 205 | function fail() { |
@@ -311,13 +311,13 @@ function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $mdP | @@ -311,13 +311,13 @@ function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $mdP | ||
311 | var actionSourceId = isDouble ? 'rowDoubleClick' : 'rowClick'; | 311 | var actionSourceId = isDouble ? 'rowDoubleClick' : 'rowClick'; |
312 | var descriptors = vm.ctx.actionsApi.getActionDescriptors(actionSourceId); | 312 | var descriptors = vm.ctx.actionsApi.getActionDescriptors(actionSourceId); |
313 | if (descriptors.length) { | 313 | if (descriptors.length) { |
314 | - var entityId; | ||
315 | - var entityName; | 314 | + var entityId, entityName, entityLabel; |
316 | if (vm.currentEntity) { | 315 | if (vm.currentEntity) { |
317 | entityId = vm.currentEntity.id; | 316 | entityId = vm.currentEntity.id; |
318 | entityName = vm.currentEntity.entityName; | 317 | entityName = vm.currentEntity.entityName; |
318 | + entityLabel = vm.currentEntity.entityLabel; | ||
319 | } | 319 | } |
320 | - vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName); | 320 | + vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, null, entityLabel); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
@@ -325,13 +325,13 @@ function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $mdP | @@ -325,13 +325,13 @@ function EntitiesTableWidgetController($element, $scope, $filter, $mdMedia, $mdP | ||
325 | if ($event) { | 325 | if ($event) { |
326 | $event.stopPropagation(); | 326 | $event.stopPropagation(); |
327 | } | 327 | } |
328 | - var entityId; | ||
329 | - var entityName; | 328 | + var entityId, entityName, entityLabel; |
330 | if (entity) { | 329 | if (entity) { |
331 | entityId = entity.id; | 330 | entityId = entity.id; |
332 | entityName = entity.entityName; | 331 | entityName = entity.entityName; |
332 | + entityLabel = entity.entityLabel; | ||
333 | } | 333 | } |
334 | - vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName); | 334 | + vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, null, entityLabel); |
335 | } | 335 | } |
336 | 336 | ||
337 | function isCurrent(entity) { | 337 | function isCurrent(entity) { |
@@ -1828,7 +1828,8 @@ export default class TbFlot { | @@ -1828,7 +1828,8 @@ export default class TbFlot { | ||
1828 | var entityInfo = this.ctx.actionsApi.getActiveEntityInfo(); | 1828 | var entityInfo = this.ctx.actionsApi.getActiveEntityInfo(); |
1829 | var entityId = entityInfo ? entityInfo.entityId : null; | 1829 | var entityId = entityInfo ? entityInfo.entityId : null; |
1830 | var entityName = entityInfo ? entityInfo.entityName : null; | 1830 | var entityName = entityInfo ? entityInfo.entityName : null; |
1831 | - this.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, item); | 1831 | + var entityLabel = entityInfo && entityInfo.entityLabel ? entityInfo.entityLabel : null; |
1832 | + this.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, item, entityLabel); | ||
1832 | } | 1833 | } |
1833 | } | 1834 | } |
1834 | } | 1835 | } |
@@ -291,7 +291,8 @@ export default class TbMapWidgetV2 { | @@ -291,7 +291,8 @@ export default class TbMapWidgetV2 { | ||
291 | entityId.id = datasource.entityId; | 291 | entityId.id = datasource.entityId; |
292 | entityId.entityType = datasource.entityType; | 292 | entityId.entityType = datasource.entityType; |
293 | var entityName = datasource.entityName; | 293 | var entityName = datasource.entityName; |
294 | - this.ctx.actionsApi.handleWidgetAction(event, descriptor, entityId, entityName); | 294 | + var entityLabel = datasource.entityLabel; |
295 | + this.ctx.actionsApi.handleWidgetAction(event, descriptor, entityId, entityName, null, entityLabel); | ||
295 | } | 296 | } |
296 | } | 297 | } |
297 | 298 | ||
@@ -560,7 +561,8 @@ export default class TbMapWidgetV2 { | @@ -560,7 +561,8 @@ export default class TbMapWidgetV2 { | ||
560 | entityId.id = datasource.entityId; | 561 | entityId.id = datasource.entityId; |
561 | entityId.entityType = datasource.entityType; | 562 | entityId.entityType = datasource.entityType; |
562 | var entityName = datasource.entityName; | 563 | var entityName = datasource.entityName; |
563 | - tbMap.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName); | 564 | + var entityLabel = datasource.entityLabel; |
565 | + tbMap.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, null, entityLabel); | ||
564 | } | 566 | } |
565 | } | 567 | } |
566 | function locationPolygonClick($event, location) { | 568 | function locationPolygonClick($event, location) { |
@@ -571,7 +573,8 @@ export default class TbMapWidgetV2 { | @@ -571,7 +573,8 @@ export default class TbMapWidgetV2 { | ||
571 | entityId.id = datasource.entityId; | 573 | entityId.id = datasource.entityId; |
572 | entityId.entityType = datasource.entityType; | 574 | entityId.entityType = datasource.entityType; |
573 | var entityName = datasource.entityName; | 575 | var entityName = datasource.entityName; |
574 | - tbMap.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName); | 576 | + var entityLabel = datasource.entityLabel; |
577 | + tbMap.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, null, entityLabel); | ||
575 | } | 578 | } |
576 | } | 579 | } |
577 | 580 |
@@ -190,9 +190,10 @@ function TimeseriesTableWidgetController($element, $scope, $filter, $timeout, ty | @@ -190,9 +190,10 @@ function TimeseriesTableWidgetController($element, $scope, $filter, $timeout, ty | ||
190 | } | 190 | } |
191 | var descriptors = vm.ctx.actionsApi.getActionDescriptors('rowClick'); | 191 | var descriptors = vm.ctx.actionsApi.getActionDescriptors('rowClick'); |
192 | if (descriptors.length) { | 192 | if (descriptors.length) { |
193 | - var entityId = vm.ctx.activeEntityInfo.entityId; | 193 | + var entityId = vm.ctx.activeEntityInfo.entityId; |
194 | var entityName = vm.ctx.activeEntityInfo.entityName; | 194 | var entityName = vm.ctx.activeEntityInfo.entityName; |
195 | - vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, row); | 195 | + var entityLabel = vm.ctx.activeEntityInfo.entityLabel; |
196 | + vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, row, entityLabel); | ||
196 | } | 197 | } |
197 | } | 198 | } |
198 | 199 | ||
@@ -200,9 +201,10 @@ function TimeseriesTableWidgetController($element, $scope, $filter, $timeout, ty | @@ -200,9 +201,10 @@ function TimeseriesTableWidgetController($element, $scope, $filter, $timeout, ty | ||
200 | if ($event) { | 201 | if ($event) { |
201 | $event.stopPropagation(); | 202 | $event.stopPropagation(); |
202 | } | 203 | } |
203 | - var entityId = vm.ctx.activeEntityInfo.entityId; | 204 | + var entityId = vm.ctx.activeEntityInfo.entityId; |
204 | var entityName = vm.ctx.activeEntityInfo.entityName; | 205 | var entityName = vm.ctx.activeEntityInfo.entityName; |
205 | - vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, row); | 206 | + var entityLabel = vm.ctx.activeEntityInfo.entityLabel; |
207 | + vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, row, entityLabel); | ||
206 | } | 208 | } |
207 | 209 | ||
208 | 210 |