Skip to content

Commit dccf74a

Browse files
authored
Merge pull request #7 from observatorycontrolsystem/fix/throttle_login
Moved getting profile from main to the App on creation so its failure…
2 parents b064556 + abea510 commit dccf74a

2 files changed

Lines changed: 27 additions & 16 deletions

File tree

src/App.vue

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@
4545
</b-collapse>
4646
</b-navbar>
4747
</div>
48-
<b-alert v-if="userIsAuthenticatedAndNotMemberOfProposals" variant="info" dismissible>
49-
<div>You are not a member of any proposals. Only public data will be shown.</div>
50-
</b-alert>
5148
<b-container class="flex-shrink-0 p-1">
49+
<b-alert v-if="userIsAuthenticatedAndNotMemberOfProposals" variant="info" show dismissible>
50+
<div>You are not a member of any proposals. Only public data will be shown.</div>
51+
</b-alert>
52+
<b-alert v-if="profileError" show variant="danger" dismissible @dismissed="profileError = ''">
53+
<p>{{ profileError }}</p>
54+
</b-alert>
5255
<router-view class="my-3" />
5356
</b-container>
5457
<ArchiveFooter
@@ -70,6 +73,11 @@ export default {
7073
components: {
7174
ArchiveFooter
7275
},
76+
data: function() {
77+
return {
78+
profileError: ''
79+
};
80+
},
7381
computed: {
7482
profile: function() {
7583
return this.$store.state.profile;
@@ -81,6 +89,17 @@ export default {
8189
return this.userIsAuthenticated && this.profile.profile.proposals.length < 1;
8290
}
8391
},
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+
});
102+
},
84103
methods: {
85104
logout: function() {
86105
this.$store.dispatch('removeArchiveToken').then(() => {

src/main.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,9 @@ $.ajax({
5252
// Initialize archive token if it is available in local storage already
5353
store.commit('initializeArchiveToken');
5454

55-
store
56-
.dispatch('getProfileData')
57-
.then(() => {
58-
new Vue({
59-
router,
60-
store,
61-
render: h => h(App)
62-
}).$mount('#app');
63-
})
64-
.catch(() => {
65-
// TODO: Display error page
66-
console.log('Error getting profile data');
67-
});
55+
new Vue({
56+
router,
57+
store,
58+
render: h => h(App)
59+
}).$mount('#app');
6860
});

0 commit comments

Comments
 (0)