Merge remote-tracking branch 'upstream/application-mgt-new' into application-mgt-new

# Conflicts:
#	components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/InstalledDevicesTable.js
#	components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js
feature/appm-store/pbac
Jayasanka 5 years ago
commit dff6d74c72

@ -585,20 +585,20 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
+ "AR.CURRENT_STATE AS RELEASE_CURRENT_STATE, " + "AR.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
+ "AR.RATED_USERS AS RATED_USER_COUNT " + "AR.RATED_USERS AS RATED_USER_COUNT "
+ "FROM AP_APP_RELEASE AS AR " + "FROM AP_APP_RELEASE AS AR "
+ "WHERE AR.TENANT_ID = ? AND AR.PACKAGE_NAME IN ("; + "WHERE AR.PACKAGE_NAME IN (";
StringJoiner joiner = new StringJoiner(",", sql, ")"); StringJoiner joiner = new StringJoiner(",", sql, ") AND AR.TENANT_ID = ? ");
packages.stream().map(ignored -> "?").forEach(joiner::add); packages.stream().map(ignored -> "?").forEach(joiner::add);
sql = joiner.toString(); sql = joiner.toString();
try { try {
Connection connection = this.getDBConnection(); Connection connection = this.getDBConnection();
try (PreparedStatement statement = connection.prepareStatement(sql)) { try (PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setInt(1, tenantId); int index = 1;
for (int y = 0; y < packages.size(); y++) { for (String packageName : packages) {
// y +2 because tenantId parameter is 1 and the counter is starting at o for y statement.setObject(index++, packageName);
statement.setString(y+2, packages.get(y));
} }
statement.setInt(index, tenantId);
try (ResultSet resultSet = statement.executeQuery()) { try (ResultSet resultSet = statement.executeQuery()) {
List<ApplicationReleaseDTO> releaseDTOs = new ArrayList<>(); List<ApplicationReleaseDTO> releaseDTOs = new ArrayList<>();
while (resultSet.next()) { while (resultSet.next()) {

@ -195,16 +195,21 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationDTO applicationDTO = APIUtil.convertToAppDTO(publicAppWrapper); ApplicationDTO applicationDTO = APIUtil.convertToAppDTO(publicAppWrapper);
ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0); ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0);
String appInstallerUrl = publicAppStorePath + applicationReleaseDTO.getPackageName(); String appInstallerUrl = publicAppStorePath + applicationReleaseDTO.getPackageName();
//todo check app package name exist or not, do it in validation method
applicationReleaseDTO.setInstallerName(appInstallerUrl); applicationReleaseDTO.setInstallerName(appInstallerUrl);
applicationReleaseDTO.setUuid(UUID.randomUUID().toString()); applicationReleaseDTO.setUuid(UUID.randomUUID().toString());
applicationReleaseDTO.setAppHashValue(DigestUtils.md5Hex(appInstallerUrl)); applicationReleaseDTO.setAppHashValue(DigestUtils.md5Hex(appInstallerUrl));
ConnectionManagerUtil.openDBConnection();
List<ApplicationReleaseDTO> exitingRelease;
try { try {
exitingRelease = applicationReleaseDAO.getReleaseByPackages(Arrays.asList(applicationReleaseDTO.getPackageName()) ConnectionManagerUtil.openDBConnection();
, tenantId); List<ApplicationReleaseDTO> exitingPubAppReleases = applicationReleaseDAO
.getReleaseByPackages(Collections.singletonList(applicationReleaseDTO.getPackageName()), tenantId);
if (!exitingPubAppReleases.isEmpty()){
String msg = "Public app release exists for package name " + applicationReleaseDTO.getPackageName()
+ ". Hence you can't add new public app for package name "
+ applicationReleaseDTO.getPackageName();
log.error(msg);
throw new BadRequestException(msg);
}
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
String msg = "Error Occured when fetching release: " + publicAppWrapper.getName(); String msg = "Error Occured when fetching release: " + publicAppWrapper.getName();
log.error(msg); log.error(msg);
@ -213,33 +218,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
if (exitingRelease != null && !exitingRelease.isEmpty()) {
applicationDTO.getApplicationReleaseDTOs().clear();
applicationReleaseDTO.setUuid(exitingRelease.get(0).getUuid());
applicationReleaseDTO.setCurrentState(exitingRelease.get(0).getCurrentState());
try { try {
applicationReleaseDTO = addImageArtifacts(applicationReleaseDTO, applicationArtifact, tenantId);
applicationDTO.getApplicationReleaseDTOs().add(applicationReleaseDTO);
ConnectionManagerUtil.beginDBTransaction();
applicationReleaseDAO.updateRelease(applicationReleaseDTO, tenantId);
ConnectionManagerUtil.commitDBTransaction();
return APIUtil.appDtoToAppResponse(applicationDTO);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occurred when updating public app: " + publicAppWrapper.getName();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) {
String msg = "Error occurred when adding artifacts of release: " + publicAppWrapper.getName();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
} else {
//uploading application artifacts //uploading application artifacts
try {
applicationReleaseDTO = addImageArtifacts(applicationReleaseDTO, applicationArtifact, tenantId); applicationReleaseDTO = addImageArtifacts(applicationReleaseDTO, applicationArtifact, tenantId);
applicationDTO.getApplicationReleaseDTOs().clear(); applicationDTO.getApplicationReleaseDTOs().clear();
applicationDTO.getApplicationReleaseDTOs().add(applicationReleaseDTO); applicationDTO.getApplicationReleaseDTOs().add(applicationReleaseDTO);
@ -252,8 +232,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
return addAppDataIntoDB(applicationDTO, tenantId); return addAppDataIntoDB(applicationDTO, tenantId);
} }
}
@Override @Override
public Application createCustomApp(CustomAppWrapper customAppWrapper, ApplicationArtifact applicationArtifact) public Application createCustomApp(CustomAppWrapper customAppWrapper, ApplicationArtifact applicationArtifact)
throws ApplicationManagementException { throws ApplicationManagementException {
@ -316,6 +294,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
/**
* Delete Application release artifacts
*
* @param directoryPaths Directory paths
* @param tenantId Tenant Id
* @throws ApplicationManagementException if error occurred while deleting application release artifacts.
*/
private void deleteApplicationArtifacts(List<String> directoryPaths, int tenantId) throws ApplicationManagementException { private void deleteApplicationArtifacts(List<String> directoryPaths, int tenantId) throws ApplicationManagementException {
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
try { try {
@ -328,6 +313,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
/**
* To add Application release artifacts
*
* @param deviceType Device Type
* @param applicationReleaseDTO Application Release
* @param applicationArtifact Application release artifacts
* @param isNewRelease Is new release or Not
* @return {@link ApplicationReleaseDTO}
* @throws ResourceManagementException if error occurred while handling application release artifacts.
* @throws ApplicationManagementException if error occurred while handling application release data.
*/
private ApplicationReleaseDTO addApplicationReleaseArtifacts(String deviceType, private ApplicationReleaseDTO addApplicationReleaseArtifacts(String deviceType,
ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact, boolean isNewRelease) ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact, boolean isNewRelease)
throws ResourceManagementException, ApplicationManagementException { throws ResourceManagementException, ApplicationManagementException {
@ -402,6 +398,16 @@ public class ApplicationManagerImpl implements ApplicationManager {
return applicationReleaseDTO; return applicationReleaseDTO;
} }
/**
* This method could be used to update enterprise application release artifacts.
*
* @param deviceType Device Type
* @param applicationReleaseDTO Application Release
* @param applicationArtifact Application release artifacts
* @return {@link ApplicationReleaseDTO}
* @throws ResourceManagementException if error occurred while handling application release artifacts.
* @throws ApplicationManagementException if error occurred while handling application release data.
*/
private ApplicationReleaseDTO updateEntAppReleaseArtifact(String deviceType, private ApplicationReleaseDTO updateEntAppReleaseArtifact(String deviceType,
ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact) ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact)
throws ResourceManagementException, ApplicationManagementException { throws ResourceManagementException, ApplicationManagementException {
@ -489,6 +495,15 @@ public class ApplicationManagerImpl implements ApplicationManager {
return applicationReleaseDTO; return applicationReleaseDTO;
} }
/**
* Add image artifacts into file system
*
* @param applicationReleaseDTO Application Release
* @param applicationArtifact Image artifacts
* @param tenantId Tenant Id
* @return {@link ApplicationReleaseDTO}
* @throws ResourceManagementException if error occurred while uploading image artifacts into file system.
*/
private ApplicationReleaseDTO addImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO, private ApplicationReleaseDTO addImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO,
ApplicationArtifact applicationArtifact, int tenantId) throws ResourceManagementException { ApplicationArtifact applicationArtifact, int tenantId) throws ResourceManagementException {
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
@ -518,6 +533,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
return applicationReleaseDTO; return applicationReleaseDTO;
} }
/**
* Update Image artifacts of Application RApplication Release
*
* @param applicationArtifact Application release Artifacts
* @param tenantId Tenant Id
* @return {@link ApplicationReleaseDTO}
* @throws ResourceManagementException if error occurred while uploading application release artifacts into the file system.
*/
private ApplicationReleaseDTO updateImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO, private ApplicationReleaseDTO updateImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO,
ApplicationArtifact applicationArtifact, int tenantId) throws ResourceManagementException{ ApplicationArtifact applicationArtifact, int tenantId) throws ResourceManagementException{
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
@ -674,9 +697,19 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
/**
* Check whether at least one filtering role is in app unrestricted roles.
*
* @param appUnrestrictedRoles Application unrestricted roles
* @param filteringUnrestrictedRoles Filtering roles
* @param userName Username
* @return True if one filtering unrestricted role is associated with application unrestricted roles.
* @throws BadRequestException if user doesn't have assigned at least one filtering role
* @throws UserStoreException if error occurred when checking whether user has assigned at least one filtering role.
*/
private boolean hasAppUnrestrictedRole(List<String> appUnrestrictedRoles, List<String> filteringUnrestrictedRoles, private boolean hasAppUnrestrictedRole(List<String> appUnrestrictedRoles, List<String> filteringUnrestrictedRoles,
String userName) throws BadRequestException, UserStoreException { String userName) throws BadRequestException, UserStoreException {
if (!haveAllUserRoles(filteringUnrestrictedRoles, userName)) { if (!hasUserRole(filteringUnrestrictedRoles, userName)) {
String msg = String msg =
"At least one filtering role is not assigned for the user: " + userName + ". Hence user " + userName "At least one filtering role is not assigned for the user: " + userName + ". Hence user " + userName
+ " Can't filter applications by giving these unrestricted role list"; + " Can't filter applications by giving these unrestricted role list";
@ -850,7 +883,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId()); DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
if (!isValidOsVersions(entAppReleaseWrapper.getSupportedOsVersions(), deviceType.getName())) { if (isInvalidOsVersionRange(entAppReleaseWrapper.getSupportedOsVersions(), deviceType.getName())) {
String msg = "You are trying to add application release which has invalid or unsupported OS versions in " String msg = "You are trying to add application release which has invalid or unsupported OS versions in "
+ "the supportedOsVersions section. Hence, please re-evaluate the request payload."; + "the supportedOsVersions section. Hence, please re-evaluate the request payload.";
log.error(msg); log.error(msg);
@ -897,6 +930,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
/**
* Get Application and all application releases associated to the application that has given application Id
*
* @param applicationId Application Id
* @return {@link ApplicationDTO}
* @throws ApplicationManagementException if error occurred application data from the databse.
*/
private ApplicationDTO getApplication(int applicationId) throws ApplicationManagementException { private ApplicationDTO getApplication(int applicationId) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { try {
@ -909,8 +949,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
return applicationDTO; return applicationDTO;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the database connection for getting application for the " String msg = "Error occurred while obtaining the database connection for getting application for the app ID"
+ "application ID: " + applicationId; + " " + applicationId;
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
@ -922,6 +962,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
/**
* Upload enterprise application release artifact into file system.
*
* @param releaseDTO Apllication Release
* @param applicationArtifact Application Release artifacts
* @param deviceTypeName Device Type name
* @param tenantId Tenant Id
* @param isNewRelease New Release or Not
* @return {@link ApplicationReleaseDTO}
* @throws ApplicationManagementException if error occurred while uploading artifacts into file system.
*/
private ApplicationReleaseDTO uploadEntAppReleaseArtifacts(ApplicationReleaseDTO releaseDTO, private ApplicationReleaseDTO uploadEntAppReleaseArtifacts(ApplicationReleaseDTO releaseDTO,
ApplicationArtifact applicationArtifact, String deviceTypeName, int tenantId, boolean isNewRelease) ApplicationArtifact applicationArtifact, String deviceTypeName, int tenantId, boolean isNewRelease)
throws ApplicationManagementException { throws ApplicationManagementException {
@ -936,7 +987,16 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
private boolean isValidOsVersions(String osRange, String deviceTypeName) /**
* Check whether given OS range is valid or invalid
*
* @param osRange OS range
* @param deviceTypeName Device Type
* @return true if invalid OS range, Otherwise returns false
* @throws ApplicationManagementException if error occurred while getting device type version for lower OS version
* and higher OS version
*/
private boolean isInvalidOsVersionRange(String osRange, String deviceTypeName)
throws ApplicationManagementException { throws ApplicationManagementException {
String lowestSupportingOsVersion; String lowestSupportingOsVersion;
String highestSupportingOsVersion = null; String highestSupportingOsVersion = null;
@ -949,9 +1009,9 @@ public class ApplicationManagerImpl implements ApplicationManager {
try { try {
DeviceManagementProviderService deviceManagementProviderService = DAOUtil.getDeviceManagementService(); DeviceManagementProviderService deviceManagementProviderService = DAOUtil.getDeviceManagementService();
return deviceManagementProviderService.getDeviceTypeVersion(deviceTypeName, lowestSupportingOsVersion) return deviceManagementProviderService.getDeviceTypeVersion(deviceTypeName, lowestSupportingOsVersion)
!= null && (highestSupportingOsVersion == null == null || (highestSupportingOsVersion != null
|| deviceManagementProviderService.getDeviceTypeVersion(deviceTypeName, highestSupportingOsVersion) && deviceManagementProviderService.getDeviceTypeVersion(deviceTypeName, highestSupportingOsVersion)
!= null); == null);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = String msg =
"Error occurred while getting supported device type versions for device type : " + deviceTypeName; "Error occurred while getting supported device type versions for device type : " + deviceTypeName;
@ -1152,9 +1212,16 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
/**
* Check whether at least one role is assigned to the given user.
*
* @param unrestrictedRoleList unrestricted role list
* @param userName Username
* @return true at least one unrestricted role has assigned to given user, otherwise returns false.
* @throws UserStoreException If it is unable to load {@link UserRealm} from {@link CarbonContext}
*/
private boolean hasUserRole(Collection<String> unrestrictedRoleList, String userName) throws UserStoreException { private boolean hasUserRole(Collection<String> unrestrictedRoleList, String userName) throws UserStoreException {
String[] roleList; String[] roleList = getRolesOfUser(userName);
roleList = getRolesOfUser(userName);
for (String unrestrictedRole : unrestrictedRoleList) { for (String unrestrictedRole : unrestrictedRoleList) {
for (String role : roleList) { for (String role : roleList) {
if (unrestrictedRole.equals(role)) { if (unrestrictedRole.equals(role)) {
@ -1165,30 +1232,18 @@ public class ApplicationManagerImpl implements ApplicationManager {
return false; return false;
} }
private boolean haveAllUserRoles(Collection<String> unrestrictedRoleList, String userName) /**
throws UserStoreException { * Check whether valid unrestricted role list or not
String[] roleList; *
roleList = getRolesOfUser(userName); * @return true or false
for (String unrestrictedRole : unrestrictedRoleList) { * @throws UserStoreException If it is unable to load {@link UserRealm} from {@link CarbonContext}
for (String role : roleList) { */
if (!unrestrictedRole.equals(role)) {
return false;
}
}
}
return true;
}
private boolean isValidRestrictedRole(Collection<String> unrestrictedRoleList) throws UserStoreException { private boolean isValidRestrictedRole(Collection<String> unrestrictedRoleList) throws UserStoreException {
List<String> roleList = new ArrayList<>(Arrays.asList(getRoleNames()));
return roleList.containsAll(unrestrictedRoleList);
}
private String[] getRoleNames() throws UserStoreException {
//todo check role by role //todo check role by role
UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm(); UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm();
if (userRealm != null) { if (userRealm != null) {
return userRealm.getUserStoreManager().getRoleNames(); List<String> roleList = new ArrayList<>(Arrays.asList(userRealm.getUserStoreManager().getRoleNames()));
return roleList.containsAll(unrestrictedRoleList);
} else { } else {
String msg = "User realm is not initiated."; String msg = "User realm is not initiated.";
log.error(msg); log.error(msg);
@ -1196,6 +1251,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
/**
* Get assigned role list of the given user.
*
* @param userName Username
* @return List of roles
* @throws UserStoreException If it is unable to load {@link UserRealm} from {@link CarbonContext}
*/
private String[] getRolesOfUser(String userName) throws UserStoreException { private String[] getRolesOfUser(String userName) throws UserStoreException {
UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm(); UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm();
String[] roleList; String[] roleList;
@ -2119,6 +2181,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
@Override
public List<String> addApplicationTags(int appId, List<String> tags) throws ApplicationManagementException { public List<String> addApplicationTags(int appId, List<String> tags) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { try {
@ -2171,6 +2234,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
@Override
public List<String> addCategories(List<String> categories) throws ApplicationManagementException { public List<String> addCategories(List<String> categories) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { try {
@ -2291,7 +2355,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
return lifecycleStateManager.getInstallableState(); return lifecycleStateManager.getInstallableState();
} }
/**
* This method can be used to validate {@link Filter} object.
*
* @param filter {@link Filter}
* @throws BadRequestException if filter object contains incompatible data.
*/
private void validateFilter(Filter filter) throws BadRequestException { private void validateFilter(Filter filter) throws BadRequestException {
if (filter == null) { if (filter == null) {
String msg = "Filter validation is failed, Filter shouldn't be null, hence please verify the request payload"; String msg = "Filter validation is failed, Filter shouldn't be null, hence please verify the request payload";
@ -2340,9 +2409,16 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
} }
/**
* This method can be used to get difference of two lists.
*
* @param list1 List of objects
* @param list2 List of object
* @param <T> Object type
* @return return list of values which are not in the list2 but in the list1
*/
private <T> List<T> getDifference(List<T> list1, Collection<T> list2) { private <T> List<T> getDifference(List<T> list1, Collection<T> list2) {
List<T> list = new ArrayList<>(); List<T> list = new ArrayList<>();
for (T t : list1) { for (T t : list1) {
@ -2353,7 +2429,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
return list; return list;
} }
/*** /**
* By invoking the method, it returns Lifecycle State Instance. * By invoking the method, it returns Lifecycle State Instance.
* @param currentState Current state of the lifecycle * @param currentState Current state of the lifecycle
* @param previousState Previouse state of the Lifecycle * @param previousState Previouse state of the Lifecycle
@ -2726,7 +2802,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
.equals(appType)) { .equals(appType)) {
DeviceType deviceTypeObj = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId()); DeviceType deviceTypeObj = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
String supportedOSVersions = applicationReleaseDTO.getSupportedOsVersions(); String supportedOSVersions = applicationReleaseDTO.getSupportedOsVersions();
if (!StringUtils.isEmpty(supportedOSVersions) && !isValidOsVersions(supportedOSVersions, if (!StringUtils.isEmpty(supportedOSVersions) && isInvalidOsVersionRange(supportedOSVersions,
deviceTypeObj.getName())) { deviceTypeObj.getName())) {
String msg = "You are trying to update application release which has invalid or unsupported OS " String msg = "You are trying to update application release which has invalid or unsupported OS "
+ "versions in the supportedOsVersions section. Hence, please re-evaluate the request payload."; + "versions in the supportedOsVersions section. Hence, please re-evaluate the request payload.";
@ -2736,7 +2812,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
} }
@Override @Override
public <T> void validateAppCreatingRequest(T param) throws ApplicationManagementException { public <T> void validateAppCreatingRequest(T param) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
@ -2988,7 +3063,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (!isValidOsVersions(entAppReleaseWrapper.get().getSupportedOsVersions(), deviceType)) { if (isInvalidOsVersionRange(entAppReleaseWrapper.get().getSupportedOsVersions(), deviceType)) {
String msg = "You are trying to create application which has an application release contains invalid or " String msg = "You are trying to create application which has an application release contains invalid or "
+ "unsupported OS versions in the supportedOsVersions section. Hence, please re-evaluate the " + "unsupported OS versions in the supportedOsVersions section. Hence, please re-evaluate the "
+ "request payload."; + "request payload.";
@ -3031,7 +3106,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (!isValidOsVersions(publicAppReleaseWrapper.getSupportedOsVersions(), deviceType)) { if (isInvalidOsVersionRange(publicAppReleaseWrapper.getSupportedOsVersions(), deviceType)) {
String msg = "You are trying to create application which has an application release contains invalid or " String msg = "You are trying to create application which has an application release contains invalid or "
+ "unsupported OS versions in the supportedOsVersions section. Hence, please re-evaluate the " + "unsupported OS versions in the supportedOsVersions section. Hence, please re-evaluate the "
+ "request payload."; + "request payload.";

@ -198,12 +198,16 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
} catch (BadRequestException e) {
String msg = "Found incompatible payload with ent. app creating request.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating the ent. application"; String msg = "Error occurred while creating the ent. application";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Error occurred while handling the ent. application creating request"; String msg = "Couldn't find the required artifacts to create new ent. application with the request";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -237,12 +241,16 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
} catch (BadRequestException e) {
String msg = "Found incompatible payload with web app creating request.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating the web application"; String msg = "Error occurred while creating the web application";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Error occurred while handling the web app creating request"; String msg = "Couldn't find the required artifacts to create new web application with the request";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -276,12 +284,16 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
} catch (BadRequestException e) {
String msg = "Found incompatible payload with pub app creating request.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating the public app."; String msg = "Error occurred while creating the public app.";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Error occurred while handling the public app creating request"; String msg = "Couldn't find the required artifacts to create new public application with the request";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -317,12 +329,16 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
} catch (BadRequestException e) {
String msg = "Found incompatible payload with pub custom creating request.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating the application"; String msg = "Error occurred while creating the application";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Error occurred while handling the application creating request"; String msg = "Couldn't find the required artifacts to create new custom application with the request";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -908,6 +924,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
} }
/*** /***
* This method can be used to construct {@link ApplicationArtifact}
* *
* @param binaryFile binary file of the application release * @param binaryFile binary file of the application release
* @param iconFile icon file of the application release * @param iconFile icon file of the application release

@ -17,12 +17,11 @@
"moment": "latest", "moment": "latest",
"prop-types": "latest", "prop-types": "latest",
"rc-viewer": "0.0.9", "rc-viewer": "0.0.9",
"react-advanced-datetimerange-picker": "^1.0.8", "react-bootstrap": "^1.0.0-beta.12",
"react-highlight-words": "^0.16.0", "react-highlight-words": "^0.16.0",
"react-image-viewer-zoom": "^1.0.36", "react-image-viewer-zoom": "^1.0.36",
"react-infinite-scroller": "^1.2.4", "react-infinite-scroller": "^1.2.4",
"react-leaflet": "^2.4.0", "react-leaflet": "^2.4.0",
"react-bootstrap": "^1.0.0-beta.12",
"react-moment": "^0.9.2", "react-moment": "^0.9.2",
"react-router": "^5.0.1", "react-router": "^5.0.1",
"react-router-config": "^5.0.1", "react-router-config": "^5.0.1",
@ -31,6 +30,7 @@
"react-star-ratings": "^2.3.0", "react-star-ratings": "^2.3.0",
"react-twemoji": "^0.2.3", "react-twemoji": "^0.2.3",
"react-virtualized": "^9.21.1", "react-virtualized": "^9.21.1",
"react-websocket": "^2.1.0",
"reqwest": "^2.0.5", "reqwest": "^2.0.5",
"storm-react-diagrams": "^5.2.1" "storm-react-diagrams": "^5.2.1"
}, },

@ -1,6 +1,6 @@
{ {
"theme": { "theme": {
"logo" : "https://localhost:9443/entgra/public/images/logo.svg", "logo" : "https://entgra.io/assets/images/svg/logo.svg",
"primaryColor": "rgb(24, 144, 255)" "primaryColor": "rgb(24, 144, 255)"
}, },
"serverConfig": { "serverConfig": {

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 48 KiB

@ -67,18 +67,53 @@ class App extends React.Component {
axios.get( axios.get(
window.location.origin + "/entgra/public/conf/config.json", window.location.origin + "/entgra/public/conf/config.json",
).then(res => { ).then(res => {
console.log(res); const config = res.data;
this.checkUserLoggedIn(config);
}).catch((error) => {
this.setState({ this.setState({
loading: false, loading: false,
config: res.data error: true
}) })
});
}
checkUserLoggedIn = (config) => {
axios.post(
window.location.origin + "/entgra-ui-request-handler/user",
"platform=entgra"
).then(res => {
config.user = res.data.data;
const pageURL = window.location.pathname;
const lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1);
if (lastURLSegment === "login") {
window.location.href = window.location.origin + `/entgra/`;
} else {
this.setState({
loading: false,
config: config
});
}
}).catch((error) => { }).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
const redirectUrl = encodeURI(window.location.href);
const pageURL = window.location.pathname;
const lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1);
if (lastURLSegment !== "login") {
window.location.href = window.location.origin + `/entgra/login?redirect=${redirectUrl}`;
} else {
this.setState({
loading: false,
config: config
})
}
} else {
this.setState({ this.setState({
loading: false, loading: false,
error: true error: true
}) })
});
} }
});
};
render() { render() {
const {loading, error} = this.state; const {loading, error} = this.state;

@ -0,0 +1,145 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import axios from "axios";
import {message, notification, Typography, Icon, Card, Col, Row} from "antd";
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
import en from 'javascript-time-ago/locale/en'
import {withConfigContext} from "../../context/ConfigContext";
const {Text} = Typography;
let config = null;
let apiUrl;
class DeviceTypesTable extends React.Component {
constructor(props) {
super(props);
config = this.props.context;
TimeAgo.addLocale(en);
this.state = {
data: [],
pagination: {},
loading: false,
selectedRows: []
};
}
componentDidMount() {
this.fetchUsers();
}
//fetch data from api
fetchUsers = (params = {}) => {
const config = this.props.context;
this.setState({loading: true});
// get current page
const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
const extraParams = {
offset: 10 * (currentPage - 1), //calculate the offset
limit: 10,
};
const encodedExtraParams = Object.keys(extraParams)
.map(key => key + '=' + extraParams[key]).join('&');
apiUrl = window.location.origin + config.serverConfig.invoker.uri +
config.serverConfig.invoker.deviceMgt +
"/device-types";
//send request to the invokerss
axios.get(apiUrl).then(res => {
if (res.status === 200) {
const pagination = {...this.state.pagination};
this.setState({
loading: false,
data: JSON.parse(res.data.data),
pagination,
});
}
}).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popop with error
message.error('You are not logged in');
window.location.href = window.location.origin + '/entgra/login';
} else {
notification["error"]({
message: "There was a problem",
duration: 0,
description:"Error occurred while trying to load device types.",
});
}
this.setState({loading: false});
});
};
handleTableChange = (pagination, filters, sorter) => {
const pager = {...this.state.pagination};
pager.current = pagination.current;
this.setState({
pagination: pager,
});
this.fetch({
results: pagination.pageSize,
page: pagination.current,
sortField: sorter.field,
sortOrder: sorter.order,
...filters,
});
};
render() {
const {data, pagination, loading, selectedRows} = this.state;
const { Meta } = Card;
const itemCard = data.map((data) =>
<Col span={5} key={data.id}>
<Card
size="default"
style={{ width: 200 }}
bordered={true}
actions={[
<Icon type="setting" key="setting" />,
<Icon type="edit" key="edit" />,]}
>
<Meta
avatar={<Icon type="desktop" key="device-types"/>}
title={data.name}
/>
</Card>
</Col>
);
return (
<div style={{ background: '#ECECEC', padding: '20px' }}>
<Row gutter={16}>
{itemCard}
</Row>
</div>
);
}
}
export default withConfigContext(DeviceTypesTable);

@ -18,7 +18,7 @@
import React from "react"; import React from "react";
import axios from "axios"; import axios from "axios";
import {Tag, message, notification, Table, Typography, Tooltip, Icon, Divider, Button, Modal, Select} from "antd"; import {Tag, message, notification, Table, Typography, Tooltip, Icon, Modal, Select} from "antd";
import TimeAgo from 'javascript-time-ago' import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules. // Load locale-specific relative date/time formatting rules.
@ -133,18 +133,11 @@ class DeviceTable extends React.Component {
selectedRows: [], selectedRows: [],
deviceGroups: [], deviceGroups: [],
groupModalVisible: false, groupModalVisible: false,
selectedGroupId: [] selectedGroupId: [],
selectedRowKeys:[]
}; };
} }
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
selectedRows: selectedRows
});
}
};
componentDidMount() { componentDidMount() {
this.fetch(); this.fetch();
} }
@ -176,7 +169,7 @@ class DeviceTable extends React.Component {
this.setState({ this.setState({
loading: false, loading: false,
data: res.data.data.devices, data: res.data.data.devices,
pagination, pagination
}); });
} }
@ -249,11 +242,14 @@ class DeviceTable extends React.Component {
).then(res => { ).then(res => {
if (res.status === 200) { if (res.status === 200) {
this.fetch(); this.fetch();
this.setState({
selectedRowKeys:[]
})
notification["success"]({ notification["success"]({
message: "Done", message: "Done",
duration: 4, duration: 4,
description: description:
"Successfully disenrolled the device.", "Successfully dis-enrolled the device.",
}); });
} }
}).catch((error) => { }).catch((error) => {
@ -266,7 +262,7 @@ class DeviceTable extends React.Component {
message: "There was a problem", message: "There was a problem",
duration: 0, duration: 0,
description: description:
"Error occurred while trying to disenroll devices.", "Error occurred while trying to dis-enroll devices.",
}); });
} }
@ -409,11 +405,30 @@ class DeviceTable extends React.Component {
}); });
}; };
render() { onSelectChange = (selectedRowKeys, selectedRows) => {
const {data, pagination, loading, selectedRows} = this.state; this.setState({
selectedRowKeys,
selectedRows: selectedRows
});
};
render() {
const {data, pagination, loading, selectedRows, selectedRowKeys} = this.state;
const isSelectedSingle = this.state.selectedRows.length == 1; const isSelectedSingle = this.state.selectedRows.length == 1;
let selectedText;
if(isSelectedSingle){
selectedText = "You have selected 1 device"
}else{
selectedText = "You have selected " + this.state.selectedRows.length + " devices"
}
const rowSelection = {
selectedRowKeys,
selectedRows,
onChange: this.onSelectChange,
};
let item = this.state.deviceGroups.map((data) => let item = this.state.deviceGroups.map((data) =>
<Select.Option <Select.Option
value={data.id} value={data.id}
@ -441,8 +456,7 @@ class DeviceTable extends React.Component {
}} }}
loading={loading} loading={loading}
onChange={this.handleTableChange} onChange={this.handleTableChange}
rowSelection={this.rowSelection} rowSelection={rowSelection}
scroll={{x: 1000}}
/> />
</div> </div>
@ -453,10 +467,11 @@ class DeviceTable extends React.Component {
onOk={this.handleOk} onOk={this.handleOk}
onCancel={this.handleCancel} onCancel={this.handleCancel}
> >
<p>{selectedText}</p>
<Select <Select
mode={isSelectedSingle ? "multiple" : "default"} mode={isSelectedSingle ? "multiple" : "default"}
showSearch showSearch
style={{width: 200}} style={{display:"block"}}
placeholder="Select Group" placeholder="Select Group"
optionFilterProp="children" optionFilterProp="children"
onChange={this.onGroupSelectChange} onChange={this.onGroupSelectChange}

@ -112,18 +112,7 @@ const columns = [
return <Tooltip title={new Date(dateOfLastUpdate).toString()}>{timeAgoString}</Tooltip>; return <Tooltip title={new Date(dateOfLastUpdate).toString()}>{timeAgoString}</Tooltip>;
} }
// todo add filtering options // todo add filtering options
}, }
{
title: 'Action',
key: 'action',
render: () => (
<span>
<a><Icon type="edit" /></a>
<Divider type="vertical" />
<a><Text type="danger"><Icon type="delete" /></Text></a>
</span>
),
},
]; ];
const getTimeAgo = (time) => { const getTimeAgo = (time) => {
@ -250,7 +239,6 @@ class ReportDeviceTable extends React.Component {
loading={loading} loading={loading}
onChange={this.handleTableChange} onChange={this.handleTableChange}
rowSelection={this.rowSelection} rowSelection={this.rowSelection}
scroll={{x: 1000}}
/> />
</div> </div>
); );

@ -18,8 +18,7 @@
import React from "react"; import React from "react";
import moment from "moment"; import moment from "moment";
import DateTimeRangeContainer from "react-advanced-datetimerange-picker"; import {Button, Select, message, notification, Tag, Tooltip, Empty, DatePicker} from "antd";
import {Button, Select, message, notification, Tag, Tooltip, Empty} from "antd";
import axios from "axios"; import axios from "axios";
import {withConfigContext} from "../../../context/ConfigContext"; import {withConfigContext} from "../../../context/ConfigContext";
import GeoCustomMap from "../geo-custom-map/GeoCustomMap"; import GeoCustomMap from "../geo-custom-map/GeoCustomMap";
@ -29,15 +28,16 @@ class GeoDashboard extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
let start = moment(new Date()); let start = moment(
new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0)
);
let end = moment(start) let end = moment(start)
.add(5, "days") .add(1, "days")
.subtract(1, "minute"); .subtract(1, "seconds");
this.state = { this.state = {
deviceData: [], deviceData: [],
selectedDevice: '', selectedDevice: '',
locationData: [], locationData: [],
// currentLocation: [],
loading: false, loading: false,
start: start, start: start,
end: end, end: end,
@ -55,11 +55,11 @@ class GeoDashboard extends React.Component {
* @param startDate - start date * @param startDate - start date
* @param endDate - end date * @param endDate - end date
*/ */
applyCallback = (startDate, endDate) => { applyCallback = (dates, dateStrings) => {
console.log("Apply Callback"); console.log("Apply Callback");
this.setState({ this.setState({
start: startDate, start: dateStrings[0],
end: endDate end: dateStrings[1]
}); });
}; };
@ -180,6 +180,7 @@ class GeoDashboard extends React.Component {
*/ */
controllerBar = () => { controllerBar = () => {
const {RangePicker} = DatePicker;
let now = new Date(); let now = new Date();
let start = moment( let start = moment(
new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0) new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0)
@ -199,32 +200,20 @@ class GeoDashboard extends React.Component {
"2 Weeks": [moment(start).subtract(14, "days"), moment(end)], "2 Weeks": [moment(start).subtract(14, "days"), moment(end)],
"1 Month": [moment(start).subtract(1, "months"), moment(end)], "1 Month": [moment(start).subtract(1, "months"), moment(end)],
}; };
let local = {
format: "DD-MM-YYYY HH:mm",
sundayFirst: false
};
let maxDate = moment(start).add(24, "hour");
let value =
`
${this.state.start.format("DD-MM-YYYY HH:mm")} - ${this.state.end.format("DD-MM-YYYY HH:mm")}
`;
let {deviceData} = this.state; let {deviceData} = this.state;
return ( return (
<div className="controllerDiv"> <div className="controllerDiv">
<RangePicker
<Button style={{marginRight: 20}}>
<DateTimeRangeContainer
ranges={ranges} ranges={ranges}
start={this.state.start} style={{marginRight: 20}}
end={this.state.end} showTime
local={local} format="YYYY-MM-DD HH:mm:ss"
maxDate={maxDate} defaultValue={[this.state.start, this.state.end]}
applyCallback={this.applyCallback} onChange={this.applyCallback}
>
{value} />
</DateTimeRangeContainer>
</Button>
<Select <Select
showSearch showSearch

@ -0,0 +1,173 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import axios from "axios";
import { message, notification, Table, Typography} from "antd";
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
import en from 'javascript-time-ago/locale/en'
import {withConfigContext} from "../../context/ConfigContext";
const {Text} = Typography;
let config = null;
let apiUrl;
const columns = [
{
title: 'Group Name',
dataIndex: 'name',
width: 100,
},
{
title: 'Owner',
dataIndex: 'owner',
key: 'owner',
// render: enrolmentInfo => enrolmentInfo.owner
// todo add filtering options
},
{
title: 'Description',
dataIndex: 'description',
key: 'description',
// render: enrolmentInfo => enrolmentInfo.ownership
// todo add filtering options
}
];
const getTimeAgo = (time) => {
const timeAgo = new TimeAgo('en-US');
return timeAgo.format(time);
};
class GroupsTable extends React.Component {
constructor(props) {
super(props);
config = this.props.context;
TimeAgo.addLocale(en);
this.state = {
data: [],
pagination: {},
loading: false,
selectedRows: []
};
}
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
selectedRows: selectedRows
})
}
};
componentDidMount() {
this.fetchGroups();
}
//fetch data from api
fetchGroups = (params = {}) => {
const config = this.props.context;
this.setState({loading: true});
// get current page
const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
const extraParams = {
offset: 10 * (currentPage - 1), //calculate the offset
limit: 10,
};
const encodedExtraParams = Object.keys(extraParams)
.map(key => key + '=' + extraParams[key]).join('&');
apiUrl = window.location.origin + config.serverConfig.invoker.uri +
config.serverConfig.invoker.deviceMgt +
"/admin/groups?" + encodedExtraParams;
//send request to the invokerss
axios.get(apiUrl).then(res => {
if (res.status === 200) {
const pagination = {...this.state.pagination};
this.setState({
loading: false,
data: res.data.data.deviceGroups,
pagination,
});
}
}).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popop with error
message.error('You are not logged in');
window.location.href = window.location.origin + '/entgra/login';
} else {
notification["error"]({
message: "There was a problem",
duration: 0,
description:"Error occurred while trying to load device groups.",
});
}
this.setState({loading: false});
});
};
handleTableChange = (pagination, filters, sorter) => {
const pager = {...this.state.pagination};
pager.current = pagination.current;
this.setState({
pagination: pager,
});
this.fetch({
results: pagination.pageSize,
page: pagination.current,
sortField: sorter.field,
sortOrder: sorter.order,
...filters,
});
};
render() {
const {data, pagination, loading, selectedRows} = this.state;
return (
<div>
<Table
columns={columns}
rowKey={record => (record.id)}
dataSource={data}
pagination={{
...pagination,
size: "small",
// position: "top",
showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} groups`
// showQuickJumper: true
}}
loading={loading}
onChange={this.handleTableChange}
rowSelection={this.rowSelection}
/>
</div>
);
}
}
export default withConfigContext(GroupsTable);

@ -0,0 +1,180 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import axios from "axios";
import {message, notification, Table, Typography} from "antd";
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
import en from 'javascript-time-ago/locale/en'
import {withConfigContext} from "../../context/ConfigContext";
const {Text} = Typography;
let config = null;
let apiUrl;
const columns = [
{
title: 'Policy Name',
dataIndex: 'policyName',
width: 100,
},
{
title: 'Description',
dataIndex: 'description',
key: 'description',
// render: enrolmentInfo => enrolmentInfo.owner
// todo add filtering options
},
{
title: 'Compilance',
dataIndex: 'compliance',
key: 'compliance',
// render: enrolmentInfo => enrolmentInfo.ownership
// todo add filtering options
},
{
title: 'Policy Type',
dataIndex: 'policyType',
key: 'policyType',
// render: enrolmentInfo => enrolmentInfo.ownership
// todo add filtering options
}
];
const getTimeAgo = (time) => {
const timeAgo = new TimeAgo('en-US');
return timeAgo.format(time);
};
class PoliciesTable extends React.Component {
constructor(props) {
super(props);
config = this.props.context;
TimeAgo.addLocale(en);
this.state = {
data: [],
pagination: {},
loading: false,
selectedRows: []
};
}
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
selectedRows: selectedRows
})
}
};
componentDidMount() {
this.fetchGroups();
}
//fetch data from api
fetchGroups = (params = {}) => {
const config = this.props.context;
this.setState({loading: true});
// get current page
const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
const extraParams = {
offset: 10 * (currentPage - 1), //calculate the offset
limit: 10,
};
const encodedExtraParams = Object.keys(extraParams)
.map(key => key + '=' + extraParams[key]).join('&');
apiUrl = window.location.origin + config.serverConfig.invoker.uri +
config.serverConfig.invoker.deviceMgt +
"/policies?" + encodedExtraParams;
//send request to the invokerss
axios.get(apiUrl).then(res => {
if (res.status === 200) {
const pagination = {...this.state.pagination};
this.setState({
loading: false,
data: res.data.data.policies,
pagination,
});
}
}).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popop with error
message.error('You are not logged in');
window.location.href = window.location.origin + '/entgra/login';
} else {
notification["error"]({
message: "There was a problem",
duration: 0,
description:"Error occurred while trying to load policies.",
});
}
this.setState({loading: false});
});
};
handleTableChange = (pagination, filters, sorter) => {
const pager = {...this.state.pagination};
pager.current = pagination.current;
this.setState({
pagination: pager,
});
this.fetch({
results: pagination.pageSize,
page: pagination.current,
sortField: sorter.field,
sortOrder: sorter.order,
...filters,
});
};
render() {
const {data, pagination, loading, selectedRows} = this.state;
return (
<div>
<Table
columns={columns}
rowKey={record => (record.id)}
dataSource={data}
pagination={{
...pagination,
size: "small",
// position: "top",
showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} groups`
// showQuickJumper: true
}}
loading={loading}
onChange={this.handleTableChange}
rowSelection={this.rowSelection}
/>
</div>
);
}
}
export default withConfigContext(PoliciesTable);

@ -0,0 +1,157 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import axios from "axios";
import {Tag, message, notification, Table, Typography, Tooltip, Icon, Divider, Card, Col, Row, Select} from "antd";
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
import en from 'javascript-time-ago/locale/en'
import {withConfigContext} from "../../context/ConfigContext";
const {Text} = Typography;
let config = null;
let apiUrl;
const columns = [
{
title: 'User Name',
dataIndex: 'username',
width: 100,
}
];
const getTimeAgo = (time) => {
const timeAgo = new TimeAgo('en-US');
return timeAgo.format(time);
};
class RolesTable extends React.Component {
constructor(props) {
super(props);
config = this.props.context;
TimeAgo.addLocale(en);
this.state = {
data: [],
pagination: {},
loading: false,
selectedRows: []
};
}
componentDidMount() {
this.fetchUsers();
}
//fetch data from api
fetchUsers = (params = {}) => {
const config = this.props.context;
this.setState({loading: true});
// get current page
const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
const extraParams = {
offset: 10 * (currentPage - 1), //calculate the offset
limit: 10,
};
const encodedExtraParams = Object.keys(extraParams)
.map(key => key + '=' + extraParams[key]).join('&');
apiUrl = window.location.origin + config.serverConfig.invoker.uri +
config.serverConfig.invoker.deviceMgt +
"/roles";
//send request to the invokerss
axios.get(apiUrl).then(res => {
if (res.status === 200) {
const pagination = {...this.state.pagination};
this.setState({
loading: false,
data: res.data.data.roles,
pagination,
});
}
}).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popop with error
message.error('You are not logged in');
window.location.href = window.location.origin + '/entgra/login';
} else {
notification["error"]({
message: "There was a problem",
duration: 0,
description:"Error occurred while trying to load users.",
});
}
this.setState({loading: false});
});
};
handleTableChange = (pagination, filters, sorter) => {
const pager = {...this.state.pagination};
pager.current = pagination.current;
this.setState({
pagination: pager,
});
this.fetch({
results: pagination.pageSize,
page: pagination.current,
sortField: sorter.field,
sortOrder: sorter.order,
...filters,
});
};
render() {
const {data, pagination, loading, selectedRows} = this.state;
const { Meta } = Card;
const itemCard = data.map((data) =>
<Col span={5} key={data}>
<Card
size="default"
style={{ width: 200 }}
bordered={true}
actions={[
<Icon type="setting" key="setting" />,
<Icon type="edit" key="edit" />,]}
>
<Meta
avatar={<Icon type="book" key="roles"/>}
title={data}
/>
</Card>
</Col>
);
return (
<div style={{ background: '#ECECEC', padding: '20px' }}>
<Row gutter={16}>
{itemCard}
</Row>
</div>
);
}
}
export default withConfigContext(RolesTable);

@ -0,0 +1,249 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import axios from "axios";
import {Tag, message, notification, Table, Typography, Tooltip, Icon, Divider} from "antd";
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
import en from 'javascript-time-ago/locale/en'
import {withConfigContext} from "../../context/ConfigContext";
const {Text} = Typography;
let config = null;
let apiUrl;
const columns = [
{
title: 'Device',
dataIndex: 'name',
width: 100,
},
{
title: 'Type',
dataIndex: 'type',
key: 'type',
render: type => {
const defaultPlatformIcons = config.defaultPlatformIcons;
let icon = defaultPlatformIcons.default.icon;
let color = defaultPlatformIcons.default.color;
let theme = defaultPlatformIcons.default.theme;
if (defaultPlatformIcons.hasOwnProperty(type)) {
icon = defaultPlatformIcons[type].icon;
color = defaultPlatformIcons[type].color;
theme = defaultPlatformIcons[type].theme;
}
return (
<span style={{fontSize: 20, color: color, textAlign: "center"}}>
<Icon type={icon} theme={theme}/>
</span>
);
}
// todo add filtering options
},
{
title: 'Owner',
dataIndex: 'enrolmentInfo',
key: 'owner',
render: enrolmentInfo => enrolmentInfo.owner
// todo add filtering options
},
{
title: 'Ownership',
dataIndex: 'enrolmentInfo',
key: 'ownership',
width: 100,
render: enrolmentInfo => enrolmentInfo.ownership
// todo add filtering options
},
{
title: 'Status',
dataIndex: 'enrolmentInfo',
width: 100,
key: 'status',
render: (enrolmentInfo) => {
const status = enrolmentInfo.status.toLowerCase();
let color = "#f9ca24";
switch (status) {
case "active":
color = "#badc58";
break;
case "created":
color = "#6ab04c";
break;
case "removed":
color = "#ff7979";
break;
case "inactive":
color = "#f9ca24";
break;
case "blocked":
color = "#636e72";
break;
}
return <Tag color={color}>{status}</Tag>;
}
// todo add filtering options
},
{
title: 'Last Updated',
dataIndex: 'enrolmentInfo',
key: 'dateOfLastUpdate',
render: (data) => {
const {dateOfLastUpdate} = data;
const timeAgoString = getTimeAgo(dateOfLastUpdate);
return <Tooltip title={new Date(dateOfLastUpdate).toString()}>{timeAgoString}</Tooltip>;
}
// todo add filtering options
}
];
const getTimeAgo = (time) => {
const timeAgo = new TimeAgo('en-US');
return timeAgo.format(time);
};
class UsersDevices extends React.Component {
constructor(props) {
super(props);
config = this.props.context;
TimeAgo.addLocale(en);
this.state = {
data: [],
pagination: {},
loading: false,
selectedRows: []
};
}
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
selectedRows: selectedRows
})
}
};
componentDidMount() {
this.fetch();
}
//Rerender component when parameters change
componentDidUpdate(prevProps, prevState, snapshot) {
if(prevProps.user !== this.props.user){
this.fetch();
}
}
//fetch data from api
fetch = (params = {}) => {
const config = this.props.context;
this.setState({loading: true});
// get current page
const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
const extraParams = {
offset: 10 * (currentPage - 1), //calculate the offset
limit: 10,
user: this.props.user,
requireDeviceInfo: true,
};
const encodedExtraParams = Object.keys(extraParams)
.map(key => key + '=' + extraParams[key]).join('&');
//send request to the invoker
axios.get(
window.location.origin + config.serverConfig.invoker.uri +
config.serverConfig.invoker.deviceMgt +
"/devices?" + encodedExtraParams,
).then(res => {
if (res.status === 200) {
const pagination = {...this.state.pagination};
this.setState({
loading: false,
data: res.data.data.devices,
pagination
});
}
}).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popop with error
message.error('You are not logged in');
window.location.href = window.location.origin + '/entgra/login';
} else {
notification["error"]({
message: "There was a problem",
duration: 0,
description:
"Error occurred while trying to load devices.",
});
}
this.setState({loading: false});
});
};
handleTableChange = (pagination, filters, sorter) => {
const pager = {...this.state.pagination};
pager.current = pagination.current;
this.setState({
pagination: pager,
});
this.fetch({
results: pagination.pageSize,
page: pagination.current,
sortField: sorter.field,
sortOrder: sorter.order,
...filters,
});
};
render() {
const {data, pagination, loading, selectedRows} = this.state;
return (
<div>
<Table
columns={columns}
rowKey={record => (record.deviceIdentifier + record.enrolmentInfo.owner + record.enrolmentInfo.ownership)}
dataSource={data}
showHeader={false}
size="small"
pagination={{
...pagination,
size: "small",
// position: "top",
showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} devices`
// showQuickJumper: true
}}
loading={loading}
onChange={this.handleTableChange}
rowSelection={this.rowSelection}
/>
</div>
);
}
}
export default withConfigContext(UsersDevices);

@ -0,0 +1,279 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import axios from "axios";
import {message, notification, Table, Typography, Panel, Collapse, Button, List, Modal, Icon, Tabs} from "antd";
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
import en from 'javascript-time-ago/locale/en'
import {withConfigContext} from "../../context/ConfigContext";
import DeviceTable from "../Devices/DevicesTable";
import UsersDevices from "./UsersDevices";
const {Text} = Typography;
let config = null;
let apiUrl;
class UsersTable extends React.Component {
constructor(props) {
super(props);
config = this.props.context;
TimeAgo.addLocale(en);
this.state = {
data: [],
pagination: {},
loading: false,
selectedRows: [],
rolesModalVisible: false,
rolesData: [],
user:''
};
}
rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
this.setState({
selectedRows: selectedRows
})
}
};
componentDidMount() {
this.fetchUsers();
}
//fetch data from api
fetchUsers = (params = {}) => {
const config = this.props.context;
this.setState({loading: true});
// get current page
const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
const extraParams = {
offset: 10 * (currentPage - 1), //calculate the offset
limit: 10,
};
const encodedExtraParams = Object.keys(extraParams)
.map(key => key + '=' + extraParams[key]).join('&');
apiUrl = window.location.origin + config.serverConfig.invoker.uri +
config.serverConfig.invoker.deviceMgt +
"/users?" + encodedExtraParams;
//send request to the invokerss
axios.get(apiUrl).then(res => {
if (res.status === 200) {
const pagination = {...this.state.pagination};
this.setState({
loading: false,
data: res.data.data.users,
pagination,
});
}
}).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popop with error
message.error('You are not logged in');
window.location.href = window.location.origin + '/entgra/login';
} else {
notification["error"]({
message: "There was a problem",
duration: 0,
description:"Error occurred while trying to load users.",
});
}
this.setState({loading: false});
});
};
//fetch data from api
fetchRoles = (username) => {
const config = this.props.context;
this.setState({
rolesModalVisible: true,
user: username
});
apiUrl = window.location.origin + config.serverConfig.invoker.uri +
config.serverConfig.invoker.deviceMgt +
"/users/" + username + "/roles";
//send request to the invokerss
axios.get(apiUrl).then(res => {
if (res.status === 200) {
this.setState({
rolesData: res.data.data.roles,
});
}
}).catch((error) => {
if (error.hasOwnProperty("response") && error.response.status === 401) {
//todo display a popop with error
message.error('You are not logged in');
window.location.href = window.location.origin + '/entgra/login';
} else {
notification["error"]({
message: "There was a problem",
duration: 0,
description:"Error occurred while trying to load roles.",
});
}
this.setState({loading: false});
});
};
handleTableChange = (pagination, filters, sorter) => {
const pager = {...this.state.pagination};
pager.current = pagination.current;
this.setState({
pagination: pager,
});
this.fetch({
results: pagination.pageSize,
page: pagination.current,
sortField: sorter.field,
sortOrder: sorter.order,
...filters,
});
};
handleOk = e => {
this.setState({
rolesModalVisible: false,
});
};
handleCancel = e => {
this.setState({
rolesModalVisible: false,
});
};
render() {
const {data, pagination, loading, selectedRows} = this.state;
const { Panel } = Collapse;
const { TabPane } = Tabs;
const columns = [
{
title: 'User Name',
dataIndex: 'username',
width: 150,
key: "username",
},
{
title: 'First Name',
width: 150,
dataIndex: 'firstname',
key: 'firstname',
},
{
title: 'Last Name',
width: 150,
dataIndex: 'lastname',
key: 'lastname',
},
{
title: 'Email',
width: 100,
dataIndex: 'emailAddress',
key: 'emailAddress',
},
{
title: '',
dataIndex: 'username',
key: 'roles',
render: (username) =>
<Button
type="link"
size={"default"}
icon="info-circle"
onClick={() => this.fetchRoles(username)}>Info</Button>
}
];
return (
<div>
<div>
<Table
columns={columns}
rowKey={record => (record.username)}
dataSource={data}
pagination={{
...pagination,
size: "small",
// position: "top",
showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} groups`
// showQuickJumper: true
}}
loading={loading}
onChange={this.handleTableChange}
rowSelection={this.rowSelection}
/>
</div>
<div>
<Modal
width="900px"
visible={this.state.rolesModalVisible}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<Tabs size="small" defaultActiveKey="1">
<TabPane
tab={
<span>
<Icon type="book"/>
Roles
</span>
}
key="1"
>
<List
size="small"
bordered
dataSource={this.state.rolesData}
renderItem={item => <List.Item>{item}</List.Item>}
/>
</TabPane>
<TabPane
tab={
<span>
<Icon type="appstore"/>
Enrolled Devices
</span>
}
key="2"
>
<UsersDevices user={this.state.user}/>
</TabPane>
</Tabs>
</Modal>
</div>
</div>
);
}
}
export default withConfigContext(UsersTable);

@ -26,6 +26,11 @@ import './index.css';
import Devices from "./pages/Dashboard/Devices/Devices"; import Devices from "./pages/Dashboard/Devices/Devices";
import Reports from "./pages/Dashboard/Reports/Reports"; import Reports from "./pages/Dashboard/Reports/Reports";
import Geo from "./pages/Dashboard/Geo/Geo"; import Geo from "./pages/Dashboard/Geo/Geo";
import Groups from "./pages/Dashboard/Groups/Groups";
import Users from "./pages/Dashboard/Users/Users";
import Policies from "./pages/Dashboard/Policies/Policies";
import Roles from "./pages/Dashboard/Roles/Roles";
import DeviceTypes from "./pages/Dashboard/DeviceTypes/DeviceTypes";
const routes = [ const routes = [
{ {
@ -52,6 +57,31 @@ const routes = [
path: '/entgra/reports', path: '/entgra/reports',
component: Reports, component: Reports,
exact: true exact: true
},
{
path: '/entgra/groups',
component: Groups,
exact: true
},
{
path: '/entgra/users',
component: Users,
exact: true
},
{
path: '/entgra/policies',
component: Policies,
exact: true
},
{
path: '/entgra/roles',
component: Roles,
exact: true
},
{
path: '/entgra/devicetypes',
component: DeviceTypes,
exact: true
} }
] ]
} }

@ -54,8 +54,11 @@
} }
.layout .logo-image img { .layout .logo-image img {
height: 32px; height: 55px;
margin: 16px; margin-top: 5px;
margin-left: 16px;
margin-right: 16px;
margin-bottom: 5px;
} }
@media only screen and (min-width: 760px) { @media only screen and (min-width: 760px) {

@ -42,9 +42,11 @@ class Dashboard extends React.Component {
mobileWidth mobileWidth
}; };
this.logo = this.props.context.theme.logo; this.logo = this.props.context.theme.logo;
this.config = this.props.context;
} }
toggle = () => { toggle = () => {
console.log(this.config)
this.setState({ this.setState({
isNavBarCollapsed: !this.state.isNavBarCollapsed, isNavBarCollapsed: !this.state.isNavBarCollapsed,
}); });
@ -63,8 +65,7 @@ class Dashboard extends React.Component {
> >
<div className="logo-image"> <div className="logo-image">
<Link to="/entgra/devices"><img alt="logo" src={this.logo}/> <Link to="/entgra/devices"><img alt="logo" src={this.logo}/></Link>
<span className="brand">Entgra</span></Link>
</div> </div>
<Menu theme="dark" mode="inline" defaultSelectedKeys={['devices']}> <Menu theme="dark" mode="inline" defaultSelectedKeys={['devices']}>
<Menu.Item key="devices"> <Menu.Item key="devices">
@ -73,18 +74,61 @@ class Dashboard extends React.Component {
<span>Devices</span> <span>Devices</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
<Menu.Item key="geo"> <SubMenu
<Link to="/entgra/geo"> key="geo"
title={
<span>
<Icon type="environment"/> <Icon type="environment"/>
<span>Geo</span> <span>Geo</span>
</span>}
>
<Menu.Item key="singleDevice">
<Link to="/entgra/geo">
<span>Single Device View</span>
</Link>
</Menu.Item>
<Menu.Item key="deviceGroup">
<Link to="#">
<span>Device Group View</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
</SubMenu>
<Menu.Item key="reports"> <Menu.Item key="reports">
<Link to="/entgra/reports"> <Link to="/entgra/reports">
<Icon type="bar-chart"/> <Icon type="bar-chart"/>
<span>Reports</span> <span>Reports</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
<Menu.Item key="groups">
<Link to="/entgra/groups">
<Icon type="deployment-unit"/>
<span>Groups</span>
</Link>
</Menu.Item>
<Menu.Item key="users">
<Link to="/entgra/users">
<Icon type="user"/>
<span>Users</span>
</Link>
</Menu.Item>
<Menu.Item key="policies">
<Link to="/entgra/policies">
<Icon type="audit"/>
<span>Policies</span>
</Link>
</Menu.Item>
<Menu.Item key="roles">
<Link to="/entgra/roles">
<Icon type="book"/>
<span>Roles</span>
</Link>
</Menu.Item>
<Menu.Item key="devicetypes">
<Link to="/entgra/devicetypes">
<Icon type="desktop"/>
<span>Device Types</span>
</Link>
</Menu.Item>
</Menu> </Menu>
</Sider> </Sider>
@ -109,9 +153,8 @@ class Dashboard extends React.Component {
title={ title={
<span className="submenu-title-wrapper"> <span className="submenu-title-wrapper">
<Icon type="user"/> <Icon type="user"/>
</span> {this.config.user}
} </span> }>
>
<Logout/> <Logout/>
</SubMenu> </SubMenu>

@ -0,0 +1,65 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import {
PageHeader,
Typography,
Breadcrumb,
Icon
} from "antd";
import {Link} from "react-router-dom";
import DeviceTypesTable from "../../../components/DeviceTypes/DeviceTypesTable";
const {Paragraph} = Typography;
class DeviceTypes extends React.Component {
routes;
constructor(props) {
super(props);
this.routes = props.routes;
}
render() {
return (
<div>
<PageHeader style={{paddingTop: 0}}>
<Breadcrumb style={{paddingBottom: 16}}>
<Breadcrumb.Item>
<Link to="/entgra"><Icon type="home"/> Home</Link>
</Breadcrumb.Item>
<Breadcrumb.Item>Device Types</Breadcrumb.Item>
</Breadcrumb>
<div className="wrap">
<h3>Device Types</h3>
<Paragraph>All device types for device management.</Paragraph>
</div>
<div style={{backgroundColor:"#ffffff", borderRadius: 5}}>
<DeviceTypesTable/>
</div>
</PageHeader>
<div style={{background: '#f0f2f5', padding: 24, minHeight: 720}}>
</div>
</div>
);
}
}
export default DeviceTypes;

@ -49,8 +49,7 @@ class Devices extends React.Component {
</Breadcrumb> </Breadcrumb>
<div className="wrap"> <div className="wrap">
<h3>Devices</h3> <h3>Devices</h3>
<Paragraph>Lorem ipsum dolor sit amet, est similique constituto at, quot inermis id mel, an <Paragraph>All enrolled devices</Paragraph>
illud incorrupte nam.</Paragraph>
</div> </div>
<div style={{backgroundColor:"#ffffff", borderRadius: 5}}> <div style={{backgroundColor:"#ffffff", borderRadius: 5}}>
<DeviceTable/> <DeviceTable/>

@ -0,0 +1,65 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import {
PageHeader,
Typography,
Breadcrumb,
Icon
} from "antd";
import {Link} from "react-router-dom";
import GroupsTable from "../../../components/Groups/GroupsTable";
const {Paragraph} = Typography;
class Groups extends React.Component {
routes;
constructor(props) {
super(props);
this.routes = props.routes;
}
render() {
return (
<div>
<PageHeader style={{paddingTop: 0}}>
<Breadcrumb style={{paddingBottom: 16}}>
<Breadcrumb.Item>
<Link to="/entgra"><Icon type="home"/> Home</Link>
</Breadcrumb.Item>
<Breadcrumb.Item>Groups</Breadcrumb.Item>
</Breadcrumb>
<div className="wrap">
<h3>Groups</h3>
<Paragraph>All device groups.</Paragraph>
</div>
<div style={{backgroundColor:"#ffffff", borderRadius: 5}}>
<GroupsTable/>
</div>
</PageHeader>
<div style={{background: '#f0f2f5', padding: 24, minHeight: 720}}>
</div>
</div>
);
}
}
export default Groups;

@ -0,0 +1,65 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import {
PageHeader,
Typography,
Breadcrumb,
Icon
} from "antd";
import {Link} from "react-router-dom";
import PoliciesTable from "../../../components/Policies/PoliciesTable";
const {Paragraph} = Typography;
class Policies extends React.Component {
routes;
constructor(props) {
super(props);
this.routes = props.routes;
}
render() {
return (
<div>
<PageHeader style={{paddingTop: 0}}>
<Breadcrumb style={{paddingBottom: 16}}>
<Breadcrumb.Item>
<Link to="/entgra"><Icon type="home"/> Home</Link>
</Breadcrumb.Item>
<Breadcrumb.Item>Policies</Breadcrumb.Item>
</Breadcrumb>
<div className="wrap">
<h3>Policies</h3>
<Paragraph>All policies for device management</Paragraph>
</div>
<div style={{backgroundColor:"#ffffff", borderRadius: 5}}>
<PoliciesTable/>
</div>
</PageHeader>
<div style={{background: '#f0f2f5', padding: 24, minHeight: 720}}>
</div>
</div>
);
}
}
export default Policies;

@ -0,0 +1,65 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import {
PageHeader,
Typography,
Breadcrumb,
Icon
} from "antd";
import {Link} from "react-router-dom";
import RolesTable from "../../../components/Roles/RolesTable";
const {Paragraph} = Typography;
class Roles extends React.Component {
routes;
constructor(props) {
super(props);
this.routes = props.routes;
}
render() {
return (
<div>
<PageHeader style={{paddingTop: 0}}>
<Breadcrumb style={{paddingBottom: 16}}>
<Breadcrumb.Item>
<Link to="/entgra"><Icon type="home"/> Home</Link>
</Breadcrumb.Item>
<Breadcrumb.Item>Roles</Breadcrumb.Item>
</Breadcrumb>
<div className="wrap">
<h3>Roles</h3>
<Paragraph>All user roles</Paragraph>
</div>
<div style={{backgroundColor:"#ffffff", borderRadius: 5}}>
<RolesTable/>
</div>
</PageHeader>
<div style={{background: '#f0f2f5', padding: 24, minHeight: 720}}>
</div>
</div>
);
}
}
export default Roles;

@ -0,0 +1,65 @@
/*
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from "react";
import {
PageHeader,
Typography,
Breadcrumb,
Icon
} from "antd";
import {Link} from "react-router-dom";
import UsersTable from "../../../components/Users/UsersTable";
const {Paragraph} = Typography;
class Users extends React.Component {
routes;
constructor(props) {
super(props);
this.routes = props.routes;
}
render() {
return (
<div>
<PageHeader style={{paddingTop: 0}}>
<Breadcrumb style={{paddingBottom: 16}}>
<Breadcrumb.Item>
<Link to="/entgra"><Icon type="home"/> Home</Link>
</Breadcrumb.Item>
<Breadcrumb.Item>Users</Breadcrumb.Item>
</Breadcrumb>
<div className="wrap">
<h3>Users</h3>
<Paragraph>All users for device management.</Paragraph>
</div>
<div style={{backgroundColor:"#ffffff", borderRadius: 5}}>
<UsersTable/>
</div>
</PageHeader>
<div style={{background: '#f0f2f5', padding: 24, minHeight: 720}}>
</div>
</div>
);
}
}
export default Users;

@ -56,45 +56,29 @@ public class DeviceLocation implements Serializable {
@ApiModelProperty(name = "updatedTime", value = "Update time of the device.", required = true) @ApiModelProperty(name = "updatedTime", value = "Update time of the device.", required = true)
private Date updatedTime; private Date updatedTime;
@ApiModelProperty(name = "altitude", value = "Device altitude.", required = true) @ApiModelProperty(name = "altitude", value = "Device altitude.", required = true)
private Double altitude; private double altitude;
@ApiModelProperty(name = "speed", value = "Device speed.", required = true) @ApiModelProperty(name = "speed", value = "Device speed.", required = true)
private Float speed; private float speed;
@ApiModelProperty(name = "bearing", value = "Device bearing.", required = true) @ApiModelProperty(name = "bearing", value = "Device bearing.", required = true)
private Float bearing; private float bearing;
@ApiModelProperty(name = "distance", value = "Device distance.", required = true) @ApiModelProperty(name = "distance", value = "Device distance.", required = true)
private Double distance; private double distance;
public Double getDistance() { public double getAltitude() { return altitude; }
return distance;
}
public void setDistance(Double distance) { public void setAltitude(double altitude) { this.altitude = altitude; }
this.distance = distance;
}
public Double getAltitude() { public float getSpeed() { return speed; }
return altitude;
}
public Float getSpeed() { public void setSpeed(float speed) { this.speed = speed; }
return speed;
}
public void setSpeed(Float speed) { public float getBearing() { return bearing; }
this.speed = speed;
}
public Float getBearing() { public void setBearing(float bearing) { this.bearing = bearing; }
return bearing;
}
public void setBearing(Float bearing) { public double getDistance() { return distance; }
this.bearing = bearing;
}
public void setAltitude(Double altitude) { public void setDistance(double distance) { this.distance = distance; }
this.altitude = altitude;
}
public int getDeviceId() { public int getDeviceId() {
return deviceId; return deviceId;

@ -3712,7 +3712,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
log.debug("Getting all devices details for device ids: " + devicesIds); log.debug("Getting all devices details for device ids: " + devicesIds);
} }
PaginationResult paginationResult = new PaginationResult(); PaginationResult paginationResult = new PaginationResult();
int count;
List<Device> subscribedDeviceDetails; List<Device> subscribedDeviceDetails;
try { try {
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
@ -3722,12 +3721,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
paginationResult.setData(new ArrayList<>()); paginationResult.setData(new ArrayList<>());
paginationResult.setRecordsFiltered(0); paginationResult.setRecordsFiltered(0);
paginationResult.setRecordsTotal(0); paginationResult.setRecordsTotal(0);
return paginationResult;
} }
count = deviceDAO.getSubscribedDeviceCount(devicesIds, tenantId, status); int count = deviceDAO.getSubscribedDeviceCount(devicesIds, tenantId, status);
paginationResult.setData(getAllDeviceInfo(subscribedDeviceDetails));
paginationResult.setRecordsFiltered(count); paginationResult.setRecordsFiltered(count);
paginationResult.setRecordsTotal(count); paginationResult.setRecordsTotal(count);
return paginationResult;
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
String msg = "Error occurred while retrieving device list for device ids " + devicesIds; String msg = "Error occurred while retrieving device list for device ids " + devicesIds;
log.error(msg, e); log.error(msg, e);
@ -3739,6 +3737,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
} }
paginationResult.setData(getAllDeviceInfo(subscribedDeviceDetails));
return paginationResult;
} }
/** /**

@ -118,7 +118,7 @@
{{/if}} {{/if}}
{{#if iosPluginFlag}} {{#if iosPluginFlag}}
<li> <li>
<a href="{{@app.context}}/dep/devices"><i class="fw fw-ios"></i> <a href="{{@app.context}}/dep/devices"><i class="fw fw-apple"></i>
DEP Configurations DEP Configurations
</a> </a>
</li> </li>

Loading…
Cancel
Save