Merge pull request #108 from thingsboard/feature/TB-48

TB-48: Show assigned customer title in dashboard card.
This commit is contained in:
Igor Kulikov 2017-04-17 20:00:02 +03:00 committed by GitHub
commit 0a78e0b081
4 changed files with 36 additions and 7 deletions

View File

@ -15,6 +15,5 @@
limitations under the License.
-->
<div class="tb-small" ng-if="item &&
item.customerId.id != parentCtl.types.id.nullUid &&
parentCtl.dashboardsScope === 'tenant'" translate>dashboard.assignedToCustomer</div>
<div class="tb-small" ng-show="vm.isAssignedToCustomer()">{{'dashboard.assignedToCustomer' | translate}} '{{vm.customerTitle}}'</div>

View File

@ -23,7 +23,35 @@ import addDashboardsToCustomerTemplate from './add-dashboards-to-customer.tpl.ht
/* eslint-enable import/no-unresolved, import/default */
/*@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) {
var customerId = $stateParams.customerId;
@ -58,6 +86,7 @@ export default function DashboardsController(userService, dashboardService, cust
clickItemFunc: openDashboard,
getItemTitleFunc: getDashboardTitle,
itemCardController: 'DashboardCardController',
itemCardTemplateUrl: dashboardCard,
parentCtl: vm,

View File

@ -35,7 +35,7 @@ import thingsboardItemBuffer from '../services/item-buffer.service';
import thingsboardImportExport from '../import-export';
import DashboardRoutes from './dashboard.routes';
import DashboardsController from './dashboards.controller';
import {DashboardsController, DashboardCardController} from './dashboards.controller';
import DashboardController from './dashboard.controller';
import DeviceAliasesController from './device-aliases.controller';
import AliasesDeviceSelectPanelController from './aliases-device-select-panel.controller';
@ -68,6 +68,7 @@ export default angular.module('thingsboard.dashboard', [
])
.config(DashboardRoutes)
.controller('DashboardsController', DashboardsController)
.controller('DashboardCardController', DashboardCardController)
.controller('DashboardController', DashboardController)
.controller('DeviceAliasesController', DeviceAliasesController)
.controller('AliasesDeviceSelectPanelController', AliasesDeviceSelectPanelController)

View File

@ -31,7 +31,7 @@ export function DeviceCardController($scope, types, customerService) {
vm.types = types;
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) {
return true;
}
@ -40,7 +40,7 @@ export function DeviceCardController($scope, types, customerService) {
$scope.$watch('vm.item',
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(
function success(title) {
vm.customerTitle = title;