Changeset 62bba0c for src/main/resources
- Timestamp:
- 02/23/25 20:37:56 (3 months ago)
- Branches:
- master
- Children:
- fda671c
- Parents:
- de83113
- git-author:
- ste08 <sjovanoska@…> (02/23/25 20:37:23)
- git-committer:
- ste08 <sjovanoska@…> (02/23/25 20:37:56)
- Location:
- src/main/resources
- Files:
-
- 1 added
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/resources/static/FlightSearch.html
rde83113 r62bba0c 113 113 padding: 10px; 114 114 color:white; 115 font-family: Cambria ;115 font-family: Cambria,sans-serif; 116 116 } 117 117 .search { … … 170 170 align-items: center; 171 171 justify-content: center; 172 z-index: 1000; 173 overflow:hidden; 174 } 175 176 .popup textarea{ 177 width: 100%; 178 padding: 10px; 179 margin-top: 10px; 180 border: 1px solid #ccc; 181 border-radius: 4px; 182 resize: vertical; 183 box-sizing: border-box; 172 184 } 173 185 … … 209 221 <button @click="showReportPopup">Report Issue</button> 210 222 <button @click="goToWishlistPage">🤍</button> 223 <button @click="goToReports">Monthly Report</button> 211 224 <button @click="home">Log Out</button> 212 225 </header> … … 296 309 showPopup: false, 297 310 issueDescription: '', 298 userId:'' 311 userId:'', 312 wishlisted:false 299 313 }, 300 314 computed: { … … 363 377 window.location.href = '/'; 364 378 }, 379 goToReports(){ 380 window.location.href = '/views' 381 }, 365 382 async toggleWishlist(flight) { 366 383 flight.wishlisted = !flight.wishlisted; 384 this.$set(this.flights, this.flights.indexOf(flight), flight); 367 385 const wishlistData = { 368 targetId: flight.flightId,369 wishlisted: flight.wishlisted386 userId: parseInt(this.userId), 387 targetId: flight.flightID 370 388 }; 371 try { 372 await axios.post('/api/wishlists', wishlistData); 373 } catch (error) { 374 console.error("Error updating wishlist:", error); 389 console.log(wishlistData); 390 if (!flight.wishlisted) { 391 try { 392 await axios.delete('/api/wishlists', { params: wishlistData }); 393 console.log("Removed from wishlist"); 394 } catch (error) { 395 console.error("Error removing from wishlist:", error); 396 } 397 } else { 398 try { 399 await axios.post('/api/wishlists/add', wishlistData); 400 console.log("Added to wishlist"); 401 } catch (error) { 402 console.error("Error adding to wishlist:", error); 403 } 375 404 } 376 405 }, 377 goToWishlistPage() { 378 window.location.href = '/api/wishlists'; 406 async goToWishlistPage() { 407 window.location.href = `/api/wishlists?userId=${encodeURIComponent(this.userId)}`; 408 379 409 }, 380 410 showReportPopup() { … … 387 417 if (this.issueDescription.trim()) { 388 418 const reviewData = { 389 userI D: this.userId,419 userId: this.userId, 390 420 subject: "Issue Report", 391 421 description: this.issueDescription -
src/main/resources/static/Wishlist.html
rde83113 r62bba0c 4 4 <meta charset="UTF-8"> 5 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <title>SkyChase-mk</title> 6 <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script> 7 <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> 8 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> 9 <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css'> 10 11 <title>SkyChase - Wishlist</title> 7 12 <style> 8 13 body { … … 24 29 display: flex; 25 30 align-items: center; 26 background-color: rebeccapurple;31 background-color: rebeccapurple; 27 32 padding: 10px; 28 33 width: 100%; … … 73 78 background-color: #0056b3; 74 79 } 80 75 81 .adminlogin { 76 top: 0;82 top: 0; 77 83 right: 0; 78 84 background-color: rebeccapurple; 79 border: 0;80 color: white;85 border: 0; 86 color: white; 81 87 padding: 0 1200px; 88 } 89 90 .wishlist-content { 91 margin-top: 60px; 92 color: white; 93 } 94 95 ul { 96 list-style-type: none; 97 } 98 99 li { 100 margin: 10px 0; 101 font-size: 18px; 82 102 } 83 103 </style> … … 90 110 </div> 91 111 92 <div class="buttons"> 93 <h1>Test</h1> 112 <div class="wishlist-content"> 113 <h1>Your Wishlist</h1> 114 <ul> 115 <li v-if="wishlist.length === 0">Your wishlist is empty!</li> 116 <li v-else v-for="item in wishlist" :key="item.wishlistID">{{ item.targetId }} || {{item.userId}}</li> 117 </ul> 94 118 </div> 119 120 <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script> 121 122 <script> 123 new Vue({ 124 el: '#app', 125 data: { 126 userId: '' 127 }, 128 mounted() { 129 const params = new URLSearchParams(window.location.search); 130 this.userId = params.get("userId"); 131 this.fetchWishlist(); 132 }, 133 async fetchWishlist() { 134 try { 135 const response = await fetch(`/api/wishlists/${this.userId}`); 136 const wishlist = await response.json(); 137 138 const wishlistElement = document.getElementById('wishlist'); 139 const emptyMessage = document.getElementById('empty-message'); 140 141 if (wishlist.length === 0) { 142 emptyMessage.style.display = 'block'; 143 } else { 144 emptyMessage.style.display = 'none'; 145 wishlistElement.innerHTML = wishlist.map(item => `<li>${item.name}</li>`).join(''); 146 } 147 } catch (error) { 148 console.error('Error fetching wishlist:', error); 149 } 150 } 151 }) 152 //window.onload = fetchWishlist; 153 </script> 95 154 </body> 96 155 </html>
Note:
See TracChangeset
for help on using the changeset viewer.