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 | 78 | $log.error('Get Alarm Entity is not implemented!'); |
79 | 79 | break; |
80 | 80 | case types.entityType.edge: |
81 | - promise = edgeService.getEdge(entityId, true, config); | |
81 | + promise = edgeService.getEdge(entityId, config); | |
82 | 82 | break; |
83 | 83 | } |
84 | 84 | return promise; | ... | ... |
... | ... | @@ -14,10 +14,11 @@ |
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 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 | 19 | var vm = this; |
20 | 20 | |
21 | + vm.types = types; | |
21 | 22 | vm.dashboards = dashboards; |
22 | 23 | vm.searchText = ''; |
23 | 24 | |
... | ... | @@ -52,7 +53,13 @@ export default function AddDashboardsToEdgeController(dashboardService, $mdDialo |
52 | 53 | fetchMoreItems_: function () { |
53 | 54 | if (vm.dashboards.hasNext && !vm.dashboards.pending) { |
54 | 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 | 63 | function success(dashboards) { |
57 | 64 | vm.dashboards.data = vm.dashboards.data.concat(dashboards.data); |
58 | 65 | vm.dashboards.nextPageLink = dashboards.nextPageLink; | ... | ... |
... | ... | @@ -57,8 +57,8 @@ export function DashboardCardController(types) { |
57 | 57 | } |
58 | 58 | |
59 | 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 | 63 | var customerId = $stateParams.customerId; |
64 | 64 | var edgeId = $stateParams.edgeId; |
... | ... | @@ -159,6 +159,13 @@ export function DashboardsController(userService, dashboardService, customerServ |
159 | 159 | |
160 | 160 | if (edgeId) { |
161 | 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 | 171 | if (vm.dashboardsScope === 'tenant') { |
... | ... | @@ -769,7 +776,14 @@ export function DashboardsController(userService, dashboardService, customerServ |
769 | 776 | $event.stopPropagation(); |
770 | 777 | } |
771 | 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 | 787 | function success(_dashboards) { |
774 | 788 | var dashboards = { |
775 | 789 | pageSize: pageSize, |
... | ... | @@ -787,7 +801,7 @@ export function DashboardsController(userService, dashboardService, customerServ |
787 | 801 | controller: 'AddDashboardsToEdgeController', |
788 | 802 | controllerAs: 'vm', |
789 | 803 | templateUrl: addDashboardsToEdgeTemplate, |
790 | - locals: {edgeId: edgeId, dashboards: dashboards}, | |
804 | + locals: {edgeId: edgeId, edgeCustomerId: vm.edgeCustomerId.id, dashboards: dashboards}, | |
791 | 805 | parent: angular.element($document[0].body), |
792 | 806 | fullscreen: true, |
793 | 807 | targetEvent: $event | ... | ... |