Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
068cdbc
Add requirements
Jan 18, 2021
831163f
Add code and component from playlists app
Jan 18, 2021
34af842
App header toolbar
Jan 18, 2021
1e03f33
Integrate Vuex, VueAxios, store to app
Jan 18, 2021
8205490
wip
Jan 20, 2021
2bb4949
Fix cycle import
Jan 21, 2021
9f7c16b
Prettier format
Jan 21, 2021
716d8eb
Use $api as a singleton
Jan 21, 2021
449c069
Login is ok now
Jan 22, 2021
c7df9be
Improve user dropdown
Jan 22, 2021
88dd51b
restore schema route
Jan 22, 2021
b158424
Comment log
Jan 22, 2021
9da19ff
wip
Jan 26, 2021
c52f1a0
Remove /publish-form route
Jan 27, 2021
58a0d1f
Introduce new Publish modal
Jan 27, 2021
5a57114
Format
Jan 28, 2021
092c1bf
Restore publish button disable state if user is not connected
Jan 28, 2021
ef68ddb
Show JSON content to publish
Jan 28, 2021
8d60f75
Formatting
Jan 29, 2021
bec0ab5
Remove dead code
Jan 29, 2021
80f1475
Disable publish button if user not loggedin or has no organizations
Jan 29, 2021
13965df
Fix organizations order in publish form
Jan 29, 2021
2f44ad7
Take organization select value into acount to enable Publish button
Jan 29, 2021
77e20ed
Change api.post signature to add headers parameter
Jan 31, 2021
39c56bc
Really publish to data.gouv.fr (only works with official schemas)
Jan 31, 2021
63e5cfe
Improve publish form display
Feb 1, 2021
ba51881
Change VUE_APP_OAUTH_BASE_URL into VUE_APP_DATAGOUV_API_URL
Feb 1, 2021
e8d6404
Add .env.example
Feb 1, 2021
310bfcb
Fix http method: post -> put
Feb 1, 2021
3d515e3
Adapt publish js code
Feb 1, 2021
2c29fdd
Wording
Feb 1, 2021
b493185
Merge branch 'master' into 34_data_gouv_sso
pierredittgen Feb 4, 2021
50aa0e1
Fix merge errors
Feb 4, 2021
f66e1a7
Update dependencies
Feb 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VUE_APP_VALIDATA_API_URL=https://api.validata.etalab.studio
VUE_APP_SCHEMAS_CATALOG_URL=https://schema.data.gouv.fr/schemas/schemas.json

# Base URL used for auth and publish API
VUE_APP_DATAGOUV_API_URL=https://data.gouv.fr

# OAUTH settings
VUE_APP_OAUTH_CALLBACK=http://localhost:8080/login
VUE_APP_OAUTH_CLIENT_ID=xxxx
VUE_APP_OAUTH_CLIENT_SECRET=yyyy
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ yarn-error.log*

