Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CNFT1-3307] event search feature flag #1922

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
- [Pull requests](documentation/Pull-Requests.md)

## Configuring local development secrets
Some containers within the `cdc-sandbox` directory require sensitive values be set prior to building.

|Container |Required environment variable|
|---|---|
|nbs-mssql|DATABASE_PASSWORD|
|nifi|NIFI_PASSWORD, DATABASE_PASSWORD|
|keycloak|KEYCLOAK_ADMIN_PASSWORD|
Some containers within the `cdc-sandbox` directory require sensitive values be set prior to building.

| Container | Required environment variable |
|-----------|----------------------------------|
| nbs-mssql | DATABASE_PASSWORD |
| nifi | NIFI_PASSWORD, DATABASE_PASSWORD |
| keycloak | KEYCLOAK_ADMIN_PASSWORD |

## Running everything inside docker

1. Gain access to the [NBS source code repository](https://github.com/cdcent/NEDSSDev) _this is required to build the wildfly container_
1. Gain access to the [NBS source code repository](https://github.com/cdcent/NEDSSDev) _this is required to build the
wildfly container_
2. Navigate to the `cdc-sandbox` directory

```sh
Expand Down Expand Up @@ -74,7 +76,7 @@ To learn more about the build process view the cdc-sandbox [README](cdc-sandbox/
```sh
cd ..
```

4. Start the `modernized-api` _Port `5005` will be open for debugger attachment._

```sh
Expand Down Expand Up @@ -130,7 +132,7 @@ achieved by altering the configuration to point to the local instances.
```

2. Start the `nbs-gateway` container configured to route to the local `modernization-ui` by executing the
following command from the root folder
following command from the root folder

```shell
MODERNIZATION_UI_SERVER=host.docker.internal MODERNIZATION_UI_PORT=3000 docker compose up -d nbs-gateway
Expand All @@ -141,8 +143,9 @@ following command from the root folder
From the root folder.

1. Start the backend API locally listening on port 9080 from the root project folder. The `nbs-gateway` container is
accessible from port `8080`, which is the default port for the `modernization-api`. It must be changed in order for the
backend to start properly.
accessible from port `8080`, which is the default port for the `modernization-api`. It must be changed in order for
the
backend to start properly.

```shell
./gradlew :modernization-api:bootRun --args='--server.port=9080'
Expand All @@ -166,7 +169,7 @@ From the root folder.
```

2. Start the `nbs-gateway` container configured to route to the local `pagebuilder-api` by executing the
following command.
following command.

```shell
PAGEBUILDER_API=host.docker.internal PAGEBUILDER_API_PORT=8095 docker compose up -d nbs-gateway
Expand Down
21 changes: 13 additions & 8 deletions apps/modernization-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
1. Java 21
2. Node / NPM
3. nbs-mssql, elasticsearch, and nifi docker containers are running. See [CDC Sandbox](../../cdc-sandbox/README.md)
4. `DATABASE_PASSWORD`, `TOKEN_SECRET` and `PARAMETER_SECRET` environment variables are set or relevant properties set in an `application-local.yml`
4. `DATABASE_PASSWORD`, `TOKEN_SECRET` and `PARAMETER_SECRET` environment variables are set or relevant properties set
in an `application-local.yml`

### VSCode

Expand Down Expand Up @@ -128,13 +129,17 @@ and [other useful means](https://docs.spring.io/spring-boot/docs/2.7.5/reference
The modernization-api contains a `/nbs/api/configuration` endpoint that returns a set of configurations for the UI. The
following configurations are present

| Name | Default | Description |
|-----------------------------------------------------|---------|-------------------------------------------------|
| nbs.ui.features.address.autocomplete | false | Enables the address autocomplete feature |
| nbs.ui.features.address.verification | false | Enables the address verification feature |
| nbs.ui.features.pageBuilder.enabled | false | Enables the PageBuilder feature |
| nbs.ui.features.pageBuilder.page.library.enabled | false | Enables the PageBuilder Page Library feature |
| nbs.ui.features.pageBuilder.page.management.enabled | false | Enables the PageBuilder Page Management feature |
| Name | Default | Description |
|-----------------------------------------------------|---------|---------------------------------------------------|
| nbs.ui.features.address.autocomplete | false | Enables the address autocomplete feature |
| nbs.ui.features.address.verification | false | Enables the address verification feature |
| nbs.ui.features.pageBuilder.enabled | false | Enables the PageBuilder feature |
| nbs.ui.features.pageBuilder.page.library.enabled | false | Enables the PageBuilder Page Library feature |
| nbs.ui.features.pageBuilder.page.management.enabled | false | Enables the PageBuilder Page Management feature |
| nbs.ui.features.search.events.enabled | true | Enables access to NBS6 Event Search |
| nbs.ui.features.search.investigations.enabled | false | Enables access to modernized Investigation search |
| nbs.ui.features.search.laboratoryReports.enabled | false | Enables access to modernized Laboratory search |
| nbs.ui.features.patient.add.extended.enabled | false | Enables access to modernized Patient Extended add |

Configuration properties can be overwritten at runtime using the `--args` Gradle option to pass arguments to Spring
Boot.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,25 @@ nbs:
ui:
features:
address:
autocomplete: false
verification: false
autocomplete: false
verification: false
pageBuilder:
enabled: true
page:
library:
library:
enabled: true
management:
management:
create:
enabled: true
edit:
enabled: true
search:
events:
enabled: true
investigations:
enabled: true
laboratory-reports:
enabled: true
view:
enabled: true
table:
Expand Down
14 changes: 0 additions & 14 deletions apps/modernization-api/src/main/resources/application-ui.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
nbs:
ui:
features:
address:
autocomplete: false
verification: false
pageBuilder:
enabled: false
page:
Expand All @@ -14,17 +11,6 @@ nbs:
enabled: false
edit:
enabled: false
search:
view:
enabled: false
table:
enabled: false
patient:
add:
extended:
enabled: false


settings:
analytics:
host: https://us.posthog.com

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions apps/nbs-gateway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ testing {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-test'
implementation libs.spring.security.test
implementation "org.wiremock:wiremock-standalone:3.4.2"
implementation "org.wiremock:wiremock-standalone:3.9.1"
}
}
}
Expand All @@ -41,7 +41,7 @@ dependencies {

implementation libs.bundles.security
implementation libs.bundles.oidc
implementation 'org.springframework.cloud:spring-cloud-starter-gateway:4.1.4'
implementation 'org.springframework.cloud:spring-cloud-starter-gateway:4.1.5'
implementation 'org.springframework.security:spring-security-oauth2-client'
implementation 'org.springframework.security:spring-security-oauth2-jose'

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ services:
- NBS_UI_FEATURES_ADDRESS_VERIFICATION=false
- NBS_UI_FEATURES_SEARCH_VIEW_ENABLED=true
- NBS_UI_FEATURES_SEARCH_VIEW_TABLE_ENABLED=true
- NBS_UI_FEATURES_SEARCH_EVENTS_ENABLED=true
- NBS_UI_FEATURES_SEARCH_INVESTIGATIONS_ENABLED=true
- NBS_UI_FEATURES_SEARCH_LABORATORYREPORTS_ENABLED=true
- NBS_UI_FEATURES_PATIENT_ADD_EXTENDED_ENABLED=true
- NBS_UI_FEATURES_PAGEBUILDER_ENABLED=${PAGEBUILDER_ENABLED}
- NBS_UI_FEATURES_PAGEBUILDER_PAGE_LIBRARY_ENABLED=${PAGEBUILDER_ENABLED}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package gov.cdc.nbs.configuration;

import gov.cdc.nbs.configuration.features.Features;
import gov.cdc.nbs.configuration.features.FeaturesResolver;
import gov.cdc.nbs.configuration.nbs.NbsPropertiesFinder;
import gov.cdc.nbs.configuration.nbs.Properties;
import gov.cdc.nbs.configuration.settings.Settings;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -11,26 +13,30 @@
@Hidden
@RestController
@RequestMapping("/nbs/api/configuration")
public class ConfigurationController {
class ConfigurationController {

private final Features features;
private final FeaturesResolver featuresResolver;
private final Settings settings;
private final NbsPropertiesFinder finder;

public ConfigurationController(
final Features features,
ConfigurationController(
final FeaturesResolver featuresResolver,
final Settings settings,
final NbsPropertiesFinder finder) {
this.features = features;
final NbsPropertiesFinder finder
) {
this.featuresResolver = featuresResolver;
this.settings = settings;
this.finder = finder;
}

@GetMapping
public Configuration getConfiguration() {
Configuration getConfiguration() {
Features features = featuresResolver.resolve();
Properties properties = finder.find();
return new Configuration(
features,
settings,
finder.find());
properties
);
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,12 @@
package gov.cdc.nbs.configuration.features;

import org.springframework.boot.context.properties.ConfigurationProperties;
import gov.cdc.nbs.configuration.features.address.Address;
import gov.cdc.nbs.configuration.features.page_builder.PageBuilder;
import gov.cdc.nbs.configuration.features.patient.Patient;
import gov.cdc.nbs.configuration.features.search.Search;

@ConfigurationProperties("nbs.ui.features")
public record Features(Search search, Address address, PageBuilder pageBuilder, Patient patient) {

public record Address(boolean autocomplete, boolean verification) {
}


public record PageBuilder(boolean enabled, Page page) {

public record Page(Library library, Management management) {

public record Library(boolean enabled) {
}


public record Management(Create create, Edit edit) {

public record Create(boolean enabled) {
}

public record Features(Search search, Address address, PageBuilder pageBuilder, Patient patient) {

public record Edit(boolean enabled) {
}
}
}
}

public record Patient(Add add) {
public record Add(Extended extended) {
public record Extended(Boolean enabled) {
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package gov.cdc.nbs.configuration.features;

import gov.cdc.nbs.configuration.features.address.Address;
import gov.cdc.nbs.configuration.features.page_builder.PageBuilder;
import gov.cdc.nbs.configuration.features.patient.Patient;
import gov.cdc.nbs.configuration.features.search.Search;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.annotation.RequestScope;

@Configuration
class FeaturesConfiguration {

@Bean
@RequestScope
FeaturesResolver featuresResolver(
Search search,
Address address,
PageBuilder pageBuilder,
Patient patient
) {
return () -> new Features(search, address, pageBuilder, patient);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gov.cdc.nbs.configuration.features;

public interface FeaturesResolver {

Features resolve();

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gov.cdc.nbs.configuration.features.address;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "nbs.ui.features.address")
public record Address(boolean autocomplete, boolean verification) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gov.cdc.nbs.configuration.features.page_builder;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "nbs.ui.features.pagebuilder")
public record PageBuilder(boolean enabled, Page page) {

public record Page(Library library, Management management) {

public record Library(boolean enabled) {
}


public record Management(Create create, Edit edit) {

public record Create(boolean enabled) {
}


public record Edit(boolean enabled) {
}
}
}
}
Loading
Loading