fixing panel gui.
This commit is contained in:
parent
f25ca4a5d0
commit
e00783b1d6
@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
@ -151,37 +153,48 @@ public class PanelController {
|
|||||||
return cards;
|
return cards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<List<Card>> toPairs(List<Card> cards) {
|
||||||
|
List<List<Card>> l = IntStream.range(0, cards.size())
|
||||||
|
.filter(i -> i % 2 == 0 && i + 1 < cards.size())
|
||||||
|
.boxed()
|
||||||
|
.map(i -> List.of(cards.get(i), cards.get(i+1)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if( cards.size() % 2 == 1 ) { l.add(Collections.singletonList(cards.get(cards.size()-1))); }
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/panel")
|
@GetMapping("/panel")
|
||||||
public String panelPage(Model model, @RequestHeader("User-Agent") String uagent, @RequestHeader("Accept") String accepth, @RequestParam(value = "section", defaultValue = "diss") String section) {
|
public String panelPage(Model model, @RequestHeader("User-Agent") String uagent, @RequestHeader("Accept") String accepth, @RequestParam(value = "section", defaultValue = "diss") String section) {
|
||||||
model.addAttribute("is_mobile", new UAgentInfo(uagent, accepth).detectSmartphone());
|
boolean is_mobile = new UAgentInfo(uagent, accepth).detectSmartphone();
|
||||||
|
model.addAttribute("is_mobile", is_mobile);
|
||||||
model.addAttribute("section", section);
|
model.addAttribute("section", section);
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case "lugg":
|
case "lugg":
|
||||||
model.addAttribute( "cards", luggageToCards() );
|
model.addAttribute( "cards", is_mobile ? luggageToCards() : toPairs(luggageToCards()) );
|
||||||
break;
|
break;
|
||||||
case "heal":
|
case "heal":
|
||||||
model.addAttribute("cards", healToCards() );
|
model.addAttribute("cards", is_mobile ? healToCards() : toPairs(healToCards()) );
|
||||||
break;
|
break;
|
||||||
case "prof":
|
case "prof":
|
||||||
model.addAttribute("cards", workToCards() );
|
model.addAttribute("cards", is_mobile ? workToCards() : toPairs(workToCards()) );
|
||||||
break;
|
break;
|
||||||
case "hobb":
|
case "hobb":
|
||||||
model.addAttribute("cards", hobbyToCards() );
|
model.addAttribute("cards", is_mobile ? hobbyToCards() : toPairs(hobbyToCards()) );
|
||||||
break;
|
break;
|
||||||
case "agge":
|
case "agge":
|
||||||
model.addAttribute("cards", bioToCards() );
|
model.addAttribute("cards", is_mobile ? bioToCards() : toPairs(bioToCards()) );
|
||||||
break;
|
break;
|
||||||
case "diss":
|
case "diss":
|
||||||
model.addAttribute("cards", dissToCards() );
|
model.addAttribute("cards", is_mobile ? dissToCards() : toPairs(dissToCards()) );
|
||||||
break;
|
break;
|
||||||
case "stats":
|
case "stats":
|
||||||
// !
|
// !
|
||||||
break;
|
break;
|
||||||
case "actions":
|
case "actions":
|
||||||
model.addAttribute("cards", actionsToCards() );
|
model.addAttribute("cards", is_mobile ? actionsToCards() : toPairs(actionsToCards()) );
|
||||||
break;
|
break;
|
||||||
case "script_request":
|
case "script_request":
|
||||||
model.addAttribute("cards", requestsToCards() );
|
model.addAttribute("cards", is_mobile ? requestsToCards() : toPairs(requestsToCards()) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return "panel";
|
return "panel";
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
<th:block th:unless="${is_mobile}">
|
<th:block th:unless="${is_mobile}">
|
||||||
<div class="d-flex justify-content-start text-center">
|
<div class="container justify-content-start text-center">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="card mt-2">
|
<div class="card mt-2">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -113,27 +113,31 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<th:block th:each="cc: ${cards}">
|
<th:block th:each="cp: ${cards}">
|
||||||
<div class="col">
|
<div class="row">
|
||||||
<div class="card mt-2">
|
<th:block th:each="cc: ${cp}">
|
||||||
<div class="card-body">
|
<div class="col">
|
||||||
<h5 class="card-title" th:text="${cc.title}"></h5>
|
<div class="card mt-2">
|
||||||
<p class="card-text">
|
<div class="card-body">
|
||||||
<ul th:each="ll: ${cc.body}">
|
<h5 class="card-title" th:text="${cc.title}"></h5>
|
||||||
<li th:text="${ll}"></li>
|
<p class="card-text">
|
||||||
</ul>
|
<ul th:each="ll: ${cc.body}">
|
||||||
</p>
|
<li th:text="${ll}"></li>
|
||||||
<th:block th:unless="${section == 'script_request'}">
|
</ul>
|
||||||
<a th:unless="${section == 'actions'}" href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal_syn" onclick="show_synergies_modal(this)" class="btn btn-primary" th:text="#{eddittsynn}"></a>
|
</p>
|
||||||
<a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal" onclick="edit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></a>
|
<th:block th:unless="${section == 'script_request'}">
|
||||||
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
|
<a th:unless="${section == 'actions'}" href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal_syn" onclick="show_synergies_modal(this)" class="btn btn-primary" th:text="#{eddittsynn}"></a>
|
||||||
</th:block>
|
<a href="#" th:data-id="${cc.id}" data-bs-toggle="modal" data-bs-target="#modal" onclick="edit_entry(this)" class="btn btn-primary" th:text="#{edditbtn}"></a>
|
||||||
<th:block th:if="${section == 'script_request'}">
|
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
|
||||||
<a href="#" th:data-id="${cc.id}" onclick="accept_script_request(this)" class="btn btn-success" th:text="#{acceptbtnreq}"></a>
|
</th:block>
|
||||||
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
|
<th:block th:if="${section == 'script_request'}">
|
||||||
</th:block>
|
<a href="#" th:data-id="${cc.id}" onclick="accept_script_request(this)" class="btn btn-success" th:text="#{acceptbtnreq}"></a>
|
||||||
|
<a href="#" th:data-id="${cc.id}" onclick="remove_entry(this)" class="btn btn-danger" th:text="#{remombtn}"></a>
|
||||||
|
</th:block>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
</th:block>
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user