feat(Select menus) + feat(Filter by service rating)
This commit is contained in:
parent
0dbbde1e98
commit
f8a7e65c5a
@ -21,6 +21,7 @@ type multiPanelCreateData struct {
|
|||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Colour int32 `json:"colour"`
|
Colour int32 `json:"colour"`
|
||||||
ChannelId uint64 `json:"channel_id,string"`
|
ChannelId uint64 `json:"channel_id,string"`
|
||||||
|
SelectMenu bool `json:"select_menu"`
|
||||||
Panels []int `json:"panels"`
|
Panels []int `json:"panels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ func (d *multiPanelCreateData) IntoMessageData(isPremium bool) multiPanelMessage
|
|||||||
Title: d.Title,
|
Title: d.Title,
|
||||||
Content: d.Content,
|
Content: d.Content,
|
||||||
Colour: int(d.Colour),
|
Colour: int(d.Colour),
|
||||||
|
SelectMenu: d.SelectMenu,
|
||||||
IsPremium: isPremium,
|
IsPremium: isPremium,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,6 +89,7 @@ func MultiPanelCreate(ctx *gin.Context) {
|
|||||||
Title: data.Title,
|
Title: data.Title,
|
||||||
Content: data.Content,
|
Content: data.Content,
|
||||||
Colour: int(data.Colour),
|
Colour: int(data.Colour),
|
||||||
|
SelectMenu: data.SelectMenu,
|
||||||
}
|
}
|
||||||
|
|
||||||
multiPanel.Id, err = dbclient.Client.MultiPanels.Create(multiPanel)
|
multiPanel.Id, err = dbclient.Client.MultiPanels.Create(multiPanel)
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/rxdn/gdl/objects/guild/emoji"
|
"github.com/rxdn/gdl/objects/guild/emoji"
|
||||||
"github.com/rxdn/gdl/objects/interaction/component"
|
"github.com/rxdn/gdl/objects/interaction/component"
|
||||||
"github.com/rxdn/gdl/rest"
|
"github.com/rxdn/gdl/rest"
|
||||||
|
"github.com/rxdn/gdl/utils"
|
||||||
"math"
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ type multiPanelMessageData struct {
|
|||||||
Title string
|
Title string
|
||||||
Content string
|
Content string
|
||||||
Colour int
|
Colour int
|
||||||
|
SelectMenu bool
|
||||||
IsPremium bool
|
IsPremium bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +27,7 @@ func multiPanelIntoMessageData(panel database.MultiPanel, isPremium bool) multiP
|
|||||||
Title: panel.Title,
|
Title: panel.Title,
|
||||||
Content: panel.Content,
|
Content: panel.Content,
|
||||||
Colour: panel.Colour,
|
Colour: panel.Colour,
|
||||||
|
SelectMenu: panel.SelectMenu,
|
||||||
IsPremium: isPremium,
|
IsPremium: isPremium,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,6 +43,38 @@ func (d *multiPanelMessageData) send(ctx *botcontext.BotContext, panels []databa
|
|||||||
e.SetFooter("Powered by ticketsbot.net", "https://ticketsbot.net/assets/img/logo.png")
|
e.SetFooter("Powered by ticketsbot.net", "https://ticketsbot.net/assets/img/logo.png")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var components []component.Component
|
||||||
|
if d.SelectMenu {
|
||||||
|
options := make([]component.SelectOption, len(panels))
|
||||||
|
for i, panel := range panels {
|
||||||
|
var emote *emoji.Emoji
|
||||||
|
if panel.ReactionEmote != "" {
|
||||||
|
emote = &emoji.Emoji{
|
||||||
|
Name: panel.ReactionEmote,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
options[i] = component.SelectOption{
|
||||||
|
Label: panel.Title,
|
||||||
|
Value: panel.CustomId,
|
||||||
|
Emoji: emote,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
components = []component.Component{
|
||||||
|
component.BuildActionRow(
|
||||||
|
component.BuildSelectMenu(
|
||||||
|
component.SelectMenu{
|
||||||
|
CustomId: "multipanel",
|
||||||
|
Options: options,
|
||||||
|
Placeholder: "Select a topic...",
|
||||||
|
MinValues: utils.IntPtr(1),
|
||||||
|
MaxValues: utils.IntPtr(1),
|
||||||
|
Disabled: false,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
buttons := make([]component.Component, len(panels))
|
buttons := make([]component.Component, len(panels))
|
||||||
for i, panel := range panels {
|
for i, panel := range panels {
|
||||||
var buttonEmoji *emoji.Emoji
|
var buttonEmoji *emoji.Emoji
|
||||||
@ -74,9 +109,12 @@ func (d *multiPanelMessageData) send(ctx *botcontext.BotContext, panels []databa
|
|||||||
rows = append(rows, row)
|
rows = append(rows, row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
components = rows
|
||||||
|
}
|
||||||
|
|
||||||
data := rest.CreateMessageData{
|
data := rest.CreateMessageData{
|
||||||
Embeds: []*embed.Embed{e},
|
Embeds: []*embed.Embed{e},
|
||||||
Components: rows,
|
Components: components,
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := rest.CreateMessage(ctx.Token, ctx.RateLimiter, d.ChannelId, data)
|
msg, err := rest.CreateMessage(ctx.Token, ctx.RateLimiter, d.ChannelId, data)
|
||||||
|
@ -88,6 +88,7 @@ func UpdatePanel(ctx *gin.Context) {
|
|||||||
Content: multiPanel.Content,
|
Content: multiPanel.Content,
|
||||||
Colour: multiPanel.Colour,
|
Colour: multiPanel.Colour,
|
||||||
ChannelId: multiPanel.ChannelId,
|
ChannelId: multiPanel.ChannelId,
|
||||||
|
SelectMenu: multiPanel.SelectMenu,
|
||||||
IsPremium: premiumTier > premium.None,
|
IsPremium: premiumTier > premium.None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ type wrappedQueryOptions struct {
|
|||||||
UserId uint64 `json:"user_id,string"`
|
UserId uint64 `json:"user_id,string"`
|
||||||
PanelId int `json:"panel_id"`
|
PanelId int `json:"panel_id"`
|
||||||
Page int `json:"page"`
|
Page int `json:"page"`
|
||||||
|
Rating int `json:"rating,string"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *wrappedQueryOptions) toQueryOptions(guildId uint64) (database.TicketQueryOptions, error) {
|
func (o *wrappedQueryOptions) toQueryOptions(guildId uint64) (database.TicketQueryOptions, error) {
|
||||||
@ -39,12 +40,17 @@ func (o *wrappedQueryOptions) toQueryOptions(guildId uint64) (database.TicketQue
|
|||||||
offset = pageLimit * (o.Page - 1)
|
offset = pageLimit * (o.Page - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.Rating < 0 || o.Rating > 5 {
|
||||||
|
o.Rating = 0
|
||||||
|
}
|
||||||
|
|
||||||
opts := database.TicketQueryOptions{
|
opts := database.TicketQueryOptions{
|
||||||
Id: o.Id,
|
Id: o.Id,
|
||||||
GuildId: guildId,
|
GuildId: guildId,
|
||||||
UserIds: userIds,
|
UserIds: userIds,
|
||||||
Open: utils.BoolPtr(false),
|
Open: utils.BoolPtr(false),
|
||||||
PanelId: o.PanelId,
|
PanelId: o.PanelId,
|
||||||
|
Rating: o.Rating,
|
||||||
Order: database.OrderTypeDescending,
|
Order: database.OrderTypeDescending,
|
||||||
Limit: pageLimit,
|
Limit: pageLimit,
|
||||||
Offset: offset,
|
Offset: offset,
|
||||||
|
@ -46,6 +46,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
database.ConnectToDatabase()
|
database.ConnectToDatabase()
|
||||||
|
|
||||||
cache.Instance = cache.NewCache()
|
cache.Instance = cache.NewCache()
|
||||||
|
|
||||||
utils.ArchiverClient = archiverclient.NewArchiverClientWithTimeout(config.Conf.Bot.ObjectStore, time.Second*15, []byte(config.Conf.Bot.AesKey))
|
utils.ArchiverClient = archiverclient.NewArchiverClientWithTimeout(config.Conf.Bot.ObjectStore, time.Second*15, []byte(config.Conf.Bot.AesKey))
|
||||||
|
3310
frontend/package-lock.json
generated
3310
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@
|
|||||||
"@babel/preset-env": "^7.14.7",
|
"@babel/preset-env": "^7.14.7",
|
||||||
"@rollup/plugin-babel": "^5.3.0",
|
"@rollup/plugin-babel": "^5.3.0",
|
||||||
"@rollup/plugin-commonjs": "^17.0.0",
|
"@rollup/plugin-commonjs": "^17.0.0",
|
||||||
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||||
"@rollup/plugin-replace": "^2.4.2",
|
"@rollup/plugin-replace": "^2.4.2",
|
||||||
"rollup": "^2.3.4",
|
"rollup": "^2.3.4",
|
||||||
|
@ -6,6 +6,7 @@ import {terser} from 'rollup-plugin-terser';
|
|||||||
import css from 'rollup-plugin-css-only';
|
import css from 'rollup-plugin-css-only';
|
||||||
import replace from "@rollup/plugin-replace";
|
import replace from "@rollup/plugin-replace";
|
||||||
import {babel} from '@rollup/plugin-babel';
|
import {babel} from '@rollup/plugin-babel';
|
||||||
|
import json from '@rollup/plugin-json';
|
||||||
|
|
||||||
const production = !process.env.ROLLUP_WATCH;
|
const production = !process.env.ROLLUP_WATCH;
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ export default {
|
|||||||
dedupe: ['svelte']
|
dedupe: ['svelte']
|
||||||
}),
|
}),
|
||||||
commonjs({ sourceMap: false }),
|
commonjs({ sourceMap: false }),
|
||||||
|
json(),
|
||||||
babel({
|
babel({
|
||||||
babelHelpers: 'bundled',
|
babelHelpers: 'bundled',
|
||||||
extensions: ['.js', '.mjs', '.html', '.svelte'],
|
extensions: ['.js', '.mjs', '.html', '.svelte'],
|
||||||
|
@ -15,9 +15,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-1">
|
<div class="col-3-4">
|
||||||
<PanelDropdown label="Panels" bind:panels bind:selected={data.panels} />
|
<PanelDropdown label="Panels" bind:panels bind:selected={data.panels} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-1-4">
|
||||||
|
<Checkbox label="Use Select Menu" bind:value={data.select_menu} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@ -29,6 +33,7 @@
|
|||||||
import ChannelDropdown from "../ChannelDropdown.svelte";
|
import ChannelDropdown from "../ChannelDropdown.svelte";
|
||||||
import PanelDropdown from "../PanelDropdown.svelte";
|
import PanelDropdown from "../PanelDropdown.svelte";
|
||||||
import {onMount} from "svelte";
|
import {onMount} from "svelte";
|
||||||
|
import Checkbox from "../form/Checkbox.svelte";
|
||||||
|
|
||||||
export let data = {};
|
export let data = {};
|
||||||
|
|
||||||
@ -83,4 +88,20 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:global(.col-1-4) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
width: 25%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.col-3-4) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
width: 75%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -17,10 +17,20 @@
|
|||||||
|
|
||||||
<Input col4=true label="User ID" placeholder="User ID" on:input={handleInputUserId}
|
<Input col4=true label="User ID" placeholder="User ID" on:input={handleInputUserId}
|
||||||
bind:value={filterSettings.userId}/>
|
bind:value={filterSettings.userId}/>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<PanelDropdown label="Panel" isMulti={false} bind:panels bind:selected={selectedPanel} />
|
<PanelDropdown label="Panel" isMulti={false} bind:panels bind:selected={selectedPanel} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Dropdown col4={true} label="Rating" bind:value={filterSettings.rating}>
|
||||||
|
<option value=0>Any</option>
|
||||||
|
<option value=1>1 ⭐</option>
|
||||||
|
<option value=2>2 ⭐</option>
|
||||||
|
<option value=3>3 ⭐</option>
|
||||||
|
<option value=4>4 ⭐</option>
|
||||||
|
<option value=5>5 ⭐</option>
|
||||||
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
<div class="row centre">
|
<div class="row centre">
|
||||||
<Button icon="fas fa-search">Filter</Button>
|
<Button icon="fas fa-search">Filter</Button>
|
||||||
@ -95,6 +105,7 @@
|
|||||||
import {setDefaultHeaders} from '../includes/Auth.svelte'
|
import {setDefaultHeaders} from '../includes/Auth.svelte'
|
||||||
import {Navigate} from 'svelte-router-spa'
|
import {Navigate} from 'svelte-router-spa'
|
||||||
import PanelDropdown from "../components/PanelDropdown.svelte";
|
import PanelDropdown from "../components/PanelDropdown.svelte";
|
||||||
|
import Dropdown from "../components/form/Dropdown.svelte";
|
||||||
|
|
||||||
setDefaultHeaders();
|
setDefaultHeaders();
|
||||||
|
|
||||||
@ -113,6 +124,10 @@
|
|||||||
let handleInputTicketId = () => {
|
let handleInputTicketId = () => {
|
||||||
filterSettings.username = undefined;
|
filterSettings.username = undefined;
|
||||||
filterSettings.userId = undefined;
|
filterSettings.userId = undefined;
|
||||||
|
|
||||||
|
if (filterSettings.ticketId === "") {
|
||||||
|
filterSettings.ticketId = undefined;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let handleInputUsername = () => {
|
let handleInputUsername = () => {
|
||||||
@ -125,7 +140,6 @@
|
|||||||
filterSettings.username = undefined;
|
filterSettings.username = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let loading = false;
|
let loading = false;
|
||||||
|
|
||||||
async function loadPrevious() {
|
async function loadPrevious() {
|
||||||
@ -166,6 +180,7 @@
|
|||||||
id: filterSettings.ticketId,
|
id: filterSettings.ticketId,
|
||||||
username: filterSettings.username,
|
username: filterSettings.username,
|
||||||
user_id: filterSettings.userId,
|
user_id: filterSettings.userId,
|
||||||
|
rating: filterSettings.rating,
|
||||||
panel_id: selectedPanel,
|
panel_id: selectedPanel,
|
||||||
page: page,
|
page: page,
|
||||||
};
|
};
|
||||||
|
6
go.mod
6
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
|
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
|
||||||
github.com/TicketsBot/common v0.0.0-20210910205523-7ce93fba6fa5
|
github.com/TicketsBot/common v0.0.0-20210910205523-7ce93fba6fa5
|
||||||
github.com/TicketsBot/database v0.0.0-20210906215136-2d0c54bd1109
|
github.com/TicketsBot/database v0.0.0-20211024191932-85d9cf1d71a8
|
||||||
github.com/TicketsBot/worker v0.0.0-20210910205947-89f7bd5ccf67
|
github.com/TicketsBot/worker v0.0.0-20210910205947-89f7bd5ccf67
|
||||||
github.com/apex/log v1.1.2
|
github.com/apex/log v1.1.2
|
||||||
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
||||||
@ -18,12 +18,12 @@ require (
|
|||||||
github.com/go-redis/redis/v8 v8.11.3
|
github.com/go-redis/redis/v8 v8.11.3
|
||||||
github.com/go-redis/redis_rate/v9 v9.1.1
|
github.com/go-redis/redis_rate/v9 v9.1.1
|
||||||
github.com/golang-jwt/jwt v3.2.1+incompatible
|
github.com/golang-jwt/jwt v3.2.1+incompatible
|
||||||
github.com/gorilla/sessions v1.2.0 // indirect
|
github.com/gorilla/sessions v1.2.1 // indirect
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/jackc/pgx/v4 v4.7.1
|
github.com/jackc/pgx/v4 v4.7.1
|
||||||
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
|
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/rxdn/gdl v0.0.0-20210906182609-337cb3c44a4c
|
github.com/rxdn/gdl v0.0.0-20210921120128-02188fdcfd88
|
||||||
github.com/sirupsen/logrus v1.5.0
|
github.com/sirupsen/logrus v1.5.0
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user