Skip to content

Commit

Permalink
Merge pull request #27 from InseeFr/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
BettyB979 authored Dec 11, 2023
2 parents 0468b22 + d7fe431 commit 7176a48
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 71 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Sonar analysis
on:
push:
branches:
- "**"
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "front-moog",
"version": "2.2.1",
"version": "2.2.3",
"private": true,
"dependencies": {
"@vtex/react-csv-parse": "^3.0.2",
Expand Down
2 changes: 2 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonar.projectKey=InseeFr_Moog
sonar.organization=inseefr
17 changes: 13 additions & 4 deletions src/actions/keycloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import {
SAVE_KEYCLOAK_TOKEN,
REFRESH_KEYCLOAK_TOKEN,
SAVE_NO_AUTH_LOGIN,
} from './constants/keycloak';
} from "./constants/keycloak";

export const saveKeycloakToken = kc => ({ type: SAVE_KEYCLOAK_TOKEN, payload: kc });
export const saveNoAuthLogin = () => ({ type: SAVE_NO_AUTH_LOGIN, payload: null });
export const refreshKeycloakToken = kc => ({ type: REFRESH_KEYCLOAK_TOKEN, payload: kc });
export const saveKeycloakToken = (kc) => ({
type: SAVE_KEYCLOAK_TOKEN,
payload: kc,
});
export const saveNoAuthLogin = () => ({
type: SAVE_NO_AUTH_LOGIN,
payload: null,
});
export const refreshKeycloakToken = (kc) => ({
type: REFRESH_KEYCLOAK_TOKEN,
payload: kc,
});
22 changes: 13 additions & 9 deletions src/components/consultation/consultation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import {
boutonSupprimerCondition,
pathConsultationFiltre,
pathContact,
pathEndSiteMiroir,
pathReadonly,
pathEnregistrerInfoSuiviGestion,
pathFinalCampagne,
pathInfoSuiviGestions,
pathMail,
pathStartSiteMiroir,
pathTransmissionCampagne,
pathUniteEnquete,
} from "../../utils/properties";
Expand Down Expand Up @@ -131,13 +130,18 @@ const Consultation = ({ roles, linkQuestionnaire, urlColemanPromotion }) => {
}, [motFiltre, activePage]);

const linkSiteMirroir = (obj) => {
const {
campagne: { idCampagne },
idUe,
} = obj;
window.open(
`${linkQuestionnaire}${pathStartSiteMiroir}${idCampagne}${pathEndSiteMiroir}${idUe}`
);
const {
campagne: { idCampagne },
idUe,
} = obj;
myAxios()
.get(`${pathReadonly}${idCampagne}/survey-unit/${idUe}`)
.then((res) => {
window.open(res.data);
})
.catch((error) => {
console.log(error);
});
};

