Просмотр исходного кода

Only show logout when logged in

master
LeneS 5 лет назад
Родитель
Сommit
bb8e9a0121

+ 8
- 0
src/assets/staticData/alertTypes.js Просмотреть файл

1
+const types = Object.freeze({
2
+  SUCCESS: 'Success',
3
+  INFO: 'Info',
4
+  WARNING: 'Warning',
5
+  ERROR: 'Error',
6
+});
7
+
8
+export default types;

+ 44
- 0
src/components/shared/alert.vue Просмотреть файл

1
+<template>
2
+  <div class="container">
3
+    <!-- eslint-disable max-len -->
4
+    <div class="alert alert-success" v-if="type === 'SUCCESS'">
5
+      <eva-icon name="checkmark-outline"></eva-icon>
6
+      <strong>{{ text }}</strong>
7
+    </div>
8
+    <div class="alert alert-info" v-if="type === 'INFO'">
9
+      <eva-icon name="info-outline"></eva-icon>
10
+      <strong>{{ text }}</strong>
11
+    </div>
12
+    <div class="alert alert-warning" v-if="type === 'WARNING'">
13
+      <eva-icon name="alert-circle-outline"></eva-icon>
14
+      <strong>{{ text }}</strong>
15
+    </div>
16
+    <div class="alert alert-danger" v-if="type === 'ERROR'">
17
+      <eva-icon name="slash-outline"></eva-icon>
18
+      <strong>{{ text }}</strong>
19
+    </div>
20
+  </div>
21
+</template>
22
+
23
+<script>
24
+export default {
25
+  name: 'Alert',
26
+  data() {
27
+    return {
28
+      alertTypes: {
29
+        SUCCESS: 'Success',
30
+        INFO: 'Info',
31
+        WARNING: 'Warning',
32
+        ERROR: 'Error',
33
+      },
34
+    };
35
+  },
36
+  props: {
37
+    text: null,
38
+    type: null,
39
+  },
40
+};
41
+</script>
42
+
43
+<style>
44
+</style>

+ 20
- 5
src/components/shared/navBar.vue Просмотреть файл

60
                   @click="routerGoTo('/timeshare/sell')"
60
                   @click="routerGoTo('/timeshare/sell')"
61
                 >To Sell</a>
61
                 >To Sell</a>
62
                 <a
62
                 <a
63
+                  v-if="showLogout"
63
                   class="dropdown-item cursor-pointer"
64
                   class="dropdown-item cursor-pointer"
64
                   @click="routerGoTo('/timeshare/sell')"
65
                   @click="routerGoTo('/timeshare/sell')"
65
                 >My Timeshare Weeks</a>
66
                 >My Timeshare Weeks</a>
103
                   class="dropdown-item cursor-pointer"
104
                   class="dropdown-item cursor-pointer"
104
                   @click="routerGoTo('/property/Residential/Rental')"
105
                   @click="routerGoTo('/property/Residential/Rental')"
105
                 >To Rent Residential Properties</a>
106
                 >To Rent Residential Properties</a>
106
-                <hr />
107
+                <hr v-if="showLogout" />
107
                 <a
108
                 <a
109
+                  v-if="showLogout"
108
                   class="dropdown-item cursor-pointer"
110
                   class="dropdown-item cursor-pointer"
109
                   @click="routerGoTo('/property/list/Commercial/MyListings')"
111
                   @click="routerGoTo('/property/list/Commercial/MyListings')"
110
                 >My Commercial Properties</a>
112
                 >My Commercial Properties</a>
111
                 <a
113
                 <a
114
+                  v-if="showLogout"
112
                   class="dropdown-item cursor-pointer"
115
                   class="dropdown-item cursor-pointer"
113
                   @click="routerGoTo('/property/list/Residential/MyListings')"
116
                   @click="routerGoTo('/property/list/Residential/MyListings')"
114
                 >My Residential Properties</a>
117
                 >My Residential Properties</a>
179
             <li class="nav-item dropdown">
182
             <li class="nav-item dropdown">
180
               <a
183
               <a
181
                 class="nav-link"
184
                 class="nav-link"
