File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5252 <b-alert v-if =" profileError" show variant =" danger" dismissible @dismissed =" profileError = ''" >
5353 <p >{{ profileError }}</p >
5454 </b-alert >
55- <router-view class =" my-3" />
55+ <router-view class =" my-3" v-if = " !loading " />
5656 </b-container >
5757 <ArchiveFooter
5858 :copyright-organization =" this.$store.state.urls.copyrightOrganization"
@@ -75,7 +75,8 @@ export default {
7575 },
7676 data : function () {
7777 return {
78- profileError: ' '
78+ profileError: ' ' ,
79+ loading: true
7980 };
8081 },
8182 computed: {
@@ -89,16 +90,16 @@ export default {
8990 return this .userIsAuthenticated && this .profile .profile .proposals .length < 1 ;
9091 }
9192 },
92- created : function () {
93- this . $store
94- . dispatch (' getProfileData' )
95- . then (() => {
96- this . profileError = ' ' ;
97- })
98- . catch (( response ) => {
99- this . profileError = ` Failed to load profile data - ${ response . status } : ${ response . statusText } - ${ response . responseText } ` ;
100- console . error ( this .profileError ) ;
101- });
93+ created : async function () {
94+ try {
95+ await this . $store . dispatch (' getProfileData' );
96+ this . profileError = ' ' ;
97+ } catch (response) {
98+ this . profileError = ` Failed to load profile data - ${ response . status } : ${ response . statusText } - ${ response . responseText } ` ;
99+ console . error ( this . profileError );
100+ } finally {
101+ this .loading = false ;
102+ }
102103 },
103104 methods: {
104105 logout : function () {
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import VueRouter from 'vue-router';
33import Home from '../views/Home.vue' ;
44import Login from '../views/Login.vue' ;
55import NotFound from '../components/NotFound.vue' ;
6- import store from '../store' ;
76
87Vue . use ( VueRouter ) ;
98
@@ -12,21 +11,6 @@ const routes = [
1211 path : '/' ,
1312 name : 'Home' ,
1413 component : Home ,
15- beforeEnter : ( to , from , next ) => {
16- // if the route contains a public parameter, honor that
17- if ( to . query . public != undefined ) {
18- next ( ) ;
19- return
20- }
21-
22- // otherwise send authenticated users to public=false
23- // and unauthenticated users to public=true
24- if ( store . state . userIsAuthenticated ) {
25- next ( { name : 'Home' , query : { ...to . query , public : "false" } } ) ;
26- } else {
27- next ( { name : 'Home' , query : { ...to . query , public : "true" } } ) ;
28- }
29- }
3014 } ,
3115 {
3216 path : '/login' ,
Original file line number Diff line number Diff line change @@ -26,6 +26,23 @@ export default {
2626 let now = moment .utc ().format (' YYYY-MM-DD HH:mm' );
2727 return ` ${ this .$store .state .urls .observationPortalApiUrl } /semesters/?start_lte=${ now} ` ;
2828 }
29- }
29+ },
30+ created : function () {
31+ // if the route contains a public parameter, honor that
32+ if (this .$route .query .public == undefined ) {
33+ let newQueryParams = {... this .$route .query };
34+ if (this .$store .state .userIsAuthenticated ) {
35+ newQueryParams .public = " false" ;
36+ }
37+ else {
38+ // anonymous users should see public data and science data by default
39+ newQueryParams .public = " true" ;
40+ }
41+ this .$router .replace ({
42+ path: this .$route .path ,
43+ query: newQueryParams
44+ });
45+ }
46+ },
3047};
3148 </script >
You can’t perform that action at this time.
0 commit comments