Commit 56d833ba authored by Christophe Benz's avatar Christophe Benz
Browse files

Enhance UI with a card per schema (#30)

parent fc9cf8e8
......@@ -10,17 +10,21 @@
</head>
<body>
<div class="container-fluid">
<div id="header">
<a href="http://validata.fr/" target="_blank">
<img alt="Validata" src="/assets/logo.png">
</a>
<p class="lead">
Validez vos jeux de données grâce aux schémas du
<a href="http://opendatalocale.net/scdl/" target="_blank">Socle Commun des Données Locales</a>.
</p>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="http://dev.validata.fr/">
<img alt="Validata" src="/assets/logo-horizontal.png" height="20">
</a>
</div>
</div>
<div id="form"></div>
</nav>
<div class="container-fluid">
<p class="lead">
Validez vos jeux de données grâce aux schémas du
<a href="http://opendatalocale.net/scdl/" target="_blank">Socle Commun des Données Locales</a> :
</p>
<div id="app"></div>
</div>
</body>
......
#header {
margin-top: 1em;
margin-bottom: 3em;
}
// See https://github.com/necolas/normalize.css/issues/640
details summary {
display: list-item;
......
import { render, Form } from "goodtables-ui/src/index.js"
import Qs from "qs"
import React from "react"
import "./assets/main.scss"
......@@ -9,28 +10,50 @@ const apiUrl = GOODTABLES_API_URL // Defined by Webpack config.
const schemas = [
{
code: "scdl-adresses",
name: "Adresses v1.1",
url: "https://git.opendatafrance.net/scdl/adresses/raw/v1.1/schema-scdl-adresses.json"
name: "Adresses locales",
shortDescription: "Liste des adresses locales d'une collectivité",
version: "v1.1",
url: "https://git.opendatafrance.net/scdl/adresses/raw/v1.1/schema-scdl-adresses.json",
specUrl: "http://www.opendatafrance.net/SCDL_Adresses_Locales"
},
{
code: "scdl-deliberations",
name: "Délibérations v2.0",
url: "https://git.opendatafrance.net/scdl/deliberations/raw/v2.0/schema.json"
name: "Délibérations",
shortDescription: "Liste des délibérations adoptées par une assemblée locale",
version: "v2.0",
url: "https://git.opendatafrance.net/scdl/deliberations/raw/v2.0/schema.json",
specUrl: "http://www.opendatafrance.net/SCDL_Deliberations"
},
{
code: "scdl-equipements",
todo: true,
name: "Équipements",
shortDescription: "Liste des équipements publics gérés par une collectivité",
specUrl: "http://www.opendatafrance.net/SCDL_Equipements_Publics"
},
{
code: "scdl-marches",
name: "Marchés publics v1.0.1",
url: "https://git.opendatafrance.net/scdl/marches-publics/raw/v1.0.1/schema.json"
name: "Marchés publics",
shortDescription: "Liste des marchés publics attribués par une collectivité",
version: "v1.0.1",
url: "https://git.opendatafrance.net/scdl/marches-publics/raw/v1.0.1/schema.json",
specUrl: "http://www.opendatafrance.net/SCDL_Marches_Publics"
},
{
code: "scdl-prenoms",
name: "Prénoms des nouveaux-nés v1.1.1",
url: "https://raw.githubusercontent.com/Jailbreak-Paris/liste-prenoms-nouveaux-nes/v1.1.2/prenom-schema.json"
name: "Prénoms des nouveaux-nés",
shortDescription: "Liste des prénoms des nouveaux-nés déclarés à l’état-civil",
version: "v1.1.1",
url: "https://raw.githubusercontent.com/Jailbreak-Paris/liste-prenoms-nouveaux-nes/v1.1.2/prenom-schema.json",
specUrl: "https://docs.google.com/document/d/1Vk0kpBw3MIocai9JqovLK2HxcUA_3QHnZicqxuOpcQ8/edit?usp=sharing"
},
{
code: "scdl-subventions",
name: "Subventions v1.1",
url: "https://git.opendatafrance.net/scdl/subventions/raw/v1.1/schema.json"
name: "Subventions",
shortDescription: "Liste des subventions publiques attribuées par une collectivité",
version: "v1.1",
url: "https://git.opendatafrance.net/scdl/subventions/raw/v1.1/schema.json",
specUrl: "http://www.opendatafrance.net/SCDL_Subventions"
},
]
......@@ -80,11 +103,11 @@ const examples = [
url: "https://git.opendatafrance.net/scdl/subventions/raw/v1.1/exemples/exemple_invalide.csv",
schemaCode: "scdl-subventions",
},
{
name: "Subventions Nièvre 2016",
url: "https://git.opendatafrance.net/scdl/subventions/raw/v1.1/exemples/DEP_Ni%C3%A8vre_CD58_SUBVENTIONS_2016_LISTE.csv",
schemaCode: "scdl-subventions",
},
// {
// name: "Subventions Nièvre 2016",
// url: "https://git.opendatafrance.net/scdl/subventions/raw/v1.1/exemples/DEP_Ni%C3%A8vre_CD58_SUBVENTIONS_2016_LISTE.csv",
// schemaCode: "scdl-subventions",
// },
{
name: "Erreur de format (HTML au lieu de CSV)",
url: "https://git.opendatafrance.net/",
......@@ -128,7 +151,7 @@ function validate(source, options) {
}),
fetchJSONWithCORSProxy(options.schema),
]).then(values => {
updateLocation({schema: options.schema})
updateLocation({ schema: options.schema })
return values
})
}
......@@ -154,19 +177,15 @@ const options = Qs.parse(location.search.slice(1))
const source = options.source
delete options.source
if (!options.schema) {
options.schema = schemas[0].url
}
const element = document.getElementById('form')
const element = document.getElementById('app')
const props = { source, schemas, examples, options, validate }
const formProps = { source, options, validate, schemas, examples }
if (source) {
// TODO Check that options.schema is an URL
props.reportPromise = Promise.all([
formProps.reportPromise = Promise.all([
fetchJSON(`${apiUrl}?${Qs.stringify({ source, schema: options.schema })}`),
fetchJSONWithCORSProxy(options.schema),
])
}
render(Form, props, element)
render(Form, formProps, element)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment