PSFPortal/app/views/CharacterList.svelte
Chord fa6e168ccc Application improvements
* Change favicon
* Display account banned status on admin search
* Pull in application version from Webpack
* Add "Feedback" button in footer and github references
* Fix faction icons to make them the same size
* PaginatedList component now supports back
* Tabbed navs support back
* Hide Pagination when only one page
* Improve admin table style and size
2019-12-31 09:46:34 -05:00

47 lines
1.2 KiB
Svelte

<script>
import { onMount } from 'svelte'
import axios from 'axios'
import CharacterLink from '../components/CharacterLink'
import PaginatedList from '../components/PaginatedList'
import moment from 'moment'
export let setURLParam = true;
export let appAlert
async function fetch(page) {
try {
const resp = await axios.get("/api/characters?page="+page)
appAlert.message("")
return [resp.data.characters, resp.data.page];
} catch (e) {
appAlert.message(e.message)
return undefined;
}
}
</script>
<PaginatedList {setURLParam} URLSearchName='page_char' bind:fetch={fetch} let:data={characters} let:pagination={pagination}>
<div slot="header">
<p>{pagination.item_count.toLocaleString()} characters in the database</p>
</div>
<table slot="body" class="table table-sm table-dark table-responsive-md table-striped table-hover">
<thead class="thead-light">
<th>ID</th>
<th>Name</th>
<th>Last Played</th>
<th>Created</th>
</thead>
<tbody>
{#each characters as char, i}
<tr>
<td>#{char.id}</td>
<td><CharacterLink character={char} /></td>
<td>{moment(char.last_login).fromNow()}</td>
<td>{moment(char.created).fromNow()}</td>
</tr>
{/each}
</tbody>
</table>
</PaginatedList>