mirror of
https://github.com/psforever/PSFPortal.git
synced 2026-04-26 14:55:24 +00:00
Enable foreign profile view
This commit is contained in:
parent
20946fdb43
commit
cb918033a6
14 changed files with 248 additions and 125 deletions
|
|
@ -13,7 +13,7 @@
|
|||
{/if}
|
||||
|
||||
{#if $isAdmin}
|
||||
<a href="/character/{character.id}">{character.name}</a>
|
||||
<a href="/user/{character.account_id}">{character.name}</a>
|
||||
{:else}
|
||||
<span>{character.name}</span>
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
import { cubicOut } from 'svelte/easing';
|
||||
|
||||
const progress = tweened(0, {
|
||||
delay: 100,
|
||||
duration: 1000,
|
||||
easing: cubicOut
|
||||
});
|
||||
|
|
@ -16,21 +17,22 @@
|
|||
let tr, nc, vs;
|
||||
|
||||
onMount(() => {
|
||||
setTimeout(() => progress.set(1.0), 100);
|
||||
|
||||
tr.style.height = "1px";
|
||||
nc.style.height = "1px";
|
||||
vs.style.height = "1px";
|
||||
|
||||
progress.subscribe((v) => {
|
||||
if (!tr || !nc || !vs)
|
||||
return;
|
||||
|
||||
tr.style.height = v*percentages.TR*200 + "px";
|
||||
nc.style.height = v*percentages.NC*200 + "px";
|
||||
vs.style.height = v*percentages.VS*200 + "px";
|
||||
})
|
||||
|
||||
setTimeout(() => progress.set(1.0), 100);
|
||||
})
|
||||
|
||||
progress.subscribe((v) => {
|
||||
if (tr === undefined || !tr.style)
|
||||
return
|
||||
|
||||
tr.style.height = v*percentages.TR*200 + "px";
|
||||
nc.style.height = v*percentages.NC*200 + "px";
|
||||
vs.style.height = v*percentages.VS*200 + "px";
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
|
|
@ -21,15 +21,26 @@
|
|||
</script>
|
||||
|
||||
<PaginatedList {fetch} let:data={logins} let:pagination={pagination}>
|
||||
<p slot="header">
|
||||
{#if pagination.item_count}
|
||||
Login data
|
||||
{:else}
|
||||
No logins yet
|
||||
{/if}
|
||||
</p>
|
||||
<table slot="body" class="table table-dark table-responsive">
|
||||
<thead>
|
||||
<td>Login Time</td>
|
||||
<td>From</td>
|
||||
<td>Login Date</td>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{#each logins as login, i}
|
||||
<tr>
|
||||
<td>{moment(login.login_time).fromNow()}</td>
|
||||
<td>
|
||||
<code>{login.hostname} - {login.ip_address}</code>
|
||||
</td>
|
||||
<td>{moment(login.login_time).format('MMMM Do YYYY, h:mm:ss a')} ({moment(login.login_time).fromNow()})</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
import { get_initial_state, logout, isAdmin, loggedIn, username } from '../UserState.js';
|
||||
import axios from 'axios'
|
||||
export let route;
|
||||
export let pageCtx;
|
||||
console.log(pageCtx)
|
||||
</script>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark justify-content-between">
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import axios from 'axios'
|
||||
import Pagination from '../components/Pagination'
|
||||
|
||||
export let setURLParam = false;
|
||||
export let fetch;
|
||||
|
||||
let data;
|
||||
|
|
@ -15,12 +16,16 @@
|
|||
|
||||
onMount(async () => {
|
||||
const url = new URL(window.location.href)
|
||||
let page = url.searchParams.get('page')
|
||||
let initialPage = 1;
|
||||
|
||||
if (page == undefined)
|
||||
page = 1;
|
||||
if (setURLParam) {
|
||||
let param = parseInt(url.searchParams.get('page'))
|
||||
|
||||
await list_fetch(page);
|
||||
if (param != NaN)
|
||||
initialPage = param;
|
||||
}
|
||||
|
||||
await list_fetch(initialPage);
|
||||
})
|
||||
|
||||
async function pageChange(page) {
|
||||
|
|
@ -50,8 +55,10 @@
|
|||
|
||||
{#if data}
|
||||
<slot name="header" data={data} pagination={pagination}></slot>
|
||||
<Pagination {pagination} {pageChange} />
|
||||
{#if pagination.item_count > 0}
|
||||
<Pagination {pagination} {pageChange} {setURLParam} />
|
||||
<slot name="body" data={data} pagination={pagination}></slot>
|
||||
<Pagination {pagination} {pageChange} />
|
||||
<Pagination {pagination} {pageChange} {setURLParam} />
|
||||
{/if}
|
||||
<slot name="footer" data={data} pagination={pagination}></slot>
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,31 @@
|
|||
<script>
|
||||
export let pagination;
|
||||
export let pageChange;
|
||||
let numPages = 10;
|
||||
export let setURLParam = false;
|
||||
export let displayPages = 10;
|
||||
|
||||
let pages = []
|
||||
|
||||
function pageClick(event) {
|
||||
const page = event.target.getAttribute('data-page');
|
||||
pageChange(parseInt(page))
|
||||
|
||||
if (!setURLParam)
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
$ : {
|
||||
const new_pages = [];
|
||||
let pi = 0, i;
|
||||
let pg = pagination;
|
||||
|
||||
const pageChunk = Math.max(Math.ceil(numPages/3), 1);
|
||||
const pageChunk = Math.max(Math.ceil(displayPages/3), 1);
|
||||
const middleChunk = Math.max(Math.ceil(pageChunk/2), 1);
|
||||
const leftBound = Math.min(pageChunk+1, pagination.page_count);
|
||||
const rightBound = Math.max(pagination.page_count-pageChunk, 1);
|
||||
|
||||
// fast path: draw all pages
|
||||
if (pg.page_count <= numPages || rightBound <= leftBound) {
|
||||
if (pg.page_count <= displayPages || rightBound <= leftBound) {
|
||||
for (i = 1; i <= pg.page_count; i++)
|
||||
new_pages[pi++] = i;
|
||||
} else {
|
||||
|
|
@ -54,27 +64,31 @@
|
|||
<p>Displaying {(pagination.page-1)*pagination.items_per_page+1} — {Math.min(pagination.page*pagination.items_per_page, pagination.item_count)}</p>
|
||||
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination pagination-sm">
|
||||
<li class="page-item" class:disabled={pagination.page<=1}>
|
||||
<a class="page-link" href={"?page="+(pagination.page-1)}
|
||||
on:click={(e) => pageChange(pagination.page-1)}
|
||||
aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
{#each pages as page,i}
|
||||
<ul class="pagination pagination-sm">
|
||||
<li class="page-item" class:disabled={pagination.page<=1}>
|
||||
<a class="page-link" href={"?page="+(pagination.page-1)}
|
||||
on:click={pageClick}
|
||||
data-page={pagination.page-1}
|
||||
aria-label="Previous">
|
||||
«
|
||||
</a>
|
||||
</li>
|
||||
{#each pages as page,i}
|
||||
{#if page == -1}
|
||||
<li class="page-item page-last-separator disabled" ><a class="page-link">...<a></li>
|
||||
<li class="page-item page-last-separator disabled"><span class="page-link">...</span></li>
|
||||
{:else}
|
||||
<li class="page-item" class:active={page==pagination.page}><a on:click={(e) => pageChange(page)} href={"?page="+page} class="page-link">{page}</a></li>
|
||||
<li class="page-item" class:active={page==pagination.page}>
|
||||
<a on:click={pageClick} href={"?page="+page} data-page={page} class="page-link">{page}</a>
|
||||
</li>
|
||||
{/if}
|
||||
{/each}
|
||||
<li class="page-item" class:disabled={pagination.page>=pagination.page_count}>
|
||||
<a class="page-link" href={"?page="+(pagination.page+1)}
|
||||
on:click={(e) => pageChange(pagination.page+1)}
|
||||
aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{/each}
|
||||
<li class="page-item" class:disabled={pagination.page>=pagination.page_count}>
|
||||
<a class="page-link" href={"?page="+(pagination.page+1)}
|
||||
data-page={pagination.page+1}
|
||||
on:click={pageClick}
|
||||
aria-label="Next">
|
||||
»
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue