Improve setting page

This commit is contained in:
Sebastien 2019-06-16 18:34:40 +02:00
parent fd90df0559
commit b05401777c
2 changed files with 71 additions and 60 deletions

View File

@ -137,7 +137,6 @@ public class GeneralWebView {
addGuildAndRedirect(model, token, guildId, user.getMutualGuilds());
Guild guild = MainBot.jda.getGuildById(guildId);
model.addAttribute("settings", SettingsUtils.getInstance().extractSettings(guild));
model.addAttribute("isAdmin", SettingsUtils.getInstance().checkPermission(token, guildId));
} catch (UnknownTokenException e) {
throw new ForbiddenException();
}

View File

@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
<title>Claptrap Bot</title>
<title>Bot Settings - Claptrap Bot</title>
<link rel="icon"
type="image/x-icon"
href="/favicon.png"/>
@ -31,72 +31,84 @@
<main>
<div class="section no-pad-bot main" id="index-banner">
<h2 class="center" th:text="${guild_name}"></h2>
<div th:each="setting : ${settings}">
<div class="section row">
<div class="col l6 offset-l3 m10 offset-m1 s10 offset-s1">
<h5 th:text="${setting.name}" style="font-weight: bold"></h5>
<div class="switch" th:if="${setting.type.toString() == 'BOOL'}">
<label>
Off
<input class="collect-switch" type="checkbox" th:id="${setting.id}"
th:checked="${setting.current}"/>
<span class="lever"></span>
On
</label>
</div>
<div class="section no-pad-bot main container" id="index-banner">
<div th:id="${setting.id}" class="input-field col l12 m12 s12 collect-select"
th:if="${setting.type.toString() == 'LIST'}">
<select>
<option disabled="disabled" th:selected="${setting.current} == ' '" value="">Choose your
option
</option>
<option th:each="val : ${setting.values}" th:value="${val.id}"
th:text="${#strings.capitalize(val.name)}"
th:selected="${setting.current} == ${val.id}"></option>
</select>
</div>
<div th:id="${setting.id}" class="input-field col l12 m12 s12 collect-select-multiple"
th:if="${setting.type.toString() == 'SELECT_LIST'}">
<select multiple="multiple">
<option disabled="disabled" value="">Choose your
option
</option>
<option th:each="val : ${setting.values}" th:value="${val.id}"
th:text="${#strings.capitalize(val.name)}"
th:selected="${val.selected} == true"></option>
</select>
</div>
<div class="input-field col l12 m12 s12 collect" th:if="${setting.type.toString() == 'STRING'}">
<input th:id="${setting.id}" placeholder="Use @name variable" th:value="${setting.current}"
id="first_name" type="text" class="validate collect-text"/>
</div>
<div class="row">
<div class="card-panel col s12 m12 l10 offset-l1" style="border-radius: 10px">
<div class="row">
<h2 class="center col s12" style="margin-bottom: 0">Bot Settings</h2>
</div>
</div>
<div class="row">
<div class="divider col l6 offset-l3"></div>
<div class="row">
<div class="divider col s12"></div>
<div class="divider col s12"></div>
<h4 class="center col s12" th:text="${guild_name}"></h4>
<div class="divider col s12"></div>
<div class="divider col s12"></div>
</div>
</div>
<div th:each="setting : ${settings}">
<div class="row">
<div class="col l10 offset-l1 m10 offset-m1 s10 offset-s1">
<h5 th:text="${setting.name}" style="font-weight: bold"></h5>
<div class="switch" th:if="${setting.type.toString() == 'BOOL'}">
<label>
Off
<input class="collect-switch" type="checkbox" th:id="${setting.id}"
th:checked="${setting.current}"/>
<span class="lever"></span>
On
</label>
</div>
<div th:id="${setting.id}" class="input-field col l12 m12 s12 collect-select"
th:if="${setting.type.toString() == 'LIST'}">
<select>
<option disabled="disabled" th:selected="${setting.current} == ' '" value="">Choose your option
</option>
<option th:each="val : ${setting.values}" th:value="${val.id}"
th:text="${#strings.capitalize(val.name)}"
th:selected="${setting.current} == ${val.id}"></option>
</select>
</div>
<div th:id="${setting.id}" class="input-field col l12 m12 s12 collect-select-multiple"
th:if="${setting.type.toString() == 'SELECT_LIST'}">
<select multiple="multiple">
<option disabled="disabled" value="">Choose your option
</option>
<option th:each="val : ${setting.values}" th:value="${val.id}"
th:text="${#strings.capitalize(val.name)}"
th:selected="${val.selected} == true"></option>
</select>
</div>
</div>
<div class="row">
<div class="col s12 center">
<a id="sendBtn" class="waves-effect waves-light btn green">Save<i
class="material-icons left">save</i></a>
<div class="input-field col l12 m12 s12 collect" th:if="${setting.type.toString() == 'STRING'}">
<input th:id="${setting.id}" placeholder="Use @name variable" th:value="${setting.current}"
id="first_name" type="text" class="validate collect-text"/>
</div>
</div>
</div>
<div class="row">
<div class="divider col s12"></div>
</div>
</div>
<div class="row">
<div class="col s12 center">
<a id="sendBtn" class="waves-effect waves-light btn green">Save<i
class="material-icons left">save</i></a>
</div>
</div>
</div>
</div>
</div>
<div id="modal_loading" class="modal valign-wrapper">