const appel = (history) => {
Expand Down
142 changes: 95 additions & 47 deletions src/components/home/component.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import button1 from 'img/button1.jpg';
import button2 from 'img/button2.jpg';
import button3 from 'img/button3.jpg';
import button4 from 'img/button4.jpg';
import button5 from 'img/button5.jpg';
import logo from 'img/logo.jpg';
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import myAxios from 'utils/api-call';
import estGestionnaire from 'utils/roles';
import { pathFinalCampagne } from '../../utils/properties';
import VersionComponent from '../version/version';
import Campagne from './campagne';
import MapObjects from '../utils/jsonUtils';
import button1 from "img/button1.jpg";
import button2 from "img/button2.jpg";
import button3 from "img/button3.jpg";
import button4 from "img/button4.jpg";
import button5 from "img/button5.jpg";
import logo from "img/logo.jpg";
import React, { Component } from "react";
import { Link } from "react-router-dom";
import myAxios from "utils/api-call";
import estGestionnaire from "utils/roles";
import { pathFinalCampagne } from "../../utils/properties";
import VersionComponent from "../version/version";
import Campagne from "./campagne";
import MapObjects from "../utils/jsonUtils";
import store from "store/configure-store";

export default class Home extends Component {
constructor(props) {
super(props);
this.state = {
idCampagneSelectionnee: '',
labelCampagneSelectionnee: '',
idCampagneSelectionnee: "",
labelCampagneSelectionnee: "",
campagnesTrouvees: [],
};
this.handleChange = this.handleChange.bind(this);
Expand All @@ -31,13 +32,17 @@ export default class Home extends Component {

myAxios()
.get(pathFinalCampagne)
.then(res => {
const campagnesTrouvees = MapObjects(res.data.datas, 'campaign');
.then((res) => {
const campagnesTrouvees = MapObjects(res.data.datas, "campaign");
campagnesTrouvees.sort(this.triage);
this.setState({ campagnesTrouvees: campagnesTrouvees });
if (idCampagneSelectionnee !== 'admin') {
if (idCampagneSelectionnee !== "admin") {
for (let i = 0; i < campagnesTrouvees.length; i++) {
if (campagnesTrouvees[i].idCampagne.localeCompare(idCampagneSelectionnee) === 0) {
if (
campagnesTrouvees[i].idCampagne.localeCompare(
idCampagneSelectionnee
) === 0
) {
this.setState({
idCampagneSelectionnee: idCampagneSelectionnee,
labelCampagneSelectionnee: campagnesTrouvees[i].labelCampagne,
Expand All @@ -52,7 +57,7 @@ export default class Home extends Component {
}
}
})
.catch(error => {
.catch((error) => {
console.log(error);
this.setState({ isLoading: false });
});
Expand All @@ -67,39 +72,45 @@ export default class Home extends Component {

handleChange(event) {
var lienFutur = event.target.value;
this.props.campagneEnCours(lienFutur, '');
this.props.campagneEnCours(lienFutur, "");
this.setState({ idCampagneSelectionnee: lienFutur });

const lienActuel = window.location.pathname;
var count = 0;
var pos = lienActuel.indexOf('/');
var pos = lienActuel.indexOf("/");
while (pos !== -1) {
count = count + 1;
pos = lienActuel.indexOf('/', pos + 1);
pos = lienActuel.indexOf("/", pos + 1);
}
if (count === 2) {
lienFutur = lienFutur + lienActuel.substring(lienActuel.lastIndexOf('/'), lienActuel.length);
lienFutur =
lienFutur +
lienActuel.substring(lienActuel.lastIndexOf("/"), lienActuel.length);
}
window.location.pathname = lienFutur;
}

estConsultation() {
const lienActuel = window.location.pathname;
var count = 0;
var pos = lienActuel.indexOf('/');
var pos = lienActuel.indexOf("/");
while (pos !== -1) {
count = count + 1;
pos = lienActuel.indexOf('/', pos + 1);
pos = lienActuel.indexOf("/", pos + 1);
}
return count === 1;
}

estCampagneChoisie() {
return this.state.idCampagneSelectionnee !== '';
return this.state.idCampagneSelectionnee !== "";
}

render() {
const { idCampagneSelectionnee, campagnesTrouvees, labelCampagneSelectionnee } = this.state;
const {
idCampagneSelectionnee,
campagnesTrouvees,
labelCampagneSelectionnee,
} = this.state;
const { roles } = this.props;
const isGestionnaire = estGestionnaire(roles);
return (
Expand All @@ -108,14 +119,22 @@ export default class Home extends Component {
<div className="container-fluid">
<div className="navbar-header">
<a className="navbar-brand" href="/">
<img src={logo} style={{ height: '60px', widdth: '60px' }} alt={'button'} />
<img
src={logo}
style={{ height: "60px", widdth: "60px" }}
alt={"button"}
/>
<VersionComponent />
</a>
</div>
<ul className="nav navbar-nav">
<li>
<Link to={`/${idCampagneSelectionnee}`}>
<img src={button1} style={{ height: '50px', widdth: '50px' }} alt={'button'} />
<img
src={button1}
style={{ height: "50px", widdth: "50px" }}
alt={"button"}
/>
Rechercher des enquêtés
</Link>
</li>
Expand All @@ -125,8 +144,8 @@ export default class Home extends Component {
<Link to={`/${idCampagneSelectionnee}/maj`}>
<img
src={button2}
style={{ height: '50px', widdth: '50px' }}
alt={'button'}
style={{ height: "50px", widdth: "50px" }}
alt={"button"}
/>
Enregistrer des évènements
</Link>
Expand All @@ -136,7 +155,11 @@ export default class Home extends Component {
{this.estCampagneChoisie() && (
<li>
<Link to={`/${idCampagneSelectionnee}/avancement`}>
<img src={button3} style={{ height: '50px', widdth: '50px' }} alt={'button'} />
<img
src={button3}
style={{ height: "50px", widdth: "50px" }}
alt={"button"}
/>
Suivre la collecte
</Link>
</li>
Expand All @@ -147,8 +170,8 @@ export default class Home extends Component {
<Link to={`/${idCampagneSelectionnee}/relance`}>
<img
src={button4}
style={{ height: '50px', widdth: '50px' }}
alt={'button'}
style={{ height: "50px", widdth: "50px" }}
alt={"button"}
/>
Relancer des enquêtés
</Link>
Expand All @@ -157,21 +180,44 @@ export default class Home extends Component {
<Link to={`/${idCampagneSelectionnee}/historique`}>
<img
src={button5}
style={{ height: '50px', widdth: '50px' }}
alt={'button'}
style={{ height: "50px", widdth: "50px" }}
alt={"button"}
/>
Consulter les archives
</Link>
</li>
</>
)}
</ul>
<form className="navbar-form pull-right">

<button
type="button"
className="pull-right"
style={{
marginTop: "20px",
height: "34px",
}}
onClick={() =>
store.getState().keycloak.kc.logout({
redirectUri: window.location.origin,
})
}
>
<i className="glyphicon glyphicon-log-out " />
{` Se déconnecter`}
</button>

<form
className="navbar-form pull-right"
style={{
marginTop: "20px",
}}
>
<select
value={idCampagneSelectionnee}
onChange={this.handleChange}
className="form-control"
style={{ width: '500px' }}
style={{ width: "500px" }}
>
<option disabled value="">
Choisir une enquête
Expand All @@ -188,13 +234,15 @@ export default class Home extends Component {
</div>
</nav>

{isGestionnaire && this.estCampagneChoisie() && !this.estConsultation() && (
<div className="container">
<h2 style={{ color: 'red' }}>
{`L'enquête sélectionnée est : ${labelCampagneSelectionnee}`}
</h2>
</div>
)}
{isGestionnaire &&
this.estCampagneChoisie() &&
!this.estConsultation() && (
<div className="container">
<h2 style={{ color: "red" }}>
{`L'enquête sélectionnée est : ${labelCampagneSelectionnee}`}
</h2>
</div>
)}
</>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/maj/bilan.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export default function Bilan(props) {
<div>
<h2 style={{ color: 'blue' }}>{props.data.ok} infoSuiviGestions correctement importées</h2>
<div style={{ color: 'red' }}>
<h2>Liste d'identifiants en erreur :</h2>
<h2>Liste d'idue en erreur :</h2>
{props.data.listError.map(item => (
<ul key={item}>{item}</ul>
<ul key={item}>{item.id}</ul>
))}
</div>
</div>
Expand Down
Loading

0 comments on commit 7176a48

Please sign in to comment.