Ignore:
Timestamp:
03/16/25 20:56:44 (3 months ago)
Author:
ste08 <sjovanoska@…>
Branches:
master
Children:
3a74959
Parents:
c064a42
Message:

Notifications + triggers!

File:
1 edited

Legend:

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

    rc064a42 r8a947b9  
    1010    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
    1111    <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css'>
     12    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
    1213    <style>
    1314        body {
     
    212213            color:white;
    213214        }
     215
     216        .notification-badge {
     217            position: absolute;
     218            top: 0;
     219            right: 0;
     220            background-color: red;
     221            color: white;
     222            border-radius: 50%;
     223            padding: 0.3em;
     224            font-size: 0.8em;
     225        }
     226
     227        button i {
     228            font-size: 24px;
     229            color: #333;
     230            position: relative;
     231        }
     232
     233        .notifications-popup {
     234            position: absolute;
     235            top: 50px;
     236            right: 0;
     237            background: white;
     238            border: 1px solid #ddd;
     239            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
     240            width: 300px;
     241            max-height: 400px;
     242            overflow-y: auto;
     243            padding: 10px;
     244            z-index: 9999;
     245        }
     246
     247        .notifications-popup ul {
     248            list-style-type: none;
     249            padding: 0;
     250        }
     251
     252        .notifications-popup li {
     253            padding: 10px;
     254            border-bottom: 1px solid #ddd;
     255        }
     256
     257        .notifications-popup button {
     258            background-color: #4CAF50; /* Green */
     259            color: white;
     260            padding: 10px;
     261            border: none;
     262            cursor: pointer;
     263            margin-top: 10px;
     264        }
     265
     266        .notifications-popup button:hover {
     267            background-color: #45a049;
     268        }
    214269    </style>
    215270</head>
     
    223278        <button @click="goToReports">Monthly Report</button>
    224279        <button @click="home">Log Out</button>
     280
     281        <button @click="toggleNotifications">
     282            <i class="fas fa-bell"></i>
     283            <span v-if="unreadNotifications > 0" class="notification-badge">{{ unreadNotifications }}</span>
     284        </button>
    225285    </header>
    226286
     
    291351        </div>
    292352    </div>
     353
     354    <div v-if="notificationsVisible" class="notifications-popup">
     355        <ul>
     356            <li v-for="notification in notifications" :key="notification.message">
     357                {{ notification.message }}
     358            </li>
     359        </ul>
     360        <button @click="markAllAsRead">Mark All as Read</button>
     361    </div>
    293362</div>
    294363
     
    310379            issueDescription: '',
    311380            userId:'',
    312             wishlisted:false
     381            wishlisted:false,
     382            unreadNotifications: 0,
     383            notifications: [],
     384            notificationsVisible: false,
    313385        },
    314386        computed: {
     
    319391
    320392        methods: {
     393            toggleNotifications() {
     394                this.notificationsVisible = !this.notificationsVisible;
     395            },
     396            fetchNotifications() {
     397                console.log('Fetching notifications for userId:', this.userId);
     398                axios.get(`/api/notifications/${this.userId}`)
     399                    .then(response => {
     400                        this.notifications = response.data;
     401                        this.unreadNotifications = this.notifications.filter(n => !n.read).length;
     402                    })
     403                    .catch(error => {
     404                        console.error('Error fetching notifications:', error);
     405                    });
     406            },
    321407            async searchFlights() {
    322408                this.isContainerVisible = !this.isContainerVisible;
     
    455541                    console.error("Error fetching flights", error);
    456542                });
    457 
     543            this.fetchNotifications();
    458544        }
    459545    });
Note: See TracChangeset for help on using the changeset viewer.