Redesign file context menus and download archives using global preference
This commit is contained in:
1 parent
6aca927851
commit
042392f611
22 files changed
+530
-363
No files matched your search
@@ -9,3 +9,6 @@
|
|||||||
Настройки интерфейса находятся в разделе «Интерфейс»: внешний вид, работа с файлами, язык и даты. Кнопка «Управление» напротив профиля ведёт через `/auth/account` на `/settings` настроенного провайдера входа. Аватар берётся из проверенного `picture` при входе, преобразуется в небольшую PNG-миниатюру и хранится только в локальной сессии. Загружаются только изображения из `/avatars/` того же провайдера, без перенаправлений и передачи cookies или токенов. Если аватара нет, отображается первая буква имени.
|
Настройки интерфейса находятся в разделе «Интерфейс»: внешний вид, работа с файлами, язык и даты. Кнопка «Управление» напротив профиля ведёт через `/auth/account` на `/settings` настроенного провайдера входа. Аватар берётся из проверенного `picture` при входе, преобразуется в небольшую PNG-миниатюру и хранится только в локальной сессии. Загружаются только изображения из `/avatars/` того же провайдера, без перенаправлений и передачи cookies или токенов. Если аватара нет, отображается первая буква имени.
|
||||||
|
|
||||||
Раздел ссылок называется «Мои ссылки» (My Shares). Уведомления отображаются справа под верхней панелью, учитывают тему и уменьшаются по ширине на мобильных устройствах. Ошибки остаются видимыми до закрытия; успешные действия закрываются автоматически.
|
Раздел ссылок называется «Мои ссылки» (My Shares). Уведомления отображаются справа под верхней панелью, учитывают тему и уменьшаются по ширине на мобильных устройствах. Ошибки остаются видимыми до закрытия; успешные действия закрываются автоматически.
|
||||||
|
Меню действий открывается правой кнопкой на файле или на пустой области, а также кнопкой «Действия» в шапке. ПКМ на пустом месте снимает выделение и показывает действия с текущей папкой. Меню ограничено размерами экрана, прокручивается, поддерживает стрелки и Escape. Верхняя панель освобождена для поиска, доступного и на мобильных устройствах.
|
||||||
|
|
||||||
|
Скачивание начинается сразу. Для папок и нескольких файлов формат задаётся в «Глобальные настройки → Скачивание → Формат архива», по умолчанию ZIP. Настройка действует и на публичные ссылки; отдельный файл передаётся без упаковки. Старые URL с явным параметром algo продолжают работать.
|
||||||
@@ -99,7 +99,7 @@ export function download(format: any, ...files: string[]) {
|
|||||||
url += `algo=${format}&`;
|
url += `algo=${format}&`;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.open(url);
|
window.location.assign(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function post(
|
export async function post(
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export function download(
|
|||||||
url += `token=${token}&`;
|
url += `token=${token}&`;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.open(url);
|
window.location.assign(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDownloadURL(res: Resource, inline = false) {
|
export function getDownloadURL(res: Resource, inline = false) {
|
||||||
|
|||||||
@@ -1,47 +1,99 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<Teleport to="body">
|
||||||
class="context-menu"
|
<div
|
||||||
ref="contextMenu"
|
v-if="show"
|
||||||
v-show="show"
|
ref="contextMenu"
|
||||||
:style="{
|
class="context-menu"
|
||||||
top: `${props.pos.y}px`,
|
role="menu"
|
||||||
left: `${left}px`,
|
tabindex="-1"
|
||||||
}"
|
:style="{ top: top + 'px', left: left + 'px' }"
|
||||||
>
|
@click="hide"
|
||||||
<slot />
|
@contextmenu.prevent.stop
|
||||||
</div>
|
@keydown="keyboard"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch, computed, onUnmounted } from "vue";
|
import { ref, watch, nextTick, onBeforeUnmount } from "vue";
|
||||||
|
|
||||||
const emit = defineEmits(["hide"]);
|
const emit = defineEmits(["hide"]);
|
||||||
const props = defineProps<{ show: boolean; pos: { x: number; y: number } }>();
|
const props = defineProps<{ show: boolean; pos: { x: number; y: number } }>();
|
||||||
const contextMenu = ref<HTMLElement | null>(null);
|
const contextMenu = ref<HTMLElement | null>(null),
|
||||||
|
left = ref(0),
|
||||||
const left = computed(() => {
|
top = ref(0);
|
||||||
return Math.min(
|
let previousFocus: HTMLElement | null = null;
|
||||||
props.pos.x,
|
const hide = () => emit("hide");
|
||||||
window.innerWidth - (contextMenu.value?.clientWidth ?? 0)
|
function outside(event: Event) {
|
||||||
|
if (
|
||||||
|
event.target instanceof Node &&
|
||||||
|
!contextMenu.value?.contains(event.target)
|
||||||
|
)
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
function keyboard(event: KeyboardEvent) {
|
||||||
|
const buttons = Array.from(
|
||||||
|
contextMenu.value?.querySelectorAll<HTMLButtonElement>(
|
||||||
|
"button:not(:disabled)"
|
||||||
|
) || []
|
||||||
);
|
);
|
||||||
});
|
const index = buttons.indexOf(document.activeElement as HTMLButtonElement);
|
||||||
|
if (event.key === "Escape") {
|
||||||
const hideContextMenu = () => {
|
event.preventDefault();
|
||||||
emit("hide");
|
event.stopPropagation();
|
||||||
};
|
hide();
|
||||||
|
previousFocus?.focus();
|
||||||
watch(
|
} else if (event.key === "Tab") hide();
|
||||||
() => props.show,
|
else if (
|
||||||
(val) => {
|
["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key) &&
|
||||||
if (val) {
|
buttons.length
|
||||||
document.addEventListener("click", hideContextMenu);
|
) {
|
||||||
} else {
|
event.preventDefault();
|
||||||
document.removeEventListener("click", hideContextMenu);
|
event.stopPropagation();
|
||||||
}
|
const next =
|
||||||
|
event.key === "Home"
|
||||||
|
? 0
|
||||||
|
: event.key === "End"
|
||||||
|
? buttons.length - 1
|
||||||
|
: (index + (event.key === "ArrowDown" ? 1 : -1) + buttons.length) %
|
||||||
|
buttons.length;
|
||||||
|
buttons[next].focus();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
function removeListeners() {
|
||||||
|
document.removeEventListener("pointerdown", outside, true);
|
||||||
|
window.removeEventListener("scroll", outside, true);
|
||||||
|
window.removeEventListener("resize", hide);
|
||||||
|
}
|
||||||
|
watch(
|
||||||
|
[() => props.show, () => props.pos],
|
||||||
|
async ([visible]) => {
|
||||||
|
removeListeners();
|
||||||
|
if (!visible) return;
|
||||||
|
previousFocus =
|
||||||
|
document.activeElement instanceof HTMLElement
|
||||||
|
? document.activeElement
|
||||||
|
: null;
|
||||||
|
await nextTick();
|
||||||
|
if (!props.show || !contextMenu.value) return;
|
||||||
|
const rect = contextMenu.value.getBoundingClientRect();
|
||||||
|
left.value = Math.max(
|
||||||
|
8,
|
||||||
|
Math.min(props.pos.x, window.innerWidth - rect.width - 8)
|
||||||
|
);
|
||||||
|
top.value = Math.max(
|
||||||
|
8,
|
||||||
|
Math.min(props.pos.y, window.innerHeight - rect.height - 8)
|
||||||
|
);
|
||||||
|
const buttons =
|
||||||
|
contextMenu.value.querySelectorAll<HTMLButtonElement>("button");
|
||||||
|
buttons.forEach((button) => button.setAttribute("role", "menuitem"));
|
||||||
|
buttons[0]?.focus({ preventScroll: true });
|
||||||
|
document.addEventListener("pointerdown", outside, true);
|
||||||
|
window.addEventListener("scroll", outside, true);
|
||||||
|
window.addEventListener("resize", hide);
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
onBeforeUnmount(removeListeners);
|
||||||
onUnmounted(() => {
|
|
||||||
document.removeEventListener("click", hideContextMenu);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Action
|
<Action
|
||||||
|
v-if="!hideTheme"
|
||||||
icon="contrast"
|
icon="contrast"
|
||||||
:label="t('sso.toggleTheme')"
|
:label="t('sso.toggleTheme')"
|
||||||
@action="toggleTheme"
|
@action="toggleTheme"
|
||||||
@@ -59,6 +60,7 @@ import { useI18n } from "vue-i18n";
|
|||||||
defineProps<{
|
defineProps<{
|
||||||
showLogo?: boolean;
|
showLogo?: boolean;
|
||||||
showMenu?: boolean;
|
showMenu?: boolean;
|
||||||
|
hideTheme?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const layoutStore = useLayoutStore();
|
const layoutStore = useLayoutStore();
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="card floating" id="download">
|
|
||||||
<div class="card-title">
|
|
||||||
<h2>{{ t("prompts.download") }}</h2>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card-content">
|
|
||||||
<p>{{ t("prompts.downloadMessage") }}</p>
|
|
||||||
|
|
||||||
<button
|
|
||||||
id="focus-prompt"
|
|
||||||
v-for="(ext, format) in formats"
|
|
||||||
:key="format"
|
|
||||||
class="button button--block"
|
|
||||||
@click="layoutStore.currentPrompt?.confirm(format)"
|
|
||||||
>
|
|
||||||
{{ ext }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { useI18n } from "vue-i18n";
|
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
|
||||||
|
|
||||||
const layoutStore = useLayoutStore();
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const formats = {
|
|
||||||
zip: "zip",
|
|
||||||
tar: "tar",
|
|
||||||
targz: "tar.gz",
|
|
||||||
tarbz2: "tar.bz2",
|
|
||||||
tarxz: "tar.xz",
|
|
||||||
tarlz4: "tar.lz4",
|
|
||||||
tarsz: "tar.sz",
|
|
||||||
tarbr: "tar.br",
|
|
||||||
tarzst: "tar.zst",
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -16,7 +16,6 @@ const Help = defineAsyncComponent(() => import("./Help.vue"));
|
|||||||
const Info = defineAsyncComponent(() => import("./Info.vue"));
|
const Info = defineAsyncComponent(() => import("./Info.vue"));
|
||||||
const Delete = defineAsyncComponent(() => import("./Delete.vue"));
|
const Delete = defineAsyncComponent(() => import("./Delete.vue"));
|
||||||
const DeleteUser = defineAsyncComponent(() => import("./DeleteUser.vue"));
|
const DeleteUser = defineAsyncComponent(() => import("./DeleteUser.vue"));
|
||||||
const Download = defineAsyncComponent(() => import("./Download.vue"));
|
|
||||||
const Rename = defineAsyncComponent(() => import("./Rename.vue"));
|
const Rename = defineAsyncComponent(() => import("./Rename.vue"));
|
||||||
const Move = defineAsyncComponent(() => import("./Move.vue"));
|
const Move = defineAsyncComponent(() => import("./Move.vue"));
|
||||||
const Copy = defineAsyncComponent(() => import("./Copy.vue"));
|
const Copy = defineAsyncComponent(() => import("./Copy.vue"));
|
||||||
@@ -49,7 +48,6 @@ const components = new Map<string, any>([
|
|||||||
["copy", Copy],
|
["copy", Copy],
|
||||||
["newFile", NewFile],
|
["newFile", NewFile],
|
||||||
["newDir", NewDir],
|
["newDir", NewDir],
|
||||||
["download", Download],
|
|
||||||
["replace", Replace],
|
["replace", Replace],
|
||||||
["share", Share],
|
["share", Share],
|
||||||
["upload", Upload],
|
["upload", Upload],
|
||||||
|
|||||||
@@ -1,21 +1,111 @@
|
|||||||
.context-menu {
|
.context-menu {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
|
padding: 6px;
|
||||||
|
min-width: 230px;
|
||||||
|
max-width: min(300px, calc(100vw - 16px));
|
||||||
|
max-height: calc(100vh - 16px);
|
||||||
|
max-height: calc(100dvh - 16px);
|
||||||
|
overflow-y: auto;
|
||||||
|
border-radius: 12px;
|
||||||
background: var(--surfacePrimary);
|
background: var(--surfacePrimary);
|
||||||
min-width: 180px;
|
color: var(--textPrimary);
|
||||||
max-width: 220px;
|
border: 1px solid var(--borderPrimary);
|
||||||
border: 1px solid var(--borderSecondary);
|
box-shadow: 0 12px 40px #0004;
|
||||||
box-shadow: 0 2px 4px var(--borderPrimary);
|
z-index: 12000;
|
||||||
z-index: 999;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu .action {
|
.context-menu .action {
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 0;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 38px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
border-radius: 7px;
|
||||||
|
color: var(--textPrimary);
|
||||||
|
text-align: start;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
.context-menu .action .app-icon {
|
||||||
|
padding: 0;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
font-size: 20px;
|
||||||
|
color: var(--textSecondary);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.context-menu .action > span:not(.counter) {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.context-menu .action:hover,
|
||||||
|
.context-menu .action:focus-visible {
|
||||||
|
background: var(--hover);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.context-menu .action:focus-visible {
|
||||||
|
box-shadow: inset 0 0 0 1px var(--blue);
|
||||||
|
}
|
||||||
|
.context-menu .context-danger,
|
||||||
|
.context-menu .context-danger .app-icon {
|
||||||
|
color: var(--red);
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu .action .counter {
|
.context-menu .action .counter {
|
||||||
left: 1.75em;
|
position: static;
|
||||||
|
display: inline-block;
|
||||||
|
margin-inline-start: auto;
|
||||||
|
font-size: 10px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border: 0;
|
||||||
|
min-width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
.context-menu-separator {
|
||||||
|
height: 1px;
|
||||||
|
margin: 5px 6px;
|
||||||
|
background: var(--borderPrimary);
|
||||||
|
}
|
||||||
|
.file-listing-workspace {
|
||||||
|
min-height: calc(100vh - 5em);
|
||||||
|
}
|
||||||
|
.file-browser-header #search:not(.active) {
|
||||||
|
display: block;
|
||||||
|
flex: 1 1 520px;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 640px;
|
||||||
|
height: 40px;
|
||||||
|
margin-inline-start: auto;
|
||||||
|
}
|
||||||
|
.file-browser-header #dropdown {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.workspace-actions-button {
|
||||||
|
background: var(--hover);
|
||||||
|
color: var(--textPrimary);
|
||||||
|
border: 1px solid var(--borderPrimary);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
margin-inline-start: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.file-browser-header .workspace-brand {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.file-browser-header #search:not(.active) {
|
||||||
|
flex-basis: 0;
|
||||||
|
}
|
||||||
|
.file-browser-header #search input {
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
.workspace-actions-button {
|
||||||
|
margin-inline-start: 6px;
|
||||||
|
padding: 10px 8px;
|
||||||
|
}
|
||||||
|
.context-menu .action {
|
||||||
|
min-height: 42px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -252,10 +252,6 @@ body.rtl .card .card-action {
|
|||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card#download {
|
|
||||||
max-width: 15em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card#share input,
|
.card#share input,
|
||||||
.card#share select,
|
.card#share select,
|
||||||
.card#share input::-webkit-inner-spin-button,
|
.card#share input::-webkit-inner-spin-button,
|
||||||
|
|||||||
@@ -282,7 +282,10 @@
|
|||||||
"username": "Username",
|
"username": "Username",
|
||||||
"users": "Users",
|
"users": "Users",
|
||||||
"currentPassword": "Your Current Password",
|
"currentPassword": "Your Current Password",
|
||||||
"showPreviews": "Show previews"
|
"showPreviews": "Show previews",
|
||||||
|
"downloadsTitle": "Downloads",
|
||||||
|
"downloadArchiveFormat": "Archive format",
|
||||||
|
"downloadArchiveHint": "Folders and multiple selected files download immediately using this format. A single file downloads without an archive."
|
||||||
},
|
},
|
||||||
"sidebar": {
|
"sidebar": {
|
||||||
"diskUsed": "{used} of {total} used",
|
"diskUsed": "{used} of {total} used",
|
||||||
@@ -379,7 +382,11 @@
|
|||||||
"pinCurrent": "Pin current folder",
|
"pinCurrent": "Pin current folder",
|
||||||
"unpin": "Remove bookmark",
|
"unpin": "Remove bookmark",
|
||||||
"folders": "Folders",
|
"folders": "Folders",
|
||||||
"retry": "Retry"
|
"retry": "Retry",
|
||||||
|
"actions": "Actions",
|
||||||
|
"paste": "Paste",
|
||||||
|
"refresh": "Refresh",
|
||||||
|
"downloadFolderArchive": "Download folder archive"
|
||||||
},
|
},
|
||||||
"preferences": {
|
"preferences": {
|
||||||
"appearance": "Appearance",
|
"appearance": "Appearance",
|
||||||
|
|||||||
@@ -279,7 +279,10 @@
|
|||||||
"username": "Имя пользователя",
|
"username": "Имя пользователя",
|
||||||
"users": "Пользователи",
|
"users": "Пользователи",
|
||||||
"currentPassword": "Your Current Password",
|
"currentPassword": "Your Current Password",
|
||||||
"showPreviews": "Показ превью"
|
"showPreviews": "Показ превью",
|
||||||
|
"downloadsTitle": "Скачивание",
|
||||||
|
"downloadArchiveFormat": "Формат архива",
|
||||||
|
"downloadArchiveHint": "Папки и несколько выбранных файлов скачиваются сразу в этом формате. Отдельный файл скачивается без архива."
|
||||||
},
|
},
|
||||||
"sidebar": {
|
"sidebar": {
|
||||||
"diskUsed": "Занято {used} из {total}",
|
"diskUsed": "Занято {used} из {total}",
|
||||||
@@ -376,7 +379,11 @@
|
|||||||
"pinCurrent": "Закрепить текущую папку",
|
"pinCurrent": "Закрепить текущую папку",
|
||||||
"unpin": "Убрать закладку",
|
"unpin": "Убрать закладку",
|
||||||
"folders": "Папки",
|
"folders": "Папки",
|
||||||
"retry": "Повторить"
|
"retry": "Повторить",
|
||||||
|
"actions": "Действия",
|
||||||
|
"paste": "Вставить",
|
||||||
|
"refresh": "Обновить",
|
||||||
|
"downloadFolderArchive": "Скачать папку архивом"
|
||||||
},
|
},
|
||||||
"preferences": {
|
"preferences": {
|
||||||
"appearance": "Внешний вид",
|
"appearance": "Внешний вид",
|
||||||
|
|||||||
Vendored
+1
@@ -1,4 +1,5 @@
|
|||||||
interface ISettings {
|
interface ISettings {
|
||||||
|
downloadArchiveFormat: string;
|
||||||
signup: boolean;
|
signup: boolean;
|
||||||
createUserDir: boolean;
|
createUserDir: boolean;
|
||||||
hideLoginButton: boolean;
|
hideLoginButton: boolean;
|
||||||
|
|||||||
@@ -110,7 +110,7 @@
|
|||||||
<a :href="link" class="button share-download-primary"
|
<a :href="link" class="button share-download-primary"
|
||||||
><AppIcon name="download" /><span>{{
|
><AppIcon name="download" /><span>{{
|
||||||
req.isDir
|
req.isDir
|
||||||
? t("sso.downloadFolderZip")
|
? t("explorer.downloadFolderArchive")
|
||||||
: t("download.downloadFile")
|
: t("download.downloadFile")
|
||||||
}}</span></a
|
}}</span></a
|
||||||
>
|
>
|
||||||
@@ -322,34 +322,9 @@ const isSingleFile = () =>
|
|||||||
|
|
||||||
const download = () => {
|
const download = () => {
|
||||||
if (!req.value) return false;
|
if (!req.value) return false;
|
||||||
|
const files = fileStore.selected.map((i) => req.value!.items[i].path);
|
||||||
if (isSingleFile()) {
|
if (!files.length) files.push(req.value.path);
|
||||||
api.download(
|
api.download(null, hash.value, token.value, ...files);
|
||||||
null,
|
|
||||||
hash.value,
|
|
||||||
token.value,
|
|
||||||
req.value.items[fileStore.selected[0]].path
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutStore.showHover({
|
|
||||||
prompt: "download",
|
|
||||||
confirm: (format: DownloadFormat) => {
|
|
||||||
if (req.value === null) return false;
|
|
||||||
layoutStore.closeHovers();
|
|
||||||
|
|
||||||
const files: string[] = [];
|
|
||||||
|
|
||||||
for (const i of fileStore.selected) {
|
|
||||||
files.push(req.value.items[i].path);
|
|
||||||
}
|
|
||||||
|
|
||||||
api.download(format, hash.value, token.value, ...files);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,128 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="file-listing-workspace" @contextmenu="showContextMenu">
|
||||||
<header-bar showMenu showLogo>
|
<header-bar showMenu showLogo hideTheme class="file-browser-header">
|
||||||
<search />
|
<search />
|
||||||
<title />
|
<button
|
||||||
<action
|
class="workspace-actions-button"
|
||||||
class="search-button"
|
type="button"
|
||||||
icon="search"
|
aria-haspopup="menu"
|
||||||
:label="t('buttons.search')"
|
:aria-expanded="isContextMenuVisible"
|
||||||
@action="openSearch()"
|
@click.stop="openActions"
|
||||||
/>
|
>
|
||||||
|
{{ t("explorer.actions")
|
||||||
<template #actions>
|
}}<span v-if="fileStore.selectedCount">
|
||||||
<template v-if="!isMobile">
|
({{ fileStore.selectedCount }})</span
|
||||||
<action
|
>
|
||||||
v-if="headerButtons.share"
|
</button>
|
||||||
icon="share"
|
|
||||||
:label="t('buttons.share')"
|
|
||||||
show="share"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.rename"
|
|
||||||
icon="mode_edit"
|
|
||||||
:label="t('buttons.rename')"
|
|
||||||
show="rename"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.copy"
|
|
||||||
id="copy-button"
|
|
||||||
icon="content_copy"
|
|
||||||
:label="t('buttons.copyFile')"
|
|
||||||
show="copy"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.move"
|
|
||||||
id="move-button"
|
|
||||||
icon="forward"
|
|
||||||
:label="t('buttons.moveFile')"
|
|
||||||
show="move"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.delete"
|
|
||||||
id="delete-button"
|
|
||||||
icon="delete"
|
|
||||||
:label="t('buttons.delete')"
|
|
||||||
show="delete"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.shell"
|
|
||||||
icon="code"
|
|
||||||
:label="t('buttons.shell')"
|
|
||||||
@action="layoutStore.toggleShell"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
:icon="viewIcon"
|
|
||||||
:label="t('buttons.switchView')"
|
|
||||||
@action="switchView"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.download"
|
|
||||||
icon="file_download"
|
|
||||||
:label="t('buttons.download')"
|
|
||||||
@action="download"
|
|
||||||
:counter="fileStore.selectedCount"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.upload"
|
|
||||||
icon="file_upload"
|
|
||||||
id="upload-button"
|
|
||||||
:label="t('buttons.upload')"
|
|
||||||
@action="uploadFunc"
|
|
||||||
/>
|
|
||||||
<action icon="info" :label="t('buttons.info')" show="info" />
|
|
||||||
<action
|
|
||||||
icon="check_circle"
|
|
||||||
:label="t('buttons.selectMultiple')"
|
|
||||||
@action="toggleMultipleSelection"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</header-bar>
|
</header-bar>
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="isMobile"
|
|
||||||
id="file-selection"
|
|
||||||
:class="{
|
|
||||||
'file-selection-margin-bottom': fileStore.multiple,
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<span v-if="fileStore.selectedCount > 0">
|
|
||||||
{{ t("prompts.filesSelected", fileStore.selectedCount) }}
|
|
||||||
</span>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.share"
|
|
||||||
icon="share"
|
|
||||||
:label="t('buttons.share')"
|
|
||||||
show="share"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.rename"
|
|
||||||
icon="mode_edit"
|
|
||||||
:label="t('buttons.rename')"
|
|
||||||
show="rename"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.copy"
|
|
||||||
icon="content_copy"
|
|
||||||
:label="t('buttons.copyFile')"
|
|
||||||
show="copy"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.move"
|
|
||||||
icon="forward"
|
|
||||||
:label="t('buttons.moveFile')"
|
|
||||||
show="move"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.delete"
|
|
||||||
icon="delete"
|
|
||||||
:label="t('buttons.delete')"
|
|
||||||
show="delete"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="layoutStore.loading">
|
<div v-if="layoutStore.loading">
|
||||||
<h2 class="message delayed">
|
<h2 class="message delayed">
|
||||||
<div class="spinner">
|
<div class="spinner">
|
||||||
@@ -215,11 +108,7 @@
|
|||||||
<h2 data-clear-on-click="true" v-if="fileStore.req?.numDirs ?? false">
|
<h2 data-clear-on-click="true" v-if="fileStore.req?.numDirs ?? false">
|
||||||
{{ t("files.folders") }}
|
{{ t("files.folders") }}
|
||||||
</h2>
|
</h2>
|
||||||
<div
|
<div v-if="fileStore.req?.numDirs ?? false" data-clear-on-click="true">
|
||||||
v-if="fileStore.req?.numDirs ?? false"
|
|
||||||
data-clear-on-click="true"
|
|
||||||
@contextmenu="showContextMenu"
|
|
||||||
>
|
|
||||||
<item
|
<item
|
||||||
v-for="item in dirs"
|
v-for="item in dirs"
|
||||||
:key="base64(item.name)"
|
:key="base64(item.name)"
|
||||||
@@ -238,11 +127,7 @@
|
|||||||
<h2 data-clear-on-click="true" v-if="fileStore.req?.numFiles ?? false">
|
<h2 data-clear-on-click="true" v-if="fileStore.req?.numFiles ?? false">
|
||||||
{{ t("files.files") }}
|
{{ t("files.files") }}
|
||||||
</h2>
|
</h2>
|
||||||
<div
|
<div v-if="fileStore.req?.numFiles ?? false" data-clear-on-click="true">
|
||||||
v-if="fileStore.req?.numFiles ?? false"
|
|
||||||
data-clear-on-click="true"
|
|
||||||
@contextmenu="showContextMenu"
|
|
||||||
>
|
|
||||||
<item
|
<item
|
||||||
v-for="item in files"
|
v-for="item in files"
|
||||||
:key="base64(item.name)"
|
:key="base64(item.name)"
|
||||||
@@ -257,53 +142,6 @@
|
|||||||
>
|
>
|
||||||
</item>
|
</item>
|
||||||
</div>
|
</div>
|
||||||
<context-menu
|
|
||||||
:show="isContextMenuVisible"
|
|
||||||
:pos="contextMenuPos"
|
|
||||||
@hide="hideContextMenu"
|
|
||||||
>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.share"
|
|
||||||
icon="share"
|
|
||||||
:label="t('buttons.share')"
|
|
||||||
show="share"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.rename"
|
|
||||||
icon="mode_edit"
|
|
||||||
:label="t('buttons.rename')"
|
|
||||||
show="rename"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.copy"
|
|
||||||
id="copy-button"
|
|
||||||
icon="content_copy"
|
|
||||||
:label="t('buttons.copyFile')"
|
|
||||||
show="copy"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.move"
|
|
||||||
id="move-button"
|
|
||||||
icon="forward"
|
|
||||||
:label="t('buttons.moveFile')"
|
|
||||||
show="move"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.delete"
|
|
||||||
id="delete-button"
|
|
||||||
icon="delete"
|
|
||||||
:label="t('buttons.delete')"
|
|
||||||
show="delete"
|
|
||||||
/>
|
|
||||||
<action
|
|
||||||
v-if="headerButtons.download"
|
|
||||||
icon="file_download"
|
|
||||||
:label="t('buttons.download')"
|
|
||||||
@action="download"
|
|
||||||
:counter="fileStore.selectedCount"
|
|
||||||
/>
|
|
||||||
<action icon="info" :label="t('buttons.info')" show="info" />
|
|
||||||
</context-menu>
|
|
||||||
|
|
||||||
<input
|
<input
|
||||||
style="display: none"
|
style="display: none"
|
||||||
@@ -336,6 +174,106 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<context-menu
|
||||||
|
:show="isContextMenuVisible"
|
||||||
|
:pos="contextMenuPos"
|
||||||
|
@hide="hideContextMenu"
|
||||||
|
>
|
||||||
|
<action
|
||||||
|
v-if="headerButtons.share"
|
||||||
|
icon="share"
|
||||||
|
:label="t('buttons.share')"
|
||||||
|
show="share"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="headerButtons.rename"
|
||||||
|
icon="mode_edit"
|
||||||
|
:label="t('buttons.rename')"
|
||||||
|
show="rename"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="headerButtons.copy"
|
||||||
|
id="copy-button"
|
||||||
|
icon="content_copy"
|
||||||
|
:label="t('buttons.copyFile')"
|
||||||
|
show="copy"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="headerButtons.move"
|
||||||
|
id="move-button"
|
||||||
|
icon="forward"
|
||||||
|
:label="t('buttons.moveFile')"
|
||||||
|
show="move"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="headerButtons.delete"
|
||||||
|
id="delete-button"
|
||||||
|
class="context-danger"
|
||||||
|
icon="delete"
|
||||||
|
:label="t('buttons.delete')"
|
||||||
|
show="delete"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="headerButtons.download"
|
||||||
|
icon="file_download"
|
||||||
|
:label="t('buttons.download')"
|
||||||
|
@action="download"
|
||||||
|
:counter="fileStore.selectedCount"
|
||||||
|
/>
|
||||||
|
<div class="context-menu-separator" v-if="fileStore.selectedCount" />
|
||||||
|
<action
|
||||||
|
v-if="authStore.user?.perm.create"
|
||||||
|
icon="create_new_folder"
|
||||||
|
:label="t('sidebar.newFolder')"
|
||||||
|
show="newDir"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="authStore.user?.perm.create"
|
||||||
|
icon="note_add"
|
||||||
|
:label="t('sidebar.newFile')"
|
||||||
|
show="newFile"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="headerButtons.upload"
|
||||||
|
icon="upload"
|
||||||
|
:label="t('buttons.upload')"
|
||||||
|
@action="uploadFunc"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="canPaste"
|
||||||
|
icon="paste"
|
||||||
|
:label="t('explorer.paste')"
|
||||||
|
@action="pasteFromMenu"
|
||||||
|
/>
|
||||||
|
<div class="context-menu-separator" />
|
||||||
|
<action
|
||||||
|
:icon="viewIcon"
|
||||||
|
:label="t('buttons.switchView')"
|
||||||
|
@action="switchView"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
icon="check_circle"
|
||||||
|
:label="t('buttons.selectMultiple')"
|
||||||
|
@action="toggleMultipleSelection"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
icon="refresh"
|
||||||
|
:label="t('explorer.refresh')"
|
||||||
|
@action="refreshFolder"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
v-if="headerButtons.shell"
|
||||||
|
icon="code"
|
||||||
|
:label="t('buttons.shell')"
|
||||||
|
@action="layoutStore.toggleShell"
|
||||||
|
/>
|
||||||
|
<action
|
||||||
|
icon="contrast"
|
||||||
|
:label="t('sso.toggleTheme')"
|
||||||
|
@action="toggleTheme"
|
||||||
|
/>
|
||||||
|
<action icon="info" :label="t('buttons.info')" show="info" />
|
||||||
|
</context-menu>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -346,6 +284,7 @@ import { useFileStore } from "@/stores/file";
|
|||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
|
|
||||||
import { users, files as api } from "@/api";
|
import { users, files as api } from "@/api";
|
||||||
|
import { toggleTheme } from "@/utils/theme";
|
||||||
import { enableExec } from "@/utils/constants";
|
import { enableExec } from "@/utils/constants";
|
||||||
import * as upload from "@/utils/upload";
|
import * as upload from "@/utils/upload";
|
||||||
import buttons from "@/utils/buttons";
|
import buttons from "@/utils/buttons";
|
||||||
@@ -375,7 +314,7 @@ import { removePrefix } from "@/api/utils";
|
|||||||
const showLimit = ref<number>(50);
|
const showLimit = ref<number>(50);
|
||||||
const columnWidth = ref<number>(280);
|
const columnWidth = ref<number>(280);
|
||||||
const dragCounter = ref<number>(0);
|
const dragCounter = ref<number>(0);
|
||||||
const width = ref<number>(window.innerWidth);
|
|
||||||
const itemWeight = ref<number>(0);
|
const itemWeight = ref<number>(0);
|
||||||
const isContextMenuVisible = ref<boolean>(false);
|
const isContextMenuVisible = ref<boolean>(false);
|
||||||
const contextMenuPos = ref<{ x: number; y: number }>({ x: 0, y: 0 });
|
const contextMenuPos = ref<{ x: number; y: number }>({ x: 0, y: 0 });
|
||||||
@@ -490,10 +429,6 @@ const headerButtons = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const isMobile = computed(() => {
|
|
||||||
return width.value <= 736;
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(req, () => {
|
watch(req, () => {
|
||||||
// Reset the show value
|
// Reset the show value
|
||||||
showLimit.value = 50;
|
showLimit.value = 50;
|
||||||
@@ -611,7 +546,7 @@ const keyEvent = (event: KeyboardEvent) => {
|
|||||||
break;
|
break;
|
||||||
case "s":
|
case "s":
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
document.getElementById("download-button")?.click();
|
if (authStore.user?.perm.download) download();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -622,7 +557,11 @@ const preventDefault = (event: Event) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const copyCut = (event: Event | KeyboardEvent): void => {
|
const copyCut = (event: Event | KeyboardEvent): void => {
|
||||||
if ((event.target as HTMLElement).tagName?.toLowerCase() === "input") return;
|
if (
|
||||||
|
event.target instanceof HTMLElement &&
|
||||||
|
event.target.closest("input, textarea, [contenteditable=true]")
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
if (fileStore.req === null) return;
|
if (fileStore.req === null) return;
|
||||||
|
|
||||||
@@ -650,7 +589,11 @@ const copyCut = (event: Event | KeyboardEvent): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const paste = async (event: Event) => {
|
const paste = async (event: Event) => {
|
||||||
if ((event.target as HTMLElement).tagName?.toLowerCase() === "input") return;
|
if (
|
||||||
|
event.target instanceof HTMLElement &&
|
||||||
|
event.target.closest("input, textarea, [contenteditable=true]")
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
// TODO router location should it be
|
// TODO router location should it be
|
||||||
const items: any[] = [];
|
const items: any[] = [];
|
||||||
@@ -961,10 +904,6 @@ const sort = async (by: string) => {
|
|||||||
fileStore.reload = true;
|
fileStore.reload = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const openSearch = () => {
|
|
||||||
layoutStore.showHover("search");
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleMultipleSelection = () => {
|
const toggleMultipleSelection = () => {
|
||||||
fileStore.toggleMultiple();
|
fileStore.toggleMultiple();
|
||||||
layoutStore.closeHovers();
|
layoutStore.closeHovers();
|
||||||
@@ -972,7 +911,6 @@ const toggleMultipleSelection = () => {
|
|||||||
|
|
||||||
const windowsResize = throttle(() => {
|
const windowsResize = throttle(() => {
|
||||||
columnsResize();
|
columnsResize();
|
||||||
width.value = window.innerWidth;
|
|
||||||
|
|
||||||
// Listing element is not displayed
|
// Listing element is not displayed
|
||||||
if (listing.value == null) return;
|
if (listing.value == null) return;
|
||||||
@@ -985,34 +923,11 @@ const windowsResize = throttle(() => {
|
|||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
const download = () => {
|
const download = () => {
|
||||||
if (fileStore.req === null) return;
|
if (!fileStore.req || !authStore.user?.perm.download) return;
|
||||||
|
const files = fileStore.selectedCount
|
||||||
if (
|
? fileStore.selected.map((i) => fileStore.req!.items[i].url)
|
||||||
fileStore.selectedCount === 1 &&
|
: [route.path];
|
||||||
!fileStore.req.items[fileStore.selected[0]].isDir
|
api.download(null, ...files);
|
||||||
) {
|
|
||||||
api.download(null, fileStore.req.items[fileStore.selected[0]].url);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutStore.showHover({
|
|
||||||
prompt: "download",
|
|
||||||
confirm: (format: any) => {
|
|
||||||
layoutStore.closeHovers();
|
|
||||||
|
|
||||||
const files = [];
|
|
||||||
|
|
||||||
if (fileStore.selectedCount > 0 && fileStore.req !== null) {
|
|
||||||
for (const i of fileStore.selected) {
|
|
||||||
files.push(fileStore.req.items[i].url);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
files.push(route.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
api.download(format, ...files);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const switchView = async () => {
|
const switchView = async () => {
|
||||||
@@ -1099,13 +1014,32 @@ const revealPreviousItem = () => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const canPaste = computed(
|
||||||
|
() =>
|
||||||
|
!!authStore.user?.perm.create &&
|
||||||
|
clipboardStore.items.length > 0 &&
|
||||||
|
(clipboardStore.key !== "x" || !!authStore.user?.perm.rename)
|
||||||
|
);
|
||||||
|
const pasteFromMenu = () => paste(new Event("paste"));
|
||||||
|
const refreshFolder = () => {
|
||||||
|
fileStore.reload = true;
|
||||||
|
};
|
||||||
|
const openActions = (event: MouseEvent) => {
|
||||||
|
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
|
||||||
|
contextMenuPos.value = { x: rect.right, y: rect.bottom + 6 };
|
||||||
|
isContextMenuVisible.value = !isContextMenuVisible.value;
|
||||||
|
};
|
||||||
const showContextMenu = (event: MouseEvent) => {
|
const showContextMenu = (event: MouseEvent) => {
|
||||||
|
const target = event.target;
|
||||||
|
if (
|
||||||
|
!(target instanceof Element) ||
|
||||||
|
target.closest("header, .context-menu, input, textarea")
|
||||||
|
)
|
||||||
|
return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
if (!target.closest(".item:not(.header)")) fileStore.selected = [];
|
||||||
isContextMenuVisible.value = true;
|
isContextMenuVisible.value = true;
|
||||||
contextMenuPos.value = {
|
contextMenuPos.value = { x: event.clientX, y: event.clientY };
|
||||||
x: event.clientX + 8,
|
|
||||||
y: event.clientY + Math.floor(window.scrollY),
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const hideContextMenu = () => {
|
const hideContextMenu = () => {
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
{{ $t("files.noPreview") }}
|
{{ $t("files.noPreview") }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a target="_blank" :href="downloadUrl" class="button button--flat">
|
<a :href="downloadUrl" class="button button--flat">
|
||||||
<div>
|
<div>
|
||||||
<AppIcon name="file_download" />{{ $t("buttons.download") }}
|
<AppIcon name="file_download" />{{ $t("buttons.download") }}
|
||||||
</div>
|
</div>
|
||||||
@@ -529,7 +529,7 @@ const close = () => {
|
|||||||
router.push({ path: uri });
|
router.push({ path: uri });
|
||||||
};
|
};
|
||||||
|
|
||||||
const download = () => window.open(downloadUrl.value);
|
const download = () => window.location.assign(downloadUrl.value);
|
||||||
|
|
||||||
const editAsText = () => {
|
const editAsText = () => {
|
||||||
router.push({ path: route.path, query: { edit: "true" } });
|
router.push({ path: route.path, query: { edit: "true" } });
|
||||||
|
|||||||
@@ -6,6 +6,22 @@
|
|||||||
@submit.prevent="save"
|
@submit.prevent="save"
|
||||||
>
|
>
|
||||||
<div class="settings-grid">
|
<div class="settings-grid">
|
||||||
|
<section class="card settings-section">
|
||||||
|
<h2><AppIcon name="archive" />{{ t("settings.downloadsTitle") }}</h2>
|
||||||
|
<label class="settings-field"
|
||||||
|
>{{ t("settings.downloadArchiveFormat") }}
|
||||||
|
<select class="input" v-model="settings.downloadArchiveFormat">
|
||||||
|
<option
|
||||||
|
v-for="(label, value) in archiveFormats"
|
||||||
|
:key="value"
|
||||||
|
:value="value"
|
||||||
|
>
|
||||||
|
{{ label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<p class="field-hint">{{ t("settings.downloadArchiveHint") }}</p>
|
||||||
|
</section>
|
||||||
<section class="card settings-section">
|
<section class="card settings-section">
|
||||||
<h2><AppIcon name="palette" />{{ t("preferences.appearance") }}</h2>
|
<h2><AppIcon name="palette" />{{ t("preferences.appearance") }}</h2>
|
||||||
<label class="settings-field"
|
<label class="settings-field"
|
||||||
@@ -103,6 +119,17 @@
|
|||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
const archiveFormats = {
|
||||||
|
zip: "ZIP",
|
||||||
|
tar: "TAR",
|
||||||
|
targz: "TAR.GZ",
|
||||||
|
tarbz2: "TAR.BZ2",
|
||||||
|
tarxz: "TAR.XZ",
|
||||||
|
tarlz4: "TAR.LZ4",
|
||||||
|
tarsz: "TAR.SZ",
|
||||||
|
tarbr: "TAR.BR",
|
||||||
|
tarzst: "TAR.ZST",
|
||||||
|
};
|
||||||
import { settings as api } from "@/api";
|
import { settings as api } from "@/api";
|
||||||
import { StatusError } from "@/api/utils";
|
import { StatusError } from "@/api/utils";
|
||||||
import Rules from "@/components/settings/Rules.vue";
|
import Rules from "@/components/settings/Rules.vue";
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package fbhttp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"archive/tar"
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filebrowser/filebrowser/v2/settings"
|
||||||
|
"github.com/filebrowser/filebrowser/v2/users"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDownloadUsesConfiguredArchiveFormat(t *testing.T) {
|
||||||
|
root := t.TempDir()
|
||||||
|
if err := os.Mkdir(filepath.Join(root, "folder"), 0750); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(filepath.Join(root, "folder", "note.txt"), []byte("hello"), 0640); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
key := []byte("archive-test-key")
|
||||||
|
perm := users.Permissions{Download: true}
|
||||||
|
store := scopedUserStorage(t, root, perm, key)
|
||||||
|
if err := store.Settings.Save(&settings.Settings{Key: key, DownloadArchiveFormat: "tar"}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
signed := signToken(t, perm, key)
|
||||||
|
request := authorizeTestRequest(httptest.NewRequest(http.MethodGet, "/folder", nil), signed)
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
handle(rawHandler, "", store, &settings.Server{}).ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != http.StatusOK || !strings.Contains(recorder.Header().Get("Content-Disposition"), ".tar") {
|
||||||
|
t.Fatalf("status=%d disposition=%s", recorder.Code, recorder.Header().Get("Content-Disposition"))
|
||||||
|
}
|
||||||
|
reader := tar.NewReader(bytes.NewReader(recorder.Body.Bytes()))
|
||||||
|
found := false
|
||||||
|
for {
|
||||||
|
header, err := reader.Next()
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if strings.HasSuffix(header.Name, "note.txt") {
|
||||||
|
data, err := io.ReadAll(reader)
|
||||||
|
if err != nil || string(data) != "hello" {
|
||||||
|
t.Fatalf("unexpected data %q: %v", data, err)
|
||||||
|
}
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Fatal("download omitted file")
|
||||||
|
}
|
||||||
|
// A regular file must remain unarchived regardless of global preference.
|
||||||
|
request = authorizeTestRequest(httptest.NewRequest(http.MethodGet, "/folder/note.txt", nil), signed)
|
||||||
|
recorder = httptest.NewRecorder()
|
||||||
|
handle(rawHandler, "", store, &settings.Server{}).ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != 200 || recorder.Body.String() != "hello" {
|
||||||
|
t.Fatalf("single-file download changed: %d %q", recorder.Code, recorder.Body.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestArchiveFormatFallbackAndExplicitRequest(t *testing.T) {
|
||||||
|
for _, value := range []string{"", "invalid"} {
|
||||||
|
if (&settings.Settings{DownloadArchiveFormat: value}).ArchiveFormat() != "zip" {
|
||||||
|
t.Fatal("missing ZIP fallback")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, value := range []string{"zip", "tar", "targz", "tarbz2", "tarxz", "tarlz4", "tarsz", "tarbr", "tarzst"} {
|
||||||
|
if !settings.ValidArchiveFormat(value) {
|
||||||
|
t.Fatalf("rejected %s", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if settings.ValidArchiveFormat("invalid") {
|
||||||
|
t.Fatal("accepted unknown format")
|
||||||
|
}
|
||||||
|
ext, _, err := parseQueryAlgorithm(httptest.NewRequest("GET", "/?algo=zip", nil), "tar")
|
||||||
|
if err != nil || ext != ".zip" {
|
||||||
|
t.Fatalf("explicit format lost: %s %v", ext, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-3
@@ -38,8 +38,12 @@ func parseQueryFiles(r *http.Request, f *files.FileInfo, _ *users.User) ([]strin
|
|||||||
return fileSlice, nil
|
return fileSlice, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseQueryAlgorithm(r *http.Request) (string, archives.Archival, error) {
|
func parseQueryAlgorithm(r *http.Request, defaultFormat string) (string, archives.Archival, error) {
|
||||||
switch r.URL.Query().Get("algo") {
|
format := r.URL.Query().Get("algo")
|
||||||
|
if format == "" || format == "true" {
|
||||||
|
format = defaultFormat
|
||||||
|
}
|
||||||
|
switch format {
|
||||||
case "zip", "true", "":
|
case "zip", "true", "":
|
||||||
return ".zip", archives.Zip{}, nil
|
return ".zip", archives.Zip{}, nil
|
||||||
case "tar":
|
case "tar":
|
||||||
@@ -174,7 +178,11 @@ func rawDirHandler(w http.ResponseWriter, r *http.Request, d *data, file *files.
|
|||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
extension, archiver, err := parseQueryAlgorithm(r)
|
format := "zip"
|
||||||
|
if d.settings != nil {
|
||||||
|
format = d.settings.ArchiveFormat()
|
||||||
|
}
|
||||||
|
extension, archiver, err := parseQueryAlgorithm(r, format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type settingsData struct {
|
type settingsData struct {
|
||||||
|
DownloadArchiveFormat string `json:"downloadArchiveFormat"`
|
||||||
Signup bool `json:"signup"`
|
Signup bool `json:"signup"`
|
||||||
HideLoginButton bool `json:"hideLoginButton"`
|
HideLoginButton bool `json:"hideLoginButton"`
|
||||||
CreateUserDir bool `json:"createUserDir"`
|
CreateUserDir bool `json:"createUserDir"`
|
||||||
@@ -25,6 +26,7 @@ type settingsData struct {
|
|||||||
|
|
||||||
var settingsGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
var settingsGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
|
||||||
data := &settingsData{
|
data := &settingsData{
|
||||||
|
DownloadArchiveFormat: d.settings.ArchiveFormat(),
|
||||||
Signup: d.settings.Signup,
|
Signup: d.settings.Signup,
|
||||||
HideLoginButton: d.settings.HideLoginButton,
|
HideLoginButton: d.settings.HideLoginButton,
|
||||||
CreateUserDir: d.settings.CreateUserDir,
|
CreateUserDir: d.settings.CreateUserDir,
|
||||||
@@ -50,6 +52,10 @@ var settingsPutHandler = withAdmin(func(w http.ResponseWriter, r *http.Request,
|
|||||||
return http.StatusBadRequest, err
|
return http.StatusBadRequest, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !settings.ValidArchiveFormat(req.DownloadArchiveFormat) {
|
||||||
|
return http.StatusBadRequest, nil
|
||||||
|
}
|
||||||
|
d.settings.DownloadArchiveFormat = req.DownloadArchiveFormat
|
||||||
d.settings.Signup = false
|
d.settings.Signup = false
|
||||||
d.settings.CreateUserDir = req.CreateUserDir
|
d.settings.CreateUserDir = req.CreateUserDir
|
||||||
d.settings.MinimumPasswordLength = req.MinimumPasswordLength
|
d.settings.MinimumPasswordLength = req.MinimumPasswordLength
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
param([string]$Version = '3.0.0-sso.16')
|
param([string]$Version = '3.0.0-sso.17')
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
$repo = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
|
||||||
Push-Location $repo
|
Push-Location $repo
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
VERSION="${VERSION:-3.0.0-sso.16}"
|
VERSION="${VERSION:-3.0.0-sso.17}"
|
||||||
COMMIT=$(git rev-parse --short HEAD)
|
COMMIT=$(git rev-parse --short HEAD)
|
||||||
(cd frontend && pnpm install --frozen-lockfile && pnpm run build)
|
(cd frontend && pnpm install --frozen-lockfile && pnpm run build)
|
||||||
mkdir -p build/release/linux-amd64
|
mkdir -p build/release/linux-amd64
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ type AuthMethod string
|
|||||||
|
|
||||||
// Settings contain the main settings of the application.
|
// Settings contain the main settings of the application.
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
|
DownloadArchiveFormat string `json:"downloadArchiveFormat"`
|
||||||
Key []byte `json:"key"`
|
Key []byte `json:"key"`
|
||||||
Signup bool `json:"signup"`
|
Signup bool `json:"signup"`
|
||||||
HideLoginButton bool `json:"hideLoginButton"`
|
HideLoginButton bool `json:"hideLoginButton"`
|
||||||
@@ -40,6 +41,21 @@ type Settings struct {
|
|||||||
HideDotfiles bool `json:"hideDotfiles"`
|
HideDotfiles bool `json:"hideDotfiles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ValidArchiveFormat(format string) bool {
|
||||||
|
switch format {
|
||||||
|
case "", "zip", "tar", "targz", "tarbz2", "tarxz", "tarlz4", "tarsz", "tarbr", "tarzst":
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Settings) ArchiveFormat() string {
|
||||||
|
if s.DownloadArchiveFormat == "" || !ValidArchiveFormat(s.DownloadArchiveFormat) {
|
||||||
|
return "zip"
|
||||||
|
}
|
||||||
|
return s.DownloadArchiveFormat
|
||||||
|
}
|
||||||
|
|
||||||
// GetRules implements rules.Provider.
|
// GetRules implements rules.Provider.
|
||||||
func (s *Settings) GetRules() []rules.Rule {
|
func (s *Settings) GetRules() []rules.Rule {
|
||||||
return s.Rules
|
return s.Rules
|
||||||
|
|||||||
Reference in new issue
Block a user