Skip to content

Commit

Permalink
return jules
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Jun 11, 2024
1 parent 8e40505 commit 71d8c40
Show file tree
Hide file tree
Showing 13 changed files with 247 additions and 160 deletions.
83 changes: 46 additions & 37 deletions components/bases-locales/charte/partenaires/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,61 @@ import PropTypes from 'prop-types'
import Section from '@/components/section'

import Badge from '@codegouvfr/react-dsfr/Badge'
import ButtonLink from '@/components/button-link'
import MoissonneurBal from './moissonneur-bal'
import Perimeters from './perimeter'

function Partenaire({partenaireDeLaCharte}) {
function Partenaire({partenaireDeLaCharte, moissonneur: {organization, sources}}) {
return (
<Section title={partenaireDeLaCharte.name}>
<h3>Type</h3>
<div style={{margin: 'var(--text-spacing)'}}>
<Badge style={{marginLeft: '5px', marginBottom: '5px'}}>{partenaireDeLaCharte.type}</Badge>
</div>
{partenaireDeLaCharte.infos &&
<>
<h3>Information</h3>
<p>{partenaireDeLaCharte.infos}</p>
</>}
{partenaireDeLaCharte.services &&
<>
<h3>Services</h3>
<div style={{margin: 'var(--text-spacing)'}}>
{partenaireDeLaCharte.services?.map(s => (
<Badge key={s} style={{marginLeft: '5px', marginBottom: '5px'}}>{s}</Badge>
))}
<Section>
<section>
<div className='fr-container fr-py-2w'>
<div className='fr-grid-row' style={{flexWrap: 'nowrap'}}>
<div>
<div className='logo' style={{backgroundImage: `url("${partenaireDeLaCharte.picture}")`}} />
</div>
<div>
<h2>{partenaireDeLaCharte.name}</h2>
{partenaireDeLaCharte.infos &&
<p>{partenaireDeLaCharte.infos}</p>}
</div>
</div>
</>}
<h3>Applications</h3>
{!partenaireDeLaCharte.dataGouvOrganizationId && !partenaireDeLaCharte.apiDepotClientId &&
<p>Aucune applications relié</p>}
{partenaireDeLaCharte.dataGouvOrganizationId &&
<ButtonLink
href={`/bases-locales/charte/partenaires/moissonneur-bal/${partenaireDeLaCharte.dataGouvOrganizationId}`}
isOutlined
>
Moissonneur
</ButtonLink>}
{partenaireDeLaCharte.apiDepotClientId &&
<ButtonLink
href={`/bases-locales/charte/partenaires/api-depot/${partenaireDeLaCharte.apiDepotClientId}`}
isOutlined
>
Api Depot
</ButtonLink>}
</div>
<div className='fr-container fr-py-2w'>
{partenaireDeLaCharte.services &&
<div style={{margin: 'var(--text-spacing)'}}>
{partenaireDeLaCharte.services?.map(s => (
<Badge key={s} style={{marginRight: '5px', marginBottom: '5px'}}>{s}</Badge>
))}
</div>}
</div>
</section>

{partenaireDeLaCharte.dataGouvOrganizationId && (
<>
<h2>Publication de Bases Adresse Locales</h2>
<p>{partenaireDeLaCharte.name} mutualise la production et diffusion des Bases Adresses Locales (BAL).</p>

<Perimeters perimeters={organization.perimeters} />
<MoissonneurBal sources={sources} />
</>
)}
<style jsx>{`
.logo {
width: 200px;
min-height: 200px;
height: 100%;
margin: 0 1em 0 0;
background-size: contain;
background-repeat: no-repeat;
}
`}</style>
</Section>
)
}

Partenaire.propTypes = {
partenaireDeLaCharte: PropTypes.object.isRequired,
moissonneur: PropTypes.object,
}

export default Partenaire
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function MoissoneurHarvestItem({startedAt, status, error, updateStatus, updateRe
return (
<tr>
<td className='fr-col fr-my-1v'>
<a>{formatDate(startedAt)}</a>
<p>{formatDate(startedAt)}</p>
</td>
<td className='fr-col fr-my-1v'>
<StatusBadge status={status} error={error} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {useEffect, useState} from 'react'
import MoissoneurHarvestItem from './harvest-item'
import {getSourceHarvests} from '@/lib/moissonneur-bal'
import Pagination from 'react-js-pagination'
import Tooltip from '@/components/base-adresse-nationale/tooltip'

const LIMIT_HARVEST = 5

Expand Down Expand Up @@ -35,17 +36,27 @@ function MoissonneurHarvestList({sourceId}) {
}, [sourceId])

return (
<>
<section>
<h5>Historique des Moissonnages</h5>
<p>Dès que des modifications ont été détéctés, le nouveau fichier est récupérer pour remplacer l&apos;ancien.</p>
{(harvests && harvests.length > 0) ?
(
<div>
<div className='fr-table'>
<table>
<thead>
<thead style={{width: '100%'}}>
<tr>
<th scope='col'>Date</th>
<th scope='col'>État du moissonnage</th>
<th scope='col'>État de la mise à jour</th>
<th scope='col'>
<Tooltip message='Est-ce le fichier a bien été récupéré sur data.gouv.fr' width='200px'>
État du moissonnage
</Tooltip>
</th>
<th scope='col'>
<Tooltip message='Est-ce que le fichier récupéré est valide ? Est-ce qu’il comporte des différences par rapport au précédent.' width='200px'>
État de la mise à jour
</Tooltip>
</th>
<th scope='col'>Fichier moissonné</th>
</tr>
</thead>
Expand Down Expand Up @@ -81,15 +92,15 @@ function MoissonneurHarvestList({sourceId}) {
</div>
</div>
) : (
<p>Aucune source</p>
<p>Aucun moissonnage</p>
)}

<style global jsx>{`
.pagination__active {
text-decoration: none !important;
}
`}</style>
</>
</section>
)
}

Expand Down
119 changes: 80 additions & 39 deletions components/bases-locales/charte/partenaires/moissonneur-bal/index.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,96 @@
import PropTypes from 'prop-types'
import {useMemo, useState} from 'react'

import Section from '@/components/section'

import Badge from '@codegouvfr/react-dsfr/Badge'
import ButtonLink from '@/components/button-link'
import MoissonneurHarvestList from './harvests/harvests-list'
import MoissonneurSourcesList from './sources/sources-list'
import MoissonneurRevisionsList from './revisions/revisions-list'
import Badge from '@codegouvfr/react-dsfr/Badge'

function MoissonneurBal({organization, sources}) {
const [sourceSelected, setSourceSelected] = useState(sources?.length > 0 ? sources[0]._id : null)

const nomSourceSelected = useMemo(() => {
return sources.find(s => s._id === sourceSelected)?.title
}, [sourceSelected, sources])

function MoissonneurBal({sources}) {
return (
<Section title={organization.name}>
<h3>Page</h3>
<div style={{margin: 'var(--text-spacing)'}}>
<ButtonLink href={organization.page} isExternal>Organisation Data.gouv</ButtonLink>
</div>
<h3>Périmètre</h3>
<div style={{margin: 'var(--text-spacing)'}}>
<section>
<h3>Moissonnage</h3>
<p>Les fichiers BAL mises à disposition sont quotidiennement moissonnées sur la plateforme ouvertes des données publiques françaises (data.gouv.fr).</p>
<div className='fr-accordions-group'>
{sources.map(source => (
<section key={source._id} className='fr-accordion'>
<h4 className='fr-accordion__title'>
<button
type='button'
className='fr-accordion__btn'
aria-expanded='false'
aria-controls={`accordion-${source._id}`}
>
<div className='accordion-header'>
<p>{source.title}</p>
<div>
{source._deleted ? (
<Badge severity='error' style={{marginRight: 2, marginBottom: 2}}>
Supprimé
</Badge>
) : (source.enabled ? (
<Badge severity='success' style={{marginRight: 2, marginBottom: 2}}>
Activé
</Badge>
) : (
<Badge severity='error' style={{marginRight: 2, marginBottom: 2}}>
Désactivé
</Badge>
))}
{(source.harvestError || source.nbRevisionError > 0) ? (
<Badge severity='error' style={{marginRight: 2, marginBottom: 2}}>
Erreur(s)
</Badge>
) : (
<Badge severity='success' style={{marginRight: 2, marginBottom: 2}}>
Aucune Erreur
</Badge>
)}
</div>
</div>

{(organization.perimeters && organization.perimeters.length > 0) ? (
<>
{organization.perimeters.map(p => (
<Badge key={p.code} style={{marginLeft: '5px', marginBottom: '5px'}}>{p.type} {p.code}</Badge>
))}
</>
) : (
<Badge severity='warning'>Aucun perimètre</Badge>
)}
</button>
</h4>
<div className='fr-collapse' id={`accordion-${source._id}`}>
<MoissonneurHarvestList sourceId={source._id} />
<MoissonneurRevisionsList sourceId={source._id} />
</div>
</section>
))}
</div>

<h3>Source(s)</h3>
<MoissonneurSourcesList sources={sources} sourceSelected={sourceSelected} setSourceSelected={setSourceSelected} />

<h3>Moissonage(s) {nomSourceSelected}</h3>
<MoissonneurHarvestList sourceId={sourceSelected} />

<h3>Revision(s) {nomSourceSelected}</h3>
<MoissonneurRevisionsList sourceId={sourceSelected} />
</Section>
<style jsx>{`
.fr-accordion {
border: 1px solid grey;
padding: 2em;
border-radius: 5px;
margin: 1em 0;
}
.fr-accordion:after {
content: none;
}
.fr-accordion:before {
content: none;
}
.fr-accordion__btn {
font-size: 16px;
}
.accordion-header {
width: 95%;
display: flex;
justify-content: space-between;
}
.fr-accordion__btn:hover {
background: none !important;
}
.accordion {
padding: 10px;
}
`}</style>
</section>
)
}

MoissonneurBal.propTypes = {
organization: PropTypes.object.isRequired,
sources: PropTypes.array.isRequired,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ButtonLink from '@/components/button-link'
import {getFileLink} from '@/lib/moissonneur-bal'
import Tooltip from '@/components/base-adresse-nationale/tooltip'
import Badge from '@codegouvfr/react-dsfr/Badge'
import {formatDate} from '@/lib/date'

const otherClients = [
{
Expand Down Expand Up @@ -65,7 +66,7 @@ function MoissoneurRevisionItem({codeCommune, _created, nbRows, nbRowsWithErrors
<p>{codeCommune}</p>
</td>
<td className='fr-col fr-my-1v'>
<p>{_created}</p>
<p>{formatDate(_created)}</p>
</td>
<td className='fr-col fr-my-1v'>
<p>{`${nbRows} / ${nbRowsWithErrors}`}</p>
Expand Down
Loading

0 comments on commit 71d8c40

Please sign in to comment.