@axium/storage 0.7.3 → 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 +10 -5
- package/lib/Usage.svelte +20 -16
- package/lib/sidebar.svelte.ts +1 -4
- package/lib/tsconfig.json +2 -1
- package/package.json +2 -2
- 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,9 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { page } from '$app/state';
|
|
3
|
+
import { copy } from '@axium/client/clipboard';
|
|
4
|
+
import { FormDialog, Icon } from '@axium/client/components';
|
|
3
5
|
import * as icon from '@axium/core/icons';
|
|
4
6
|
import { deleteItem, updateItemMetadata } from '@axium/storage/client';
|
|
5
7
|
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
6
|
-
import { getDirectory,
|
|
8
|
+
import { getDirectory, selection, toggle, toggleRange } from '@axium/storage/sidebar';
|
|
7
9
|
import SidebarItem from './SidebarItem.svelte';
|
|
8
10
|
|
|
9
11
|
let {
|
|
@@ -58,7 +60,7 @@
|
|
|
58
60
|
e.preventDefault();
|
|
59
61
|
dialogs[name].showModal();
|
|
60
62
|
}}
|
|
61
|
-
class="action"
|
|
63
|
+
class="action icon-text"
|
|
62
64
|
>
|
|
63
65
|
<Icon {i} --size="14px" />
|
|
64
66
|
{text}
|
|
@@ -104,8 +106,11 @@
|
|
|
104
106
|
{#if item.type == 'cas_item'}
|
|
105
107
|
{@render action('download', 'download', 'Download')}
|
|
106
108
|
{/if}
|
|
107
|
-
{#if preferences.debug}
|
|
108
|
-
<
|
|
109
|
+
{#if page.data.session?.user.preferences.debug}
|
|
110
|
+
<div class="action icon-text" onclick={() => copy('text/plain', item.id)}>
|
|
111
|
+
<Icon i="copy" --size="14px" />
|
|
112
|
+
Copy ID
|
|
113
|
+
</div>
|
|
109
114
|
{/if}
|
|
110
115
|
</div>
|
|
111
116
|
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/storage",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
|
|
5
5
|
"description": "User file storage for Axium",
|
|
6
6
|
"funding": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"build": "tsc"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@axium/client": ">=0.4.
|
|
41
|
+
"@axium/client": ">=0.4.4",
|
|
42
42
|
"@axium/core": ">=0.6.0",
|
|
43
43
|
"@axium/server": ">=0.22.5",
|
|
44
44
|
"@sveltejs/kit": "^2.27.3",
|
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
|
}
|