comparison client/src/components/Sidebar.vue @ 2774:6c1c4f55d99b

sidebar: only update when user is logged in
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 22 Mar 2019 12:45:53 +0100
parents 5b990f612420
children 6c5364ff0abb
comparison
equal deleted inserted replaced
2773:eb1b7479c5e3 2774:6c1c4f55d99b
164 stagingNotifications: null 164 stagingNotifications: null
165 }; 165 };
166 }, 166 },
167 computed: { 167 computed: {
168 ...mapGetters("user", ["isSysAdmin", "isWaterwayAdmin"]), 168 ...mapGetters("user", ["isSysAdmin", "isWaterwayAdmin"]),
169 ...mapState("user", ["user", "roles"]), 169 ...mapState("user", ["user", "roles", "isAuthenticated"]),
170 ...mapState("application", [ 170 ...mapState("application", [
171 "showSidebar", 171 "showSidebar",
172 "showSearchbarLastState", 172 "showSearchbarLastState",
173 "contextBoxContent", 173 "contextBoxContent",
174 "showContextBox" 174 "showContextBox"
198 return ( 198 return (
199 this.showContextBox && 199 this.showContextBox &&
200 this.contextBoxContent === item && 200 this.contextBoxContent === item &&
201 this.routeName == "mainview" 201 this.routeName == "mainview"
202 ); 202 );
203 }, 203 }
204 updateIndicators() { 204 },
205 mounted() {
206 const updateIndicators = () => {
205 if (this.isWaterwayAdmin) { 207 if (this.isWaterwayAdmin) {
206 this.$store; 208 this.$store;
207 HTTP.get("/imports?states=pending&count=true", { 209 HTTP.get("/imports?states=pending&count=true", {
208 headers: { "X-Gemma-Auth": localStorage.getItem("token") } 210 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
209 }) 211 })
210 .then(response => { 212 .then(response => {
211 this.stagingNotifications = response.data; 213 this.stagingNotifications = response.data;
214 if (this.isAuthenticated) {
215 setTimeout(updateIndicators, 15000);
216 }
212 }) 217 })
213 .catch(error => { 218 .catch(error => {
214 const { status, data } = error.response; 219 const { status, data } = error.response;
215 displayError({ 220 displayError({
216 title: "Backend Error", 221 title: "Backend Error",
217 message: `${status}: ${data.message || data}` 222 message: `${status}: ${data.message || data}`
218 }); 223 });
219 }); 224 });
220 } 225 }
221 } 226 };
222 }, 227 setTimeout(updateIndicators, 15000);
223 mounted() {
224 this.updateIndicators();
225 setInterval(this.updateIndicators, 15000);
226 } 228 }
227 }; 229 };
228 </script> 230 </script>
229 231
230 <style lang="scss" scoped> 232 <style lang="scss" scoped>