185
+                v-if="hideLogin"
182
                 @click="routerGoTo('/user/login')"
186
                 @click="routerGoTo('/user/login')"
183
                 id="navbarDropdown"
187
                 id="navbarDropdown"
184
                 role="button"
188
                 role="button"
187
                 aria-expanded="false"
191
                 aria-expanded="false"
188
               >Login</a>
192
               >Login</a>
189
             </li>
193
             </li>
194
+            <li class="nav-item dropdown">
195
+              <span v-if="showLogout">
196
+                <a class="nav-link" @click="logout()">Logout</a>
197
+              </span>
198
+              <span v-else></span>
199
+            </li>
200
+            <li>
201
+              <span v-if="showLogout">
202
+                <a>Welcome! {{ }}</a>
203
+              </span>
204
+              <span v-else></span>
205
+            </li>
190
           </ul>
206
           </ul>
191
         </div>
207
         </div>
192
       </div>
208
       </div>
202
         </button>
218
         </button>
203
       </div>
219
       </div>
204
     </div>
220
     </div>
205
-    <span v-if="showLogout">
206
-      <a @click="logout()">Logout</a>
207
-    </span>
208
-    <span v-else></span>
209
   </nav>
221
   </nav>
210
 </template>
222
 </template>
211
 
223
 
220
     showLogout() {
232
     showLogout() {
221
       return this.$store.state.authentication.status === 'success';
233
       return this.$store.state.authentication.status === 'success';
222
     },
234
     },
235
+    hideLogin() {
236
+      return this.$store.state.authentication.status !== 'success';
237
+    },
223
     Logout() {
238
     Logout() {
224
       return this.$store.state.authentication.methods.logout;
239
       return this.$store.state.authentication.methods.logout;
225
     },
240
     },

+ 10
- 2
src/components/user/loginPage.vue Просмотреть файл

8
             <h4>Login</h4>
8
             <h4>Login</h4>
9
             <br />
9
             <br />
10
           </div>
10
           </div>
11
+          <!-- <alert :text="'Login successful'" :type="'SUCCESS'" />
12
+          <alert :text="'User does not exist, please register'" :type="'ERROR'" />
13
+          <alert :text="'Username is incorrect'" :type="'WARNING'" />
14
+          <alert :text="'Password is incorrect'" :type="'WARNING'" />
15
+          <alert :text="'Caps Lock is on'" :type="'INFO'" />-->
11
           <div class="row">
16
           <div class="row">
12
             <div class="col-md-11" style="margin-bottom: 1em">
17
             <div class="col-md-11" style="margin-bottom: 1em">
13
               <div class="input-group mb-3">
18
               <div class="input-group mb-3">
76
         <div class="form">
81
         <div class="form">
77
           <h5>Trouble signing in?</h5>
82
           <h5>Trouble signing in?</h5>
78
           <div>
83
           <div>
84
+            <!-- <alert :text="'Username & password request email sent'" :type="'SUCCESS'" /> -->
79
             <div class="row">
85
             <div class="row">
80
               <div class="input-group-prepend">
86
               <div class="input-group-prepend">
81
                 <span class="input-group-text">
87
                 <span class="input-group-text">
97
 
103
 
98
 <script>
104
 <script>
99
 import { mapActions, mapState } from 'vuex';
105
 import { mapActions, mapState } from 'vuex';
100
-// import axios from 'axios';
101
-// import User from '../../assets/Log';
106
+import alert from '../shared/alert.vue';
102
 
107
 
103
 export default {
108
 export default {
104
   name: 'Login',
109
   name: 'Login',
110
+  components: {
111
+    alert,
112
+  },
105
   data() {
113
   data() {
106
     return {
114
     return {
107
       username: '',
115
       username: '',

+ 1
- 1
vue.config.js Просмотреть файл

2
   devServer: {
2
   devServer: {
3
     proxy: {
3
     proxy: {
4
       '/api': {
4
       '/api': {
5
-        target: 'http://192.168.6.188:5000',
5
+        target: 'http://localhost:57260',
6
         changeOrigin: true,
6
         changeOrigin: true,
7
       },
7
       },
8
     },
8
     },

Загрузка…
Отмена
Сохранить