Filter by panel ID
This commit is contained in:
parent
9d23c3ef39
commit
4d42043732
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "locale"]
|
||||||
|
path = locale
|
||||||
|
url = https://github.com/TicketsBot/locale.git
|
@ -11,6 +11,7 @@ type wrappedQueryOptions struct {
|
|||||||
Id int `json:"id,string"`
|
Id int `json:"id,string"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
UserId uint64 `json:"user_id,string"`
|
UserId uint64 `json:"user_id,string"`
|
||||||
|
PanelId int `json:"panel_id"`
|
||||||
Page int `json:"page"`
|
Page int `json:"page"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ func (o *wrappedQueryOptions) toQueryOptions(guildId uint64) (database.TicketQue
|
|||||||
GuildId: guildId,
|
GuildId: guildId,
|
||||||
UserIds: userIds,
|
UserIds: userIds,
|
||||||
Open: utils.BoolPtr(false),
|
Open: utils.BoolPtr(false),
|
||||||
|
PanelId: o.PanelId,
|
||||||
Order: database.OrderTypeDescending,
|
Order: database.OrderTypeDescending,
|
||||||
Limit: pageLimit,
|
Limit: pageLimit,
|
||||||
Offset: offset,
|
Offset: offset,
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/TicketsBot/archiverclient"
|
"github.com/TicketsBot/archiverclient"
|
||||||
"github.com/TicketsBot/common/chatrelay"
|
"github.com/TicketsBot/common/chatrelay"
|
||||||
"github.com/TicketsBot/common/premium"
|
"github.com/TicketsBot/common/premium"
|
||||||
"github.com/TicketsBot/worker/bot/i18n"
|
"github.com/TicketsBot/worker/i18n"
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/rxdn/gdl/rest/request"
|
"github.com/rxdn/gdl/rest/request"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@ -40,9 +40,8 @@ func main() {
|
|||||||
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))
|
||||||
|
|
||||||
utils.LoadEmoji()
|
utils.LoadEmoji()
|
||||||
if err := i18n.LoadMessages(database.Client); err != nil {
|
|
||||||
panic(err)
|
i18n.LoadMessages()
|
||||||
}
|
|
||||||
|
|
||||||
if config.Conf.Bot.ProxyUrl != "" {
|
if config.Conf.Bot.ProxyUrl != "" {
|
||||||
request.RegisterHook(utils.ProxyHook)
|
request.RegisterHook(utils.ProxyHook)
|
||||||
|
@ -58,7 +58,7 @@ export default {
|
|||||||
browser: true,
|
browser: true,
|
||||||
dedupe: ['svelte']
|
dedupe: ['svelte']
|
||||||
}),
|
}),
|
||||||
commonjs(),
|
commonjs({ sourceMap: false }),
|
||||||
babel({
|
babel({
|
||||||
babelHelpers: 'bundled',
|
babelHelpers: 'bundled',
|
||||||
extensions: ['.js', '.mjs', '.html', '.svelte'],
|
extensions: ['.js', '.mjs', '.html', '.svelte'],
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
<label class="form-label">{label}</label>
|
<label class="form-label">{label}</label>
|
||||||
<div class="multiselect-super">
|
<div class="multiselect-super">
|
||||||
<Select placeholder="Select..." items={panels} optionIdentifier="panel_id" getOptionLabel={labelMapper}
|
<Select placeholder="Select..." items={panels} optionIdentifier="panel_id" getOptionLabel={labelMapper}
|
||||||
getSelectionLabel={labelMapper} bind:selectedValue={panelsRaw}
|
getSelectionLabel={labelMapper} bind:selectedValue={selectedRaw}
|
||||||
on:select={update} isMulti={true}/>
|
on:select={update} on:clear={handleClear} {isMulti} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -13,24 +11,48 @@
|
|||||||
|
|
||||||
export let label;
|
export let label;
|
||||||
export let panels = [];
|
export let panels = [];
|
||||||
export let selected = [];
|
export let selected;
|
||||||
|
export let isMulti = true;
|
||||||
|
|
||||||
let panelsRaw = [];
|
let selectedRaw;
|
||||||
|
|
||||||
function labelMapper(panel) {
|
function labelMapper(panel) {
|
||||||
return panel.title;
|
return panel.title || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
if (panelsRaw === undefined) {
|
if (selectedRaw === undefined) {
|
||||||
panelsRaw = [];
|
selectedRaw = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
selected = panelsRaw.map((panel) => panel.panel_id);
|
if (isMulti) {
|
||||||
|
selected = selectedRaw.map((panel) => panel.panel_id);
|
||||||
|
} else {
|
||||||
|
if (selectedRaw) {
|
||||||
|
selected = selectedRaw.panel_id;
|
||||||
|
} else {
|
||||||
|
selected = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClear() {
|
||||||
|
if (isMulti) {
|
||||||
|
selected = [];
|
||||||
|
} else {
|
||||||
|
selected = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyOverrides() {
|
function applyOverrides() {
|
||||||
panelsRaw = panels.filter((p) => selected.includes(p.panel_id));
|
if (isMulti) {
|
||||||
|
selected = [];
|
||||||
|
selectedRaw = panels.filter((p) => selected.includes(p.panel_id));
|
||||||
|
} else {
|
||||||
|
if (selectedRaw) {
|
||||||
|
selectedRaw = selectedRaw.panel_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<Card footer="{false}" dropdown="{true}" ref="filter-card">
|
<Card footer={false} ref="filter-card">
|
||||||
<span slot="title">
|
<span slot="title">
|
||||||
<i class="fas fa-filter"></i>
|
<i class="fas fa-filter"></i>
|
||||||
Filter Logs
|
Filter Logs
|
||||||
@ -9,14 +9,18 @@
|
|||||||
<div slot="body" class="body-wrapper">
|
<div slot="body" class="body-wrapper">
|
||||||
<form class="form-wrapper" on:submit|preventDefault={filter}>
|
<form class="form-wrapper" on:submit|preventDefault={filter}>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<Input col3=true label="Ticket ID" placeholder="Ticket ID"
|
<Input col4=true label="Ticket ID" placeholder="Ticket ID"
|
||||||
on:input={handleInputTicketId} bind:value={filterSettings.ticketId}/>
|
on:input={handleInputTicketId} bind:value={filterSettings.ticketId}/>
|
||||||
|
|
||||||
<Input col3=true label="Username" placeholder="Username" on:input={handleInputUsername}
|
<Input col4=true label="Username" placeholder="Username" on:input={handleInputUsername}
|
||||||
bind:value={filterSettings.username}/>
|
bind:value={filterSettings.username}/>
|
||||||
|
|
||||||
<Input col3=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 class="col-4">
|
||||||
|
<PanelDropdown label="Panel" isMulti={false} bind:panels bind:selected={selectedPanel} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row centre">
|
<div class="row centre">
|
||||||
<Button icon="fas fa-search">Filter</Button>
|
<Button icon="fas fa-search">Filter</Button>
|
||||||
@ -90,6 +94,7 @@
|
|||||||
import {API_URL} from "../js/constants";
|
import {API_URL} from "../js/constants";
|
||||||
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";
|
||||||
|
|
||||||
setDefaultHeaders();
|
setDefaultHeaders();
|
||||||
|
|
||||||
@ -99,6 +104,9 @@
|
|||||||
let filterSettings = {};
|
let filterSettings = {};
|
||||||
let transcripts = [];
|
let transcripts = [];
|
||||||
|
|
||||||
|
let panels = [];
|
||||||
|
let selectedPanel;
|
||||||
|
|
||||||
const pageLimit = 15;
|
const pageLimit = 15;
|
||||||
let page = 1;
|
let page = 1;
|
||||||
|
|
||||||
@ -146,6 +154,7 @@
|
|||||||
id: filterSettings.ticketId,
|
id: filterSettings.ticketId,
|
||||||
username: filterSettings.username,
|
username: filterSettings.username,
|
||||||
user_id: filterSettings.userId,
|
user_id: filterSettings.userId,
|
||||||
|
panel_id: selectedPanel,
|
||||||
page: page,
|
page: page,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -156,6 +165,16 @@
|
|||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadPanels() {
|
||||||
|
const res = await axios.get(`${API_URL}/api/${guildId}/panels`);
|
||||||
|
if (res.status !== 200) {
|
||||||
|
notifyError(res.data.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
panels = res.data;
|
||||||
|
}
|
||||||
|
|
||||||
async function loadData(paginationSettings) {
|
async function loadData(paginationSettings) {
|
||||||
const res = await axios.post(`${API_URL}/api/${guildId}/transcripts`, paginationSettings);
|
const res = await axios.post(`${API_URL}/api/${guildId}/transcripts`, paginationSettings);
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
@ -172,6 +191,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
withLoadingScreen(async () => {
|
withLoadingScreen(async () => {
|
||||||
|
await loadPanels();
|
||||||
await loadData({})
|
await loadData({})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
4
go.mod
4
go.mod
@ -6,8 +6,8 @@ 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-20210727134627-35eb7ed03a44
|
github.com/TicketsBot/common v0.0.0-20210727134627-35eb7ed03a44
|
||||||
github.com/TicketsBot/database v0.0.0-20210816195201-90c765ca95c8
|
github.com/TicketsBot/database v0.0.0-20210901165354-a7e41939592c
|
||||||
github.com/TicketsBot/worker v0.0.0-20210830140323-d24e405daad7
|
github.com/TicketsBot/worker v0.0.0-20210831230124-0f73f4a70602
|
||||||
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
|
||||||
github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2
|
github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2
|
||||||
|
1
locale
Submodule
1
locale
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit ce006c345e84acdffd369878dc16b45048f5a92b
|
Loading…
x
Reference in New Issue
Block a user