Skip to content

Commit

Permalink
frontend pour Admin Dashboard view
Browse files Browse the repository at this point in the history
  • Loading branch information
e.elhjoujy committed Oct 20, 2023
1 parent 149900d commit 242805b
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 167 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>2.0.0-M1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>



<dependency>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/ma/yc/airafraik/FunctionalTest/Vol.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ma.yc.airafraik.FunctionalTest;

import ma.yc.airafraik.dao.Impl.VolDaoImpl;
import ma.yc.airafraik.entities.VolEntity;

import java.util.Collection;

public class Vol {
public static void main(String[] args) {

Collection<VolEntity> vols = new VolDaoImpl().consulterVols();
vols.forEach(volEntity -> {
System.out.println(volEntity.getVol().getId());
});


}
}
27 changes: 24 additions & 3 deletions src/main/java/ma/yc/airafraik/entities/AvionEntity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
package ma.yc.airafraik.entities;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.*;
import lombok.*;

import java.util.ArrayList;
import java.util.Collection;

@AllArgsConstructor
@NoArgsConstructor
@Setter
@Getter
@Builder
@Entity
@Table(name = "AVION")
public class AvionEntity {
@Id
private int idAvion;
private int id;
@Column(name = "nom_avion")
private String nomAvion;

@Column(name = "nomber_place")
private int nombrePlace;

// @ManyToOne

// private SocieteAerienneEntity societeAerienneEntity;
@OneToMany
@JoinColumn(name = "avion_id")
Collection <VolEntity> vols = new ArrayList<>();
}
4 changes: 4 additions & 0 deletions src/main/java/ma/yc/airafraik/entities/VolEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public class VolEntity {

private int nomberDePlaces ;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "avion_id")
private AvionEntity avion ;



@ManyToOne(fetch = FetchType.EAGER)
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ma/yc/airafraik/service/SearchVolsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public interface SearchVolsService {
public Collection<VolEntity> searchVols(String villeDepart, String villeArrivee, String dateDepart, String dateArrivee, String nombrePassagers);

VolEntity searchVolParId(String id);

Collection<VolEntity> consulterVols();
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public VolEntity searchVolParId(String id) {


}

@Override
public Collection<VolEntity> consulterVols() {
return this.volDao.consulterVols();
}
}
32 changes: 31 additions & 1 deletion src/main/java/ma/yc/airafraik/web/Admin/DashboardController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,58 @@
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import ma.yc.airafraik.dto.Account;
import ma.yc.airafraik.entities.VolEntity;
import ma.yc.airafraik.service.AccountService;
import ma.yc.airafraik.service.SearchVolsService;
import ma.yc.airafraik.service.impl.AccountAdminServiceImpl;
import ma.yc.airafraik.service.impl.SearchVolsServiceImpl;

import java.io.IOException;
import java.util.Collection;

@WebServlet(name = "DashboardController", value = "/admin-dashboard")
public class DashboardController extends HttpServlet {

private AccountService accountService ;
private boolean isAccountValid = true;
private String message;
private SearchVolsService searchVolsService;


@Override
public void init() throws ServletException {
this.accountService = new AccountAdminServiceImpl();
this.searchVolsService = new SearchVolsServiceImpl();
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// this.verifyAccount(req,resp);
req.setAttribute("message",message);
Collection<VolEntity> volEntities = this.searchVolsService.consulterVols();
req.setAttribute("vols",volEntities);
req.getRequestDispatcher("views/admin/dashboard.jsp").forward(req,resp);

}

private void verifyAccount(HttpServletRequest req, HttpServletResponse resp) {
// ma.yc.airafraik.dto.Account account = (ma.yc.airafraik.dto.Account) req.getSession().getAttribute("account");
// if(account != null){
// if(accountService.isAccountValid(account)){
// this.isAccountValid = true;
// }
// }
// if (isAccountValid){
// req.setAttribute("account",account);
// }else{
// try {
// resp.sendRedirect("login");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
}

@Override
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doHead(req, resp);
Expand Down
11 changes: 11 additions & 0 deletions src/main/webapp/static/css/admin/dashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.nav-bar-admin{
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
gap : 20px;
/*height: 60px;*/
/*background-color: #fdfcfc;*/
flex-wrap: wrap;
margin-top: 1rem !important;
}
Loading

0 comments on commit 242805b

Please sign in to comment.