Skip to content

Commit

Permalink
#EHA-33 GET functions for desktop is arranged and number of veterinar…
Browse files Browse the repository at this point in the history
…ians, pet owners and pets is added to UI.
  • Loading branch information
beyzaaydeniz committed Jan 3, 2024
1 parent d7680f3 commit d728e26
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.production.ehayvanbackendapi.Controllers;
import com.production.ehayvanbackendapi.Services.PetOwnerService;
import com.production.ehayvanbackendapi.Services.PetService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -17,8 +19,14 @@
public class VeterinarianController {
private final VeterinarianService veterinarianService;

public VeterinarianController(VeterinarianService veterinarianService) {
private final PetService petService;
private final PetOwnerService petOwnerService;


public VeterinarianController(VeterinarianService veterinarianService, PetService petService, PetOwnerService petOwnerService) {
this.veterinarianService = veterinarianService;
this.petService = petService;
this.petOwnerService = petOwnerService;
}

@GetMapping("/count")
Expand Down Expand Up @@ -115,6 +123,12 @@ public String desktop(Model model) {
List<VeterinarianDTO> veterinarians = veterinarianService.getAllVeterinarians();
model.addAttribute("veterinarians", veterinarians);
model.addAttribute("viewType", "default");
Integer vetCount = veterinarianService.getAllVetsCount();
Integer petCount = petService.getAllPetsCount();
Integer petOwnerCount = petOwnerService.getAllPetOwnersCount();
model.addAttribute("vetCount", vetCount);
model.addAttribute("petCount", petCount);
model.addAttribute("petOwnerCount", petOwnerCount);
return "desktop";
}

Expand All @@ -129,6 +143,13 @@ public String desktopFormSubmit(@RequestParam String clinicName, RedirectAttribu
public String desktop(@PathVariable String name, Model model) {
List<VeterinarianDTO> filteredVeterinarians = veterinarianService.getVeterinariansByClinic(name);

Integer vetCount = veterinarianService.getAllVetsCount();
Integer petCount = petService.getAllPetsCount();
Integer petOwnerCount = petOwnerService.getAllPetOwnersCount();
model.addAttribute("vetCount", vetCount);
model.addAttribute("petCount", petCount);
model.addAttribute("petOwnerCount", petOwnerCount);

if (filteredVeterinarians == null || filteredVeterinarians.isEmpty()) {
// Handle the case where no veterinarians are found
model.addAttribute("viewType", "noResults");
Expand Down
23 changes: 16 additions & 7 deletions src/main/resources/templates/desktop.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,28 @@
N
</div>
</div>

<div class="LineDivider" style="align-self: stretch; margin-top: 2px; height: 0px; border: 1.50px #606873 solid"></div>





<div class="LineDivider" style="align-self: stretch; margin-top: 2px; height: 0px; border: 1.50px #606873 solid"></div>
<div class="Text" style="color: white; font-size: 20px; font-family: RocknRoll One; font-weight: 400; margin-top: 150px" >
<p>Number of Veterinarian: <span th:text="${vetCount}"></span></p>
<p>Number of Pet Owner: <span th:text="${petOwnerCount}"></span></p>
<p>Number of Pet: <span th:text="${petCount}"></span></p>
</div>
<div class="LogoFrame" style="align-self: stretch; height: 100px; padding-top: 24px; padding-bottom: 24px"></div>
<div class="Content" style="align-self: stretch; flex: 1 1 0; flex-direction: column; justify-content: flex-start; align-items: center; gap: 36px; display: flex">
<div class="Frame280113" style="width: 220px; flex: 1 1 0; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 42px; display: flex">
<div class="SectionContainer" style="height: 96px"></div>
</div>
<div class="AvatarText" style="align-self: stretch; padding-top: 12px; padding-bottom: 12px; padding-left: 12px; padding-right: 16px; background: #606873; border-radius: 14px; border: 1px #606873 solid; justify-content: flex-start; align-items: center; gap: 12px; display: inline-flex">
<div class="Text" style="flex: 1 1 0; flex-direction: column; justify-content: flex-start; align-items: flex-start; display: inline-flex">
<div class="Hello" style="align-self: stretch; color: #ECEFF2; font-size: 14px; font-weight: 400; line-height: 22px; word-wrap: break-word">Hello</div>
<div class="Esther" style="align-self: stretch; color: white; font-size: 18px; font-weight: 600; line-height: 26px; word-wrap: break-word">Esther</div>
</div>
<div class="Icon" style="width: 20px; height: 20px; position: relative; overflow: hidden;">
<div class="Text" style="flex: 1 1 0; flex-direction: column; justify-content: flex-start; align-items: flex-start; display: inline-flex">
<div class="Hello!" style="align-self: stretch; color: #ECEFF2; font-family: 'RocknRoll One'; font-size: 20px; font-weight: 400; line-height: 22px; word-wrap: break-word">Hello!</div>
</div>

<div class="Icon" style="width: 20px; height: 20px; position: relative; overflow: hidden;">
<img th:src="@{/images/logout.png}" alt="Logout Icon" style="width: 100%; height: 100%; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);">
</div>
</div>
Expand Down

0 comments on commit d728e26

Please sign in to comment.