PluralKit/src/pages/profiles/Main.svelte

79 lines
2.4 KiB
Svelte
Raw Normal View History

2021-12-12 09:31:08 +00:00
<script lang="ts">
import { Container, Col, Row, TabContent, TabPane, Alert, Spinner } from 'sveltestrap';
import { useParams } from "svelte-navigator";
import { onMount } from 'svelte';
import System from '../../lib/system/Main.svelte';
import PKAPI from '../../api';
import Sys from '../../api/system';
2021-12-18 19:10:02 +00:00
import MemberList from '../../lib/member/List.svelte';
import GroupList from '../../lib/group/List.svelte';
2021-12-12 09:31:08 +00:00
let isPublic = true;
let user = new Sys({});
let settings = JSON.parse(localStorage.getItem("pk-settings"));
2021-12-18 19:10:02 +00:00
let members = [];
let groups = [];
2021-12-12 09:31:08 +00:00
let params = useParams();
$: id = $params.id;
let err: string;
const api = new PKAPI();
let title = "system"
onMount(() => {
getSystem();
})
async function getSystem() {
try {
let res: Sys = await api.getSystem({id: id})
user = res;
2021-12-20 06:57:59 +00:00
title = user.name ? user.name : "system";
2021-12-12 09:31:08 +00:00
} catch (error) {
console.log(error);
err = error.message;
}
}
</script>
<!-- display the banner if there's a banner set, and if the current settings allow for it-->
{#if user && user.banner && ((settings && settings.appearance.banner_top) || !settings)}
2021-12-12 09:31:08 +00:00
<div class="banner" style="background-image: url({user.banner})" />
{/if}
<Container>
<Row>
<Col class="mx-auto" xs={12} lg={11} xl={10}>
2021-12-12 09:31:08 +00:00
{#if !user.id && !err}
<div class="mx-auto text-center">
<Spinner class="d-inline-block" />
</div>
{:else if err}
<Alert color="danger">{err}</Alert>
{:else}
<Alert color="info">You are currently <b>viewing</b> a system.</Alert>
<TabContent class="mt-3">
<TabPane tabId="system" tab="System" active>
2021-12-15 12:52:18 +00:00
<System bind:user bind:isPublic />
2021-12-12 09:31:08 +00:00
</TabPane>
<TabPane tabId="members" tab="Members">
2021-12-18 19:10:02 +00:00
<MemberList bind:list={members} bind:isPublic/>
</TabPane>
<TabPane tabId="groups" tab="Groups">
<GroupList bind:members={members} bind:list={groups} bind:isPublic/>
</TabPane>
2021-12-12 09:31:08 +00:00
</TabContent>
{/if}
</Col>
</Row>
</Container>
<svelte:head>
<title>pk-webs | {title}</title>
</svelte:head>