mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat(dashboard): add formatted group view
This commit is contained in:
parent
66187ab40f
commit
209ca0fa0d
1 changed files with 53 additions and 13 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Row, Col, Button, Alert, ListGroup, ListGroupItem, Spinner } from 'sveltestrap';
|
import { Row, Col, Button, Alert, ListGroup, ListGroupItem, Spinner, TabContent, TabPane, Card, CardBody } from 'sveltestrap';
|
||||||
import ListPagination from "../common/ListPagination.svelte";
|
import ListPagination from "../common/ListPagination.svelte";
|
||||||
import twemoji from "twemoji";
|
import twemoji from "twemoji";
|
||||||
import Svelecte, { addFormatter } from 'svelecte';
|
import Svelecte, { addFormatter } from 'svelecte';
|
||||||
|
|
@ -100,30 +100,70 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: shortGroupList = (list: Group[]) => {
|
||||||
|
let str = []
|
||||||
|
list.forEach(g => {
|
||||||
|
str.push(`[\`${g.id}\`] **${g.display_name ? g.display_name : g.name}**`)
|
||||||
|
})
|
||||||
|
|
||||||
|
return str.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
$: longGroupList = (list: Group[]) => list.map(g => g.display_name ? g.display_name : g.name).join(", ")
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{#if err}
|
{#if err}
|
||||||
<Alert color="danger">{err}</Alert>
|
<Alert color="danger">{err}</Alert>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if longGroupList(groupsWithMember).length > 1000}
|
||||||
|
<Alert color="warning">The total length of the group list is <b>greater than 1000 characters</b>, which means the group list will be cut short when viewed in the bot!</Alert>
|
||||||
|
{/if}
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={12} lg={6} class="text-center mb-3">
|
<Col xs={12} lg={6} class="text-center mb-3">
|
||||||
<h5><div class="icon d-inline-block">
|
<h5><div class="icon d-inline-block">
|
||||||
<FaFolderOpen />
|
<FaFolderOpen />
|
||||||
</div>Current Groups
|
</div>Current Groups
|
||||||
{#if finalGroupsList && finalGroupsList.length > 0}
|
{#if groupsWithMember && groupsWithMember.length > 0}
|
||||||
({groupsWithMember.length} total)
|
({groupsWithMember.length} total)
|
||||||
{/if}
|
{/if}
|
||||||
</h5>
|
</h5>
|
||||||
<ListPagination bind:currentPage bind:pageAmount bind:smallPages/>
|
<TabContent>
|
||||||
{#if finalGroupsList && finalGroupsList.length > 0}
|
<TabPane tabId="list" tab="List" active={true}>
|
||||||
<ListGroup>
|
<Card>
|
||||||
{#each finalGroupsList as group, index (group.id)}
|
<CardBody>
|
||||||
<ListGroupItem class="d-flex"><span bind:this={listGroupElements[index]} class="d-flex justify-content-between flex-grow-1"><span><b>{group.name}</b> (<code>{group.id}</code>)</span> <span><AwaitHtml htmlPromise={group.display_name ? parseMarkdown(group.display_name) : Promise.resolve("")} /></span></span></ListGroupItem>
|
{#if groupsWithMember && groupsWithMember.length > 0}
|
||||||
{/each}
|
<ListPagination bind:currentPage bind:pageAmount bind:smallPages/>
|
||||||
</ListGroup>
|
<ListGroup>
|
||||||
{:else}
|
{#each finalGroupsList as group, index (group.id)}
|
||||||
<p>This member is inside no groups.</p>
|
<ListGroupItem class="d-flex"><span bind:this={listGroupElements[index]} class="d-flex justify-content-between flex-grow-1"><span><b>{group.name}</b> (<code>{group.id}</code>)</span> <span><AwaitHtml htmlPromise={group.display_name ? parseMarkdown(group.display_name) : Promise.resolve("")} /></span></span></ListGroupItem>
|
||||||
<p>You can add groups in this menu!</p>
|
{/each}
|
||||||
{/if}
|
</ListGroup>
|
||||||
|
{:else}
|
||||||
|
<p>This member is not a part of any group.</p>
|
||||||
|
<p>You can add this member to groups in this menu!</p>
|
||||||
|
{/if}
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</TabPane>
|
||||||
|
<TabPane tabId="formatted" tab="Formatted">
|
||||||
|
<Card>
|
||||||
|
<CardBody>
|
||||||
|
{#if groupsWithMember && groupsWithMember.length > 0}
|
||||||
|
<p class="mb-0" style="text-align: left;">
|
||||||
|
{#if finalGroupsList.length <= 5}
|
||||||
|
<AwaitHtml htmlPromise={parseMarkdown(shortGroupList(groupsWithMember), { embed: true, parseTimestamps: true })} />
|
||||||
|
{:else}
|
||||||
|
<AwaitHtml htmlPromise={parseMarkdown(longGroupList(groupsWithMember), { embed: true, parseTimestamps: true })} />
|
||||||
|
{/if}
|
||||||
|
</p>
|
||||||
|
{:else}
|
||||||
|
<p>This member is not a part of any group.</p>
|
||||||
|
<p>You can add this member to groups in this menu!</p>
|
||||||
|
{/if}
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</TabPane>
|
||||||
|
</TabContent>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={12} lg={6} class="text-center mb-3">
|
<Col xs={12} lg={6} class="text-center mb-3">
|
||||||
<h5><div class="icon d-inline-block">
|
<h5><div class="icon d-inline-block">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue