Showed dashboards based on edge assignment

This commit is contained in:
Volodymyr Babak 2019-10-22 21:04:23 +03:00
parent 0cca90ff21
commit 4327f4d3a6
3 changed files with 28 additions and 7 deletions

View File

@ -78,7 +78,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
$log.error('Get Alarm Entity is not implemented!');
break;
case types.entityType.edge:
promise = edgeService.getEdge(entityId, true, config);
promise = edgeService.getEdge(entityId, config);
break;
}
return promise;

View File

@ -14,10 +14,11 @@
* limitations under the License.
*/
/*@ngInject*/
export default function AddDashboardsToEdgeController(dashboardService, $mdDialog, $q, edgeId, dashboards) {
export default function AddDashboardsToEdgeController(dashboardService, types, $mdDialog, $q, edgeId, edgeCustomerId, dashboards) {
var vm = this;
vm.types = types;
vm.dashboards = dashboards;
vm.searchText = '';
@ -52,7 +53,13 @@ export default function AddDashboardsToEdgeController(dashboardService, $mdDialo
fetchMoreItems_: function () {
if (vm.dashboards.hasNext && !vm.dashboards.pending) {
vm.dashboards.pending = true;
dashboardService.getTenantDashboards(vm.dashboards.nextPageLink).then(
var fetchDashboardsPromise;
if (edgeCustomerId === vm.types.id.nullUid) {
fetchDashboardsPromise = dashboardService.getTenantDashboards(vm.dashboards.nextPageLink);
} else {
fetchDashboardsPromise = dashboardService.getCustomerDashboards(edgeCustomerId, vm.dashboards.nextPageLink);
}
fetchDashboardsPromise.then(
function success(dashboards) {
vm.dashboards.data = vm.dashboards.data.concat(dashboards.data);
vm.dashboards.nextPageLink = dashboards.nextPageLink;

View File

@ -57,8 +57,8 @@ export function DashboardCardController(types) {
}
/*@ngInject*/
export function DashboardsController(userService, dashboardService, customerService, importExport, types,
$state, $stateParams, $mdDialog, $document, $q, $translate) {
export function DashboardsController(userService, dashboardService, customerService, importExport, edgeService,
$state, $stateParams, $mdDialog, $document, $q, $translate, types) {
var customerId = $stateParams.customerId;
var edgeId = $stateParams.edgeId;
@ -159,6 +159,13 @@ export function DashboardsController(userService, dashboardService, customerServ
if (edgeId) {
vm.edgeDashboardsTitle = $translate.instant('edge.dashboards');
edgeService.getEdge(edgeId).then(
function success(edge) {
if (edge.customerId) {
vm.edgeCustomerId = edge.customerId;
}
}
)
}
if (vm.dashboardsScope === 'tenant') {
@ -769,7 +776,14 @@ export function DashboardsController(userService, dashboardService, customerServ
$event.stopPropagation();
}
var pageSize = 10;
dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}).then(
var fetchDashboardsPromise;
if (vm.edgeCustomerId.id === vm.types.id.nullUid) {
fetchDashboardsPromise = dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''});
} else {
fetchDashboardsPromise = dashboardService.getCustomerDashboards(vm.edgeCustomerId.id, {limit: pageSize, textSearch: ''});
}
fetchDashboardsPromise.then(
function success(_dashboards) {
var dashboards = {
pageSize: pageSize,
@ -787,7 +801,7 @@ export function DashboardsController(userService, dashboardService, customerServ
controller: 'AddDashboardsToEdgeController',
controllerAs: 'vm',
templateUrl: addDashboardsToEdgeTemplate,
locals: {edgeId: edgeId, dashboards: dashboards},
locals: {edgeId: edgeId, edgeCustomerId: vm.edgeCustomerId.id, dashboards: dashboards},
parent: angular.element($document[0].body),
fullscreen: true,
targetEvent: $event