Commit 4327f4d3a6a15a3e857ab8574ef986cfb0c9a56a
1 parent
0cca90ff
Showed dashboards based on edge assignment
Showing
3 changed files
with
28 additions
and
7 deletions
@@ -78,7 +78,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device | @@ -78,7 +78,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device | ||
78 | $log.error('Get Alarm Entity is not implemented!'); | 78 | $log.error('Get Alarm Entity is not implemented!'); |
79 | break; | 79 | break; |
80 | case types.entityType.edge: | 80 | case types.entityType.edge: |
81 | - promise = edgeService.getEdge(entityId, true, config); | 81 | + promise = edgeService.getEdge(entityId, config); |
82 | break; | 82 | break; |
83 | } | 83 | } |
84 | return promise; | 84 | return promise; |
@@ -14,10 +14,11 @@ | @@ -14,10 +14,11 @@ | ||
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | /*@ngInject*/ | 16 | /*@ngInject*/ |
17 | -export default function AddDashboardsToEdgeController(dashboardService, $mdDialog, $q, edgeId, dashboards) { | 17 | +export default function AddDashboardsToEdgeController(dashboardService, types, $mdDialog, $q, edgeId, edgeCustomerId, dashboards) { |
18 | 18 | ||
19 | var vm = this; | 19 | var vm = this; |
20 | 20 | ||
21 | + vm.types = types; | ||
21 | vm.dashboards = dashboards; | 22 | vm.dashboards = dashboards; |
22 | vm.searchText = ''; | 23 | vm.searchText = ''; |
23 | 24 | ||
@@ -52,7 +53,13 @@ export default function AddDashboardsToEdgeController(dashboardService, $mdDialo | @@ -52,7 +53,13 @@ export default function AddDashboardsToEdgeController(dashboardService, $mdDialo | ||
52 | fetchMoreItems_: function () { | 53 | fetchMoreItems_: function () { |
53 | if (vm.dashboards.hasNext && !vm.dashboards.pending) { | 54 | if (vm.dashboards.hasNext && !vm.dashboards.pending) { |
54 | vm.dashboards.pending = true; | 55 | vm.dashboards.pending = true; |
55 | - dashboardService.getTenantDashboards(vm.dashboards.nextPageLink).then( | 56 | + var fetchDashboardsPromise; |
57 | + if (edgeCustomerId === vm.types.id.nullUid) { | ||
58 | + fetchDashboardsPromise = dashboardService.getTenantDashboards(vm.dashboards.nextPageLink); | ||
59 | + } else { | ||
60 | + fetchDashboardsPromise = dashboardService.getCustomerDashboards(edgeCustomerId, vm.dashboards.nextPageLink); | ||
61 | + } | ||
62 | + fetchDashboardsPromise.then( | ||
56 | function success(dashboards) { | 63 | function success(dashboards) { |
57 | vm.dashboards.data = vm.dashboards.data.concat(dashboards.data); | 64 | vm.dashboards.data = vm.dashboards.data.concat(dashboards.data); |
58 | vm.dashboards.nextPageLink = dashboards.nextPageLink; | 65 | vm.dashboards.nextPageLink = dashboards.nextPageLink; |
@@ -57,8 +57,8 @@ export function DashboardCardController(types) { | @@ -57,8 +57,8 @@ export function DashboardCardController(types) { | ||
57 | } | 57 | } |
58 | 58 | ||
59 | /*@ngInject*/ | 59 | /*@ngInject*/ |
60 | -export function DashboardsController(userService, dashboardService, customerService, importExport, types, | ||
61 | - $state, $stateParams, $mdDialog, $document, $q, $translate) { | 60 | +export function DashboardsController(userService, dashboardService, customerService, importExport, edgeService, |
61 | + $state, $stateParams, $mdDialog, $document, $q, $translate, types) { | ||
62 | 62 | ||
63 | var customerId = $stateParams.customerId; | 63 | var customerId = $stateParams.customerId; |
64 | var edgeId = $stateParams.edgeId; | 64 | var edgeId = $stateParams.edgeId; |
@@ -159,6 +159,13 @@ export function DashboardsController(userService, dashboardService, customerServ | @@ -159,6 +159,13 @@ export function DashboardsController(userService, dashboardService, customerServ | ||
159 | 159 | ||
160 | if (edgeId) { | 160 | if (edgeId) { |
161 | vm.edgeDashboardsTitle = $translate.instant('edge.dashboards'); | 161 | vm.edgeDashboardsTitle = $translate.instant('edge.dashboards'); |
162 | + edgeService.getEdge(edgeId).then( | ||
163 | + function success(edge) { | ||
164 | + if (edge.customerId) { | ||
165 | + vm.edgeCustomerId = edge.customerId; | ||
166 | + } | ||
167 | + } | ||
168 | + ) | ||
162 | } | 169 | } |
163 | 170 | ||
164 | if (vm.dashboardsScope === 'tenant') { | 171 | if (vm.dashboardsScope === 'tenant') { |
@@ -769,7 +776,14 @@ export function DashboardsController(userService, dashboardService, customerServ | @@ -769,7 +776,14 @@ export function DashboardsController(userService, dashboardService, customerServ | ||
769 | $event.stopPropagation(); | 776 | $event.stopPropagation(); |
770 | } | 777 | } |
771 | var pageSize = 10; | 778 | var pageSize = 10; |
772 | - dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}).then( | 779 | + var fetchDashboardsPromise; |
780 | + if (vm.edgeCustomerId.id === vm.types.id.nullUid) { | ||
781 | + fetchDashboardsPromise = dashboardService.getTenantDashboards({limit: pageSize, textSearch: ''}); | ||
782 | + } else { | ||
783 | + fetchDashboardsPromise = dashboardService.getCustomerDashboards(vm.edgeCustomerId.id, {limit: pageSize, textSearch: ''}); | ||
784 | + } | ||
785 | + | ||
786 | + fetchDashboardsPromise.then( | ||
773 | function success(_dashboards) { | 787 | function success(_dashboards) { |
774 | var dashboards = { | 788 | var dashboards = { |
775 | pageSize: pageSize, | 789 | pageSize: pageSize, |
@@ -787,7 +801,7 @@ export function DashboardsController(userService, dashboardService, customerServ | @@ -787,7 +801,7 @@ export function DashboardsController(userService, dashboardService, customerServ | ||
787 | controller: 'AddDashboardsToEdgeController', | 801 | controller: 'AddDashboardsToEdgeController', |
788 | controllerAs: 'vm', | 802 | controllerAs: 'vm', |
789 | templateUrl: addDashboardsToEdgeTemplate, | 803 | templateUrl: addDashboardsToEdgeTemplate, |
790 | - locals: {edgeId: edgeId, dashboards: dashboards}, | 804 | + locals: {edgeId: edgeId, edgeCustomerId: vm.edgeCustomerId.id, dashboards: dashboards}, |
791 | parent: angular.element($document[0].body), | 805 | parent: angular.element($document[0].body), |
792 | fullscreen: true, | 806 | fullscreen: true, |
793 | targetEvent: $event | 807 | targetEvent: $event |