Commit 2ec11b2af1dc3c7538536bcd6996e2c6f9af9ee1

Authored by Volodymyr Babak
1 parent 15f4a85d

Display edge related entities on customer level

... ... @@ -415,7 +415,7 @@ public class AssetController extends BaseController {
415 415 }
416 416 }
417 417
418   - @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
  418 + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
419 419 @RequestMapping(value = "/edge/{edgeId}/assets", params = {"limit"}, method = RequestMethod.GET)
420 420 @ResponseBody
421 421 public TimePageData<Asset> getEdgeAssets(
... ... @@ -431,7 +431,16 @@ public class AssetController extends BaseController {
431 431 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
432 432 checkEdgeId(edgeId, Operation.READ);
433 433 TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
434   - return checkNotNull(assetService.findAssetsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get());
  434 + TimePageData<Asset> nonFilteredResult = assetService.findAssetsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
  435 + List<Asset> filteredAssets = nonFilteredResult.getData().stream().filter(asset -> {
  436 + try {
  437 + accessControlService.checkPermission(getCurrentUser(), Resource.ASSET, Operation.READ, asset.getId(), asset);
  438 + return true;
  439 + } catch (ThingsboardException e) {
  440 + return false;
  441 + }
  442 + }).collect(Collectors.toList());
  443 + return checkNotNull(new TimePageData<>(filteredAssets, nonFilteredResult.getNextPageLink(), nonFilteredResult.hasNext()));
435 444 } catch (Exception e) {
436 445 throw handleException(e);
437 446 }
... ...
... ... @@ -50,6 +50,7 @@ import org.thingsboard.server.service.security.permission.Resource;
50 50 import java.util.HashSet;
51 51 import java.util.List;
52 52 import java.util.Set;
  53 +import java.util.stream.Collectors;
53 54
54 55 @RestController
55 56 @TbCoreComponent
... ... @@ -554,7 +555,7 @@ public class DashboardController extends BaseController {
554 555 }
555 556 }
556 557
557   - @PreAuthorize("hasAuthority('TENANT_ADMIN')")
  558 + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
558 559 @RequestMapping(value = "/edge/{edgeId}/dashboards", params = { "limit" }, method = RequestMethod.GET)
559 560 @ResponseBody
560 561 public TimePageData<DashboardInfo> getEdgeDashboards(
... ... @@ -570,7 +571,16 @@ public class DashboardController extends BaseController {
570 571 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
571 572 checkEdgeId(edgeId, Operation.READ);
572 573 TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
573   - return checkNotNull(dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get());
  574 + TimePageData<DashboardInfo> nonFilteredResult = dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
  575 + List<DashboardInfo> filteredDashboards = nonFilteredResult.getData().stream().filter(dashboard -> {
  576 + try {
  577 + accessControlService.checkPermission(getCurrentUser(), Resource.DASHBOARD, Operation.READ, dashboard.getId(), dashboard);
  578 + return true;
  579 + } catch (ThingsboardException e) {
  580 + return false;
  581 + }
  582 + }).collect(Collectors.toList());
  583 + return checkNotNull(new TimePageData<>(filteredDashboards, nonFilteredResult.getNextPageLink(), nonFilteredResult.hasNext()));
574 584 } catch (Exception e) {
575 585 throw handleException(e);
576 586 }
... ...
... ... @@ -631,7 +631,7 @@ public class DeviceController extends BaseController {
631 631 }
632 632 }
633 633
634   - @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
  634 + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