# Editor directories and files
.idea
.prettierrc
.vscode
*.suo
*.ntvs*
Expand Down
1,663 changes: 989 additions & 674 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
"now-build": "vue-cli-service build"
},
"dependencies": {
"axios": "^0.21.1",
"babel-runtime": "^6.26.0",
"bootstrap-vue": "^2.0.0-rc.15",
"pkce": "^1.0.0-beta2",
"query-string": "^6.13.8",
"vue": "^2.6.6",
"vue-axios": "^3.2.2",
"vue-client-only": "^2.0.0",
"vue-loading-overlay": "^3.2.0",
"vue-markdown": "^2.2.4",
"vue-router": "^3.0.1",
"vue-simple-suggest": "^1.10.3"
"vue-simple-suggest": "^1.10.3",
"vuex": "^3.6.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.12.0",
Expand Down
73 changes: 58 additions & 15 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,62 @@
<template>
<div id="app">
<b-container>
<h1 class="text-center mt-2"><img src="/assets/csvgg.gif" alt="csv-gg"></h1>
<router-view/>
<footer class="text-center">
<hr/>
<p class="mb-0">
<strong>csv-gg</strong> est un <a title="dépôt github" href="https://github.com/etalab/csv-gg">logiciel libre</a> développé par <a title="site d'Etalab" href="https://www.etalab.gouv.fr/">Etalab</a>.
</p>
<p class="mt-0">
<span class="badge badge-pill badge-warning">Attention</span> il s'agit d'un projet expérimental. En cas de question ou de problème, vous pouvez <a title="ouvrir un ticket" href="https://github.com/etalab/csv-gg/issues/new">ouvrir un ticket ici</a> ou nous <a title="contact mail" href="mailto:validation@data.gouv.fr?subject=A%20propos%20de%20csv-gg">envoyer un email</a>.
</p>
</footer>
</b-container>
<header>
<b-navbar toggleable="lg" type="dark" variant="dark">
<b-container>
<b-navbar-brand to="/">
csv-gg
</b-navbar-brand>
<client-only>
<nav-user />
</client-only>
</b-container>
</b-navbar>
</header>
<b-container>
<h1 class="text-center mt-2">
<img src="/assets/csvgg.gif" alt="csv-gg" />
</h1>
<router-view />
<footer class="text-center">
<hr />
<p class="mb-0">
<strong>csv-gg</strong> est un
<a title="dépôt github" href="https://github.com/etalab/csv-gg"
>logiciel libre</a
>
développé par
<a title="site d'Etalab" href="https://www.etalab.gouv.fr/">Etalab</a
>.
</p>
<p class="mt-0">
<span class="badge badge-pill badge-warning">Attention</span> il
s'agit d'un projet expérimental. En cas de question ou de problème,
vous pouvez
<a
title="ouvrir un ticket"
href="https://github.com/etalab/csv-gg/issues/new"
>ouvrir un ticket ici</a
>
ou nous
<a
title="contact mail"
href="mailto:validation@data.gouv.fr?subject=A%20propos%20de%20csv-gg"
>envoyer un email</a
>.
</p>
</footer>
</b-container>
</div>
</template>
<style>
</style>

<script>
import ClientOnly from "vue-client-only"
import NavUser from "@/components/NavUser.vue"

export default {
components: {
ClientOnly,
NavUser
}
}
</script>
54 changes: 54 additions & 0 deletions src/components/NavUser.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<template>
<b-navbar-nav class="ml-auto">
<b-navbar-nav v-if="user && !user.loggedIn">
<b-nav-item @click="submitLogin">
Se connecter
</b-nav-item>
</b-navbar-nav>

<b-nav-item-dropdown right v-if="user && user.loggedIn">
<!-- Using 'button-content' slot -->
<template v-slot:button-content>
{{ user.data.first_name }} {{ user.data.last_name }}
</template>
<b-dropdown-item :href="user.data.page">
Mon profil
</b-dropdown-item>
<b-dropdown-divider></b-dropdown-divider>
<b-dropdown-item @click="logout">
Se déconnecter
</b-dropdown-item>
</b-nav-item-dropdown>
</b-navbar-nav>
</template>

<script>
import Auth from '@/services/Auth'

const $auth = new Auth()

export default {
computed: {
user() {
return this.$store.state.auth.user
}
},
methods: {
submitLogin(evt) {
evt.preventDefault()
window.location = $auth.authUrl()
},
async logout() {
await $auth.proceedLogout(this.$store.state.auth.user.token)
this.$store.dispatch('auth/logout')
}
},
mounted() {
this.polling = setInterval(() => {
if (this.$store.state.auth.user.token !== '') {
this.$store.dispatch('auth/checkToken')
}
}, 3000)
}
}
</script>
143 changes: 143 additions & 0 deletions src/components/PublishForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<template>
<div>
<b-form>
<p class="text-muted">
Publiez le fichier CSV en cours d'édition dans un nouveau jeu de données
</p>

<!-- Organisation -->
<b-form-group
id="input-group-org"
label-for="input-org"
description="Choisissez l'organisation dans laquelle sera créé le jeu de données"
>
<template v-slot:label>
Organisation <span class="text-danger">*</span>
</template>
<b-form-select
id="input-org"
v-model="form.org"
:options="organizations"
v-on:change="onChange"
required
></b-form-select>
</b-form-group>

<!-- Dataset title -->
<b-form-group
id="input-group-dataset-title"
label-for="input-dataset-title"
>
<template v-slot:label>
Nom du jeu de données <span class="text-danger">*</span>
</template>
<b-form-input
id="input-dataset-title"
v-model="form.dataset.title"
v-on:change="onChange"
:trim="true"
></b-form-input>
</b-form-group>

<!-- Dataset description -->
<b-form-group
id="input-group-dataset-description"
label-for="input-dataset-description"
>
<template v-slot:label>
Description du jeu de données <span class="text-danger">*</span>
</template>
<b-form-textarea
id="input-dataset-description"
v-model="form.dataset.description"
rows="4"
v-on:change="onChange"
:trim="true"
></b-form-textarea>
</b-form-group>

<!-- Resource title -->
<b-form-group
id="input-group-resource-title"
label-for="input-resource-title"
>
<template v-slot:label>
Nom du fichier CSV <span class="text-danger">*</span>
</template>
<b-form-input
id="input-resource-title"
v-model="form.resource.title"
v-on:change="onChange"
:trim="true"
placeholder="data.csv"
></b-form-input>
</b-form-group>
<p class="text-muted">
Les champs suivis d'une astérisque (<span class="text-danger">*</span>)
sont obligatoires
</p>
</b-form>
</div>
</template>
<script>
export default {
props: {
schemaName: String,
organizations: Array,
value: {
type: undefined,
required: true
}
},
data() {
return {
form: {
org: '',
dataset: {
title: '',
description: ''
},
resource: {
title: ''
}
}
}
},
mounted() {
this.$emit('form-state-change', this.okState)
},
computed: {
okState() {
return (
this.form.org != '' &&
this.form.dataset.title !== '' &&
this.form.dataset.description !== '' &&
this.form.resource.title !== ''
)
},
payload() {
return {
organizationId: this.form.org,
dataset: {
title: this.form.dataset.title,
description: this.form.dataset.description
},
resource: {
title: this.form.resource.title,
schemaName: this.schemaName
}
}
}
},
methods: {
onChange() {
const okState = this.okState
this.$emit('form-state-change', okState)

if (okState) {
this.$emit('input', this.payload)
}
}
}
}
</script>
22 changes: 21 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

import Vue from 'vue'
import Vuex from 'vuex'
import App from './App.vue'
import router from './router'
import BootstrapVue from 'bootstrap-vue'
Expand All @@ -10,12 +12,30 @@ import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import 'vue-simple-suggest/dist/styles.css'


import axios from 'axios'
import VueAxios from 'vue-axios'

import store from './store'

Vue.config.productionTip = false
Vue.use(VueAxios, axios)
Vue.use(BootstrapVue)
Vue.use(Loading)
Vue.use(Vuex)

Vue.component('vue-simple-suggest', VueSimpleSuggest)

new Vue({
router,
render: h => h(App)
render: h => h(App),
store,
mounted(){
this.$store.subscribe((mutation, state) => {
localStorage.setItem('store', JSON.stringify(state))
})
this.$store.beforeCreate = function () {
this.$store.commit('initialiseStore')
}
}
}).$mount('#app')
18 changes: 12 additions & 6 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import Login from './views/Login.vue'

Vue.use(Router)

export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/:schema',
name: 'home_schema',
component: Home
},
{
path: '/',
name: 'home',
component: Home
},
{
path: '/login',
name: 'login',
component: Login
},
{
path: '/:schema',
name: 'home_schema',
component: Home
}
]
],
})
Loading