source: src/main/resources/static/Wishlist.html@ 62bba0c

Last change on this file since 62bba0c was 62bba0c, checked in by ste08 <sjovanoska@…>, 3 months ago

Report working, Wishlist partly working.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
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>
12 <style>
13 body {
14 background: url('images/homepage.jpg') no-repeat center center fixed;
15 background-size: cover;
16 display: flex;
17 flex-direction: column;
18 align-items: center;
19 justify-content: center;
20 height: 100vh;
21 margin: 0;
22 font-family: Arial, sans-serif;
23 }
24
25 .header {
26 position: absolute;
27 top: 0;
28 left: 0;
29 display: flex;
30 align-items: center;
31 background-color: rebeccapurple;
32 padding: 10px;
33 width: 100%;
34 }
35
36 .header img {
37 width: 40px;
38 height: 40px;
39 margin-right: 10px;
40 }
41
42 .header h1 {
43 color: white;
44 margin: 0;
45 font-size: 15px;
46 padding-right: 50px;
47 }
48
49 .buttons {
50 text-align: center;
51 }
52
53 .buttons button {
54 padding: 15px 30px;
55 margin: 10px;
56 font-size: 18px;
57 border: none;
58 border-radius: 5px;
59 cursor: pointer;
60 transition: 0.3s;
61 }
62
63 .signup {
64 background-color: rebeccapurple;
65 color: white;
66 }
67
68 .signup:hover {
69 background-color: mediumpurple;
70 }
71
72 .login {
73 background-color: #007bff;
74 color: white;
75 }
76
77 .login:hover {
78 background-color: #0056b3;
79 }
80
81 .adminlogin {
82 top: 0;
83 right: 0;
84 background-color: rebeccapurple;
85 border: 0;
86 color: white;
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;
102 }
103 </style>
104</head>
105<body>
106<div class="header">
107 <img src="/images/home.png" alt="Home Icon">
108 <h1>SkyChase</h1>
109 <button class="adminlogin" onclick="location.href='/admin'">Admin?</button>
110</div>
111
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>
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>
154</body>
155</html>
Note: See TracBrowser for help on using the repository browser.