feat: add tag page

This commit is contained in:
Damillora 2021-05-11 03:34:59 +07:00
parent a09058ceb2
commit 5d239b0a05
6 changed files with 634 additions and 293 deletions

View File

@ -10,6 +10,7 @@
import Logout from "./routes/Logout.svelte";
import Upload from "./routes/Upload.svelte";
import Edit from "./routes/Edit.svelte";
import Tags from "./routes/Tags.svelte";
export let url = "";
let baseURL = window.BASE_URL;
@ -25,6 +26,7 @@
<Route path="/auth/login" component={Login} />
<Route path="/auth/logout" component={Logout} />
<Route path="/upload" component={Upload} />
<Route path="/tags" component={Tags} />
</div>
</Router>

View File

@ -21,6 +21,11 @@ export async function login({ username, password }) {
return response.data;
}
export async function getTags() {
const endpoint = url + "/api/tag";
const response = await axios.get(endpoint);
return response.data;
}
export async function getPosts({ page }) {
const endpoint = url + "/api/post?page=" + page;
const response = await axios.get(endpoint);

View File

@ -11,6 +11,12 @@
};
</script>
<section class="hero is-primary">
<div class="hero-body">
<p class="title">Login</p>
</div>
</section>
<div class="container">
<form on:submit|preventDefault={doLogin}>
<div class="field">

View File

@ -0,0 +1,42 @@
<script>
import { getTags } from "../api";
let tags = [];
const getData = async () => {
const data = await getTags();
tags = data;
};
$: {
getData();
}
</script>
<section class="hero is-primary">
<div class="hero-body">
<p class="title">Tags</p>
</div>
</section>
<section class="section">
<div class="container">
<table class="table is-fullwidth">
<thead>
<tr>
<th>Tag</th>
<th>Tag Type</th>
</tr>
</thead>
<tbody>
{#each tags as tag}
<tr>
<td>{tag.name}</td>
<td>{tag.tagType}</td>
</tr>
{/each}
</tbody>
</table>
</div>
</section>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long