Skip to content

Commit 9190018

Browse files
committed
fix firestore handlers
1 parent f31420b commit 9190018

File tree

7 files changed

+542
-475
lines changed

7 files changed

+542
-475
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
-------------
55
##Roadmap
6+
- average data values between players
67
- treeshaking
78
- move to vue 3
89
- move math calcs to TS
10+
- move DB functions in module

src/App.vue

Lines changed: 152 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<template>
22
<v-app class="mx-lg-4">
33
<div
4-
v-if="!globalPreloader"
5-
:class="!isAuth ? 'd-flex' : ''"
6-
class="fill-height"
4+
v-if="!globalPreloader"
5+
:class="!isAuth ? 'd-flex' : ''"
6+
class="fill-height"
77
>
88
<preloader
9-
v-if="getPreloader"
10-
class="mx-auto"
9+
v-if="getPreloader"
10+
class="mx-auto"
1111
/>
1212

1313
<v-toolbar
14-
v-if="isAuth"
15-
color="primary"
14+
v-if="isAuth"
15+
color="primary"
1616
>
1717
<v-btn>
1818
<a
19-
class=" text-decoration-none"
20-
target="_blank"
21-
href="https://vllesh.medium.com/healthboard-tech-user-manual-5d075d46c408">
19+
class=" text-decoration-none"
20+
target="_blank"
21+
href="https://vllesh.medium.com/healthboard-tech-user-manual-5d075d46c408">
2222
<span class="text-decoration-underline">
2323
READ USER MANUAL
2424
</span>
@@ -28,190 +28,202 @@
2828
<v-spacer></v-spacer>
2929
<v-btn icon>
3030
<v-icon
31-
settings
32-
class="secondary--text"
33-
@click.stop="isOpenSettings = !isOpenSettings">settings
31+
settings
32+
class="secondary--text"
33+
@click.stop="isOpenSettings = !isOpenSettings">settings
3434
</v-icon>
3535
</v-btn>
3636
<v-btn icon>
3737
<Logout class="align-content-end secondary--text"/>
3838
</v-btn>
3939
<v-dialog
40-
v-model="isOpenSettings"
41-
max-width="300"
40+
v-model="isOpenSettings"
41+
max-width="300"
4242
>
4343
<settings @closeSettings="isOpenSettings = false"/>
4444
</v-dialog>
4545
</v-toolbar>
46-
46+
<ServiceEmails v-if="isAuth || _isService"/>
4747
<v-main :class="isAuth ? '' : 'align-center'">
4848
<v-card-title
49-
v-if="!getPreloader"
50-
class="text-center justify-center py-6">
49+
v-if="!getPreloader"
50+
class="text-center justify-center py-6">
5151
<h1 class="font-weight-bold display-3 primary--text text-break px-2">
5252
Health Board
5353
</h1>
5454
</v-card-title>
5555
<v-col
56-
v-if="isAuth"
57-
cols="12"
58-
lg="7"
59-
class="d-flex flex-column mx-auto px-0 px-md-12 py-0"
56+
v-if="isAuth"
57+
cols="12"
58+
lg="7"
59+
class="d-flex flex-column mx-auto px-0 px-md-12 py-0"
6060
>
6161
<Tabs/>
6262
<Data/>
6363
</v-col>
6464
<Authorization
65-
v-else
66-
class="mx-auto"
65+
v-else
66+
class="mx-auto"
6767
/>
6868
</v-main>
6969
<v-footer
70-
light
71-
absolute
72-
inset
73-
app
74-
min-height="50"
75-
class="d-flex justify-center"
70+
light
71+
absolute
72+
inset
73+
app
74+
min-height="50"
75+
class="d-flex justify-center"
7676
>
7777
Feedback Email:
7878
<a href="mailto:[email protected]" class="pl-2">[email protected]</a>
7979
</v-footer>
8080
</div>
8181
<div
82-
v-else
83-
class="my-auto"
82+
v-else
83+
class="my-auto"
8484
>
8585
<Preloader class="mx-auto"/>
8686
</div>
8787
</v-app>
8888
</template>
8989

