Display edge related entities on customer level
This commit is contained in:
parent
15f4a85dec
commit
2ec11b2af1
@ -415,7 +415,7 @@ public class AssetController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}/assets", params = {"limit"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/edge/{edgeId}/assets", params = {"limit"}, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TimePageData<Asset> getEdgeAssets(
|
public TimePageData<Asset> getEdgeAssets(
|
||||||
@ -431,7 +431,16 @@ public class AssetController extends BaseController {
|
|||||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||||
checkEdgeId(edgeId, Operation.READ);
|
checkEdgeId(edgeId, Operation.READ);
|
||||||
TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
|
TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
|
||||||
return checkNotNull(assetService.findAssetsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get());
|
TimePageData<Asset> nonFilteredResult = assetService.findAssetsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
|
||||||
|
List<Asset> filteredAssets = nonFilteredResult.getData().stream().filter(asset -> {
|
||||||
|
try {
|
||||||
|
accessControlService.checkPermission(getCurrentUser(), Resource.ASSET, Operation.READ, asset.getId(), asset);
|
||||||
|
return true;
|
||||||
|
} catch (ThingsboardException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return checkNotNull(new TimePageData<>(filteredAssets, nonFilteredResult.getNextPageLink(), nonFilteredResult.hasNext()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,7 @@ import org.thingsboard.server.service.security.permission.Resource;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@TbCoreComponent
|
@TbCoreComponent
|
||||||
@ -554,7 +555,7 @@ public class DashboardController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}/dashboards", params = { "limit" }, method = RequestMethod.GET)
|
@RequestMapping(value = "/edge/{edgeId}/dashboards", params = { "limit" }, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TimePageData<DashboardInfo> getEdgeDashboards(
|
public TimePageData<DashboardInfo> getEdgeDashboards(
|
||||||
@ -570,7 +571,16 @@ public class DashboardController extends BaseController {
|
|||||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||||
checkEdgeId(edgeId, Operation.READ);
|
checkEdgeId(edgeId, Operation.READ);
|
||||||
TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
|
TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
|
||||||
return checkNotNull(dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get());
|
TimePageData<DashboardInfo> nonFilteredResult = dashboardService.findDashboardsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
|
||||||
|
List<DashboardInfo> filteredDashboards = nonFilteredResult.getData().stream().filter(dashboard -> {
|
||||||
|
try {
|
||||||
|
accessControlService.checkPermission(getCurrentUser(), Resource.DASHBOARD, Operation.READ, dashboard.getId(), dashboard);
|
||||||
|
return true;
|
||||||
|
} catch (ThingsboardException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return checkNotNull(new TimePageData<>(filteredDashboards, nonFilteredResult.getNextPageLink(), nonFilteredResult.hasNext()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -631,7 +631,7 @@ public class DeviceController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}/devices", params = {"limit"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/edge/{edgeId}/devices", params = {"limit"}, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TimePageData<Device> getEdgeDevices(
|
public TimePageData<Device> getEdgeDevices(
|
||||||
@ -647,7 +647,16 @@ public class DeviceController extends BaseController {
|
|||||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||||
checkEdgeId(edgeId, Operation.READ);
|
checkEdgeId(edgeId, Operation.READ);
|
||||||
TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
|
TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
|
||||||
return checkNotNull(deviceService.findDevicesByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get());
|
TimePageData<Device> nonFilteredResult = deviceService.findDevicesByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
|
||||||
|
List<Device> filteredDevices = nonFilteredResult.getData().stream().filter(device -> {
|
||||||
|
try {
|
||||||
|
accessControlService.checkPermission(getCurrentUser(), Resource.DEVICE, Operation.READ, device.getId(), device);
|
||||||
|
return true;
|
||||||
|
} catch (ThingsboardException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return checkNotNull(new TimePageData<>(filteredDevices, nonFilteredResult.getNextPageLink(), nonFilteredResult.hasNext()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,9 +162,9 @@ public class EdgeController extends BaseController {
|
|||||||
@RequestMapping(value = "/edges", params = {"limit"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/edges", params = {"limit"}, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TextPageData<Edge> getEdges(@RequestParam int limit,
|
public TextPageData<Edge> getEdges(@RequestParam int limit,
|
||||||
@RequestParam(required = false) String textSearch,
|
@RequestParam(required = false) String textSearch,
|
||||||
@RequestParam(required = false) String idOffset,
|
@RequestParam(required = false) String idOffset,
|
||||||
@RequestParam(required = false) String textOffset) throws ThingsboardException {
|
@RequestParam(required = false) String textOffset) throws ThingsboardException {
|
||||||
try {
|
try {
|
||||||
TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
|
TextPageLink pageLink = createPageLink(limit, textSearch, idOffset, textOffset);
|
||||||
TenantId tenantId = getCurrentUser().getTenantId();
|
TenantId tenantId = getCurrentUser().getTenantId();
|
||||||
|
|||||||
@ -449,7 +449,7 @@ public class EntityViewController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
|
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/edge/{edgeId}/entityViews", params = {"limit"}, method = RequestMethod.GET)
|
@RequestMapping(value = "/edge/{edgeId}/entityViews", params = {"limit"}, method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public TimePageData<EntityView> getEdgeEntityViews(
|
public TimePageData<EntityView> getEdgeEntityViews(
|
||||||
@ -465,7 +465,16 @@ public class EntityViewController extends BaseController {
|
|||||||
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
|
||||||
checkEdgeId(edgeId, Operation.READ);
|
checkEdgeId(edgeId, Operation.READ);
|
||||||
TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
|
TimePageLink pageLink = createPageLink(limit, startTime, endTime, ascOrder, offset);
|
||||||
return checkNotNull(entityViewService.findEntityViewsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get());
|
TimePageData<EntityView> nonFilteredResult = entityViewService.findEntityViewsByTenantIdAndEdgeId(tenantId, edgeId, pageLink).get();
|
||||||
|
List<EntityView> filteredEntityViews = nonFilteredResult.getData().stream().filter(entityView -> {
|
||||||
|
try {
|
||||||
|
accessControlService.checkPermission(getCurrentUser(), Resource.ENTITY_VIEW, Operation.READ, entityView.getId(), entityView);
|
||||||
|
return true;
|
||||||
|
} catch (ThingsboardException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return checkNotNull(new TimePageData<>(filteredEntityViews, nonFilteredResult.getNextPageLink(), nonFilteredResult.hasNext()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw handleException(e);
|
throw handleException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -142,7 +142,11 @@ export function AssetController($rootScope, userService, assetService, customerS
|
|||||||
var user = userService.getCurrentUser();
|
var user = userService.getCurrentUser();
|
||||||
|
|
||||||
if (user.authority === 'CUSTOMER_USER') {
|
if (user.authority === 'CUSTOMER_USER') {
|
||||||
vm.assetsScope = 'customer_user';
|
if (vm.assetsScope === 'edge') {
|
||||||
|
vm.assetsScope = 'edge_customer_user';
|
||||||
|
} else {
|
||||||
|
vm.assetsScope = 'customer_user';
|
||||||
|
}
|
||||||
customerId = user.customerId;
|
customerId = user.customerId;
|
||||||
}
|
}
|
||||||
if (customerId) {
|
if (customerId) {
|
||||||
@ -323,51 +327,64 @@ export function AssetController($rootScope, userService, assetService, customerS
|
|||||||
}
|
}
|
||||||
vm.assetGridConfig.addItemActions = [];
|
vm.assetGridConfig.addItemActions = [];
|
||||||
|
|
||||||
} else if (vm.assetsScope === 'edge') {
|
} else if (vm.assetsScope === 'edge' || vm.assetsScope === 'edge_customer_user') {
|
||||||
fetchAssetsFunction = function (pageLink) {
|
fetchAssetsFunction = function (pageLink) {
|
||||||
return assetService.getEdgeAssets(edgeId, pageLink, null);
|
return assetService.getEdgeAssets(edgeId, pageLink, null);
|
||||||
};
|
};
|
||||||
deleteAssetFunction = function (assetId) {
|
if (vm.assetsScope === 'edge') {
|
||||||
return assetService.unassignAssetFromEdge(edgeId, assetId);
|
deleteAssetFunction = function (assetId) {
|
||||||
};
|
return assetService.unassignAssetFromEdge(edgeId, assetId);
|
||||||
refreshAssetsParamsFunction = function () {
|
};
|
||||||
return {"edgeId": edgeId, "topIndex": vm.topIndex};
|
refreshAssetsParamsFunction = function () {
|
||||||
};
|
return {"edgeId": edgeId, "topIndex": vm.topIndex};
|
||||||
|
};
|
||||||
|
|
||||||
assetActionsList.push(
|
assetActionsList.push(
|
||||||
{
|
{
|
||||||
onAction: function ($event, item) {
|
onAction: function ($event, item) {
|
||||||
unassignFromEdge($event, item, false);
|
unassignFromEdge($event, item, false);
|
||||||
},
|
},
|
||||||
name: function() { return $translate.instant('action.unassign') },
|
name: function () {
|
||||||
details: function() { return $translate.instant('edge.unassign-from-edge') },
|
return $translate.instant('action.unassign')
|
||||||
icon: "assignment_return"
|
},
|
||||||
}
|
details: function () {
|
||||||
);
|
return $translate.instant('edge.unassign-from-edge')
|
||||||
|
},
|
||||||
|
icon: "assignment_return"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
assetGroupActionsList.push(
|
assetGroupActionsList.push(
|
||||||
{
|
{
|
||||||
onAction: function ($event, items) {
|
onAction: function ($event, items) {
|
||||||
unassignAssetsFromEdge($event, items);
|
unassignAssetsFromEdge($event, items);
|
||||||
},
|
},
|
||||||
name: function() { return $translate.instant('asset.unassign-assets') },
|
name: function () {
|
||||||
details: function(selectedCount) {
|
return $translate.instant('asset.unassign-assets')
|
||||||
return $translate.instant('asset.unassign-assets-from-edge-action-title', {count: selectedCount}, "messageformat");
|
},
|
||||||
},
|
details: function (selectedCount) {
|
||||||
icon: "assignment_return"
|
return $translate.instant('asset.unassign-assets-from-edge-action-title', {count: selectedCount}, "messageformat");
|
||||||
}
|
},
|
||||||
);
|
icon: "assignment_return"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
vm.assetGridConfig.addItemAction = {
|
vm.assetGridConfig.addItemAction = {
|
||||||
onAction: function ($event) {
|
onAction: function ($event) {
|
||||||
addAssetsToEdge($event);
|
addAssetsToEdge($event);
|
||||||
},
|
},
|
||||||
name: function() { return $translate.instant('asset.assign-assets') },
|
name: function () {
|
||||||
details: function() { return $translate.instant('asset.assign-new-asset') },
|
return $translate.instant('asset.assign-assets')
|
||||||
icon: "add"
|
},
|
||||||
};
|
details: function () {
|
||||||
|
return $translate.instant('asset.assign-new-asset')
|
||||||
|
},
|
||||||
|
icon: "add"
|
||||||
|
};
|
||||||
|
} else if (vm.assetsScope === 'edge_customer_user') {
|
||||||
|
vm.assetGridConfig.addItemAction = {};
|
||||||
|
}
|
||||||
vm.assetGridConfig.addItemActions = [];
|
vm.assetGridConfig.addItemActions = [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.assetGridConfig.refreshParamsFunc = refreshAssetsParamsFunction;
|
vm.assetGridConfig.refreshParamsFunc = refreshAssetsParamsFunction;
|
||||||
|
|||||||
@ -141,7 +141,11 @@ export function DashboardsController(userService, dashboardService, customerServ
|
|||||||
var user = userService.getCurrentUser();
|
var user = userService.getCurrentUser();
|
||||||
|
|
||||||
if (user.authority === 'CUSTOMER_USER') {
|
if (user.authority === 'CUSTOMER_USER') {
|
||||||
vm.dashboardsScope = 'customer_user';
|
if (vm.dashboardsScope === 'edge') {
|
||||||
|
vm.dashboardsScope = 'edge_customer_user';
|
||||||
|
} else {
|
||||||
|
vm.dashboardsScope = 'customer_user';
|
||||||
|
}
|
||||||
customerId = user.customerId;
|
customerId = user.customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,60 +385,80 @@ export function DashboardsController(userService, dashboardService, customerServ
|
|||||||
} else if (vm.dashboardsScope === 'customer_user') {
|
} else if (vm.dashboardsScope === 'customer_user') {
|
||||||
vm.dashboardGridConfig.addItemAction = {};
|
vm.dashboardGridConfig.addItemAction = {};
|
||||||
}
|
}
|
||||||
} else if (vm.dashboardsScope === 'edge') {
|
} else if (vm.dashboardsScope === 'edge' || vm.dashboardsScope === 'edge_customer_user') {
|
||||||
fetchDashboardsFunction = function (pageLink) {
|
fetchDashboardsFunction = function (pageLink) {
|
||||||
return dashboardService.getEdgeDashboards(edgeId, pageLink, null);
|
return dashboardService.getEdgeDashboards(edgeId, pageLink, null);
|
||||||
};
|
};
|
||||||
deleteDashboardFunction = function (dashboardId) {
|
|
||||||
return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId);
|
|
||||||
};
|
|
||||||
refreshDashboardsParamsFunction = function () {
|
|
||||||
return {"edgeId": edgeId, "topIndex": vm.topIndex};
|
|
||||||
};
|
|
||||||
|
|
||||||
dashboardActionsList.push(
|
if (vm.dashboardsScope === 'edge') {
|
||||||
{
|
deleteDashboardFunction = function (dashboardId) {
|
||||||
onAction: function ($event, item) {
|
return dashboardService.unassignDashboardFromEdge(edgeId, dashboardId);
|
||||||
exportDashboard($event, item);
|
};
|
||||||
},
|
refreshDashboardsParamsFunction = function () {
|
||||||
name: function() { $translate.instant('action.export') },
|
return {"edgeId": edgeId, "topIndex": vm.topIndex};
|
||||||
details: function() { return $translate.instant('dashboard.export') },
|
};
|
||||||
icon: "file_download"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
dashboardActionsList.push(
|
dashboardActionsList.push(
|
||||||
{
|
{
|
||||||
onAction: function ($event, item) {
|
onAction: function ($event, item) {
|
||||||
unassignFromEdge($event, item, edgeId);
|
exportDashboard($event, item);
|
||||||
},
|
},
|
||||||
name: function() { return $translate.instant('action.unassign') },
|
name: function () {
|
||||||
details: function() { return $translate.instant('edge.unassign-from-edge') },
|
$translate.instant('action.export')
|
||||||
icon: "assignment_return"
|
},
|
||||||
}
|
details: function () {
|
||||||
);
|
return $translate.instant('dashboard.export')
|
||||||
|
},
|
||||||
|
icon: "file_download"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
dashboardGroupActionsList.push(
|
dashboardActionsList.push(
|
||||||
{
|
{
|
||||||
onAction: function ($event, items) {
|
onAction: function ($event, item) {
|
||||||
unassignDashboardsFromEdge($event, items, edgeId);
|
unassignFromEdge($event, item, edgeId);
|
||||||
},
|
},
|
||||||
name: function() { return $translate.instant('dashboard.unassign-dashboards') },
|
name: function () {
|
||||||
details: function(selectedCount) {
|
return $translate.instant('action.unassign')
|
||||||
return $translate.instant('dashboard.unassign-dashboards-from-edge-action-title', {count: selectedCount}, "messageformat");
|
},
|
||||||
},
|
details: function () {
|
||||||
icon: "assignment_return"
|
return $translate.instant('edge.unassign-from-edge')
|
||||||
}
|
},
|
||||||
);
|
icon: "assignment_return"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
vm.dashboardGridConfig.addItemAction = {
|
dashboardGroupActionsList.push(
|
||||||
onAction: function ($event) {
|
{
|
||||||
addDashboardsToEdge($event);
|
onAction: function ($event, items) {
|
||||||
},
|
unassignDashboardsFromEdge($event, items, edgeId);
|
||||||
name: function() { return $translate.instant('dashboard.assign-dashboards') },
|
},
|
||||||
details: function() { return $translate.instant('dashboard.assign-new-dashboard') },
|
name: function () {
|
||||||
icon: "add"
|
return $translate.instant('dashboard.unassign-dashboards')
|
||||||
};
|
},
|
||||||
|
details: function (selectedCount) {
|
||||||
|
return $translate.instant('dashboard.unassign-dashboards-from-edge-action-title', {count: selectedCount}, "messageformat");
|
||||||
|
},
|
||||||
|
icon: "assignment_return"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
vm.dashboardGridConfig.addItemAction = {
|
||||||
|
onAction: function ($event) {
|
||||||
|
addDashboardsToEdge($event);
|
||||||
|
},
|
||||||
|
name: function () {
|
||||||
|
return $translate.instant('dashboard.assign-dashboards')
|
||||||
|
},
|
||||||
|
details: function () {
|
||||||
|
return $translate.instant('dashboard.assign-new-dashboard')
|
||||||
|
},
|
||||||
|
icon: "add"
|
||||||
|
};
|
||||||
|
} else if (vm.dashboardsScope === 'edge_customer_user') {
|
||||||
|
vm.dashboardGridConfig.addItemAction = {};
|
||||||
|
vm.dashboardGridConfig.addItemActions = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.dashboardGridConfig.refreshParamsFunc = refreshDashboardsParamsFunction;
|
vm.dashboardGridConfig.refreshParamsFunc = refreshDashboardsParamsFunction;
|
||||||
|
|||||||
@ -143,7 +143,11 @@ export function DeviceController($rootScope, userService, deviceService, custome
|
|||||||
var user = userService.getCurrentUser();
|
var user = userService.getCurrentUser();
|
||||||
|
|
||||||
if (user.authority === 'CUSTOMER_USER') {
|
if (user.authority === 'CUSTOMER_USER') {
|
||||||
vm.devicesScope = 'customer_user';
|
if (vm.devicesScope === 'edge') {
|
||||||
|
vm.devicesScope = 'edge_customer_user';
|
||||||
|
} else {
|
||||||
|
vm.devicesScope = 'customer_user';
|
||||||
|
}
|
||||||
customerId = user.customerId;
|
customerId = user.customerId;
|
||||||
}
|
}
|
||||||
if (customerId) {
|
if (customerId) {
|
||||||
@ -356,49 +360,64 @@ export function DeviceController($rootScope, userService, deviceService, custome
|
|||||||
}
|
}
|
||||||
vm.deviceGridConfig.addItemActions = [];
|
vm.deviceGridConfig.addItemActions = [];
|
||||||
|
|
||||||
} else if (vm.devicesScope === 'edge') {
|
} else if (vm.devicesScope === 'edge' || vm.devicesScope === 'edge_customer_user') {
|
||||||
fetchDevicesFunction = function (pageLink) {
|
fetchDevicesFunction = function (pageLink) {
|
||||||
return deviceService.getEdgeDevices(edgeId, pageLink, null);
|
return deviceService.getEdgeDevices(edgeId, pageLink, null);
|
||||||
};
|
};
|
||||||
deleteDeviceFunction = function (deviceId) {
|
|
||||||
return deviceService.unassignDeviceFromEdge(edgeId, deviceId);
|
|
||||||
};
|
|
||||||
refreshDevicesParamsFunction = function () {
|
|
||||||
return {"edgeId": edgeId, "topIndex": vm.topIndex};
|
|
||||||
};
|
|
||||||
|
|
||||||
deviceActionsList.push(
|
if (vm.devicesScope === 'edge') {
|
||||||
{
|
deleteDeviceFunction = function (deviceId) {
|
||||||
onAction: function ($event, item) {
|
return deviceService.unassignDeviceFromEdge(edgeId, deviceId);
|
||||||
unassignFromEdge($event, item, false);
|
};
|
||||||
},
|
refreshDevicesParamsFunction = function () {
|
||||||
name: function() { return $translate.instant('action.unassign') },
|
return {"edgeId": edgeId, "topIndex": vm.topIndex};
|
||||||
details: function() { return $translate.instant('edge.unassign-from-edge') },
|
};
|
||||||
icon: "assignment_return"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
deviceGroupActionsList.push(
|
deviceActionsList.push(
|
||||||
{
|
{
|
||||||
onAction: function ($event, items) {
|
onAction: function ($event, item) {
|
||||||
unassignDevicesFromEdge($event, items);
|
unassignFromEdge($event, item, false);
|
||||||
},
|
},
|
||||||
name: function() { return $translate.instant('device.unassign-devices') },
|
name: function() { return $translate.instant('action.unassign') },
|
||||||
details: function(selectedCount) {
|
details: function() { return $translate.instant('edge.unassign-from-edge') },
|
||||||
return $translate.instant('device.unassign-devices-from-edge-action-title', {count: selectedCount}, "messageformat");
|
icon: "assignment_return"
|
||||||
},
|
}
|
||||||
icon: "assignment_return"
|
);
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
vm.deviceGridConfig.addItemAction = {
|
deviceGroupActionsList.push(
|
||||||
onAction: function ($event) {
|
{
|
||||||
addDevicesToEdge($event);
|
onAction: function ($event, items) {
|
||||||
},
|
unassignDevicesFromEdge($event, items);
|
||||||
name: function() { return $translate.instant('device.assign-devices') },
|
},
|
||||||
details: function() { return $translate.instant('device.assign-new-device') },
|
name: function() { return $translate.instant('device.unassign-devices') },
|
||||||
icon: "add"
|
details: function(selectedCount) {
|
||||||
};
|
return $translate.instant('device.unassign-devices-from-edge-action-title', {count: selectedCount}, "messageformat");
|
||||||
|
},
|
||||||
|
icon: "assignment_return"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
vm.deviceGridConfig.addItemAction = {
|
||||||
|
onAction: function ($event) {
|
||||||
|
addDevicesToEdge($event);
|
||||||
|
},
|
||||||
|
name: function() { return $translate.instant('device.assign-devices') },
|
||||||
|
details: function() { return $translate.instant('device.assign-new-device') },
|
||||||
|
icon: "add"
|
||||||
|
};
|
||||||
|
} else if (vm.devicesScope === 'edge_customer_user') {
|
||||||
|
deviceActionsList.push(
|
||||||
|
{
|
||||||
|
onAction: function ($event, item) {
|
||||||
|
manageCredentials($event, item);
|
||||||
|
},
|
||||||
|
name: function() { return $translate.instant('device.credentials') },
|
||||||
|
details: function() { return $translate.instant('device.view-credentials') },
|
||||||
|
icon: "security"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
vm.deviceGridConfig.addItemAction = {};
|
||||||
|
}
|
||||||
vm.deviceGridConfig.addItemActions = [];
|
vm.deviceGridConfig.addItemActions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,16 +31,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div layout="row">
|
<div layout="row">
|
||||||
<md-button ng-click="onManageEdgeAssets({event: $event})"
|
<md-button ng-click="onManageEdgeAssets({event: $event})"
|
||||||
ng-show="!isEdit && edgeScope === 'tenant'"
|
ng-show="!isEdit && (edgeScope === 'tenant' || edgeScope === 'customer_user')"
|
||||||
class="md-raised md-primary">{{ 'edge.assets' | translate }}</md-button>
|
class="md-raised md-primary">{{ 'edge.assets' | translate }}</md-button>
|
||||||
<md-button ng-click="onManageEdgeDevices({event: $event})"
|
<md-button ng-click="onManageEdgeDevices({event: $event})"
|
||||||
ng-show="!isEdit && edgeScope === 'tenant'"
|
ng-show="!isEdit && (edgeScope === 'tenant' || edgeScope === 'customer_user')"
|
||||||
class="md-raised md-primary">{{ 'edge.devices' | translate }}</md-button>
|
class="md-raised md-primary">{{ 'edge.devices' | translate }}</md-button>
|
||||||
<md-button ng-click="onManageEdgeEntityViews({event: $event})"
|
<md-button ng-click="onManageEdgeEntityViews({event: $event})"
|
||||||
ng-show="!isEdit && edgeScope === 'tenant'"
|
ng-show="!isEdit && (edgeScope === 'tenant' || edgeScope === 'customer_user')"
|
||||||
class="md-raised md-primary">{{ 'edge.entity-views' | translate }}</md-button>
|
class="md-raised md-primary">{{ 'edge.entity-views' | translate }}</md-button>
|
||||||
<md-button ng-click="onManageEdgeDashboards({event: $event})"
|
<md-button ng-click="onManageEdgeDashboards({event: $event})"
|
||||||
ng-show="!isEdit && edgeScope === 'tenant'"
|
ng-show="!isEdit && (edgeScope === 'tenant' || edgeScope === 'customer_user')"
|
||||||
class="md-raised md-primary">{{ 'edge.dashboards' | translate }}</md-button>
|
class="md-raised md-primary">{{ 'edge.dashboards' | translate }}</md-button>
|
||||||
<md-button ng-click="onManageEdgeRuleChains({event: $event})"
|
<md-button ng-click="onManageEdgeRuleChains({event: $event})"
|
||||||
ng-show="!isEdit && edgeScope === 'tenant'"
|
ng-show="!isEdit && edgeScope === 'tenant'"
|
||||||
|
|||||||
@ -399,9 +399,59 @@ export function EdgeController($rootScope, userService, edgeService, customerSer
|
|||||||
|
|
||||||
} else if (vm.edgesScope === 'customer_user') {
|
} else if (vm.edgesScope === 'customer_user') {
|
||||||
vm.edgeGridConfig.addItemAction = {};
|
vm.edgeGridConfig.addItemAction = {};
|
||||||
|
edgeActionsList.push(
|
||||||
|
{
|
||||||
|
onAction: function ($event, item) {
|
||||||
|
openEdgeAssets($event, item);
|
||||||
|
},
|
||||||
|
name: function() { return $translate.instant('asset.assets') },
|
||||||
|
details: function() {
|
||||||
|
return $translate.instant('edge.manage-edge-assets');
|
||||||
|
},
|
||||||
|
icon: "domain"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
edgeActionsList.push(
|
||||||
|
{
|
||||||
|
onAction: function ($event, item) {
|
||||||
|
openEdgeDevices($event, item);
|
||||||
|
},
|
||||||
|
name: function() { return $translate.instant('device.devices') },
|
||||||
|
details: function() {
|
||||||
|
return $translate.instant('edge.manage-edge-devices');
|
||||||
|
},
|
||||||
|
icon: "devices_other"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
edgeActionsList.push(
|
||||||
|
{
|
||||||
|
onAction: function ($event, item) {
|
||||||
|
openEdgeEntityViews($event, item);
|
||||||
|
},
|
||||||
|
name: function() { return $translate.instant('entity-view.entity-views') },
|
||||||
|
details: function() {
|
||||||
|
return $translate.instant('edge.manage-edge-entity-views');
|
||||||
|
},
|
||||||
|
icon: "view_quilt"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
edgeActionsList.push(
|
||||||
|
{
|
||||||
|
onAction: function ($event, item) {
|
||||||
|
openEdgeDashboards($event, item);
|
||||||
|
},
|
||||||
|
name: function() { return $translate.instant('dashboard.dashboards') },
|
||||||
|
details: function() {
|
||||||
|
return $translate.instant('edge.manage-edge-dashboards');
|
||||||
|
},
|
||||||
|
icon: "dashboard"
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
vm.edgeGridConfig.addItemActions = [];
|
vm.edgeGridConfig.addItemActions = [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.edgeGridConfig.refreshParamsFunc = refreshEdgesParamsFunction;
|
vm.edgeGridConfig.refreshParamsFunc = refreshEdgesParamsFunction;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ export default function EdgeRoutes($stateProvider, types) {
|
|||||||
url: '/:edgeId/entityViews',
|
url: '/:edgeId/entityViews',
|
||||||
params: {'topIndex': 0},
|
params: {'topIndex': 0},
|
||||||
module: 'private',
|
module: 'private',
|
||||||
auth: ['TENANT_ADMIN'],
|
auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
|
||||||
views: {
|
views: {
|
||||||
"content@home": {
|
"content@home": {
|
||||||
templateUrl: entityViewsTemplate,
|
templateUrl: entityViewsTemplate,
|
||||||
@ -77,7 +77,7 @@ export default function EdgeRoutes($stateProvider, types) {
|
|||||||
url: '/:edgeId/devices',
|
url: '/:edgeId/devices',
|
||||||
params: {'topIndex': 0},
|
params: {'topIndex': 0},
|
||||||
module: 'private',
|
module: 'private',
|
||||||
auth: ['TENANT_ADMIN'],
|
auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
|
||||||
views: {
|
views: {
|
||||||
"content@home": {
|
"content@home": {
|
||||||
templateUrl: devicesTemplate,
|
templateUrl: devicesTemplate,
|
||||||
@ -99,7 +99,7 @@ export default function EdgeRoutes($stateProvider, types) {
|
|||||||
url: '/:edgeId/assets',
|
url: '/:edgeId/assets',
|
||||||
params: {'topIndex': 0},
|
params: {'topIndex': 0},
|
||||||
module: 'private',
|
module: 'private',
|
||||||
auth: ['TENANT_ADMIN'],
|
auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
|
||||||
views: {
|
views: {
|
||||||
"content@home": {
|
"content@home": {
|
||||||
templateUrl: assetsTemplate,
|
templateUrl: assetsTemplate,
|
||||||
@ -121,7 +121,7 @@ export default function EdgeRoutes($stateProvider, types) {
|
|||||||
url: '/:edgeId/dashboards',
|
url: '/:edgeId/dashboards',
|
||||||
params: {'topIndex': 0},
|
params: {'topIndex': 0},
|
||||||
module: 'private',
|
module: 'private',
|
||||||
auth: ['TENANT_ADMIN'],
|
auth: ['TENANT_ADMIN', 'CUSTOMER_USER'],
|
||||||
views: {
|
views: {
|
||||||
"content@home": {
|
"content@home": {
|
||||||
templateUrl: dashboardsTemplate,
|
templateUrl: dashboardsTemplate,
|
||||||
|
|||||||
@ -118,7 +118,11 @@ export function EntityViewController($rootScope, userService, entityViewService,
|
|||||||
var user = userService.getCurrentUser();
|
var user = userService.getCurrentUser();
|
||||||
|
|
||||||
if (user.authority === 'CUSTOMER_USER') {
|
if (user.authority === 'CUSTOMER_USER') {
|
||||||
vm.entityViewsScope = 'customer_user';
|
if (vm.entityViewsScope === 'edge') {
|
||||||
|
vm.entityViewsScope = 'edge_customer_user';
|
||||||
|
} else {
|
||||||
|
vm.entityViewsScope = 'customer_user';
|
||||||
|
}
|
||||||
customerId = user.customerId;
|
customerId = user.customerId;
|
||||||
}
|
}
|
||||||
if (customerId) {
|
if (customerId) {
|
||||||
@ -284,48 +288,63 @@ export function EntityViewController($rootScope, userService, entityViewService,
|
|||||||
} else if (vm.entityViewsScope === 'customer_user') {
|
} else if (vm.entityViewsScope === 'customer_user') {
|
||||||
vm.entityViewGridConfig.addItemAction = {};
|
vm.entityViewGridConfig.addItemAction = {};
|
||||||
}
|
}
|
||||||
} else if (vm.entityViewsScope === 'edge') {
|
} else if (vm.entityViewsScope === 'edge' || vm.entityViewsScope === 'edge_customer_user') {
|
||||||
fetchEntityViewsFunction = function (pageLink) {
|
fetchEntityViewsFunction = function (pageLink) {
|
||||||
return entityViewService.getEdgeEntityViews(edgeId, pageLink, null);
|
return entityViewService.getEdgeEntityViews(edgeId, pageLink, null);
|
||||||
};
|
};
|
||||||
deleteEntityViewFunction = function (entityViewId) {
|
|
||||||
return entityViewService.unassignEntityViewFromEdge(edgeId, entityViewId);
|
|
||||||
};
|
|
||||||
refreshEntityViewsParamsFunction = function () {
|
|
||||||
return {"edgeId": edgeId, "topIndex": vm.topIndex};
|
|
||||||
};
|
|
||||||
|
|
||||||
entityViewActionsList.push({
|
if (vm.entityViewsScope === 'edge') {
|
||||||
onAction: function ($event, item) {
|
deleteEntityViewFunction = function (entityViewId) {
|
||||||
unassignFromEdge($event, item, false);
|
return entityViewService.unassignEntityViewFromEdge(edgeId, entityViewId);
|
||||||
},
|
};
|
||||||
name: function() { return $translate.instant('action.unassign') },
|
refreshEntityViewsParamsFunction = function () {
|
||||||
details: function() { return $translate.instant('edge.unassign-from-edge') },
|
return {"edgeId": edgeId, "topIndex": vm.topIndex};
|
||||||
icon: "assignment_return"
|
};
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
entityViewGroupActionsList.push(
|
entityViewActionsList.push({
|
||||||
{
|
onAction: function ($event, item) {
|
||||||
onAction: function ($event, items) {
|
unassignFromEdge($event, item, false);
|
||||||
unassignEntityViewsFromEdge($event, items);
|
},
|
||||||
},
|
name: function () {
|
||||||
name: function() { return $translate.instant('entity-view.unassign-entity-views') },
|
return $translate.instant('action.unassign')
|
||||||
details: function(selectedCount) {
|
},
|
||||||
return $translate.instant('entity-view.unassign-entity-views-from-edge-action-title', {count: selectedCount}, "messageformat");
|
details: function () {
|
||||||
},
|
return $translate.instant('edge.unassign-from-edge')
|
||||||
icon: "assignment_return"
|
},
|
||||||
}
|
icon: "assignment_return"
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
vm.entityViewGridConfig.addItemAction = {
|
entityViewGroupActionsList.push(
|
||||||
onAction: function ($event) {
|
{
|
||||||
addEntityViewsToEdge($event);
|
onAction: function ($event, items) {
|
||||||
},
|
unassignEntityViewsFromEdge($event, items);
|
||||||
name: function() { return $translate.instant('entity-view.assign-entity-views') },
|
},
|
||||||
details: function() { return $translate.instant('entity-view.assign-new-entity-view') },
|
name: function () {
|
||||||
icon: "add"
|
return $translate.instant('entity-view.unassign-entity-views')
|
||||||
};
|
},
|
||||||
|
details: function (selectedCount) {
|
||||||
|
return $translate.instant('entity-view.unassign-entity-views-from-edge-action-title', {count: selectedCount}, "messageformat");
|
||||||
|
},
|
||||||
|
icon: "assignment_return"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
vm.entityViewGridConfig.addItemAction = {
|
||||||
|
onAction: function ($event) {
|
||||||
|
addEntityViewsToEdge($event);
|
||||||
|
},
|
||||||
|
name: function () {
|
||||||
|
return $translate.instant('entity-view.assign-entity-views')
|
||||||
|
},
|
||||||
|
details: function () {
|
||||||
|
return $translate.instant('entity-view.assign-new-entity-view')
|
||||||
|
},
|
||||||
|
icon: "add"
|
||||||
|
};
|
||||||
|
} else if (vm.entityViewsScope === 'edge_customer_user') {
|
||||||
|
vm.entityViewGridConfig.addItemAction = {};
|
||||||
|
}
|
||||||
vm.entityViewGridConfig.addItemActions = [];
|
vm.entityViewGridConfig.addItemActions = [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user