TB-48: Show assigned customer title in dashboard card.
This commit is contained in:
parent
c692699f7b
commit
d530a98b8e
@ -15,6 +15,5 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<div class="tb-small" ng-if="item &&
|
<div class="tb-small" ng-show="vm.isAssignedToCustomer()">{{'dashboard.assignedToCustomer' | translate}} '{{vm.customerTitle}}'</div>
|
||||||
item.customerId.id != parentCtl.types.id.nullUid &&
|
|
||||||
parentCtl.dashboardsScope === 'tenant'" translate>dashboard.assignedToCustomer</div>
|
|
||||||
|
|||||||
@ -23,7 +23,35 @@ import addDashboardsToCustomerTemplate from './add-dashboards-to-customer.tpl.ht
|
|||||||
/* eslint-enable import/no-unresolved, import/default */
|
/* eslint-enable import/no-unresolved, import/default */
|
||||||
|
|
||||||
/*@ngInject*/
|
/*@ngInject*/
|
||||||
export default function DashboardsController(userService, dashboardService, customerService, importExport, types, $scope, $controller,
|
export function DashboardCardController($scope, types, customerService) {
|
||||||
|
|
||||||
|
var vm = this;
|
||||||
|
|
||||||
|
vm.types = types;
|
||||||
|
|
||||||
|
vm.isAssignedToCustomer = function() {
|
||||||
|
if (vm.item && vm.item.customerId && vm.parentCtl.dashboardsScope === 'tenant' &&
|
||||||
|
vm.item.customerId.id != vm.types.id.nullUid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.$watch('vm.item',
|
||||||
|
function() {
|
||||||
|
if (vm.isAssignedToCustomer()) {
|
||||||
|
customerService.getCustomerTitle(vm.item.customerId.id).then(
|
||||||
|
function success(title) {
|
||||||
|
vm.customerTitle = title;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@ngInject*/
|
||||||
|
export function DashboardsController(userService, dashboardService, customerService, importExport, types, $scope, $controller,
|
||||||
$state, $stateParams, $mdDialog, $document, $q, $translate) {
|
$state, $stateParams, $mdDialog, $document, $q, $translate) {
|
||||||
|
|
||||||
var customerId = $stateParams.customerId;
|
var customerId = $stateParams.customerId;
|
||||||
@ -58,6 +86,7 @@ export default function DashboardsController(userService, dashboardService, cust
|
|||||||
clickItemFunc: openDashboard,
|
clickItemFunc: openDashboard,
|
||||||
|
|
||||||
getItemTitleFunc: getDashboardTitle,
|
getItemTitleFunc: getDashboardTitle,
|
||||||
|
itemCardController: 'DashboardCardController',
|
||||||
itemCardTemplateUrl: dashboardCard,
|
itemCardTemplateUrl: dashboardCard,
|
||||||
parentCtl: vm,
|
parentCtl: vm,
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ import thingsboardItemBuffer from '../services/item-buffer.service';
|
|||||||
import thingsboardImportExport from '../import-export';
|
import thingsboardImportExport from '../import-export';
|
||||||
|
|
||||||
import DashboardRoutes from './dashboard.routes';
|
import DashboardRoutes from './dashboard.routes';
|
||||||
import DashboardsController from './dashboards.controller';
|
import {DashboardsController, DashboardCardController} from './dashboards.controller';
|
||||||
import DashboardController from './dashboard.controller';
|
import DashboardController from './dashboard.controller';
|
||||||
import DeviceAliasesController from './device-aliases.controller';
|
import DeviceAliasesController from './device-aliases.controller';
|
||||||
import AliasesDeviceSelectPanelController from './aliases-device-select-panel.controller';
|
import AliasesDeviceSelectPanelController from './aliases-device-select-panel.controller';
|
||||||
@ -68,6 +68,7 @@ export default angular.module('thingsboard.dashboard', [
|
|||||||
])
|
])
|
||||||
.config(DashboardRoutes)
|
.config(DashboardRoutes)
|
||||||
.controller('DashboardsController', DashboardsController)
|
.controller('DashboardsController', DashboardsController)
|
||||||
|
.controller('DashboardCardController', DashboardCardController)
|
||||||
.controller('DashboardController', DashboardController)
|
.controller('DashboardController', DashboardController)
|
||||||
.controller('DeviceAliasesController', DeviceAliasesController)
|
.controller('DeviceAliasesController', DeviceAliasesController)
|
||||||
.controller('AliasesDeviceSelectPanelController', AliasesDeviceSelectPanelController)
|
.controller('AliasesDeviceSelectPanelController', AliasesDeviceSelectPanelController)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ export function DeviceCardController($scope, types, customerService) {
|
|||||||
vm.types = types;
|
vm.types = types;
|
||||||
|
|
||||||
vm.isAssignedToCustomer = function() {
|
vm.isAssignedToCustomer = function() {
|
||||||
if (vm.item && vm.item.customerId && vm.parentCtl.devicesScope === 'tenant',
|
if (vm.item && vm.item.customerId && vm.parentCtl.devicesScope === 'tenant' &&
|
||||||
vm.item.customerId.id != vm.types.id.nullUid) {
|
vm.item.customerId.id != vm.types.id.nullUid) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ export function DeviceCardController($scope, types, customerService) {
|
|||||||
|
|
||||||
$scope.$watch('vm.item',
|
$scope.$watch('vm.item',
|
||||||
function() {
|
function() {
|
||||||
if (vm.item && vm.item.customerId && vm.item.customerId.id != vm.types.id.nullUid) {
|
if (vm.isAssignedToCustomer()) {
|
||||||
customerService.getCustomerTitle(vm.item.customerId.id).then(
|
customerService.getCustomerTitle(vm.item.customerId.id).then(
|
||||||
function success(title) {
|
function success(title) {
|
||||||
vm.customerTitle = title;
|
vm.customerTitle = title;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user