635 635 @RequestMapping(value = "/edge/{edgeId}/devices", params = {"limit"}, method = RequestMethod.GET)
636 636 @ResponseBody
637 637 public TimePageData<Device> getEdgeDevices(
... ... @@ -647,7 +647,16 @@ public class DeviceController extends BaseController {
647 647 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
648 648 checkEdgeId(edgeId, Operation.READ);
649 649 TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
650   - return checkNotNull(deviceService.findDevicesByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get());
  650 + TimePageData<Device> nonFilteredResult = deviceService.findDevicesByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
  651 + List<Device> filteredDevices = nonFilteredResult.getData().stream().filter(device -> {
  652 + try {
  653 + accessControlService.checkPermission(getCurrentUser(), Resource.DEVICE, Operation.READ, device.getId(), device);
  654 + return true;
  655 + } catch (ThingsboardException e) {
  656 + return false;
  657 + }
  658 + }).collect(Collectors.toList());
  659 + return checkNotNull(new TimePageData<>(filteredDevices, nonFilteredResult.getNextPageLink(), nonFilteredResult.hasNext()));
651 660 } catch (Exception e) {
652 661 throw handleException(e);
653 662 }
... ...
... ... @@ -162,9 +162,9 @@ public class EdgeController extends BaseController {
162 162 @RequestMapping(value = "/edges", params = {"limit"}, method = RequestMethod.GET)
163 163 @ResponseBody
164 164 public TextPageData<Edge> getEdges(@RequestParam int limit,
165   - @RequestParam(required = false) String textSearch,
166   - @RequestParam(required = false) String idOffset,
167   - @RequestParam(required = false) String textOffset) throws ThingsboardException {
  165 + @RequestParam(required = false) String textSearch,
  166 + @RequestParam(required = false) String idOffset,
  167 + @RequestParam(required = false) String textOffset) throws ThingsboardException {
168 168 try {
169 169 TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
170 170 TenantId tenantId = getCurrentUser().getTenantId();
... ...
... ... @@ -449,7 +449,7 @@ public class EntityViewController extends BaseController {
449 449 }
450 450 }
451 451
452   - @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
  452 + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
453 453 @RequestMapping(value = "/edge/{edgeId}/entityViews", params = {"limit"}, method = RequestMethod.GET)
454 454 @ResponseBody
455 455 public TimePageData<EntityView> getEdgeEntityViews(
... ... @@ -465,7 +465,16 @@ public class EntityViewController extends BaseController {
465 465 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
466 466 checkEdgeId(edgeId, Operation.READ);
467 467 TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
468   - return checkNotNull(entityViewService.findEntityViewsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get());
  468 + TimePageData<EntityView> nonFilteredResult = entityViewService.findEntityViewsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
  469 + List<EntityView> filteredEntityViews = nonFilteredResult.getData().stream().filter(entityView -> {
  470 + try {
  471 + accessControlService.checkPermission(getCurrentUser(), Resource.ENTITY_VIEW, Operation.READ, entityView.getId(), entityView);
  472 + return true;
  473 + } catch (ThingsboardException e) {
  474 + return false;
  475 + }
  476 + }).collect(Collectors.toList());
  477 + return checkNotNull(new TimePageData<>(filteredEntityViews, nonFilteredResult.getNextPageLink(), nonFilteredResult.hasNext()));
469 478 } catch (Exception e) {
470 479 throw handleException(e);
471 480 }
... ...
... ... @@ -142,7 +142,11 @@ export function AssetController($rootScope, userService, assetService, customerS
142 142 var user = userService.getCurrentUser();
143 143
144 144 if (user.authority === 'CUSTOMER_USER') {
145   - vm.assetsScope = 'customer_user';
  145 + if (vm.assetsScope === 'edge') {
  146 + vm.assetsScope = 'edge_customer_user';
  147 + } else {
  148 + vm.assetsScope = 'customer_user';
  149 + }
146 150 customerId = user.customerId;
147 151 }
148 152 if (customerId) {
... ... @@ -323,51 +327,64 @@ export function AssetController($rootScope, userService, assetService, customerS
323 327 }
324 328 vm.assetGridConfig.addItemActions = [];
325 329
326   - } else if (vm.assetsScope === 'edge') {
  330 + } else if (vm.assetsScope === 'edge' || vm.assetsScope === 'edge_customer_user') {
327 331 fetchAssetsFunction = function (pageLink) {
328 332 return assetService.getEdgeAssets(edgeId, pageLink, null);
329 333 };
330   - deleteAssetFunction = function (assetId) {
331   - return assetService.unassignAssetFromEdge(edgeId, assetId);
332   - };
333   - refreshAssetsParamsFunction = function () {
334   - return {"edgeId": edgeId, "topIndex": vm.topIndex};
335   - };
  334 + if (vm.assetsScope === 'edge') {
  335 + deleteAssetFunction = function (assetId) {
  336 + return assetService.unassignAssetFromEdge(edgeId, assetId);
  337 + };
  338 + refreshAssetsParamsFunction = function () {
  339 + return {"edgeId": edgeId, "topIndex": vm.topIndex};
  340 + };
336 341
337   - assetActionsList.push(
338   - {
339   - onAction: function ($event, item) {
340   - unassignFromEdge($event, item, false);
341   - },
342   - name: function() { return $translate.instant('action.unassign') },
343   - details: function() { return $translate.instant('edge.unassign-from-edge') },
344   - icon: "assignment_return"
345   - }
346   - );
  342 + assetActionsList.push(
  343 + {
  344 + onAction: function ($event, item) {
  345 + unassignFromEdge($event, item, false);
  346 + },
  347 + name: function () {
  348 + return $translate.instant('action.unassign')
  349 + },
  350 + details: function () {
  351 + return $translate.instant('edge.unassign-from-edge')
  352 + },
  353 + icon: "assignment_return"
  354 + }
  355 + );
347 356
348   - assetGroupActionsList.push(
349   - {
350   - onAction: function ($event, items) {
351   - unassignAssetsFromEdge($event, items);
  357 + assetGroupActionsList.push(
  358 + {
  359 + onAction: function ($event, items) {
  360 + unassignAssetsFromEdge($event, items);
  361 + },
  362 + name: function () {
  363 + return $translate.instant('asset.unassign-assets')
  364 + },
  365 + details: function (selectedCount) {
  366 + return $translate.instant('asset.unassign-assets-from-edge-action-title', {count: selectedCount}, "messageformat");
  367 + },
  368 + icon: "assignment_return"
  369 + }
  370 + );
  371 +
  372 + vm.assetGridConfig.addItemAction = {
  373 + onAction: function ($event) {
  374 + addAssetsToEdge($event);
352 375 },
353   - name: function() { return $translate.instant('asset.unassign-assets') },
354   - details: function(selectedCount) {
355   - return $translate.instant('asset.unassign-assets-from-edge-action-title', {count: selectedCount}, "messageformat");
  376 + name: function () {
  377 + return $translate.instant('asset.assign-assets')
356 378 },
357   - icon: "assignment_return"
358   - }
359   - );
360   -
361   - vm.assetGridConfig.addItemAction = {
362   - onAction: function ($event) {
363   - addAssetsToEdge($event);
364   - },
365   - name: function() { return $translate.instant('asset.assign-assets') },
366   - details: function() { return $translate.instant('asset.assign-new-asset') },
367   - icon: "add"
368   - };
  379 + details: function () {
  380 + return $translate.instant('asset.assign-new-asset')
  381 + },
  382 + icon: "add"
  383 + };
  384 + } else if (vm.assetsScope === 'edge_customer_user') {
  385 + vm.assetGridConfig.addItemAction = {};
  386 + }
369 387 vm.assetGridConfig.addItemActions = [];
370   -
371 388 }
372 389
373 390 vm.assetGridConfig.refreshParamsFunc = refreshAssetsParamsFunction;
... ...
... ... @@ -141,7 +141,11 @@ export function DashboardsController(userService, dashboardService, customerServ
141 141 var user = userService.getCurrentUser();
142 142
143 143 if (user.authority === 'CUSTOMER_USER') {
144   - vm.dashboardsScope = 'customer_user';
  144 + if (vm.dashboardsScope === 'edge') {
  145 + vm.dashboardsScope = 'edge_customer_user';
  146 + } else {
  147 + vm.dashboardsScope = 'customer_user';
  148 + }
145 149 customerId = user.customerId;
146 150 }
147 151
... ... @@ -381,60 +385,80 @@ export function DashboardsController(userService, dashboardService, customerServ
381 385 } else if (vm.dashboardsScope === 'customer_user') {
382 386 vm.dashboardGridConfig.addItemAction = {};
383 387 }
384   - } else if (vm.dashboardsScope === 'edge') {
  388 + } else if (vm.dashboardsScope === 'edge' || vm.dashboardsScope === 'edge_customer_user') {
385 389 fetchDashboardsFunction = function (pageLink) {
386 390 return dashboardService.getEdgeDashboards(edgeId, pageLink, null);
387 391 };
388   - deleteDashboardFunction = function (dashboardId) {
389   - return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId);
390   - };
391   - refreshDashboardsParamsFunction = function () {
392   - return {"edgeId": edgeId, "topIndex": vm.topIndex};
393   - };
394 392
395   - dashboardActionsList.push(
396   - {
397   - onAction: function ($event, item) {
398   - exportDashboard($event, item);
399   - },
400   - name: function() { $translate.instant('action.export') },
401   - details: function() { return $translate.instant('dashboard.export') },
402   - icon: "file_download"
403   - }
404   - );
  393 + if (vm.dashboardsScope === 'edge') {
  394 + deleteDashboardFunction = function (dashboardId) {
  395 + return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId);
  396 + };
  397 + refreshDashboardsParamsFunction = function () {
  398 + return {"edgeId": edgeId, "topIndex": vm.topIndex};
  399 + };
405 400
406   - dashboardActionsList.push(
407   - {
408   - onAction: function ($event, item) {
409   - unassignFromEdge($event, item, edgeId);
410   - },
411   - name: function() { return $translate.instant('action.unassign') },
412   - details: function() { return $translate.instant('edge.unassign-from-edge') },
413   - icon: "assignment_return"
414   - }
415   - );
  401 + dashboardActionsList.push(
  402 + {
  403 + onAction: function ($event, item) {
  404 + exportDashboard($event, item);
  405 + },
  406 + name: function () {
  407 + $translate.instant('action.export')
  408 + },
  409 + details: function () {
  410 + return $translate.instant('dashboard.export')
  411 + },
  412 + icon: "file_download"
  413 + }
  414 + );
416 415
417   - dashboardGroupActionsList.push(
418   - {
419   - onAction: function ($event, items) {
420   - unassignDashboardsFromEdge($event, items, edgeId);
  416 + dashboardActionsList.push(
  417 + {
  418 + onAction: function ($event, item) {
  419 + unassignFromEdge($event, item, edgeId);
  420 + },
  421 + name: function () {
  422 + return $translate.instant('action.unassign')
  423 + },
  424 + details: function () {
  425 + return $translate.instant('edge.unassign-from-edge')
  426 + },
  427 + icon: "assignment_return"
  428 + }
  429 + );
  430 +
  431 + dashboardGroupActionsList.push(
  432 + {
  433 + onAction: function ($event, items) {
  434 + unassignDashboardsFromEdge($event, items, edgeId);
  435 + },
  436 + name: function () {
  437 + return $translate.instant('dashboard.unassign-dashboards')
  438 + },
  439 + details: function (selectedCount) {
  440 + return $translate.instant('dashboard.unassign-dashboards-from-edge-action-title', {count: selectedCount}, "messageformat");
  441 + },
  442 + icon: "assignment_return"
  443 + }
  444 + );
  445 +
  446 + vm.dashboardGridConfig.addItemAction = {
  447 + onAction: function ($event) {
  448 + addDashboardsToEdge($event);
421 449 },
422   - name: function() { return $translate.instant('dashboard.unassign-dashboards') },
423   - details: function(selectedCount) {
424   - return $translate.instant('dashboard.unassign-dashboards-from-edge-action-title', {count: selectedCount}, "messageformat");
  450 + name: function () {
  451 + return $translate.instant('dashboard.assign-dashboards')
425 452 },
426   - icon: "assignment_return"
427   - }
428   - );
429   -
430   - vm.dashboardGridConfig.addItemAction = {
431   - onAction: function ($event) {
432   - addDashboardsToEdge($event);
433   - },
434   - name: function() { return $translate.instant('dashboard.assign-dashboards') },
435   - details: function() { return $translate.instant('dashboard.assign-new-dashboard') },
436   - icon: "add"
437   - };
  453 + details: function () {
  454 + return $translate.instant('dashboard.assign-new-dashboard')
  455 + },
  456 + icon: "add"
  457 + };
  458 + } else if (vm.dashboardsScope === 'edge_customer_user') {
  459 + vm.dashboardGridConfig.addItemAction = {};
  460 + vm.dashboardGridConfig.addItemActions = [];
  461 + }
438 462 }
439 463
440 464 vm.dashboardGridConfig.refreshParamsFunc = refreshDashboardsParamsFunction;
... ...
... ... @@ -143,7 +143,11 @@ export function DeviceController($rootScope, userService, deviceService, custome
143 143 var user = userService.getCurrentUser();
144 144
145 145 if (user.authority === 'CUSTOMER_USER') {
146   - vm.devicesScope = 'customer_user';
  146 + if (vm.devicesScope === 'edge') {
  147 + vm.devicesScope = 'edge_customer_user';
  148 + } else {
  149 + vm.devicesScope = 'customer_user';
  150 + }
147 151 customerId = user.customerId;
148 152 }
149 153 if (customerId) {
... ... @@ -356,49 +360,64 @@ export function DeviceController($rootScope, userService, deviceService, custome
356 360 }
357 361 vm.deviceGridConfig.addItemActions = [];
358 362
359   - } else if (vm.devicesScope === 'edge') {
  363 + } else if (vm.devicesScope === 'edge' || vm.devicesScope === 'edge_customer_user') {
360 364 fetchDevicesFunction = function (pageLink) {
361 365 return deviceService.getEdgeDevices(edgeId, pageLink, null);
362 366 };
363   - deleteDeviceFunction = function (deviceId) {
364   - return deviceService.unassignDeviceFromEdge(edgeId, deviceId);
365   - };
366   - refreshDevicesParamsFunction = function () {
367   - return {"edgeId": edgeId, "topIndex": vm.topIndex};
368   - };
369 367
370   - deviceActionsList.push(
371   - {
372   - onAction: function ($event, item) {
373   - unassignFromEdge($event, item, false);
374   - },
375   - name: function() { return $translate.instant('action.unassign') },
376   - details: function() { return $translate.instant('edge.unassign-from-edge') },
377   - icon: "assignment_return"
378   - }
379   - );
  368 + if (vm.devicesScope === 'edge') {
  369 + deleteDeviceFunction = function (deviceId) {
  370 + return deviceService.unassignDeviceFromEdge(edgeId, deviceId);
  371 + };
  372 + refreshDevicesParamsFunction = function () {
  373 + return {"edgeId": edgeId, "topIndex": vm.topIndex};
  374 + };
380 375
381   - deviceGroupActionsList.push(
382   - {
383   - onAction: function ($event, items) {
384   - unassignDevicesFromEdge($event, items);
385   - },
386   - name: function() { return $translate.instant('device.unassign-devices') },
387   - details: function(selectedCount) {
388   - return $translate.instant('device.unassign-devices-from-edge-action-title', {count: selectedCount}, "messageformat");
389   - },
390   - icon: "assignment_return"
391   - }
392   - );
  376 + deviceActionsList.push(
  377 + {
  378 + onAction: function ($event, item) {
  379 + unassignFromEdge($event, item, false);
  380 + },
  381 + name: function() { return $translate.instant('action.unassign') },
  382 + details: function() { return $translate.instant('edge.unassign-from-edge') },
  383 + icon: "assignment_return"
  384 + }
  385 + );
393 386
394   - vm.deviceGridConfig.addItemAction = {
395   - onAction: function ($event) {
396   - addDevicesToEdge($event);
397   - },
398   - name: function() { return $translate.instant('device.assign-devices') },
399   - details: function() { return $translate.instant('device.assign-new-device') },
400   - icon: "add"
401   - };
  387 + deviceGroupActionsList.push(
  388 + {
  389 + onAction: function ($event, items) {
  390 + unassignDevicesFromEdge($event, items);
  391 + },
  392 + name: function() { return $translate.instant('device.unassign-devices') },
  393 + details: function(selectedCount) {
  394 + return $translate.instant('device.unassign-devices-from-edge-action-title', {count: selectedCount}, "messageformat");
  395 + },
  396 + icon: "assignment_return"
  397 + }
  398 + );
  399 +
  400 + vm.deviceGridConfig.addItemAction = {
  401 + onAction: function ($event) {
  402 + addDevicesToEdge($event);
  403 + },
  404 + name: function() { return $translate.instant('device.assign-devices') },
  405 + details: function() { return $translate.instant('device.assign-new-device') },
  406 + icon: "add"
  407 + };
  408 + } else if (vm.devicesScope === 'edge_customer_user') {
  409 + deviceActionsList.push(
  410 + {
  411 + onAction: function ($event, item) {
  412 + manageCredentials($event, item);
  413 + },
  414 + name: function() { return $translate.instant('device.credentials') },
  415 + details: function() { return $translate.instant('device.view-credentials') },
  416 + icon: "security"
  417 + }
  418 + );
  419 + vm.deviceGridConfig.addItemAction = {};
  420 + }
402 421 vm.deviceGridConfig.addItemActions = [];
403 422 }
404 423
... ...
... ... @@ -31,16 +31,16 @@
31 31 </div>
32 32 <div layout="row">
33 33 <md-button ng-click="onManageEdgeAssets({event: $event})"
34   - ng-show="!isEdit && edgeScope === 'tenant'"
  34 + ng-show="!isEdit && (edgeScope === 'tenant' || edgeScope === 'customer_user')"
35 35 class="md-raised md-primary">{{ 'edge.assets' | translate }}</md-button>
36 36 <md-button ng-click="onManageEdgeDevices({event: $event})"
37   - ng-show="!isEdit && edgeScope === 'tenant'"
  37 + ng-show="!isEdit && (edgeScope === 'tenant' || edgeScope === 'customer_user')"
38 38 class="md-raised md-primary">{{ 'edge.devices' | translate }}</md-button>
39 39 <md-button ng-click="onManageEdgeEntityViews({event: $event})"
40   - ng-show="!isEdit && edgeScope === 'tenant'"
  40 + ng-show="!isEdit && (edgeScope === 'tenant' || edgeScope === 'customer_user')"
41 41 class="md-raised md-primary">{{ 'edge.entity-views' | translate }}</md-button>
42 42 <md-button ng-click="onManageEdgeDashboards({event: $event})"
43   - ng-show="!isEdit && edgeScope === 'tenant'"
  43 + ng-show="!isEdit && (edgeScope === 'tenant' || edgeScope === 'customer_user')"
44 44 class="md-raised md-primary">{{ 'edge.dashboards' | translate }}</md-button>
45 45 <md-button ng-click="onManageEdgeRuleChains({event: $event})"
46 46 ng-show="!isEdit && edgeScope === 'tenant'"
... ...
... ... @@ -399,9 +399,59 @@ export function EdgeController($rootScope, userService, edgeService, customerSer
399 399
400 400 } else if (vm.edgesScope === 'customer_user') {
401 401 vm.edgeGridConfig.addItemAction = {};
  402 + edgeActionsList.push(
  403 + {
  404 + onAction: function ($event, item) {
  405 + openEdgeAssets($event, item);
  406 + },
  407 + name: function() { return $translate.instant('asset.assets') },
  408 + details: function() {
  409 + return $translate.instant('edge.manage-edge-assets');
  410 + },
  411 + icon: "domain"
  412 + }
  413 + );
  414 +
  415 + edgeActionsList.push(
  416 + {
  417 + onAction: function ($event, item) {
  418 + openEdgeDevices($event, item);
  419 + },
  420 + name: function() { return $translate.instant('device.devices') },
  421 + details: function() {
  422 + return $translate.instant('edge.manage-edge-devices');
  423 + },
  424 + icon: "devices_other"
  425 + }
  426 + );
  427 +
  428 + edgeActionsList.push(
  429 + {
  430 + onAction: function ($event, item) {
  431 + openEdgeEntityViews($event, item);
  432 + },
  433 + name: function() { return $translate.instant('entity-view.entity-views') },
  434 + details: function() {
  435 + return $translate.instant('edge.manage-edge-entity-views');
  436 + },
  437 + icon: "view_quilt"
  438 + }
  439 + );
  440 +
  441 + edgeActionsList.push(
  442 + {
  443 + onAction: function ($event, item) {
  444 + openEdgeDashboards($event, item);
  445 + },
  446 + name: function() { return $translate.instant('dashboard.dashboards') },
  447 + details: function() {
  448 + return $translate.instant('edge.manage-edge-dashboards');
  449 + },
  450 + icon: "dashboard"
  451 + }
  452 + );
402 453 }
403 454 vm.edgeGridConfig.addItemActions = [];
404   -
405 455 }
406 456
407 457 vm.edgeGridConfig.refreshParamsFunc = refreshEdgesParamsFunction;
... ...
... ... @@ -55,7 +55,7 @@ export default function EdgeRoutes($stateProvider, types) {
55 55 url: '/:edgeId/entityViews',
56 56 params: {'topIndex': 0},
57 57 module: 'private',
58   - auth: ['TENANT_ADMIN'],
  58 + auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
59 59 views: {
60 60 "content@home": {
61 61 templateUrl: entityViewsTemplate,
... ... @@ -77,7 +77,7 @@ export default function EdgeRoutes($stateProvider, types) {
77 77 url: '/:edgeId/devices',
78 78 params: {'topIndex': 0},
79 79 module: 'private',
80   - auth: ['TENANT_ADMIN'],
  80 + auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
81 81 views: {
82 82 "content@home": {
83 83 templateUrl: devicesTemplate,
... ... @@ -99,7 +99,7 @@ export default function EdgeRoutes($stateProvider, types) {
99 99 url: '/:edgeId/assets',
100 100 params: {'topIndex': 0},
101 101 module: 'private',
102   - auth: ['TENANT_ADMIN'],
  102 + auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
103 103 views: {
104 104 "content@home": {
105 105 templateUrl: assetsTemplate,
... ... @@ -121,7 +121,7 @@ export default function EdgeRoutes($stateProvider, types) {
121 121 url: '/:edgeId/dashboards',
122 122 params: {'topIndex': 0},
123 123 module: 'private',
124   - auth: ['TENANT_ADMIN'],
  124 + auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
125 125 views: {
126 126 "content@home": {
127 127 templateUrl: dashboardsTemplate,
... ...
... ... @@ -118,7 +118,11 @@ export function EntityViewController($rootScope, userService, entityViewService,
118 118 var user = userService.getCurrentUser();
119 119
120 120 if (user.authority === 'CUSTOMER_USER') {
121   - vm.entityViewsScope = 'customer_user';
  121 + if (vm.entityViewsScope === 'edge') {
  122 + vm.entityViewsScope = 'edge_customer_user';
  123 + } else {
  124 + vm.entityViewsScope = 'customer_user';
  125 + }
122 126 customerId = user.customerId;
123 127 }
124 128 if (customerId) {
... ... @@ -284,48 +288,63 @@ export function EntityViewController($rootScope, userService, entityViewService,
284 288 } else if (vm.entityViewsScope === 'customer_user') {
285 289 vm.entityViewGridConfig.addItemAction = {};
286 290 }
287   - } else if (vm.entityViewsScope === 'edge') {
  291 + } else if (vm.entityViewsScope === 'edge' || vm.entityViewsScope === 'edge_customer_user') {
288 292 fetchEntityViewsFunction = function (pageLink) {
289 293 return entityViewService.getEdgeEntityViews(edgeId, pageLink, null);
290 294 };
291   - deleteEntityViewFunction = function (entityViewId) {
292   - return entityViewService.unassignEntityViewFromEdge(edgeId, entityViewId);
293   - };
294   - refreshEntityViewsParamsFunction = function () {
295   - return {"edgeId": edgeId, "topIndex": vm.topIndex};
296   - };
297 295
298   - entityViewActionsList.push({
299   - onAction: function ($event, item) {
300   - unassignFromEdge($event, item, false);
301   - },
302   - name: function() { return $translate.instant('action.unassign') },
303   - details: function() { return $translate.instant('edge.unassign-from-edge') },
304   - icon: "assignment_return"
305   - }
306   - );
  296 + if (vm.entityViewsScope === 'edge') {
  297 + deleteEntityViewFunction = function (entityViewId) {
  298 + return entityViewService.unassignEntityViewFromEdge(edgeId, entityViewId);
  299 + };
  300 + refreshEntityViewsParamsFunction = function () {
  301 + return {"edgeId": edgeId, "topIndex": vm.topIndex};
  302 + };
307 303
308   - entityViewGroupActionsList.push(
309   - {
310   - onAction: function ($event, items) {
311   - unassignEntityViewsFromEdge($event, items);
  304 + entityViewActionsList.push({
  305 + onAction: function ($event, item) {
  306 + unassignFromEdge($event, item, false);
  307 + },
  308 + name: function () {
  309 + return $translate.instant('action.unassign')
  310 + },
  311 + details: function () {
  312 + return $translate.instant('edge.unassign-from-edge')
  313 + },
  314 + icon: "assignment_return"
  315 + }
  316 + );
  317 +
  318 + entityViewGroupActionsList.push(
  319 + {
  320 + onAction: function ($event, items) {
  321 + unassignEntityViewsFromEdge($event, items);
  322 + },
  323 + name: function () {
  324 + return $translate.instant('entity-view.unassign-entity-views')
  325 + },
  326 + details: function (selectedCount) {
  327 + return $translate.instant('entity-view.unassign-entity-views-from-edge-action-title', {count: selectedCount}, "messageformat");
  328 + },
  329 + icon: "assignment_return"
  330 + }
  331 + );
  332 +
  333 + vm.entityViewGridConfig.addItemAction = {
  334 + onAction: function ($event) {
  335 + addEntityViewsToEdge($event);
312 336 },
313   - name: function() { return $translate.instant('entity-view.unassign-entity-views') },
314   - details: function(selectedCount) {
315   - return $translate.instant('entity-view.unassign-entity-views-from-edge-action-title', {count: selectedCount}, "messageformat");
  337 + name: function () {
  338 + return $translate.instant('entity-view.assign-entity-views')
316 339 },
317   - icon: "assignment_return"
318   - }
319   - );
320   -
321   - vm.entityViewGridConfig.addItemAction = {
322   - onAction: function ($event) {
323   - addEntityViewsToEdge($event);
324   - },
325   - name: function() { return $translate.instant('entity-view.assign-entity-views') },
326   - details: function() { return $translate.instant('entity-view.assign-new-entity-view') },
327   - icon: "add"
328   - };
  340 + details: function () {
  341 + return $translate.instant('entity-view.assign-new-entity-view')
  342 + },
  343 + icon: "add"
  344 + };
  345 + } else if (vm.entityViewsScope === 'edge_customer_user') {
  346 + vm.entityViewGridConfig.addItemAction = {};
  347 + }
329 348 vm.entityViewGridConfig.addItemActions = [];
330 349
331 350 }
... ...