Changeset c064a42


Ignore:
Timestamp:
02/24/25 23:48:34 (3 months ago)
Author:
ste08 <sjovanoska@…>
Branches:
master
Children:
8a947b9
Parents:
07fe0be
Message:

Support ticket working!

Location:
src/main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/skychasemk/controller/SupportTicketController.java

    r07fe0be rc064a42  
    3939    }
    4040
    41     @PutMapping("/{ticketID}/status")
    42     public ResponseEntity<SupportTicket> updateTicket(@PathVariable("ticketID") Integer ticketID, @RequestBody String status) {
     41    @PutMapping("/{ticketId}/{status}")
     42    public ResponseEntity<SupportTicket> updateTicket(@PathVariable("ticketId") Integer ticketId, @PathVariable String status) {
    4343        try {
    4444            SupportTicket.TicketStatus newStatus = SupportTicket.TicketStatus.valueOf(status.toUpperCase());
    45             return ResponseEntity.ok(supportTicketService.updateTicket(ticketID, newStatus));
     45            return ResponseEntity.ok(supportTicketService.updateTicket(ticketId, newStatus));
    4646        } catch (IllegalArgumentException e) {
    4747            return ResponseEntity.badRequest().build();
  • src/main/java/com/example/skychasemk/model/SupportTicket.java

    r07fe0be rc064a42  
    1111public class SupportTicket {
    1212
    13     @Setter
    1413    @Id
    1514    @GeneratedValue(strategy = GenerationType.IDENTITY)
    16     @Column(name = "TicketID")
     15    @Column(name = "ticketid")
     16    private Integer ticketId;
    1717
    18     private Integer ticketID;
     18    public Integer getTicketId() {
     19        return ticketId;
     20    }
     21
     22    public void setTicketId(Integer ticketId) {
     23        this.ticketId = ticketId;
     24    }
     25
    1926    @Setter
    2027    @Getter
  • src/main/java/com/example/skychasemk/repository/SupportTicketRepository.java

    r07fe0be rc064a42  
    22
    33import com.example.skychasemk.model.SupportTicket;
     4import org.springframework.data.jpa.repository.EntityGraph;
    45import org.springframework.data.jpa.repository.JpaRepository;
    56import org.springframework.data.jpa.repository.Query;
  • src/main/java/com/example/skychasemk/services/SupportTicketService.java

    r07fe0be rc064a42  
    2626    }
    2727    public List<SupportTicket> getAllTickets() {
    28         return supportTicketRepository.findTickets();
     28        List<SupportTicket> tickets = supportTicketRepository.findTickets();
     29        tickets.forEach(ticket -> System.out.println(ticket.getTicketId() + " - " + ticket.getStatus()));
     30        return tickets;
    2931    }
    3032    public List<SupportTicket> getResolvedTickets() {
    31         return supportTicketRepository.findResolvedTickets();
     33        List<SupportTicket> tickets = supportTicketRepository.findResolvedTickets();
     34        tickets.forEach(ticket -> System.out.println(ticket.getTicketId() + " - " + ticket.getStatus()));
     35        return tickets;
    3236    }
    3337
  • src/main/resources/static/SupportTickets.html

    r07fe0be rc064a42  
    88    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    99</head>
     10<style>
     11    body {
     12        background: url('images/flight.jpg') no-repeat center center fixed;
     13        background-size: cover;
     14        display: flex;
     15        flex-direction: column;
     16        align-items: center;
     17        justify-content: center;
     18        height: 100vh;
     19        margin: 0;
     20        font-family: Arial, sans-serif;
     21        padding-top: 30px;
     22        margin-top: 10px;
     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        z-index: 10;
     35        margin-bottom: 10px;
     36    }
     37    .header img {
     38        width: 40px;
     39        height: 40px;
     40        margin-right: 20px;
     41    }
     42
     43    .header h1 {
     44        color: white;
     45        margin: 0;
     46        font-size: 15px;
     47        padding-right: 50px;
     48    }
     49
     50    .header button {
     51        background-color: transparent;
     52        border: none;
     53        color: white;
     54        font-size: 14px;
     55    }
     56
     57    .header button:hover {
     58        background-color: transparent;
     59        cursor: pointer;
     60    }
     61
     62    select {
     63        -webkit-appearance: none;
     64        -moz-appearance: none;
     65        appearance: none;
     66        border: 0;
     67        outline: 0;
     68        font: inherit;
     69        width: 20em;
     70        height: 3em;
     71        padding: 0 4em 0 1em;
     72        background: url(https://upload.wikimedia.org/wikipedia/commons/9/9d/Caret_down_font_awesome_whitevariation.svg) no-repeat right 0.8em center/1.4em, linear-gradient(to left, rgba(255, 255, 255, 0.3) 3em, rgba(255, 255, 255, 0.2) 3em);
     73        color: white;
     74        border-radius: 0.25em;
     75        box-shadow: 0 0 1em 0 rgba(0, 0, 0, 0.2);
     76        cursor: pointer;
     77    }
     78    select option {
     79        color: inherit;
     80        background-color: #320a28;
     81    }
     82    select:focus {
     83        outline: none;
     84    }
     85    select::-ms-expand {
     86        display: none;
     87    }
     88
     89    .search-form-container h2 {
     90        color: white;
     91        padding-top: 110px;
     92    }
     93
     94
     95    .flights-list-container h2{
     96        padding-top: 110px;
     97    }
     98    .flights-list .flight-item {
     99        margin-bottom: 15px;
     100    }
     101
     102    .flights-list .flight-item span {
     103        margin-right: 15px;
     104    }
     105
     106
     107    .popup textarea{
     108        width: 100%;
     109        padding: 10px;
     110        margin-top: 10px;
     111        border: 1px solid #ccc;
     112        border-radius: 4px;
     113        resize: vertical;
     114        box-sizing: border-box;
     115    }
     116
     117
     118    .popup button {
     119        margin-top: 10px;
     120        background-color: rebeccapurple;
     121        color: white;
     122        border: none;
     123        padding: 5px;
     124        cursor: pointer;
     125    }
     126
     127    .popup button:hover {
     128        background-color: mediumpurple;
     129    }
     130    .ticket-list{
     131        margin-top:20px;
     132        padding-top:60px;
     133    }
     134
     135
     136</style>
    10137<body>
    11138
    12139<div id="app" class="support-ticket-container">
    13     <button @click="fetchResolved">Fetch Resolved Tickets</button>
    14     <button @click="fetchTickets">Fetch Unresolved Tickets</button>
     140    <header class="header">
     141        <button @click="fetchResolved">Fetch Resolved Tickets</button>
     142        <button @click="fetchTickets">Fetch Unresolved Tickets</button>
     143    </header>
     144
    15145    <h1>Support Tickets</h1>
    16146    <div class="ticket-list">
    17         <div class="ticket-item" v-for="ticket in tickets" :key="ticket.ticketID">
     147        <div class="ticket-item" v-for="ticket in tickets" :key="ticket.ticketId">
    18148            <div class="ticket-info">
    19149                <p><strong>Subject:</strong> {{ ticket.subject }}</p>
     
    22152            </div>
    23153            <div class="ticket-actions">
    24                 <button @click="resolveTicket(ticket.ticketID)">Resolve</button>
     154                <button @click="resolveTicket(ticket.ticketId)">Resolve</button>
    25155            </div>
    26156        </div>
     
    61191                    });
    62192            },
    63             resolveTicket(ticketID) {
    64                 console.log(ticketID);
     193            resolveTicket(ticketId) {
     194                console.log(ticketId);
    65195                const status = 'RESOLVED';
    66                 axios.put(`http://localhost:8080/api/support-tickets/${ticketID}/status`, status,
     196                axios.put(`api/support-tickets/${ticketId}/${status}`, {},
    67197                {
    68198                    headers: {
    69                         'Content-Type': 'text/plain'
     199                        'Content-Type': 'application/json'
    70200                    }
    71201                })
    72202                    .then(() => {
    73                         alert(`Ticket ${ticketID} resolved.`);
     203                        alert(`Ticket ${ticketId} resolved.`);
    74204                        this.fetchTickets();
    75205                    })
Note: See TracChangeset for help on using the changeset viewer.