Starting to implement announcements into dashboard.

This commit is contained in:
NovaFox161
2018-01-15 21:38:41 -06:00
parent e58c3544df
commit 3c6232f3af
4 changed files with 115 additions and 5 deletions
@@ -1,6 +1,8 @@
package com.cloudcraftgaming.discal.api.network.discord;
import com.cloudcraftgaming.discal.api.enums.GoodTimezone;
import com.cloudcraftgaming.discal.api.enums.announcement.AnnouncementType;
import com.cloudcraftgaming.discal.api.enums.event.EventColor;
import com.cloudcraftgaming.discal.api.object.BotSettings;
import com.cloudcraftgaming.discal.api.utils.ExceptionHandler;
import com.cloudcraftgaming.discal.api.utils.GuildUtils;
@@ -53,6 +55,8 @@ public class DiscordLoginHandler {
m.put("guilds", GuildUtils.getGuilds(userInfo.getString("id")));
m.put("goodTz", GoodTimezone.values());
m.put("anTypes", AnnouncementType.values());
m.put("eventColors", EventColor.values());
DiscordAccountHandler.getHandler().addAccount(m, request.session().id());
@@ -3,6 +3,7 @@ package com.cloudcraftgaming.discal.api.object.web;
import com.cloudcraftgaming.discal.Main;
import com.cloudcraftgaming.discal.api.database.DatabaseManager;
import com.cloudcraftgaming.discal.api.object.GuildSettings;
import com.cloudcraftgaming.discal.api.object.announcement.Announcement;
import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IGuild;
import sx.blah.discord.handle.obj.IRole;
@@ -31,6 +32,7 @@ public class WebGuild {
//Lists and stuffs
private List<WebRole> roles = new ArrayList<>();
private List<WebChannel> channels = new ArrayList<>();
private List<Announcement> announcements = new ArrayList<>();
private WebCalendar calendar;
@@ -63,6 +65,10 @@ public class WebGuild {
return channels;
}
public List<Announcement> getAnnouncements() {
return announcements;
}
public WebCalendar getCalendar() {
return calendar;
}
@@ -131,6 +137,7 @@ public class WebGuild {
for (IChannel c : g.getChannels()) {
channels.add(new WebChannel().fromChannel(c, settings));
}
announcements.addAll(DatabaseManager.getManager().getAnnouncements(g.getLongID()));
calendar = new WebCalendar().fromCalendar(DatabaseManager.getManager().getMainCalendar(Long.valueOf(id)), settings);
@@ -15,9 +15,10 @@
<!--Locally hosted-->
<link href="/styles/global.css" rel="stylesheet">
<script src="/scripts/dashboard/main.js"></script>
<script src="/scripts/dashboard/announcement.js"></script>
</head>
<body>
<body onload="handleVisibility()">
<div class="top-nav">
<h1>DISCAL</h1>
<a href="/">Home</a>
@@ -302,10 +303,90 @@
</form>
<br>
<br>
<p>
It's a work in progress. Soon you will be able to create/edit/manage/delete
announcements from here!!
</p>
<hr>
<h6>Announcement List</h6>
<!--TODO: Add pagination for larger guilds....-->
<th:block th:each="ann : ${selected.announcements}">
<!--TODO: Implement permission handling-->
<div>
<p style="float: left" th:text="${ann.announcementId}"></p>
<a th:href="'/account/dashboard/edit/announcement?id=' + ${ann.announcementId}">
<button>Edit</button>
</a>
<a th:href="'/account/dashboard/delete/announcement?id=' + ${ann.announcementId}">
<button class="danger">Delete</button>
</a>
</div>
<br>
</th:block>
<br>
<br>
<hr>
<h6>Create An Announcement Below!</h6>
<!--TODO: Actually make announcement create form-->
<p>THIS IS NOT ACTIVE! ITS JUST TO TEST STYLING!</p>
<div id="create-announcement">
<form style="text-align: left;" method="post"
enctype="application/x-www-form-urlencoded"
action="/account/dashboard/create/announcement" name="announcement-create">
<label>Channel
<br>
<select name="channel">
<th:block th:each="chan : ${selected.channels}">
<option th:value="${chan.id}" th:text="${chan.name}"></option>
</th:block>
</select>
</label>
<br>
<br>
<label>Type
<br>
<select name="type" id="create-ann-type" onchange="handleVisibility()">
<th:block th:each="ty : ${anTypes}">
<option th:value="${ty.name}" th:text="${ty.name}"></option>
</th:block>
</select>
</label>
<br>
<br>
<label id="create-ann-event">Event ID
<br>
<input name="event-id" type="text">
</label>
<br>
<br>
<label id="create-ann-color">Color
<br>
<select name="color">
<th:block th:each="c : ${eventColors}">
<option th:value="${c.id}" th:text="${c.name}"></option>
</th:block>
</select>
</label>
<br>
<br>
<label>Minutes Before
<br>
<input name="minutes" type="number" value="0">
</label>
<br>
<br>
<label>Hours Before
<br>
<input name="hours" type="number" value="0">
</label>
<br>
<br>
<label>Info (Leave as "None" if you don't want it to display).
<br>
<input name="info" type="text" value="None">
</label>
<br>
<br>
<input type="submit" class="submit" value="Create Announcement!"
th:disabled="${selected.discalRole} == false">
</form>
</div>
</div>
<!--RSVP Settings-->
<div th:if="${settings} == rsvp">
@@ -0,0 +1,18 @@
function handleVisibility() {
var e = document.getElementById("create-ann-type");
var value = e.options[e.selectedIndex].value;
if (value === "UNIVERSAL") {
//HIde color and event ID
document.getElementById("create-ann-event").style.visibility = "hidden";
document.getElementById("create-ann-color").style.visibility = "hidden";
} else if (value === "SPECIFIC" || value === "RECUR") {
//Hide color, show event ID.
document.getElementById("create-ann-event").style.visibility = "visible";
document.getElementById("create-ann-color").style.visibility = "hidden";
} else if (value === "COLOR") {
//Hide event ID, show color.
document.getElementById("create-ann-event").style.visibility = "hidden";
document.getElementById("create-ann-color").style.visibility = "visible";
}
}