Add guild icon on navbar
This commit is contained in:
parent
e9b42f6938
commit
9fcac88f95
@ -4,11 +4,13 @@ public class GuildInfo {
|
||||
public String name;
|
||||
public String id;
|
||||
public boolean isAdmin;
|
||||
public String imageUrl;
|
||||
|
||||
public GuildInfo(String name, String id, boolean isAdmin) {
|
||||
public GuildInfo(String name, String id, boolean isAdmin, String imageUrl) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.isAdmin = isAdmin;
|
||||
this.imageUrl = imageUrl;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class UserManagerAPIController {
|
||||
if(user != null){
|
||||
for (Guild guild : user.getMutualGuilds()){
|
||||
|
||||
temp.add(new GuildInfo(guild.getName(), guild.getId(), guild.getMember(user).hasPermission(Permission.ADMINISTRATOR)));
|
||||
temp.add(new GuildInfo(guild.getName(), guild.getId(), guild.getMember(user).hasPermission(Permission.ADMINISTRATOR), guild.getIconUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,10 +180,16 @@ public class GeneralWebView {
|
||||
|
||||
private Model addGuildAndRedirect(Model model, String guildId){
|
||||
Guild guild = MainBot.jda.getGuildById(guildId);
|
||||
if(guild != null)
|
||||
if(guild != null){
|
||||
model.addAttribute("guild_name", guild.getName());
|
||||
else
|
||||
model.addAttribute("guild_icon", guild.getIconUrl() == null ? "https://discordapp.com/assets/dd4dbc0016779df1378e7812eabaa04d.png": guild.getIconUrl());
|
||||
}
|
||||
|
||||
else{
|
||||
model.addAttribute("guild_name", "");
|
||||
model.addAttribute("guild_icon", "");
|
||||
}
|
||||
|
||||
model.addAttribute("redirect_url", System.getenv("OAUTH_URL"));
|
||||
return model;
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ function navListeners() {
|
||||
|
||||
$('#btn_ok_guild').click(function () {
|
||||
guild = $('input[name=guildRadio]:checked').val();
|
||||
let url = $('input[name=guildRadio]:checked').attr("data-icon");
|
||||
Cookies.set('guild', guild, { expires: 31 });
|
||||
window.location.reload(true);
|
||||
});
|
||||
@ -113,6 +114,7 @@ function getGuild(){
|
||||
var content = template.html();
|
||||
content = content.replace("@name", element.name);
|
||||
content = content.replace(/@id/g, element.id);
|
||||
content = content.replace(/@url/g, element.imageUrl == null ? "https://discordapp.com/assets/dd4dbc0016779df1378e7812eabaa04d.png" : element.imageUrl);
|
||||
template.html(content);
|
||||
|
||||
$('#guild_form').append(template);
|
||||
|
@ -20,7 +20,7 @@
|
||||
<a href="/" class="brand-logo hide-on-med-and-up show-on-small" style="white-space: nowrap">Claptrap</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>
|
||||
<a class="nav-change-guild truncate waves-effect waves-light btn-flat grey-text text-darken-1" th:inline="text" style="margin-top: 2px;margin-right: 0px;">[[${guild_name}]]<img th:src="${guild_icon}" id="guildLogo" class="brand-logo left circle" style="max-height: 100%; margin-right: 10px"/></a>
|
||||
</li>
|
||||
<li class="" th:classappend="(${page} == 'home')? 'active' : ''">
|
||||
<a class="waves-effect waves-light" href="/">Home</a>
|
||||
@ -149,8 +149,8 @@
|
||||
|
||||
<p id="radioTemplateGuild" class="" style="visibility: hidden; display: none ">
|
||||
<label>
|
||||
<input name="guildRadio" class="with-gap" type="radio" value="@id" id="@id"/>
|
||||
<span>@name</span>
|
||||
<input name="guildRadio" class="with-gap" type="radio" value="@id" id="@id" data-icon="@url"/>
|
||||
<span><img src="@url" class="circle left" style="max-height: 100%; margin-right: 6px"/> @name</span>
|
||||
</label>
|
||||
</p>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user