diff --git a/src/router/index.js b/src/router/index.js index 0b5919d5aa3c5f43a7b4a03633082ddddc543ba1..224af0a5ca722d79536b713d0032b6769310ac6f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -125,7 +125,7 @@ const routes = [ }, { - path: '/projet/:slug/catalogue', + path: '/projet/:slug/catalog/:feature_type_slug', name: 'catalog-import', component: () => import('../views/Catalog.vue') }, diff --git a/src/services/misc-api.js b/src/services/misc-api.js index a8447446d1ceb3f38fb624f63f5f399fca08eadf..5bce25aa7e0148ae102652ba2b22d3f66eb0af2a 100644 --- a/src/services/misc-api.js +++ b/src/services/misc-api.js @@ -6,6 +6,20 @@ const baseUrl = store.state.configuration.VUE_APP_DJANGO_API_BASE; const miscAPI = { + async getIdgoCatalog(vector_by_user) { + const response = await axios.get( + `${baseUrl}idgo-catalog/?vector_by_user=${vector_by_user}` + ); + if ( + response.status === 200 && + response.data + ) { + return response.data; + } else { + return null; + } + }, + async getExternalGeojson(queryParams) { const response = await axios.get( `${baseUrl}external-geojson/${queryParams ? '?' + queryParams : ""}` diff --git a/src/views/Catalog.vue b/src/views/Catalog.vue index 42cc0a530ee6ff84d545427e5db351001cb490eb..d841382eefecdc7ec2cbc4fb0c932cbeea4b7119 100644 --- a/src/views/Catalog.vue +++ b/src/views/Catalog.vue @@ -13,7 +13,7 @@ </div> <div v-for="(resource, index) in paginatedRessources" - :key="`${resource.resource}-${index}`" + :key="`${resource.resource_name}-${index}`" @click="selectResource(resource)" :class="[ 'row', @@ -24,9 +24,9 @@ }, ]" > - <div>{{ resource.organisation }}</div> - <div>{{ resource.dataset }}</div> - <div>{{ resource.resource }}</div> + <div>{{ resource.organization_name }}</div> + <div>{{ resource.dataset_name }}</div> + <div>{{ resource.resource_name }}</div> </div> </div> @@ -103,231 +103,13 @@ export default { data() { return { - ressources: [ - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 1", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 2", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 3", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 4", - }, - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 11", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 12", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 13", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 14", - }, - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 21", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 22", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 23", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 24", - }, - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 31", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 32", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 33", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 34", - }, - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 41", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 42", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 43", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 44", - }, - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 51", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 52", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 53", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 54", - }, - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 61", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 62", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 63", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 64", - }, - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 71", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 72", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 73", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 74", - }, - { - organisation: "Organisation 1", - dataset: "Dataset 1", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 81", - }, - { - organisation: "Organisation 2", - dataset: "Dataset 2", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 82", - }, - { - organisation: "Organisation 3", - dataset: "Dataset 3", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 83", - }, - { - organisation: "Organisation 4", - dataset: "Dataset 4", - layerName: "travaux_ccpro_867f108", - resource: "Ressource 84", - }, - ], + ressources: [], pagination: { currentPage: 1, pagesize: 15, start: 0, end: 15, }, - geojson: null, selectedResource: null, }; }, @@ -384,32 +166,28 @@ export default { } }, - redirect() { - const routerHistory = this.$router.history.router.options.routerHistory - const name = routerHistory[routerHistory.length - 1].name === "details-type-signalement" ? "details-type-signalement" : "ajouter-type-signalement" + redirect(geojson) { + const name = this.$route.params.feature_type_slug === "create" ? "ajouter-type-signalement" : "details-type-signalement" this.$router.push({ - name, + name: name, params: { - geojson: this.geojson, + geojson, type: "external-geojson", }, }); }, launchImport() { - const user = "communaute-de-communes-du-pays-reuni-dorange"; - const paramsTest = `user=${user}&TYPENAME=${this.selectedResource.layerName}`; - miscAPI.getExternalGeojson(paramsTest).then((data) => { - this.geojson = data; - this.redirect(); + const queryParams = `typename=${this.selectedResource.layer}`; + miscAPI.getExternalGeojson(queryParams).then((data) => { + if (data) this.redirect(data); }); }, }, - created() { - console.log(this.$router) - console.log(this.$router.history.router.options.routerHistory[this.$router.history.router.options.routerHistory.length -1].name) + mounted() { this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); + miscAPI.getIdgoCatalog('mmeliani').then((data)=> this.ressources = data.layers); }, }; </script> diff --git a/src/views/feature_type/Feature_type_detail.vue b/src/views/feature_type/Feature_type_detail.vue index 8e66330348e1387900ebd04a211b92a6d2d395bf..506fcc84b4007beeea7eaed8e8a40658a076f167 100644 --- a/src/views/feature_type/Feature_type_detail.vue +++ b/src/views/feature_type/Feature_type_detail.vue @@ -93,7 +93,10 @@ " :to="{ name: 'catalog-import', - params: { slug: project.slug }, + params: { + slug: project.slug, + feature_type_slug: $route.params.feature_type_slug + }, }" class="ui icon button import-catalog" >Créer un nouveau type de signalement à partir du catalogue Datasud diff --git a/src/views/feature_type/Feature_type_edit.vue b/src/views/feature_type/Feature_type_edit.vue index 26bf6819a8c874cb1a8511b8578123593bb58132..22b98958768e19438113996394545e0a1706b804 100644 --- a/src/views/feature_type/Feature_type_edit.vue +++ b/src/views/feature_type/Feature_type_edit.vue @@ -604,7 +604,6 @@ export default { this.form.title.value = // * use the filename as title by default this.fileToImport.name.split(".")[0]; } else { //* case when the geojson comes from datasud catalog - console.log("external-geojson", this.geojson) this.form.title.value = this.geojson.name;// * use the typename as title by default } } diff --git a/src/views/project/Project_detail.vue b/src/views/project/Project_detail.vue index a24c49fcd1aa459a80974b5e3202f7766d5da00b..604663b20087bb7eb7c7a3457cad1a7f0341820c 100644 --- a/src/views/project/Project_detail.vue +++ b/src/views/project/Project_detail.vue @@ -333,7 +333,10 @@ " :to="{ name: 'catalog-import', - params: { slug: project.slug }, + params: { + slug: project.slug, + feature_type_slug: 'create' + }, }" class="ui compact basic button button-hover-green button-align-left" >