Skip to content

Commit

Permalink
feat: Show DEAD connectors as OFFLINE in the FE
Browse files Browse the repository at this point in the history
  • Loading branch information
jridderbusch committed Apr 29, 2024
1 parent 0a71e0d commit 3d094a5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md).

#### Minor

- Changed connector status DEAD to OFFLINE in UI responses ([#184](https://github.com/sovity/authority-portal/issues/184))

#### Patch

- Fixed the connector status missing in the CSV reports ([#190](https://github.com/sovity/authority-portal/issues/189))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import de.sovity.authorityportal.web.services.ConnectorService
import de.sovity.authorityportal.web.services.OrganizationService
import de.sovity.authorityportal.web.thirdparty.broker.BrokerClientService
import de.sovity.authorityportal.web.thirdparty.broker.model.AddedConnector
import de.sovity.authorityportal.web.thirdparty.broker.model.ConnectorOnlineStatus
import de.sovity.authorityportal.web.thirdparty.caas.CaasClient
import de.sovity.authorityportal.web.thirdparty.daps.DapsClientService
import de.sovity.authorityportal.web.utils.idmanagement.ClientIdUtils
Expand Down Expand Up @@ -109,7 +110,7 @@ class ConnectorManagementApiService {
connector.frontendUrl,
connector.endpointUrl,
connector.managementUrl,
buildConnectorStatus(connector)
buildConnectorStatusFromConnectorDetails(connector)
)
}

Expand Down Expand Up @@ -158,7 +159,7 @@ class ConnectorManagementApiService {
it.type.toDto(),
deploymentEnvironmentDtoService.findByIdOrThrow(it.environment),
it.name,
if (it.type == ConnectorType.CAAS) it.caasStatus.toDto() else connectorMetadataService.getConnectorStatus(it.connectorId, it.environment).toDto(),
buildConnectorStatusFromConnectorRecord(it),
it.frontendUrl
)
}
Expand Down Expand Up @@ -346,11 +347,28 @@ class ConnectorManagementApiService {
dapsClient.configureMappers(clientId, connectorId, connector.certificate)
}

private fun buildConnectorStatus(connector: ConnectorService.ConnectorDetailRs): ConnectorStatusDto {
return if (connector.type == ConnectorType.CAAS) {
private fun buildConnectorStatusFromConnectorDetails(connector: ConnectorService.ConnectorDetailRs) =
if (connector.type == ConnectorType.CAAS) {
connector.caasStatus!!.toDto()
} else {
connectorMetadataService.getConnectorStatus(connector.connectorId, connector.environment).toDto()
connectorMetadataService.getConnectorStatus(connector.connectorId, connector.environment).let { status ->
filterDeadConnectorStatus(status)
}.toDto()
}

private fun buildConnectorStatusFromConnectorRecord(it: ConnectorRecord) =
if (it.type == ConnectorType.CAAS) {
it.caasStatus.toDto()
} else {
connectorMetadataService.getConnectorStatus(it.connectorId, it.environment).let { status ->
filterDeadConnectorStatus(status)
}.toDto()
}

private fun filterDeadConnectorStatus(status: ConnectorOnlineStatus) =
if (status == ConnectorOnlineStatus.DEAD) {
ConnectorOnlineStatus.OFFLINE
} else {
status
}
}
}

0 comments on commit 3d094a5

Please sign in to comment.