feat: public system page!

This commit is contained in:
Spectralitree
2021-12-12 10:31:08 +01:00
parent dc9a7a67b6
commit ddda4ac58b
5 changed files with 156 additions and 12 deletions

38
src/pages/Public.svelte Normal file
View File

@@ -0,0 +1,38 @@
<script lang="ts">
import { Container, Row, Col, Card, CardHeader, CardTitle, CardBody, Input, Button } from 'sveltestrap';
import { Link } from 'svelte-navigator';
import FaRocket from 'svelte-icons/fa/FaRocket.svelte';
let sysInput: string = "";
</script>
<Container>
<Row>
<Col class="mx-auto" xs={12} lg={10}>
<Card>
<CardHeader>
<CardTitle style="margin-top: 8px; outline: none;">
<div class="icon d-inline-block">
<FaRocket />
</div>Profile
</CardTitle>
</CardHeader>
<CardBody>
Submit a <b>system ID</b> to view that system's profile.
<Row>
<Col xs={12} lg={9} class="my-2">
<Input bind:value={sysInput} />
</Col>
<Col xs={12} lg={3} class="my-2 d-flex">
{#if sysInput !== ""}
<Link style="text-decoration: none; flex: 1 0 auto" to="/public/s/{sysInput.trim()}"><Button class="w-100" color="primary">View</Button></Link>
{:else}
<Button class="w-100" disabled color="primary">View</Button>
{/if}
</Col>
</Row>
</CardBody>
</Card>
</Col>
</Row>
</Container>

View File

@@ -0,0 +1,71 @@
<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';
let isPublic = true;
let user = new Sys({});
let settings = JSON.parse(localStorage.getItem("pk-settings"));
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;
title = user.name;
} 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}
<div class="banner" style="background-image: url({user.banner})" />
{/if}
<Container>
<Row>
<Col class="mx-auto" xs={12} lg={10}>
{#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>
<System bind:user={user} bind:isPublic={isPublic} />
</TabPane>
<TabPane tabId="members" tab="Members">
alo
</TabPane>
</TabContent>
{/if}
</Col>
</Row>
</Container>
<svelte:head>
<title>pk-webs | {title}</title>
</svelte:head>