@axium/storage 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/SidebarItem.svelte +4 -3
- package/lib/Usage.svelte +20 -16
- package/lib/sidebar.svelte.ts +1 -4
- package/lib/tsconfig.json +2 -1
- package/package.json +1 -1
- package/routes/files/+layout.svelte +1 -1
- package/routes/files/+layout.ts +2 -5
- package/routes/files/+page.ts +5 -5
- package/routes/files/[id]/+page.ts +1 -1
- package/routes/files/shared/+page.ts +5 -5
- package/routes/files/trash/+page.ts +5 -5
package/lib/SidebarItem.svelte
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { page } from '$app/state';
|
|
3
3
|
import { copy } from '@axium/client/clipboard';
|
|
4
|
+
import { FormDialog, Icon } from '@axium/client/components';
|
|
4
5
|
import * as icon from '@axium/core/icons';
|
|
5
6
|
import { deleteItem, updateItemMetadata } from '@axium/storage/client';
|
|
6
7
|
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
7
|
-
import { getDirectory,
|
|
8
|
+
import { getDirectory, selection, toggle, toggleRange } from '@axium/storage/sidebar';
|
|
8
9
|
import SidebarItem from './SidebarItem.svelte';
|
|
9
10
|
|
|
10
11
|
let {
|
|
@@ -105,7 +106,7 @@
|
|
|
105
106
|
{#if item.type == 'cas_item'}
|
|
106
107
|
{@render action('download', 'download', 'Download')}
|
|
107
108
|
{/if}
|
|
108
|
-
{#if preferences.debug}
|
|
109
|
+
{#if page.data.session?.user.preferences.debug}
|
|
109
110
|
<div class="action icon-text" onclick={() => copy('text/plain', item.id)}>
|
|
110
111
|
<Icon i="copy" --size="14px" />
|
|
111
112
|
Copy ID
|
package/lib/Usage.svelte
CHANGED
|
@@ -4,21 +4,25 @@
|
|
|
4
4
|
import { getUserStorageInfo } from '@axium/storage/client';
|
|
5
5
|
import type { UserStorageInfo } from '@axium/storage/common';
|
|
6
6
|
|
|
7
|
-
const { userId, info }: { userId
|
|
7
|
+
const { userId, info }: { userId?: string; info?: UserStorageInfo } = $props();
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
|
-
{#
|
|
11
|
-
<p>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
10
|
+
{#if !info && !userId}
|
|
11
|
+
<p>Log in to see storage usage.</p>
|
|
12
|
+
{:else}
|
|
13
|
+
{#await info || getUserStorageInfo(userId!) then info}
|
|
14
|
+
<p>
|
|
15
|
+
<a href="/files/usage">
|
|
16
|
+
<NumberBar
|
|
17
|
+
max={info.limits.user_size * 1_000_000}
|
|
18
|
+
value={info.usage.bytes}
|
|
19
|
+
text="Using {formatBytes(info.usage.bytes)} of {formatBytes(info.limits.user_size * 1_000_000)}"
|
|
20
|
+
--fill="#345"
|
|
21
|
+
/>
|
|
22
|
+
</a>
|
|
23
|
+
</p>
|
|
24
|
+
{:catch error}
|
|
25
|
+
<p>Couldn't load your uploads.</p>
|
|
26
|
+
<p>{error.message}</p>
|
|
27
|
+
{/await}
|
|
28
|
+
{/if}
|
package/lib/sidebar.svelte.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
2
1
|
import { getDirectoryMetadata } from '@axium/storage/client';
|
|
2
|
+
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
3
3
|
import { SvelteSet } from 'svelte/reactivity';
|
|
4
|
-
import { preferenceDefaults, type Preferences } from '@axium/core';
|
|
5
|
-
|
|
6
|
-
export const preferences = $state<Preferences>(preferenceDefaults);
|
|
7
4
|
|
|
8
5
|
export const selection = $state(new SvelteSet());
|
|
9
6
|
|
package/lib/tsconfig.json
CHANGED
package/package.json
CHANGED
package/routes/files/+layout.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { getCurrentSession } from '@axium/client/user';
|
|
2
|
-
import { redirect } from '@sveltejs/kit';
|
|
3
|
-
import type { LayoutLoadEvent, LayoutRouteId } from './$types';
|
|
4
2
|
import type { Session } from '@axium/core';
|
|
3
|
+
import type { LayoutRouteId } from './$types';
|
|
5
4
|
|
|
6
5
|
export const ssr = false;
|
|
7
6
|
|
|
8
|
-
export async function load({ url, route, parent }
|
|
7
|
+
export async function load({ url, route, parent }) {
|
|
9
8
|
let { session }: { session?: Session | null } = await parent();
|
|
10
9
|
|
|
11
10
|
session ||= await getCurrentSession().catch(() => null);
|
|
12
11
|
|
|
13
|
-
if (!session) redirect(307, '/login?after=' + url.pathname);
|
|
14
|
-
|
|
15
12
|
const tabs = [
|
|
16
13
|
{ name: 'files', href: '/files', icon: 'folders', active: route.id.endsWith('/files/[id]') || route.id.endsWith('/files') },
|
|
17
14
|
{ name: 'trash', href: '/files/trash', icon: 'trash', active: route.id.endsWith('/files/trash') },
|
package/routes/files/+page.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getUserStorageRoot } from '@axium/storage/client';
|
|
2
|
-
import
|
|
2
|
+
import { redirect } from '@sveltejs/kit';
|
|
3
3
|
|
|
4
4
|
export const ssr = false;
|
|
5
5
|
|
|
6
|
-
export async function load({ parent }
|
|
6
|
+
export async function load({ parent }) {
|
|
7
7
|
const { session } = await parent();
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
9
|
+
if (!session) redirect(307, '/login?after=/files');
|
|
10
|
+
|
|
11
|
+
return { items: await getUserStorageRoot(session.userId) };
|
|
12
12
|
}
|
|
@@ -4,7 +4,7 @@ import type { StorageItemMetadata } from '@axium/storage/common';
|
|
|
4
4
|
|
|
5
5
|
export const ssr = false;
|
|
6
6
|
|
|
7
|
-
export async function load({
|
|
7
|
+
export async function load({ params }: PageLoadEvent) {
|
|
8
8
|
const item = await getItemMetadata(params.id);
|
|
9
9
|
|
|
10
10
|
let items: StorageItemMetadata[] | undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { LoadEvent } from '@sveltejs/kit';
|
|
2
1
|
import { itemsSharedWith } from '@axium/storage/client';
|
|
2
|
+
import { redirect } from '@sveltejs/kit';
|
|
3
3
|
|
|
4
4
|
export const ssr = false;
|
|
5
5
|
|
|
6
|
-
export async function load({ parent }
|
|
6
|
+
export async function load({ parent }) {
|
|
7
7
|
const { session } = await parent();
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
9
|
+
if (!session) redirect(307, '/login?after=/files/shared');
|
|
10
|
+
|
|
11
|
+
return { items: await itemsSharedWith(session.userId) };
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getUserTrash } from '@axium/storage/client';
|
|
2
|
-
import
|
|
2
|
+
import { redirect } from '@sveltejs/kit';
|
|
3
3
|
|
|
4
4
|
export const ssr = false;
|
|
5
5
|
|
|
6
|
-
export async function load({ parent }
|
|
6
|
+
export async function load({ parent }) {
|
|
7
7
|
const { session } = await parent();
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
9
|
+
if (!session) redirect(307, '/login?after=/files/trash');
|
|
10
|
+
|
|
11
|
+
return { items: await getUserTrash(session.userId) };
|
|
12
12
|
}
|