2021-12-12 09:31:08 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { Container, Col, Row, TabContent, TabPane, Alert, Spinner } from 'sveltestrap';
|
2022-03-19 10:46:09 +00:00
|
|
|
import { useParams, useLocation } from "svelte-navigator";
|
2021-12-12 09:31:08 +00:00
|
|
|
import { onMount } from 'svelte';
|
|
|
|
|
2022-02-01 20:24:45 +00:00
|
|
|
import SystemMain from '../../lib/system/Main.svelte';
|
2021-12-18 19:10:02 +00:00
|
|
|
import MemberList from '../../lib/member/List.svelte';
|
2021-12-18 23:58:55 +00:00
|
|
|
import GroupList from '../../lib/group/List.svelte';
|
2021-12-12 09:31:08 +00:00
|
|
|
|
2022-02-01 20:24:45 +00:00
|
|
|
import { System } from '../../api/types';
|
|
|
|
import api from '../../api';
|
|
|
|
|
|
|
|
let user: System = {};
|
2021-12-12 09:31:08 +00:00
|
|
|
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;
|
|
|
|
|
2022-03-19 10:46:09 +00:00
|
|
|
let location = useLocation();
|
|
|
|
let urlParams = $location.search && new URLSearchParams($location.search);
|
|
|
|
let tabPane: string;
|
|
|
|
if (urlParams) {
|
|
|
|
tabPane = urlParams.get("tab");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tabPane) {
|
|
|
|
tabPane = "system";
|
|
|
|
}
|
|
|
|
|
2021-12-12 09:31:08 +00:00
|
|
|
let err: string;
|
|
|
|
|
|
|
|
let title = "system"
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
getSystem();
|
|
|
|
})
|
|
|
|
|
|
|
|
async function getSystem() {
|
|
|
|
try {
|
2022-03-02 15:49:41 +00:00
|
|
|
let res: System = await api().systems(id).get();
|
2021-12-12 09:31:08 +00:00
|
|
|
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-->
|
2021-12-12 13:48:22 +00:00
|
|
|
{#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>
|
2022-05-20 10:09:10 +00:00
|
|
|
<h1 class="visually-hidden">Viewing a public system</h1>
|
2021-12-30 07:23:13 +00:00
|
|
|
<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}
|
2022-05-20 10:09:10 +00:00
|
|
|
<Alert color="info" aria-hidden>You are currently <b>viewing</b> a system.</Alert>
|
2021-12-12 09:31:08 +00:00
|
|
|
<TabContent class="mt-3">
|
2022-03-19 10:46:09 +00:00
|
|
|
<TabPane tabId="system" tab="System" active={tabPane === "system"}>
|
2022-04-25 17:17:05 +00:00
|
|
|
<SystemMain bind:user isPublic={true} />
|
2021-12-12 09:31:08 +00:00
|
|
|
</TabPane>
|
2022-03-19 10:46:09 +00:00
|
|
|
<TabPane tabId="members" tab="Members" active={tabPane === "members"}>
|
2022-04-25 17:29:15 +00:00
|
|
|
<MemberList bind:list={members} isPublic={true} />
|
2021-12-18 23:58:55 +00:00
|
|
|
</TabPane>
|
2022-03-19 10:46:09 +00:00
|
|
|
<TabPane tabId="groups" tab="Groups" active={tabPane === "groups"}>
|
2022-04-25 17:29:15 +00:00
|
|
|
<GroupList bind:members={members} bind:list={groups} isPublic={true}/>
|
2021-12-18 23:58:55 +00:00
|
|
|
</TabPane>
|
2021-12-12 09:31:08 +00:00
|
|
|
</TabContent>
|
|
|
|
{/if}
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Container>
|
|
|
|
|
|
|
|
<svelte:head>
|
2022-05-17 03:22:51 +00:00
|
|
|
<title>PluralKit | {title}</title>
|
2021-12-12 09:31:08 +00:00
|
|
|
</svelte:head>
|