diff --git a/public/config/config.json b/public/config/config.json index 9f916fe8f512f65e737851eadce1cc77403f7b0a..9651190e5aa2d349aead14b9d85304d92d6f2356 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -10,6 +10,8 @@ "VUE_APP_DJANGO_BASE":"http://localhost:8010", "VUE_APP_DJANGO_API_BASE":"http://localhost:8010/api/", "VUE_APP_RELOAD_INTERVAL": 15000, + "VUE_APP_DISABLE_LOGIN_BUTTON":false, + "VUE_APP_LOGIN_URL":"", "DEFAULT_BASE_MAP":{ "SERVICE": "https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", "OPTIONS": { diff --git a/src/App.vue b/src/App.vue index 6318200de53a648114dbce4085498216ca450e97..b356b5c01613825879292d3e248f95963068fff8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -88,24 +88,30 @@ {{ userFullname || user.username || "Utilisateur inconnu" }} </router-link> <div - v-if="user && user.is_administrator" + v-if="USER_LEVEL_PROJECTS && project" class="item ui label vertical no-hover" > - <span v-if="USER_LEVEL_PROJECTS && project"> - {{ USER_LEVEL_PROJECTS[project.slug] }}</span - > + {{ USER_LEVEL_PROJECTS[project.slug] }} <br /> - <span v-if="user.is_administrator"> - Gestionnaire métier - </span> </div> - <!-- // todo : find out SSO_SETTED in django --> - <a v-if="user && !SSO_SETTED" @click="logout" class="item" - ><i class="ui logout icon"></i> - </a> - <router-link v-else-if="!user" to="/connexion/" class="item" - >Se Connecter</router-link + <div + v-if="user && user.is_administrator" + class="item ui label vertical no-hover" > + Gestionnaire métier + </div> + <div v-frag v-if="!DISABLE_LOGIN_BUTTON"> + <a v-if="user" @click="logout" class="item" + ><i class="ui logout icon"></i> + </a> + <router-link + v-else-if="!user && !SSO_LOGIN_URL" + to="/connexion/" + class="item" + >Se connecter</router-link + > + <a v-else class="item" :href="SSO_LOGIN_URL">Se connecter</a> + </div> </div> </div> </div> @@ -115,22 +121,30 @@ {{ userFullname || user.username || "Utilisateur inconnu" }} </router-link> <div - v-if="user || user.is_administrator" + v-if="USER_LEVEL_PROJECTS && project" class="item ui label vertical no-hover" > - <span v-if="USER_LEVEL_PROJECTS && project"> - {{ USER_LEVEL_PROJECTS[project.slug] }}</span - > + {{ USER_LEVEL_PROJECTS[project.slug] }} <br /> - <span v-if="user.is_administrator"> Gestionnaire métier </span> </div> - <!-- // todo : find out SSO_SETTED in django --> - <a v-if="user && !SSO_SETTED" @click="logout" class="item" - ><i class="ui logout icon"></i> - </a> - <router-link v-else-if="!user" to="/connexion/" class="item" - >Se Connecter</router-link + <div + v-if="user && user.is_administrator" + class="item ui label vertical no-hover" > + Gestionnaire métier + </div> + <div v-frag v-if="!DISABLE_LOGIN_BUTTON"> + <a v-if="user" @click="logout" class="item" + ><i class="ui logout icon"></i> + </a> + <router-link + v-else-if="!user && !SSO_LOGIN_URL" + to="/connexion/" + class="item" + >Se Connecter</router-link + > + <a v-else class="item" :href="SSO_LOGIN_URL">Se connecter</a> + </div> </div> </div> </div> @@ -200,7 +214,6 @@ export default { ...mapState([ "projects", "user", - "SSO_SETTED", "USER_LEVEL_PROJECTS", "configuration", "messages", @@ -210,6 +223,12 @@ export default { APPLICATION_NAME() { return this.configuration.VUE_APP_APPLICATION_NAME; }, + DISABLE_LOGIN_BUTTON() { + return this.configuration.VUE_APP_DISABLE_LOGIN_BUTTON; + }, + SSO_LOGIN_URL() { + return this.configuration.VUE_APP_LOGIN_URL; + }, PACKAGE_VERSION: () => process.env.PACKAGE_VERSION || "0", logo() { return this.configuration.VUE_APP_LOGO_PATH; @@ -306,8 +325,6 @@ footer { } .menu.container { width: auto !important; - margin-left: 1em !important; - margin-right: 1em !important; } .push-right-desktop { margin-left: auto; diff --git a/src/services/feature-api.js b/src/services/feature-api.js index 3618c8687cd360acd707e991b6f8bd050e5768c7..30b3fb8e55ab30d617b6abf4e2564aa186f86a12 100644 --- a/src/services/feature-api.js +++ b/src/services/feature-api.js @@ -14,8 +14,8 @@ const featureAPI = { ) { const bbox = response.data; return [ - [bbox[2], bbox[3]], - [bbox[0], bbox[1]], + [bbox.minLat, bbox.minLon], + [bbox.maxLat, bbox.maxLon], ]; } else { return null; diff --git a/src/store/index.js b/src/store/index.js index 45e7a263f33fc6ca9511615f0091042eaf680a0c..f3ff33c6acfdc5c150fb01ef3efc8fd1ab35d31e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -6,27 +6,8 @@ import feature_type from "./modules/feature_type" import feature from "./modules/feature" import map from "./modules/map" -// axios.defaults.headers.common['X-CSRFToken'] = (name => { -// var re = new RegExp(name + "=([^;]+)"); -// var value = re.exec(document.cookie); -// return (value !== null) ? unescape(value[1]) : null; -// })('csrftoken'); - - Vue.use(Vuex); - -// axios.defaults.withCredentials = true; // * add cookies to axios -// function updateAxiosHeader() { -// axios.defaults.headers.common['X-CSRFToken'] = (name => { -// var re = new RegExp(name + "=([^;]+)"); -// var value = re.exec(document.cookie); -// return (value !== null) ? unescape(value[1]) : null; -// })('csrftoken'); -// } -// // ! À vérifier s'il y a un changement de token pendant l'éxécution de l'appli -// updateAxiosHeader(); - const noPermissions = { can_view_project: true, can_create_project: false, @@ -56,7 +37,6 @@ export default new Vuex.Store({ projects: [], last_comments: [], staticPages: null, - SSO_SETTED: false, USER_LEVEL_PROJECTS: null, user_permissions: null, levelsPermissions: [], @@ -95,9 +75,6 @@ export default new Vuex.Store({ SET_STATIC_PAGES(state, staticPages) { state.staticPages = staticPages; }, - SET_SSO(state, SSO_SETTED) { - state.SSO_SETTED = SSO_SETTED; - }, SET_USER_LEVEL_PROJECTS(state, USER_LEVEL_PROJECTS) { state.USER_LEVEL_PROJECTS = USER_LEVEL_PROJECTS; }, @@ -224,11 +201,13 @@ export default new Vuex.Store({ if (response && response.status === 200) { const user = response.data.user; commit("SET_USER", user); - //window.localStorage.setItem("user", JSON.stringify(user)); // ? nécessaire ? } }) .catch(() => { - router.push({ name: "login" }); + //* if an url to redirect to an external authentification system is present, do not redirect to the login page + if (!state.configuration.VUE_APP_LOGIN_URL) { + router.push({ name: "login" }); + } }); } }, @@ -251,7 +230,6 @@ export default new Vuex.Store({ }, LOGOUT({ commit, dispatch }) { - // const pageNoRedirect = ["liste-signalements", "details-type-signalement", "details-signalement", "project_detail", "mentions", "aide", "index"] axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}logout/`) .then((response) => { @@ -259,7 +237,6 @@ export default new Vuex.Store({ commit("SET_USER", false); commit("SET_USER_LEVEL_PROJECTS", null); dispatch("GET_USER_LEVEL_PERMISSIONS"); - // if (!pageNoRedirect.includes(router.history.current.name)) router.push("/"); if (router.history.current.name !== "index") router.push("/"); } }) diff --git a/src/views/feature/Feature_detail.vue b/src/views/feature/Feature_detail.vue index 759f27f0e21385cdd2b2120a032e6df83a328c31..2b32956f85be131e5f311c30d12b2d83c31b6b55 100644 --- a/src/views/feature/Feature_detail.vue +++ b/src/views/feature/Feature_detail.vue @@ -111,7 +111,7 @@ {{ feature.updated_on | formatDate }} </td> </tr> - <tr> + <!-- <tr> <td>Date d'archivage automatique</td> <td v-if="feature.archived_on"> {{ feature.archived_on }} @@ -122,7 +122,7 @@ <td v-if="feature.deletion_on"> {{ feature.deletion_on }} </td> - </tr> + </tr> --> </tbody> </table> diff --git a/src/views/feature_type/Feature_type_detail.vue b/src/views/feature_type/Feature_type_detail.vue index a0022e3b9786163afa49061cc576f56defa1263e..e6a15e7802a0bceff60dbcb729fc0cdd8ea772b2 100644 --- a/src/views/feature_type/Feature_type_detail.vue +++ b/src/views/feature_type/Feature_type_detail.vue @@ -258,7 +258,7 @@ export default { (el) => el.slug === this.$route.params.feature_type_slug ); } - return null; + return {}; }, feature_type_features: function () { @@ -384,6 +384,7 @@ export default { this.$store.dispatch('feature/GET_PROJECT_FEATURES', { project_slug: this.$route.params.slug, feature_type__slug : this.structure.slug, + ordering: '-created_on', limit: '5' }) @@ -393,21 +394,20 @@ export default { } } }, - // watch:{ - // 'feature_type_features'(newValue){ - // console.log(newValue) - // if (newValue){ - // this.featuresLoading = false; - // } - // } - // }, + watch:{ + 'structure'(newValue){ + console.log(newValue) + if (newValue){ + this.$store.dispatch("feature_type/GET_IMPORTS", { + feature_type: this.structure.slug + }); + } + } + }, created() { if (!this.project) { this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); } - this.$store.dispatch("feature_type/GET_IMPORTS", { - feature_type: this.structure.slug - }); this.setCurrentFeatureTypeSlug(); // .then(res => resolve(res)) // .catch(err => reject(err)); diff --git a/src/views/project/Project_edit.vue b/src/views/project/Project_edit.vue index 90406b3e34157dcd5aa57f4eff109eec1504a81d..f925b211dbabb87f780c1cf4be0b959c518abcbf 100644 --- a/src/views/project/Project_edit.vue +++ b/src/views/project/Project_edit.vue @@ -128,7 +128,7 @@ >Visibilité des signalements publiés</label > <Dropdown - :options="levelPermissions" + :options="levelPermissionsPub" :selected="form.access_level_pub_feature.name" :selection.sync="form.access_level_pub_feature" /> @@ -259,18 +259,37 @@ export default { }, levelPermissions(){ let self = this; - let levels = [] - this.levelsPermissions.map(function(item) { - if (item.user_type_id != "super_contributor") - levels.push({ - 'name': self.traslateRoleToFrench(item.user_type_id), - 'value': item.user_type_id, - }) - if (!self.form.moderation && item.user_type_id == "moderator"){ - levels.pop() + let levels = new Array(); + if(self.levelsPermissions){ + self.levelsPermissions.map(function(item) { + if (item.user_type_id != "super_contributor") + levels.push({ + 'name': self.traslateRoleToFrench(item.user_type_id), + 'value': item.user_type_id, + }) + if (!self.form.moderation && item.user_type_id == "moderator"){ + levels.pop() + } + }); + } + return levels; + }, + levelPermissionsPub(){ + let self = this; + let levels = new Array(); + if(self.levelsPermissions){ + self.levelsPermissions.map(function(item) { + if (item.user_type_id != "super_contributor" + && item.user_type_id != "admin" + && item.user_type_id != "moderator"){ + levels.push({ + 'name': self.traslateRoleToFrench(item.user_type_id), + 'value': item.user_type_id, + }) } }); - return levels + } + return levels; } }, @@ -286,7 +305,7 @@ export default { }, traslateRoleToFrench(role){ - if (role == "admin") return "Administrateur de projet"; + if (role == "admin") return "Administrateur projet"; if (role == "moderator") return "Modérateur"; if (role == "contributor") return "Contributeur"; if (role == "logged_user") return "Utilisateur connecté"; @@ -494,27 +513,38 @@ export default { this.form.is_project_type = false; } //* transform string values to objects for dropdowns display (could be in a computed) - - this.form.access_level_pub_feature = { - name: this.project.access_level_pub_feature, - value: this.levelPermissions.find( - (el) => el.name === this.project.access_level_pub_feature - ).value, - }; - this.form.access_level_arch_feature = { - name: this.project.access_level_arch_feature, - value: this.levelPermissions.find( - (el) => el.name === this.project.access_level_arch_feature - ).value, - }; + if(this.levelPermissionsPub){ + let value = {} + value = this.levelPermissionsPub.find( + (el) => el.name === this.project.access_level_pub_feature + ) + if(value){ + this.form.access_level_pub_feature = { + name: this.project.access_level_pub_feature, + value: value.value , + }; + } + } + if(this.levelPermissions){ + let value = {} + value = this.levelPermissions.find( + (el) => el.name === this.project.access_level_arch_feature + ) + if(value){ + this.form.access_level_arch_feature = { + name: this.project.access_level_arch_feature, + value: value.value , + }; + } + } }, }, watch: { 'form.moderation': function (newValue){ - if(newValue){ - this.form.access_level_pub_feature = { name: "", value: "" }; - this.form.access_level_arch_feature = { name: "", value: "" }; - } + if(!newValue){ + this.form.access_level_pub_feature = { name: "", value: "" }; + this.form.access_level_arch_feature = { name: "", value: "" }; + } } }, created() {