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

Merge branch 'thirtyFive' into 'develop'

Thirty five

See merge request !93
parents a51942b0 7122c3b1
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,40 @@ 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<Shops>> categorySortedShops = new HashMap<>();
//For each shop
for (Shops sh : shopsRepo.findAll()){
//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 && user.get().getUserId() == p.getUser().getUserId()){
//Set an empty list for the category if it doesn't exist
if(!categorySortedShops.containsKey(sh.getCategory().getCategoryName())){
categorySortedShops.put(sh.getCategory().getCategoryName(),new ArrayList<>());
}
//Add the pair to the correct category list
ArrayList<Shops> cat = categorySortedShops.get(sh.getCategory().getCategoryName());
cat.add(sh);
categorySortedShops.put(sh.getCategory().getCategoryName(), cat);
}
}
}
Map<String,ArrayList<Shops>> filteredCategorySortedShops = new HashMap<>();
for(Map.Entry e : categorySortedShops.entrySet()){
ArrayList<Shops> val = (ArrayList<Shops>) 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 +160,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,16 @@ 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 100ms;
pointer-events: all;
overflow-x: hidden;
}
#open-sidebar-tab {
......@@ -127,10 +130,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;
......@@ -143,6 +151,45 @@ html{
color: #628ed6;
}
.sidebar .shop-tab{
height: 49px;
width: 200px;
display: flex;
padding: 0 10px;
justify-content: space-between;
align-items: center;
cursor: pointer;
color: #3273dc;
}
.sidebar .shop-tab:hover{
color: #628ed6;
}
.sidebar .shop-tab.shop-name{
height: 50px;
color: #4a4a4a;
}
.sidebar .shop-tab.shop-name:hover{
opacity: 0.8;
}
.shop-tab-container{
border-bottom: 1px solid lightgray;
max-height: 50px;
overflow-y: hidden;
transition: max-height 300ms;
}
.shop-tab-container.open{
max-height: 500px;
}
.shop-tab-container.open .shop-tab .baseIcon .fa-caret-down{
transform: rotate(180deg);
}
.sidebar .active{
background-color: #f9f9f9;
}
......
src/main/resources/static/imgs/uploaded/45f41b47_75c1_4c81_b743_cd649a58f69c.jpg

6.35 KiB

// 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) {
......@@ -171,6 +182,7 @@ function saveStampboardChanges(shopId){
var formData = new FormData();
formData.append("file", icon[0]);
xhr.onload = function() {
console.log(xhr.responseText)
if (xhr.readyState === 4 && xhr.status === 200) {
filename = xhr.responseText;
var xhttp = new XMLHttpRequest();
......
......@@ -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,24 @@
<p>Shop Rewards</p>
</div>
</div>
<div class="sidebar closed" id="side_shop_select">
<th:block th:each="category: ${adminOfByCategory.entrySet()}">
<div class="shop-tab-container">
<div class="shop-tab shop-category" onclick="this.parentElement.classList.toggle('open')">
<p th:text="${category.getKey()}"></p>
<div class="baseIcon">
<i class="fas fa-caret-down fa-lg"></i>
</div>
</div>
<th:block th:each="sh: ${category.getValue()}">
<div th:class="'shop-tab shop-name' + ${shop.getShopId() == sh.getShopId()?' active':''}"
th:onclick="'window.location.href=\'/settings?shopId='+${sh.getShopId()} + '&tab=shop-setup\''">
<p th:text="'- ' + ${sh.getShopName()}"></p>
</div>
</th:block>
</div>
</th:block>
</div>
<main th:if="${highestPerm > 1 || linkedShop}">
<section id="profile-section" class="admin-section active">
<div th:replace="fragments/user_settings.html :: settings_page"/>
......
......@@ -36,7 +36,7 @@
stamps=${shopMap.get('UserStampBoard').userStampPosition},
next_reward=${@claimableRewards.nextReward(shopMap.get('UserStampBoard'))},
reward_amount_obtained=${@claimableRewards.totalClaimableRewards(shopMap.get('UserStampBoard'))},
isFavourite=false,
isFavourite=${@checkFavourite.isFavourite(shopMap.get('Shop').shopId,loggedInUser.userId)},
total_reward_amount=${shopMap.get('Shop').getStampBoard.getRewards.size},
img_path=${shopMap.get('Shop').shopImage},
shopId=${shopMap.get('Shop').shopId}"></div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment