basic file sharing
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import type { Share } from '~/shared/types/shares';
|
||||
|
||||
export function getApiUrl(path: string): string {
|
||||
const API_BASE_URL = useRuntimeConfig().public.apiBase;
|
||||
return `${API_BASE_URL}/${path}`;
|
||||
@@ -19,3 +21,7 @@ export function routeWithWarrenName(warrenId: string, path: string): string {
|
||||
|
||||
return `${warrenName}${path}`;
|
||||
}
|
||||
|
||||
export function getShareLink(share: Share): string {
|
||||
return `${window.location.origin}/share?id=${share.id}`;
|
||||
}
|
||||
|
||||
@@ -75,3 +75,14 @@ export async function pasteFile(
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
export function downloadFile(fileName: string, href: string) {
|
||||
const anchor = document.createElement('a');
|
||||
|
||||
anchor.href = href;
|
||||
anchor.download = fileName;
|
||||
anchor.rel = 'noopener';
|
||||
anchor.target = '_blank';
|
||||
|
||||
anchor.click();
|
||||
}
|
||||
|
||||
@@ -27,3 +27,13 @@ export function trim(str: string, char: string) {
|
||||
|
||||
return start > 0 || end < str.length ? str.substring(start, end) : str;
|
||||
}
|
||||
|
||||
export function copyToClipboard(content: string): boolean {
|
||||
navigator.clipboard.writeText(content);
|
||||
|
||||
return navigator.clipboard != null;
|
||||
}
|
||||
|
||||
export function capitalize(s: string): string {
|
||||
return s.slice(0, 1).toUpperCase() + s.slice(1);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,12 @@ export type UserWarrenPermissionKey =
|
||||
| 'canListFiles'
|
||||
| 'canReadFiles'
|
||||
| 'canModifyFiles'
|
||||
| 'canDeleteFiles';
|
||||
| 'canDeleteFiles'
|
||||
| 'canListShares'
|
||||
| 'canListShares'
|
||||
| 'canCreateShares'
|
||||
| 'canModifyShares'
|
||||
| 'canDeleteShares';
|
||||
|
||||
export function getUserWarrenPermissions(
|
||||
userWarren: UserWarren
|
||||
@@ -14,6 +19,10 @@ export function getUserWarrenPermissions(
|
||||
['canReadFiles', userWarren.canReadFiles],
|
||||
['canModifyFiles', userWarren.canModifyFiles],
|
||||
['canDeleteFiles', userWarren.canDeleteFiles],
|
||||
['canListShares', userWarren.canListShares],
|
||||
['canCreateShares', userWarren.canCreateShares],
|
||||
['canModifyShares', userWarren.canModifyShares],
|
||||
['canDeleteShares', userWarren.canDeleteShares],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -22,6 +31,10 @@ const PERMISSION_NAMES: Record<UserWarrenPermissionKey, string> = {
|
||||
canReadFiles: 'Read files',
|
||||
canModifyFiles: 'Modify files',
|
||||
canDeleteFiles: 'Delete files',
|
||||
canListShares: 'List shares',
|
||||
canCreateShares: 'Create shares',
|
||||
canModifyShares: 'Modify shares',
|
||||
canDeleteShares: 'Delete shares',
|
||||
};
|
||||
|
||||
export function getUserWarrenPermissionName(
|
||||
|
||||
Reference in New Issue
Block a user