Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
larousso committed Oct 11, 2024
1 parent 381224a commit 888518d
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions nio-server/app/controllers/ConsentController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
13 changes: 13 additions & 0 deletions nio-server/app/models/ConsentFact.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions nio-server/conf/dev.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include "application"
include "dataset"

db.flush=true
2 changes: 1 addition & 1 deletion nio-server/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions nio-server/javascript/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v11.8.0
5 changes: 4 additions & 1 deletion nio-server/javascript/src/nio/pages/Consents.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ class Consents extends Component {
checked={consent.checked}
onChange={() => this.onChangeConsents(consent.key, !consent.checked)}/>
<label style={{marginLeft: "20px"}}
htmlFor={`${this.props.index}-${index}-${consent.key}`}>{consent.label}</label>
htmlFor={`${this.props.index}-${index}-${consent.key}`}>{consent.label}
{consent.expiredAt && (new Date(consent.expiredAt) >= new Date()) && <span> (expire le {new Date(consent.expiredAt).toLocaleString()})</span>}
{consent.expiredAt && (new Date(consent.expiredAt) < new Date()) && <span> (a expiré le {new Date(consent.expiredAt).toLocaleString()})</span>}
</label>
</div>
</div>
)
Expand Down
7 changes: 7 additions & 0 deletions nio-server/javascript/src/nio/pages/GroupPermissionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ class Permission extends Component {
possibleValues={["OptIn", "OptOut"]}
errorKey={`${this.props.prefixe}permissions.${this.props.index}.type.required`}/>

<TextInput label={"Validité de la permission"}
value={this.state.permission.validityPeriod}
onChange={(e) => this.onChange(e, "validityPeriod")}
disabled={this.props.readOnlyMode}
errorMessage={this.props.errors}
errorKey={`${this.props.prefixe}permissions.${this.props.index}.validityPeriod.required`}
/>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion nio-server/javascript/src/nio/services/ConsentService.js
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion nio-server/test/utils/TestUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 888518d

Please sign in to comment.