Add Guild name on navbar

This commit is contained in:
Sebastien 2018-05-14 11:57:05 +02:00
parent 0d6e32bded
commit 7ae7ae9bf6
8 changed files with 41 additions and 10 deletions

View File

@ -32,11 +32,16 @@ import java.util.List;
@RequestMapping("/api/music/")
public class MusicWebAPIController {
Logger logger = LogManager.getLogger();
@Autowired
private final
UserRepository userRepository;
UserUtils userUtils = UserUtils.getInstance();
@Autowired
public MusicWebAPIController(UserRepository userRepository) {
this.userRepository = userRepository;
}
@RequestMapping("/currentMusicInfo")
public ResponseEntity<CurrentMusicData> getCurrentM(@RequestParam(value = "guild") String guildId){

View File

@ -4,11 +4,15 @@ import net.Broken.DB.Entity.PlaylistEntity;
import net.Broken.DB.Entity.TrackEntity;
import net.Broken.DB.Entity.UserEntity;
import net.Broken.DB.Repository.UserRepository;
import net.Broken.MainBot;
import net.Broken.RestApi.Commands.Play;
import net.dv8tion.jda.core.entities.Guild;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.ArrayList;
import java.util.List;
@ -21,7 +25,12 @@ public class GeneralWebView {
@RequestMapping("/")
public String music(Model model){
public String music(Model model, @CookieValue(value = "guild", defaultValue = "1") String guildId){
Guild guild = MainBot.jda.getGuildById(guildId);
if(guild != null)
model.addAttribute("guild_name", guild.getName());
else
model.addAttribute("guild_name", "");
return CheckPage.getPageIfReady("index");
}

View File

@ -1,7 +1,10 @@
package net.Broken.webView;
import net.Broken.MainBot;
import net.dv8tion.jda.core.entities.Guild;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
/**
@ -10,7 +13,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class MusicWebView {
@RequestMapping("/music")
public String music(Model model){
public String music(Model model, @CookieValue(value = "guild", defaultValue = "1") String guildId){
Guild guild = MainBot.jda.getGuildById(guildId);
if(guild != null)
model.addAttribute("guild_name", guild.getName());
else
model.addAttribute("guild_name", "");
return CheckPage.getPageIfReady("music");
}
}

View File

@ -79,7 +79,9 @@ function disconnected() {
console.log("Disconnected");
nav_bar_account_link.html(disconnected_link);
var modalConnection = $('#modal_connection');
modalConnection.modal();
modalConnection.modal({
dismissible: false // Modal can be dismissed by clicking outside of the modal
});
if (typeof needLogin !== 'undefined'){
modalConnection.modal('open');
}

View File

@ -4,24 +4,30 @@
<head>
<meta charset="UTF-8"/>
</head>
<body>
<!--__________________________________________________________-->
<!-- NAV BAR -->
<!-- AND -->
<!-- LOGIN -->
<!--__________________________________________________________-->
<div th:fragment="header (page)">
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<div th:fragment="header (page, guild_name)">
<nav class="blue-grey darken-4 z-depth-3" role="navigation" >
<div class="nav-wrapper container">
<a id="logo-container" href="/" class="brand-logo">Claptrap Bot</a>
<ul class="right hide-on-med-and-down">
<li>
<a class="nav-change-guild truncate waves-effect waves-light btn-flat grey-text text-darken-1" th:text="${guild_name}" style="margin-top: 2px;margin-right: 0px;"></a>
</li>
<li class="" th:classappend="(${page} == 'home')? 'active' : ''">
<a class="waves-effect waves-light" href="/">Home</a>
</li>
<li class="" th:classappend="(${page} == 'music')? 'active' : ''">
<li class="disable" th:classappend="(${page} == 'music')? 'active' : ''">
<a class="waves-effect waves-light" href="/music">Music Control</a>
</li>
<li id="nav-bar-account">
<a class="dropdown-account dropdown-trigger" data-target="dropdown_connected"><i class="material-icons">account_box</i></a>
</li>

View File

@ -16,7 +16,7 @@
<body class="blue-grey lighten-5" >
<div th:replace="header :: header ('home')">...</div>
<div th:replace="header :: header ('home',${guild_name})">...</div>
<div class="section no-pad-bot main" id="index-banner">
<div class="center center-align">

View File

@ -16,7 +16,7 @@
<body class="blue-grey lighten-5" >
<div th:replace="header :: header ('music')">...</div>
<div th:replace="header :: header ('music',${guild_name})">...</div>
<div class="section no-pad-bot main" id="index-banner">
<div class="row">

View File

@ -14,7 +14,7 @@
<body class="blue-grey lighten-5" >
<div th:replace="header :: header ('')">...</div>
<div th:replace="header :: header ('','')">...</div>