Skip to content
Snippets Groups Projects
Commit ff91fbc6 authored by John Watkins's avatar John Watkins
Browse files

Server now returns the correct info and an animated sidebar has been added in the admin page

parent 3560c9c8
No related branches found
No related tags found
2 merge requests!114LoggingService service class, new method to add a log to the "Logs" table when...,!93Thirty five
......@@ -91,4 +91,9 @@ public class Users {
)
private List<Tags> favouriteTags;
public String toString(){
return "User:" + this.getUserFirstName();
}
}
......@@ -23,10 +23,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
@Controller
public class AdminController {
......@@ -117,8 +115,44 @@ public class AdminController {
highestShopLevel = u.getAdminType().getAdminTypeId();
}
}
System.out.println(highestShopLevel);
//System.out.println(userShopLinked.hasShop(user.get().getUserId()));
//Get the shops paired with admin, sorted by category
Map<String,ArrayList<Map<Shops,Users>>> categorySortedShops = new HashMap<>();
//For each shop
for (Shops sh : shopsRepo.findAll()){
Map<Shops, Users> shopsUsersMap = new HashMap<>();
//Get the perms for that shop
List<UserPermissions> permList = userPermissionsRepo.findByShopID(sh.getShopId());
//For each perm
for(UserPermissions p : permList){
//If it is the shop creator then pair them with the shop
if(p.getAdminType().getAdminTypeId() == 2){
shopsUsersMap.put(sh, p.getUser());
}
}
//Set an empty list for the category if it doesn't exist
if(!categorySortedShops.containsKey(sh.getCategory())){
categorySortedShops.put(sh.getCategory().getCategoryName(),new ArrayList<>());
}
//Add the pair to the correct category list
ArrayList<Map<Shops,Users>> cat = categorySortedShops.get(sh.getCategory().getCategoryName());
if(shopsUsersMap.size() != 0){
cat.add(shopsUsersMap);
categorySortedShops.put(sh.getCategory().getCategoryName(), cat);
}
}
Map<String,ArrayList<Map<Shops,Users>>> filteredCategorySortedShops = new HashMap<>();
for(Map.Entry e : categorySortedShops.entrySet()){
ArrayList<Map<Shops,Users>> val = (ArrayList<Map<Shops, Users>>) e.getValue();
if(val.size() != 0){
filteredCategorySortedShops.put(e.getKey().toString(), val);
}
}
model.addAttribute("adminOfByCategory",filteredCategorySortedShops);
model.addAttribute("linkedShop", userShopLinked.hasShop(user.get().getUserId()));
model.addAttribute("highestShopLevel", highestShopLevel);
model.addAttribute("staffMembers", linkedUsers);
......@@ -130,8 +164,6 @@ public class AdminController {
List<Integer> shopActive = Collections.singletonList(shopActiveService.isShopActive(intShopId));
model.addAttribute("shopActive", shopActive);
//Get the stamp board for the chosen shop
StampBoards stampBoard = stampBoardsRepo.findById(shop.getStampBoard().getStampBoardId()).get();
model.addAttribute("stampBoard",stampBoard);
......
......@@ -13,13 +13,15 @@ html{
.sidebar{
height: 100%;
width: 250px;
width: 200px;
background-color: white;
display: flex;
justify-content: flex-start;
align-items: flex-start;
flex-direction: column;
z-index: 3;
transition: width 200ms, opacity 200ms;
pointer-events: all;
}
#open-sidebar-tab {
......@@ -127,10 +129,15 @@ html{
transform: scale(1.15) rotate(-45deg);
}
.sidebar.closed{
width: 0px;
opacity: 0;
pointer-events: none;
}
.sidebar .admin-tab{
height: 50px;
width: 250px;
width: 200px;
display: flex;
justify-content: flex-start;
align-items: center;
......
// noinspection DuplicatedCode
var isShopSelectOpen = {
"profile":false,
"shop-setup":true,
"shop-rewards":true
}
function toggle_tab(tab){
if(isShopSelectOpen[tab]){
document.getElementById("side_shop_select").classList.remove("closed");
}else{
document.getElementById("side_shop_select").classList.add("closed");
}
Array.prototype.forEach.call(
document.getElementsByClassName("admin-tab"),
function (el) {
......
......@@ -25,7 +25,7 @@
<div th:replace="fragments/nav.html :: nav"></div>
<div id="adminPage">
<div class="sidebar" th:if="${linkedShop}">
<div class="admin-tab active" onclick="toggle_tab('profile')" id="profile-tab">
<div class="admin-tab active" onclick="toggle_tab('profile');" id="profile-tab">
<div class="baseIcon">
<i class="fas fa-user fa-lg"></i>
</div>
......@@ -44,6 +44,9 @@
<p>Shop Rewards</p>
</div>
</div>
<div class="sidebar closed" id="side_shop_select">
test
</div>
<main th:if="${highestPerm > 1 || linkedShop}">
<section id="profile-section" class="admin-section active">
<div th:replace="fragments/user_settings.html :: settings_page"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment