Commit d530a98b8e405e08d05e730263f97ae95fadc17e
Committed by
mp-loki
1 parent
c692699f
TB-48: Show assigned customer title in dashboard card.
Showing
4 changed files
with
36 additions
and
7 deletions
... | ... | @@ -15,6 +15,5 @@ |
15 | 15 | limitations under the License. |
16 | 16 | |
17 | 17 | --> |
18 | -<div class="tb-small" ng-if="item && | |
19 | - item.customerId.id != parentCtl.types.id.nullUid && | |
20 | - parentCtl.dashboardsScope === 'tenant'" translate>dashboard.assignedToCustomer</div> | |
18 | +<div class="tb-small" ng-show="vm.isAssignedToCustomer()">{{'dashboard.assignedToCustomer' | translate}} '{{vm.customerTitle}}'</div> | |
19 | + | ... | ... |
... | ... | @@ -23,7 +23,35 @@ import addDashboardsToCustomerTemplate from './add-dashboards-to-customer.tpl.ht |
23 | 23 | /* eslint-enable import/no-unresolved, import/default */ |
24 | 24 | |
25 | 25 | /*@ngInject*/ |
26 | -export default function DashboardsController(userService, dashboardService, customerService, importExport, types, $scope, $controller, | |
26 | +export function DashboardCardController($scope, types, customerService) { | |
27 | + | |
28 | + var vm = this; | |
29 | + | |
30 | + vm.types = types; | |
31 | + | |
32 | + vm.isAssignedToCustomer = function() { | |
33 | + if (vm.item && vm.item.customerId && vm.parentCtl.dashboardsScope === 'tenant' && | |
34 | + vm.item.customerId.id != vm.types.id.nullUid) { | |
35 | + return true; | |
36 | + } | |
37 | + return false; | |
38 | + } | |
39 | + | |
40 | + $scope.$watch('vm.item', | |
41 | + function() { | |
42 | + if (vm.isAssignedToCustomer()) { | |
43 | + customerService.getCustomerTitle(vm.item.customerId.id).then( | |
44 | + function success(title) { | |
45 | + vm.customerTitle = title; | |
46 | + } | |
47 | + ); | |
48 | + } | |
49 | + } | |
50 | + ); | |
51 | +} | |
52 | + | |
53 | +/*@ngInject*/ | |
54 | +export function DashboardsController(userService, dashboardService, customerService, importExport, types, $scope, $controller, | |
27 | 55 | $state, $stateParams, $mdDialog, $document, $q, $translate) { |
28 | 56 | |
29 | 57 | var customerId = $stateParams.customerId; |
... | ... | @@ -58,6 +86,7 @@ export default function DashboardsController(userService, dashboardService, cust |
58 | 86 | clickItemFunc: openDashboard, |
59 | 87 | |
60 | 88 | getItemTitleFunc: getDashboardTitle, |
89 | + itemCardController: 'DashboardCardController', | |
61 | 90 | itemCardTemplateUrl: dashboardCard, |
62 | 91 | parentCtl: vm, |
63 | 92 | ... | ... |
... | ... | @@ -35,7 +35,7 @@ import thingsboardItemBuffer from '../services/item-buffer.service'; |
35 | 35 | import thingsboardImportExport from '../import-export'; |
36 | 36 | |
37 | 37 | import DashboardRoutes from './dashboard.routes'; |
38 | -import DashboardsController from './dashboards.controller'; | |
38 | +import {DashboardsController, DashboardCardController} from './dashboards.controller'; | |
39 | 39 | import DashboardController from './dashboard.controller'; |
40 | 40 | import DeviceAliasesController from './device-aliases.controller'; |
41 | 41 | import AliasesDeviceSelectPanelController from './aliases-device-select-panel.controller'; |
... | ... | @@ -68,6 +68,7 @@ export default angular.module('thingsboard.dashboard', [ |
68 | 68 | ]) |
69 | 69 | .config(DashboardRoutes) |
70 | 70 | .controller('DashboardsController', DashboardsController) |
71 | + .controller('DashboardCardController', DashboardCardController) | |
71 | 72 | .controller('DashboardController', DashboardController) |
72 | 73 | .controller('DeviceAliasesController', DeviceAliasesController) |
73 | 74 | .controller('AliasesDeviceSelectPanelController', AliasesDeviceSelectPanelController) | ... | ... |
... | ... | @@ -31,7 +31,7 @@ export function DeviceCardController($scope, types, customerService) { |
31 | 31 | vm.types = types; |
32 | 32 | |
33 | 33 | vm.isAssignedToCustomer = function() { |
34 | - if (vm.item && vm.item.customerId && vm.parentCtl.devicesScope === 'tenant', | |
34 | + if (vm.item && vm.item.customerId && vm.parentCtl.devicesScope === 'tenant' && | |
35 | 35 | vm.item.customerId.id != vm.types.id.nullUid) { |
36 | 36 | return true; |
37 | 37 | } |
... | ... | @@ -40,7 +40,7 @@ export function DeviceCardController($scope, types, customerService) { |
40 | 40 | |
41 | 41 | $scope.$watch('vm.item', |
42 | 42 | function() { |
43 | - if (vm.item && vm.item.customerId && vm.item.customerId.id != vm.types.id.nullUid) { | |
43 | + if (vm.isAssignedToCustomer()) { | |
44 | 44 | customerService.getCustomerTitle(vm.item.customerId.id).then( |
45 | 45 | function success(title) { |
46 | 46 | vm.customerTitle = title; | ... | ... |