|
1 | 1 | <template>
|
2 | 2 | <v-app class="mx-lg-4">
|
3 | 3 | <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" |
7 | 7 | >
|
8 | 8 | <preloader
|
9 |
| - v-if="getPreloader" |
10 |
| - class="mx-auto" |
| 9 | + v-if="getPreloader" |
| 10 | + class="mx-auto" |
11 | 11 | />
|
12 | 12 |
|
13 | 13 | <v-toolbar
|
14 |
| - v-if="isAuth" |
15 |
| - color="primary" |
| 14 | + v-if="isAuth" |
| 15 | + color="primary" |
16 | 16 | >
|
17 | 17 | <v-btn>
|
18 | 18 | <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"> |
22 | 22 | <span class="text-decoration-underline">
|
23 | 23 | READ USER MANUAL
|
24 | 24 | </span>
|
|
28 | 28 | <v-spacer></v-spacer>
|
29 | 29 | <v-btn icon>
|
30 | 30 | <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 |
34 | 34 | </v-icon>
|
35 | 35 | </v-btn>
|
36 | 36 | <v-btn icon>
|
37 | 37 | <Logout class="align-content-end secondary--text"/>
|
38 | 38 | </v-btn>
|
39 | 39 | <v-dialog
|
40 |
| - v-model="isOpenSettings" |
41 |
| - max-width="300" |
| 40 | + v-model="isOpenSettings" |
| 41 | + max-width="300" |
42 | 42 | >
|
43 | 43 | <settings @closeSettings="isOpenSettings = false"/>
|
44 | 44 | </v-dialog>
|
45 | 45 | </v-toolbar>
|
46 |
| - |
| 46 | + <ServiceEmails v-if="isAuth || _isService"/> |
47 | 47 | <v-main :class="isAuth ? '' : 'align-center'">
|
48 | 48 | <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"> |
51 | 51 | <h1 class="font-weight-bold display-3 primary--text text-break px-2">
|
52 | 52 | Health Board
|
53 | 53 | </h1>
|
54 | 54 | </v-card-title>
|
55 | 55 | <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" |
60 | 60 | >
|
61 | 61 | <Tabs/>
|
62 | 62 | <Data/>
|
63 | 63 | </v-col>
|
64 | 64 | <Authorization
|
65 |
| - v-else |
66 |
| - class="mx-auto" |
| 65 | + v-else |
| 66 | + class="mx-auto" |
67 | 67 | />
|
68 | 68 | </v-main>
|
69 | 69 | <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" |
76 | 76 | >
|
77 | 77 | Feedback Email:
|
78 | 78 | < a href= "mailto:[email protected]" class= "pl-2"> [email protected]</ a>
|
79 | 79 | </v-footer>
|
80 | 80 | </div>
|
81 | 81 | <div
|
82 |
| - v-else |
83 |
| - class="my-auto" |
| 82 | + v-else |
| 83 | + class="my-auto" |
84 | 84 | >
|
85 | 85 | <Preloader class="mx-auto"/>
|
86 | 86 | </div>
|
87 | 87 | </v-app>
|
88 | 88 | </template>
|
89 | 89 |
|
90 | 90 | <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, |
124 | 114 | },
|
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 |
| - }, |
139 | 115 |
|
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 | + }, |
145 | 123 |
|
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; |
149 | 138 | }
|
150 |
| - const url = location.origin + "/"; |
151 |
| - history.pushState({page: 1}, document.title, url); |
152 |
| - return token; |
153 | 139 | },
|
154 | 140 |
|
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 | + } |
161 | 149 | },
|
162 | 150 |
|
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; |
177 | 181 | 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 | + }; |
183 | 195 | </script>
|
184 | 196 |
|
185 | 197 | <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 | + } |
190 | 202 |
|
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 | + } |
197 | 209 |
|
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 | + } |
202 | 215 | }
|
203 |
| -} |
204 | 216 |
|
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 | + } |
208 | 220 |
|
209 |
| -.white-input input { |
210 |
| - color: #fff !important; |
211 |
| -} |
| 221 | + .white-input input { |
| 222 | + color: #fff !important; |
| 223 | + } |
212 | 224 |
|
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 | + } |
217 | 229 | </style>
|
0 commit comments