show image preview + single file downloads
This commit is contained in:
@@ -32,12 +32,12 @@ export async function loginUser(
|
||||
const token = data.value.data.token;
|
||||
const { user, expiresAt } = data.value.data;
|
||||
|
||||
useAuthSession().value = {
|
||||
setAuthSession({
|
||||
type: 'WarrenAuth',
|
||||
id: token,
|
||||
user,
|
||||
expiresAt,
|
||||
};
|
||||
});
|
||||
|
||||
toast.success('Login', {
|
||||
description: `Successfully logged in`,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export async function logout() {
|
||||
useAuthSession().value = null;
|
||||
clearAuthSession();
|
||||
useAdminStore().$reset();
|
||||
useWarrenStore().$reset();
|
||||
await navigateTo({
|
||||
|
||||
@@ -57,12 +57,12 @@ export async function oidcLoginUser(
|
||||
const token = data.value.data.token;
|
||||
const { user, expiresAt } = data.value.data;
|
||||
|
||||
useAuthSession().value = {
|
||||
setAuthSession({
|
||||
type: 'WarrenAuth',
|
||||
id: token,
|
||||
user,
|
||||
expiresAt,
|
||||
};
|
||||
});
|
||||
|
||||
toast.success('OpenID Connect', {
|
||||
description: `Successfully logged in`,
|
||||
|
||||
@@ -9,7 +9,9 @@ export function getAuthHeader(): ['authorization', string] | null {
|
||||
export function getApiHeaders(
|
||||
includeAuth: boolean = true
|
||||
): Record<string, string> {
|
||||
const headers: Record<string, string> = {};
|
||||
const headers: Record<string, string> = {
|
||||
cookie: document.cookie,
|
||||
};
|
||||
|
||||
if (includeAuth) {
|
||||
const header = getAuthHeader();
|
||||
|
||||
@@ -301,6 +301,40 @@ export async function fetchFile(
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchFileStream(
|
||||
warrenId: string,
|
||||
path: string,
|
||||
fileName: string
|
||||
): Promise<
|
||||
{ success: true; stream: ReadableStream<Uint8Array> } | { success: false }
|
||||
> {
|
||||
if (!path.endsWith('/')) {
|
||||
path += '/';
|
||||
}
|
||||
path += fileName;
|
||||
|
||||
const { data, error } = await useFetch<ReadableStream<Uint8Array>>(
|
||||
getApiUrl(`warrens/files/cat?warrenId=${warrenId}&path=${path}`),
|
||||
{
|
||||
method: 'GET',
|
||||
headers: getApiHeaders(),
|
||||
responseType: 'stream',
|
||||
cache: 'default',
|
||||
}
|
||||
);
|
||||
|
||||
if (data.value == null || error.value != null) {
|
||||
return {
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
stream: data.value,
|
||||
};
|
||||
}
|
||||
|
||||
export async function moveFile(
|
||||
warrenId: string,
|
||||
currentPath: string,
|
||||
|
||||
Reference in New Issue
Block a user