Skip to content

Commit

Permalink
Merge pull request #162 from Ree6-Applications/dev
Browse files Browse the repository at this point in the history
Developer Branch Merge
  • Loading branch information
DxsSucuk authored Jun 28, 2023
2 parents 7d65a8f + 148a646 commit 1a04f50
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>de.presti.ree6</groupId>
<artifactId>Webinterface-Backend</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>
<name>Webinterface-Backend</name>
<description>The Backend for the Webinterface</description>

Expand Down Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>de.ree6</groupId>
<artifactId>Ree6-SQL</artifactId>
<version>2.0.4</version>
<version>7de8b7b96f</version>
</dependency>

<!-- Discord -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public GenericResponse removeChatAutoRole(@RequestHeader(name = "X-Session-Authe
@PostMapping(value = "/{guildId}/chatrole/add", produces = MediaType.APPLICATION_JSON_VALUE)
public GenericResponse addChatAutoRole(@RequestHeader(name = "X-Session-Authenticator") String sessionIdentifier, @PathVariable(name = "guildId") String guildId, @RequestBody LevelAutoRoleRequest levelAutoRoleRequest) {
try {
guildService.addChatAutoRole(sessionIdentifier, guildId, levelAutoRoleRequest.roleId(), levelAutoRoleRequest.level());
guildService.addChatAutoRole(sessionIdentifier, guildId, levelAutoRoleRequest.role(), levelAutoRoleRequest.level());
return new GenericResponse(true, "Chat Auto-role added!");
} catch (Exception e) {
return new GenericResponse(false, e.getMessage());
Expand Down Expand Up @@ -283,7 +283,7 @@ public GenericResponse removeVoiceAutoRole(@RequestHeader(name = "X-Session-Auth
@PostMapping(value = "/{guildId}/voicerole/add", produces = MediaType.APPLICATION_JSON_VALUE)
public GenericResponse addVoiceAutoRole(@RequestHeader(name = "X-Session-Authenticator") String sessionIdentifier, @PathVariable(name = "guildId") String guildId, @RequestBody LevelAutoRoleRequest levelAutoRoleRequest) {
try {
guildService.addVoiceAutoRole(sessionIdentifier, guildId, levelAutoRoleRequest.roleId(), levelAutoRoleRequest.level());
guildService.addVoiceAutoRole(sessionIdentifier, guildId, levelAutoRoleRequest.role(), levelAutoRoleRequest.level());
return new GenericResponse(true, "Voice Auto-role added!");
} catch (Exception e) {
return new GenericResponse(false, e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public List<RoleLevelContainer> getChatAutoRoles(String sessionIdentifier, Strin
}

public void addChatAutoRole(String sessionIdentifier, String guildId, String roleId, long level) throws IllegalAccessException {
GuildContainer guildContainer = sessionService.retrieveGuild(sessionIdentifier, guildId, false, false);
GuildContainer guildContainer = sessionService.retrieveGuild(sessionIdentifier, guildId, false, true);

if (guildContainer.getRoleById(roleId) == null)
throw new IllegalAccessException("Role not found");
Expand Down Expand Up @@ -845,7 +845,7 @@ public List<MessageReactionRoleContainer> retrieveReactionRoles(String sessionId
GuildContainer guildContainer = sessionService.retrieveGuild(sessionIdentifier, guildId, true, true);

List<ReactionRole> roles = SQLSession.getSqlConnector().getSqlWorker().getEntityList(new ReactionRole(),
"SELECT * FROM ReactionRole WHERE guild = :gid",
"SELECT * FROM ReactionRole WHERE gid = :gid",
Map.of("gid", guildId));

Map<Long, List<ReactionRole>> map = roles.stream().collect(Collectors.groupingBy(ReactionRole::getMessageId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Request for the Level Auto Role.
* @param level Level of the Auto Role.
* @param roleId Role ID of the Auto Role.
* @param role Role ID of the Auto Role.
*/
public record LevelAutoRoleRequest(long level, String roleId) {
public record LevelAutoRoleRequest(long level, String role) {
}
4 changes: 2 additions & 2 deletions Frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-netlify": "^2.0.7",
"@sveltejs/kit": "^1.5.0",
"@sveltejs/kit": "^1.20.5",
"svelte": "^4.0.0",
"svelte-check": "^3.0.1",
"svelte-check": "^3.4.4",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.2.0"
Expand Down
4 changes: 2 additions & 2 deletions Frontend/src/lib/components/data_popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export function model2JSON(model: DataType<any>[]): string {
model.forEach((data: DataType<any>) => {

if(data.type == "string" || data.type == "int" || data.type == "selector") {
json += `"${data.jsonName}": "${data.value}",`;
json += `"${data.jsonName}":"${data.value}",`;
} else {
json += `"${data.jsonName}": ${data.value == null ? null : '"' + data.value.id + '"'},`;
json += `"${data.jsonName}":${data.value == null ? null : '"' + data.value.id + '"'},`;
}
});
json = json.slice(0, -1);
Expand Down
50 changes: 50 additions & 0 deletions Frontend/src/lib/components/settings/booleanSelector.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script lang="ts">
import LoadingIndicator from "../loadingIndicator.svelte";
import { setting, updateSetting } from "$lib/scripts/settings";
import { currentServer } from "$lib/scripts/servers";
export let title: string;
export let icon: string;
export let description: string;
export let settingName: string;
let current = setting(settingName);
let store = current.value;
current.value.subscribe((value) => {
console.log(value)
})
</script>

<div class="box default-margin">
<div class="box-title">
<div class="content">
<div class="title">
<span class="material-icons icon-primary icon-small">{icon}</span>
<h1 class="text-medium">{title}</h1>
</div>
<p class="text-bg">{description}</p>
</div>

{#if $store == ":loading"}
<div class="loading">
<LoadingIndicator size="45" />
</div>
{:else}
<div class="button-bar">

<div on:click={() => {
updateSetting(settingName, $currentServer.id + "", $store == "true" ? "false" : "true")
}} class="button">
<span class="material-icons icon-small icon-primary">{$store == "true" ? "close" : "check"}</span>
<p>{$store == "true" ? "Disable" : "Enable"}</p>
</div>
</div>
{/if}
</div>
</div>

<style lang="scss">
@import '$lib/styles/box.scss';
</style>
9 changes: 6 additions & 3 deletions Frontend/src/lib/components/settings/massDataSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
export let endpoint: string;
export let description: string;
export let deleteField: (json: any) => string; // Function used to read value for deleting object
export let deleteField: (json: any) => string = (json) => ""; // Function used to read value for deleting object
export let deleteJson: (json: any) => any = (json) => {}; // Function used to create json for deleting object
export let models: Model[] = [];
let currentModel = 0;
Expand Down Expand Up @@ -167,9 +168,11 @@ close={async (b) => {

loading = true;

const json = await post_js(endpoint + "/remove", JSON.stringify({
const requestJson = deleteField(object.object) != "" ? JSON.stringify({
"value": deleteField(object.object)
}))
}) : JSON.stringify(deleteJson(object.object));

const json = await post_js(endpoint + "/remove", requestJson)

if(!json.success) {
setTimeout(() => {
Expand Down
88 changes: 88 additions & 0 deletions Frontend/src/routes/(dashboard)/dash/[serverId]/news/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<script>
import { page } from "$app/stores";
import BooleanSelector from "$lib/components/settings/booleanSelector.svelte";
import MassDataSelector from "$lib/components/settings/massDataSelector.svelte";
import { currentServer } from "$lib/scripts/servers";
</script>

<svelte:head>
<title>Levels - { $currentServer.name }</title>
</svelte:head>

<h1 class="headline">News</h1>

<div class="default-margin"></div>

<BooleanSelector icon="newspaper" title="Publish news messages" description="Let Ree6 publish your news messages after you sent them!" settingName="configuration_autopublish" />

<div class="default-margin"></div>

<BooleanSelector icon="sync" title="Ree6 announcements" description="Receive announcements published by us." settingName="configuration_news" />

<h1 class="headline">Rewards</h1>

<MassDataSelector icon="mic" title="Voice level rewards" description="Add rewards for reaching certain voice levels."
models={[
{
name: "Role reward",
primaryIcon: "military_tech",
isModel: (json) => json.level,
renderFormat: (json) => "When becoming voice level " + json.level + ", the user gets the " + json.role.name + " role.",
model: [
{
name: "Needed level",
jsonName: "level",
type: "int",
value: 1,
visible: true,
unit: "",
},
{
name: "Rewarded role",
jsonName: "role",
type: "role",
value: null,
visible: true,
unit: ""
}
]
}
]}
endpoint={"/guilds/" + $page.params.serverId + "/voicerole"} deleteField={(json) => json.level}/>

<MassDataSelector icon="message" title="Message level rewards" description="Add rewards for reaching certain chat message levels."
models={[
{
name: "Role reward",
primaryIcon: "military_tech",
isModel: (json) => json.level,
renderFormat: (json) => "When becoming chat level " + json.level + ", the user gets the " + json.role.name + " role.",
model: [
{
name: "Needed level",
jsonName: "level",
type: "int",
value: 1,
visible: true,
unit: "",
},
{
name: "Rewarded role",
jsonName: "role",
type: "role",
value: null,
visible: true,
unit: ""
}
]
}
]}
endpoint={"/guilds/" + $page.params.serverId + "/chatrole"} deleteField={(json) => json.role.id}/>

<style lang="scss">
@import '$lib/default.scss';
@import '$lib/styles/box.scss';
</style>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import { page } from "$app/stores";
import BooleanSelector from "$lib/components/settings/booleanSelector.svelte";
import ChannelSelector from "$lib/components/settings/channelSelector.svelte";
import MassDataSelector from "$lib/components/settings/massDataSelector.svelte";
import MassDataSetup from "$lib/components/settings/massDataSetup.svelte";
import MessageSelector from "$lib/components/settings/messageSelector.svelte";
import { currentServer } from "$lib/scripts/servers";
Expand Down Expand Up @@ -70,10 +72,71 @@ render={(json) => {

<MessageSelector icon="sticky_note_2" title="Suggestions embed message" description="Configure the message that will be shown in the suggestions embed." settingName="message_suggestion_menu"/>

<h1 class="headline">Temporal voice channel</h1>
<h1 class="headline">Interactions</h1>

<ChannelSelector icon="mic" title="Temporal voice channel" type="VOICE" description="Select the channel that creates new temporal voice channels." endpoint={"/guilds/" + $page.params.serverId + "/temporalvoice"} />

<div class="default-margin"></div>

<!--
<MassDataSelector icon="add_reaction" title="Reaction roles" description="Add reactions on messages that remove/add roles to users."
models={[
{
name: "Reaction role",
primaryIcon: "message",
isModel: (json) => json.level,
renderFormat: (json) => "More than " + json.level + " warnings result in a timeout for " + json.role.name + " seconds.",
model: [
{
name: "Channel",
jsonName: "channelId",
type: "channel",
value: {
id: null,
name: "hi",
type: "TEXT"
},
visible: true,
unit: "",
},
{
name: "Message ID",
jsonName: "messageId",
type: "string",
value: null,
visible: true,
unit: "",
},
{
name: "Emoji ID",
jsonName: "emojiId",
type: "string",
value: null,
visible: true,
unit: "",
},
{
name: "Formatted emoji",
jsonName: "formattedEmoji",
type: "string",
value: null,
visible: true,
unit: "",
},
{
name: "Role",
jsonName: "roleId",
type: "role",
value: null,
visible: true,
unit: "",
}
]
}
]}
endpoint={"/guilds/" + $page.params.serverId + "/reactionroles"} deleteField={(json) => json.role.id}/>
-->

<style lang="scss">
@import '$lib/default.scss';
@import '$lib/styles/box.scss';
Expand Down
11 changes: 8 additions & 3 deletions Frontend/src/routes/(dashboard)/dash/sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@
link: "/moderation",
},
{
icon: "touch_app",
name: "Interactions",
link: "/interactions",
icon: "confirmation_number",
name: "Tickets & tools",
link: "/systems",
},
{
icon: "newspaper",
name: "News & rewards",
link: "/news",
},
{
icon: "leaderboard",
Expand Down

0 comments on commit 1a04f50

Please sign in to comment.