diff --git a/app/controllers/ApiController.scala b/app/controllers/ApiController.scala index ded815a57..5c1634274 100644 --- a/app/controllers/ApiController.scala +++ b/app/controllers/ApiController.scala @@ -4,11 +4,13 @@ import actions.LoginAction import Operators.UserOperators import helper.StringHelper import java.util.UUID + import javax.inject.{Inject, Singleton} import models.EventType.DeploymentDashboardUnauthorized -import models.{Area, UserGroup} +import models.{Area, Organisation, UserGroup} import play.api.libs.json.Json -import play.api.mvc.InjectedController +import play.api.mvc._ + import scala.concurrent.ExecutionContext import serializers.ApiModel._ import services.{EventService, OrganisationService, UserGroupService, UserService} @@ -47,14 +49,19 @@ case class ApiController @Inject() ( .stripEverythingButLettersAndNumbers(group.name) .contains(StringHelper.stripEverythingButLettersAndNumbers(franceServiceInstance.commune)) ) - byEmail.orElse(byName).orElse(byCommune) + byEmail.orElse(byName).orElse(byCommune).filter { userGroup => + val areas: List[Area] = userGroup.areaIds.flatMap(Area.fromId) + areas.exists(_.inseeCode == franceServiceInstance.departementCode.code) + } } - def franceServiceDeployment = loginAction { implicit request => + def franceServiceDeployment: Action[AnyContent] = loginAction { implicit request => asAdmin { () => DeploymentDashboardUnauthorized -> "Accès non autorisé au dashboard de déploiement" } { () => - val userGroups = userGroupService.allGroups + val userGroups = userGroupService.allGroups.filter( + _.organisationSetOrDeducted.exists(_.id == Organisation.franceServicesId) + ) val matches: List[(FranceServiceInstance, Option[UserGroup], Area)] = organisationService.franceServiceInfos.instances .map(instance => diff --git a/app/models/Organisation.scala b/app/models/Organisation.scala index 1d745a15e..63a7b1ba8 100644 --- a/app/models/Organisation.scala +++ b/app/models/Organisation.scala @@ -47,6 +47,8 @@ object Organisation { def byId(id: Id): Option[Organisation] = all.find(org => (org.id: Id) == (id: Id)) + val franceServicesId = Organisation.Id("MFS") + val all = List( Organisation("ANAH", "Agence nationale de l'habitat"), Organisation("ANTS", "Agence nationale des titres sécurisés"), @@ -67,7 +69,7 @@ object Organisation { Organisation("La Poste", "La Poste"), Organisation("Mairie", "Mairie"), //Ville Organisation("MDPH", "Maison départementale des personnes handicapées"), - Organisation(Organisation.Id("MFS"), "FS", "France Services"), + Organisation(franceServicesId, "FS", "France Services"), Organisation("Mission locale", "Mission locale"), //Ville Organisation("MSA", "Mutualité sociale agricole"), Organisation("MSAP", "Maison de services au public"), // Ville diff --git a/app/views/franceServiceDeploymentDashboard.scala.html b/app/views/franceServiceDeploymentDashboard.scala.html index 760e0c6a2..5e535a5b3 100644 --- a/app/views/franceServiceDeploymentDashboard.scala.html +++ b/app/views/franceServiceDeploymentDashboard.scala.html @@ -1,11 +1,11 @@ @(currentUser: User)(implicit webJarsUtil: org.webjars.play.WebJarsUtil, flash: Flash, request: RequestHeader) -@main(currentUser, maxWidth = false)(s"Tableau de déploiement France Service") { +@main(currentUser, maxWidth = false)(s"Tableau de déploiement France Services") { @webJarsUtil.locate("tabulator.min.css").css() @webJarsUtil.locate("tabulator.min.js").script() @webJarsUtil.locate("xlsx.full.min.js").script() }{ -
Tableau de déploiement France Service
+
Tableau de déploiement France Services
diff --git a/public/javascripts/admin.js b/public/javascripts/admin.js index f0c13daf5..d6e986524 100644 --- a/public/javascripts/admin.js +++ b/public/javascripts/admin.js @@ -70,12 +70,12 @@ if (window.document.getElementById(franceServiceDeploymentTableTagId)) { var nrOfDeployed = 0; var totalNr = response.length; for (var i = 0; i < totalNr; i++) { - if (response[i].groupSize >= 2) { + if (response[i].groupSize >= 1) { nrOfDeployed++; } } var element = window.document.getElementById(franceServiceDeploymentTotalTagId); - element.textContent = "Nombre de déploiements (plus de 2 utilisateurs): " + + element.textContent = "Nombre de déploiements (plus de 1 utilisateur): " + nrOfDeployed + " ; Nombre total: " + totalNr return response; //return the response data to tabulator },