Changeset 62bba0c for src/main/resources


Ignore:
Timestamp:
02/23/25 20:37:56 (3 months ago)
Author:
ste08 <sjovanoska@…>
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)
Message:

Report working, Wishlist partly working.

Location:
src/main/resources
Files:
1 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • src/main/resources/static/FlightSearch.html

    rde83113 r62bba0c  
    113113            padding: 10px;
    114114            color:white;
    115             font-family: Cambria;
     115            font-family: Cambria,sans-serif;
    116116        }
    117117        .search {
     
    170170            align-items: center;
    171171            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;
    172184        }
    173185
     
    209221        <button @click="showReportPopup">Report Issue</button>
    210222        <button @click="goToWishlistPage">🤍</button>
     223        <button @click="goToReports">Monthly Report</button>
    211224        <button @click="home">Log Out</button>
    212225    </header>
     
    296309            showPopup: false,
    297310            issueDescription: '',
    298             userId:''
     311            userId:'',
     312            wishlisted:false
    299313        },
    300314        computed: {
     
    363377                window.location.href = '/';
    364378            },
     379            goToReports(){
     380                window.location.href = '/views'
     381            },
    365382            async toggleWishlist(flight) {
    366383                flight.wishlisted = !flight.wishlisted;
     384                this.$set(this.flights, this.flights.indexOf(flight), flight);
    367385                const wishlistData = {
    368                     targetId: flight.flightId,
    369                     wishlisted: flight.wishlisted
     386                    userId: parseInt(this.userId),
     387                    targetId: flight.flightID
    370388                };
    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                    }
    375404                }
    376405            },
    377             goToWishlistPage() {
    378                 window.location.href = '/api/wishlists';
     406            async goToWishlistPage() {
     407                window.location.href = `/api/wishlists?userId=${encodeURIComponent(this.userId)}`;
     408
    379409            },
    380410            showReportPopup() {
     
    387417                if (this.issueDescription.trim()) {
    388418                    const reviewData = {
    389                         userID: this.userId,
     419                        userId: this.userId,
    390420                        subject: "Issue Report",
    391421                        description: this.issueDescription
  • src/main/resources/static/Wishlist.html

    rde83113 r62bba0c  
    44    <meta charset="UTF-8">
    55    <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>
    712    <style>
    813        body {
     
    2429            display: flex;
    2530            align-items: center;
    26             background-color:rebeccapurple;
     31            background-color: rebeccapurple;
    2732            padding: 10px;
    2833            width: 100%;
     
    7378            background-color: #0056b3;
    7479        }
     80
    7581        .adminlogin {
    76             top:0;
     82            top: 0;
    7783            right: 0;
    7884            background-color: rebeccapurple;
    79             border:0;
    80             color:white;
     85            border: 0;
     86            color: white;
    8187            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;
    82102        }
    83103    </style>
     
    90110</div>
    91111
    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>
    94118</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>
    95154</body>
    96155</html>
Note: See TracChangeset for help on using the changeset viewer.