diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index e4611cf2..1a5c53ba 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -6,7 +6,7 @@ services: - 27017:27017 zookeeper: - image: confluentinc/cp-zookeeper:3.2.1 + image: confluentinc/cp-zookeeper:5.2.3 ports: - 32182:32181 expose: @@ -16,7 +16,7 @@ services: - ZOOKEEPER_TICK_TIME=2000 kafka: - image: confluentinc/cp-kafka:3.2.1 + image: confluentinc/cp-kafka:5.2.3 ports: - 29092:29092 expose: diff --git a/docker-compose.yml b/docker-compose.yml index 2e14a8a7..bba3ae6c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: ports: - 27017:27017 zookeeper: - image: confluentinc/cp-zookeeper:3.2.1 + image: confluentinc/cp-zookeeper:5.2.3 ports: - 32182:32181 environment: @@ -15,7 +15,7 @@ services: - "moby:127.0.0.1" - "localhost: 127.0.0.1" kafka: - image: confluentinc/cp-kafka:3.2.1 + image: confluentinc/cp-kafka:5.2.3 ports: - 29092:29092 depends_on: diff --git a/nio-server/app/controllers/ConsentController.scala b/nio-server/app/controllers/ConsentController.scala index 7c3f5db1..b3b59b80 100644 --- a/nio-server/app/controllers/ConsentController.scala +++ b/nio-server/app/controllers/ConsentController.scala @@ -130,12 +130,12 @@ class ConsentController( } - def find(tenant: String, orgKey: String, userId: String): Action[AnyContent] = AuthAction.async { implicit req => + def find(tenant: String, orgKey: String, userId: String, showExpiredConsents: Boolean): Action[AnyContent] = AuthAction.async { implicit req => import cats.data._ import cats.implicits._ EitherT(findConsentFacts(tenant, orgKey, userId, req.authInfo.offerRestrictionPatterns)) - .fold(error => error.renderError(), consentFact => renderMethod(consentFact)) + .fold(error => error.renderError(), consentFact => renderMethod(consentFact.filterExpiredConsent(showExpiredConsents))) } private def findConsentFacts( diff --git a/nio-server/app/models/ConsentFact.scala b/nio-server/app/models/ConsentFact.scala index e79f38e8..efece07e 100644 --- a/nio-server/app/models/ConsentFact.scala +++ b/nio-server/app/models/ConsentFact.scala @@ -468,6 +468,19 @@ case class ConsentFact( ) )) } + + def filterExpiredConsent(showExpiredConsents: Boolean): ConsentFact = { + if (showExpiredConsents) { + this + } else { + val now = LocalDateTime.now(Clock.systemUTC()) + this.copy(groups = this.groups.map(group => + group.copy(consents = group.consents.toList.filter(c => + c.expiredAt.isEmpty || c.expiredAt.exists(d => d.isAfter(now)) + )) + )) + } + } } object ConsentFact extends ReadableEntity[ConsentFact] { diff --git a/nio-server/test/resources/default.conf b/nio-server/conf/dataset.conf similarity index 100% rename from nio-server/test/resources/default.conf rename to nio-server/conf/dataset.conf diff --git a/nio-server/conf/dev.conf b/nio-server/conf/dev.conf new file mode 100644 index 00000000..93b4e95e --- /dev/null +++ b/nio-server/conf/dev.conf @@ -0,0 +1,4 @@ +include "application" +include "dataset" + +db.flush=true \ No newline at end of file diff --git a/nio-server/conf/routes b/nio-server/conf/routes index c7a1f057..b8955067 100644 --- a/nio-server/conf/routes +++ b/nio-server/conf/routes @@ -109,7 +109,7 @@ PATCH /api/:tenant/organisations/:orgKey/users/:userId DELETE /api/:tenant/organisations/:orgKey/users/:userId/offers/:offerKey controllers.ConsentController.deleteOffer(tenant: String, orgKey: String, userId: String, offerKey: String) -GET /api/:tenant/organisations/:orgKey/users/:userId controllers.ConsentController.find(tenant: String, orgKey: String, userId: String) +GET /api/:tenant/organisations/:orgKey/users/:userId controllers.ConsentController.find(tenant: String, orgKey: String, userId: String, showExpiredConsents: Boolean ?= false) GET /api/:tenant/organisations/:orgKey/users/:userId/logs controllers.ConsentController.getConsentFactHistory(tenant: String, orgKey: String, userId: String, page: Int ?= 0, pageSize: Int ?= 10) diff --git a/nio-server/javascript/.nvmrc b/nio-server/javascript/.nvmrc new file mode 100644 index 00000000..4f426dd6 --- /dev/null +++ b/nio-server/javascript/.nvmrc @@ -0,0 +1 @@ +v11.8.0 \ No newline at end of file diff --git a/nio-server/javascript/src/nio/pages/Consents.js b/nio-server/javascript/src/nio/pages/Consents.js index c5800586..fc3691b9 100644 --- a/nio-server/javascript/src/nio/pages/Consents.js +++ b/nio-server/javascript/src/nio/pages/Consents.js @@ -182,7 +182,10 @@ class Consents extends Component { checked={consent.checked} onChange={() => this.onChangeConsents(consent.key, !consent.checked)}/> + htmlFor={`${this.props.index}-${index}-${consent.key}`}>{consent.label} + {consent.expiredAt && (new Date(consent.expiredAt) >= new Date()) && (expire le {new Date(consent.expiredAt).toLocaleString()})} + {consent.expiredAt && (new Date(consent.expiredAt) < new Date()) && (a expiré le {new Date(consent.expiredAt).toLocaleString()})} + ) diff --git a/nio-server/javascript/src/nio/pages/GroupPermissionPage.js b/nio-server/javascript/src/nio/pages/GroupPermissionPage.js index b84e5d91..e5d37c79 100644 --- a/nio-server/javascript/src/nio/pages/GroupPermissionPage.js +++ b/nio-server/javascript/src/nio/pages/GroupPermissionPage.js @@ -200,6 +200,13 @@ class Permission extends Component { possibleValues={["OptIn", "OptOut"]} errorKey={`${this.props.prefixe}permissions.${this.props.index}.type.required`}/> + this.onChange(e, "validityPeriod")} + disabled={this.props.readOnlyMode} + errorMessage={this.props.errors} + errorKey={`${this.props.prefixe}permissions.${this.props.index}.validityPeriod.required`} + /> ); } diff --git a/nio-server/javascript/src/nio/services/ConsentService.js b/nio-server/javascript/src/nio/services/ConsentService.js index 254a46e4..b79aa538 100644 --- a/nio-server/javascript/src/nio/services/ConsentService.js +++ b/nio-server/javascript/src/nio/services/ConsentService.js @@ -1,6 +1,6 @@ export function getConsents(tenant, organisationKey, userId) { - return fetch(`/api/${tenant}/organisations/${organisationKey}/users/${userId}`, { + return fetch(`/api/${tenant}/organisations/${organisationKey}/users/${userId}?showExpiredConsents=true`, { method: "GET", credentials: 'include', headers: { diff --git a/nio-server/test/utils/TestUtils.scala b/nio-server/test/utils/TestUtils.scala index a7cbea41..6add3c1a 100644 --- a/nio-server/test/utils/TestUtils.scala +++ b/nio-server/test/utils/TestUtils.scala @@ -94,7 +94,7 @@ trait TestUtils |db.tenants=["$tenant"] |nio.filter.securityMode="default" """.stripMargin) - .resolve().withFallback(ConfigFactory.load("default.conf")) + .resolve().withFallback(ConfigFactory.load("dataset.conf")) } protected lazy val authInfo: AuthInfoMock = new AuthInfoTest