Moved test connection coding in button + aligned test connection naming with others
MODIFY
src/server/rest/CentralRestServerService.ts
src/server/rest/CentralRestServerService.ts
@@ -131,7 +131,7 @@ class RequestMapper {
[ServerAction.ASSET]: AssetService.handleGetAsset.bind(this),
[ServerAction.ASSET_IMAGE]: AssetService.handleGetAssetImage.bind(this),
[ServerAction.ASSET_IN_ERROR]: AssetService.handleGetAssetsInError.bind(this),
- [ServerAction.ASSET_TEST_CONNECTION]: AssetService.handleCheckAssetConnection.bind(this),
+ [ServerAction.CHECK_ASSET_CONNECTION]: AssetService.handleCheckAssetConnection.bind(this),
[ServerAction.SITES]: SiteService.handleGetSites.bind(this),
[ServerAction.SITE]: SiteService.handleGetSite.bind(this),
[ServerAction.SITE_IMAGE]: SiteService.handleGetSiteImage.bind(this),

MODIFY
src/server/rest/service/AssetService.ts
src/server/rest/service/AssetService.ts
@@ -58,9 +58,9 @@ export default class AssetService {
// Create success response
const response = {
isConnectionValid: true
- }
+ };
// Success
- res.json(Object.assign(response, Constants.REST_RESPONSE_SUCCESS))
+ res.json(Object.assign(response, Constants.REST_RESPONSE_SUCCESS));
} catch (error) {
// KO
Logging.logError({
@@ -72,11 +72,7 @@ export default class AssetService {
detailedMessages: { error: error.message, stack: error.stack }
});
// Create fail response
- const response = {
- isConnectionValid: false,
- error: (error.response && error.response.data) ? error.response.data.error : 'unknown_connection_error'
- }
- res.json(Object.assign(response));
+ res.json(Object.assign({ connectionIsValid: false }, Constants.REST_RESPONSE_SUCCESS));
}
next();
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -263,7 +263,7 @@ export enum ServerAction {
ASSET_IN_ERROR = 'AssetsInError',
ASSET_UPDATE = 'AssetUpdate',
ASSET_DELETE = 'AssetDelete',
- ASSET_TEST_CONNECTION = 'AssetTestConnection',
+ CHECK_ASSET_CONNECTION = 'CheckAssetConnection',
TENANT_CREATE = 'TenantCreate',
TENANTS = 'Tenants',

Moved test connection coding in button + aligned test connection naming with others