9090
<script>
91-
import Cookies from "js-cookie";
92-
import axios from "axios";
93-
94-
import Logout from "./components/Logout";
95-
import Authorization from "./components/Authorization";
96-
import Data from "./components/main/Data";
97-
import Tabs from "./components/Tabs";
98-
import Settings from './components/settings';
99-
import Preloader from "./components/Preloader";
100-
101-
export default {
102-
name: "App",
103-
104-
components: {
105-
Authorization,
106-
Data,
107-
Logout,
108-
Tabs,
109-
Preloader,
110-
Settings
111-
},
112-
113-
data() {
114-
return {
115-
auth: false,
116-
globalPreloader: true,
117-
isOpenSettings: false,
118-
};
119-
},
120-
121-
computed: {
122-
isAuth: function () {
123-
return this.$store.state.Auth.token;
91+
import {mapGetters} from 'vuex';
92+
import Cookies from "js-cookie";
93+
import axios from "axios";
94+
95+
import Logout from "./components/Logout";
96+
import Authorization from "./components/Authorization";
97+
import Data from "./components/main/Data";
98+
import Tabs from "./components/Tabs";
99+
import Settings from './components/Settings';
100+
import Preloader from "./components/Preloader";
101+
import ServiceEmails from "./components/ServiceEmails";
102+
103+
export default {
104+
name: "App",
105+
106+
components: {
107+
Authorization,
108+
Data,
109+
Logout,
110+
Tabs,
111+
Preloader,
112+
Settings,
113+
ServiceEmails,
124114
},
125-
getPreloader: function () {
126-
return this.$store.state.Data.preloader;
127-
}
128-
},
129-
130-
mounted() {
131-
let token = this.getToken();
132-
if (token) {
133-
this.checksTokenEnDecay(token);
134-
} else {
135-
this.auth = false;
136-
this.globalPreloader = false;
137-
}
138-
},
139115
140-
methods: {
141-
getTokenInHref() {
142-
let token;
143-
const href = decodeURIComponent(location.href);
144-
const token_lifetime = this.$store.state.Auth.token_lifetime;
116+
data() {
117+
return {
118+
auth: false,
119+
globalPreloader: true,
120+
isOpenSettings: false,
121+
};
122+
},
145123
146-
if (href.includes("access_token")) {
147-
token = href.split("access_token=")[1].split("&")[0];
148-
Cookies.set("token_oura", token, {expires: token_lifetime});
124+
computed: {
125+
...mapGetters(['userInfo']),
126+
isAuth: function () {
127+
return this.$store.state.Auth.token;
128+
},
129+
getPreloader: function () {
130+
return this.$store.state.Data.preloader;
131+
},
132+
133+
_isService() {
134+
// if (this.userInfo?.email) {
135+
// return this.userInfo.email === '[email protected]';
136+
// }
137+
return false;
149138
}
150-
const url = location.origin + "/";
151-
history.pushState({page: 1}, document.title, url);
152-
return token;
153139
},
154140
155-
getToken() {
156-
let token = Cookies.get("token_oura") || null;
157-
if (!token) token = this.getTokenInHref();
158-
const url = location.origin + "/";
159-
history.pushState({page: 1}, document.title, url);
160-
return token;
141+
mounted() {
142+
let token = this.getToken();
143+
if (token) {
144+
this.checksTokenEnDecay(token);
145+
} else {
146+
this.auth = false;
147+
this.globalPreloader = false;
148+
}
161149
},
162150
163-
checksTokenEnDecay(token) {
164-
axios
165-
.get(`https://api.ouraring.com/v1/userinfo?access_token=${token}`)
166-
.then(() => {
167-
if (!this.$store.state.Auth.token)
168-
this.$store.commit("saveToken", token);
169-
this.auth = true;
170-
this.globalPreloader = false;
171-
})
172-
.catch(e => {
173-
const codeError = new Error(e);
174-
if (codeError.message.includes(401)) {
175-
Cookies.remove("token_oura");
176-
this.auth = false;
151+
methods: {
152+
getTokenInHref() {
153+
let token;
154+
const href = decodeURIComponent(location.href);
155+
const token_lifetime = this.$store.state.Auth.token_lifetime;
156+
157+
if (href.includes("access_token")) {
158+
token = href.split("access_token=")[1].split("&")[0];
159+
Cookies.set("token_oura", token, {expires: token_lifetime});
160+
}
161+
const url = location.origin + "/";
162+
history.pushState({page: 1}, document.title, url);
163+
return token;
164+
},
165+
166+
getToken() {
167+
let token = Cookies.get("token_oura") || null;
168+
if (!token) token = this.getTokenInHref();
169+
const url = location.origin + "/";
170+
history.pushState({page: 1}, document.title, url);
171+
return token;
172+
},
173+
174+
checksTokenEnDecay(token) {
175+
axios
176+
.get(`https://api.ouraring.com/v1/userinfo?access_token=${token}`)
177+
.then(response => {
178+
if (!this.$store.state.Auth.token)
179+
this.$store.commit("saveToken", token);
180+
this.auth = true;
177181
this.globalPreloader = false;
178-
}
179-
});
180-
}
181-
},
182-
};
182+
this.$store.dispatch('processEmail', response.data.email);
183+
})
184+
.catch(e => {
185+
const codeError = new Error(e);
186+
if (codeError.message.includes(401)) {
187+
Cookies.remove("token_oura");
188+
this.auth = false;
189+
this.globalPreloader = false;
190+
}
191+
});
192+
}
193+
},
194+
};
183195
</script>
184196

185197
<style>
186-
@media screen and (min-width: 991px) {
187-
::-webkit-scrollbar-track {
188-
background: transparent
189-
}
198+
@media screen and (min-width: 991px) {
199+
::-webkit-scrollbar-track {
200+
background: transparent
201+
}
190202
191-
::-webkit-scrollbar {
192-
position: absolute;
193-
width: 8px;
194-
z-index: 1000;
195-
background-color: transparent;
196-
}
203+
::-webkit-scrollbar {
204+
position: absolute;
205+
width: 8px;
206+
z-index: 1000;
207+
background-color: transparent;
208+
}
197209
198-
::-webkit-scrollbar-thumb {
199-
background-color: #ccc;
200-
border-radius: 3px;
201-
border: 1px solid #fff;
210+
::-webkit-scrollbar-thumb {
211+
background-color: #ccc;
212+
border-radius: 3px;
213+
border: 1px solid #fff;
214+
}
202215
}
203-
}
204216
205-
.theme--dark.v-btn.v-btn--disabled:not(.v-btn--flat):not(.v-btn--text):not(.v-btn--outlined) {
206-
background-color: #ccc !important;
207-
}
217+
.theme--dark.v-btn.v-btn--disabled:not(.v-btn--flat):not(.v-btn--text):not(.v-btn--outlined) {
218+
background-color: #ccc !important;
219+
}
208220
209-
.white-input input {
210-
color: #fff !important;
211-
}
221+
.white-input input {
222+
color: #fff !important;
223+
}
212224
213-
.v-application .primary--text.white-input {
214-
color: #ffffff;
215-
caret-color: #fff;
216-
}
225+
.v-application .primary--text.white-input {
226+
color: #ffffff;
227+
caret-color: #fff;
228+
}
217229
</style>

0 commit comments

Comments
 (0)