fix: Correct JS formatting
parent
11a4de5784
commit
ddb21c0f5e
|
@ -188,10 +188,15 @@ export async function diskUsage(url: string) {
|
||||||
return await data.json();
|
return await data.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function archive(url: string, name: string, format: string, ...files: string[]) {
|
export async function archive(
|
||||||
|
url: string,
|
||||||
|
name: string,
|
||||||
|
format: string,
|
||||||
|
...files: string[]
|
||||||
|
) {
|
||||||
let arg = "";
|
let arg = "";
|
||||||
|
|
||||||
for (let file of files) {
|
for (const file of files) {
|
||||||
arg += file + ",";
|
arg += file + ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +219,12 @@ export async function unarchive(path: string, name: string, override: boolean) {
|
||||||
return resourceAction(url, "PATCH");
|
return resourceAction(url, "PATCH");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function chmod(path: string, perms: number, recursive: boolean, recursionType: string) {
|
export async function chmod(
|
||||||
|
path: string,
|
||||||
|
perms: number,
|
||||||
|
recursive: boolean,
|
||||||
|
recursionType: string
|
||||||
|
) {
|
||||||
const action = `chmod`;
|
const action = `chmod`;
|
||||||
let url = `${path}?action=${action}&permissions=${perms}&recursive=${recursive}`;
|
let url = `${path}?action=${action}&permissions=${perms}&recursive=${recursive}`;
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
|
|
|
@ -44,23 +44,37 @@ const quotaStore = useQuotaStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const loaded = computed(() =>
|
const loaded = computed(() =>
|
||||||
quotaStore.quota ? quotaStore.quota.inodes !== null && quotaStore.quota.space !== null : false
|
quotaStore.quota
|
||||||
|
? quotaStore.quota.inodes !== null && quotaStore.quota.space !== null
|
||||||
|
: false
|
||||||
);
|
);
|
||||||
|
|
||||||
const spaceProgress = computed(() =>
|
const spaceProgress = computed(() =>
|
||||||
quotaStore.quota && quotaStore.quota.space !== null ? progress(quotaStore.quota.space) : 0
|
quotaStore.quota && quotaStore.quota.space !== null
|
||||||
|
? progress(quotaStore.quota.space)
|
||||||
|
: 0
|
||||||
);
|
);
|
||||||
|
|
||||||
const inodeProgress = computed(() =>
|
const inodeProgress = computed(() =>
|
||||||
quotaStore.quota && quotaStore.quota.inodes !== null ? progress(quotaStore.quota.inodes) : 0
|
quotaStore.quota && quotaStore.quota.inodes !== null
|
||||||
|
? progress(quotaStore.quota.inodes)
|
||||||
|
: 0
|
||||||
);
|
);
|
||||||
|
|
||||||
const spaceUsageTitle = computed(() =>
|
const spaceUsageTitle = computed(() =>
|
||||||
!quotaStore.quota ? "- / -" : filesize(quotaStore.quota.space.usage) + " / " + filesize(quotaStore.quota.space.quota)
|
!quotaStore.quota
|
||||||
|
? "- / -"
|
||||||
|
: filesize(quotaStore.quota.space.usage) +
|
||||||
|
" / " +
|
||||||
|
filesize(quotaStore.quota.space.quota)
|
||||||
);
|
);
|
||||||
|
|
||||||
const inodeUsageTitle = computed(() =>
|
const inodeUsageTitle = computed(() =>
|
||||||
!quotaStore.quota ? "- / -" : filesize(quotaStore.quota.inodes.usage) + " / " + filesize(quotaStore.quota.inodes.quota)
|
!quotaStore.quota
|
||||||
|
? "- / -"
|
||||||
|
: filesize(quotaStore.quota.inodes.usage) +
|
||||||
|
" / " +
|
||||||
|
filesize(quotaStore.quota.inodes.quota)
|
||||||
);
|
);
|
||||||
|
|
||||||
const progress = (info: QuotaInfo) => {
|
const progress = (info: QuotaInfo) => {
|
||||||
|
@ -71,5 +85,5 @@ const progress = (info: QuotaInfo) => {
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
quotaStore.fetchQuota();
|
quotaStore.fetchQuota();
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -131,7 +131,7 @@
|
||||||
href="https://github.com/filebrowser/filebrowser"
|
href="https://github.com/filebrowser/filebrowser"
|
||||||
>File Browser</a
|
>File Browser</a
|
||||||
>
|
>
|
||||||
<span> {{ ' ' }} {{ version }}</span>
|
<span> {{ " " }} {{ version }}</span>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<a @click="help">{{ $t("sidebar.help") }}</a>
|
<a @click="help">{{ $t("sidebar.help") }}</a>
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div id="context-menu" ref="contextMenuDiv" class="card" :style="menuStyle">
|
||||||
id="context-menu"
|
|
||||||
ref="contextMenuDiv"
|
|
||||||
class="card"
|
|
||||||
:style="menuStyle"
|
|
||||||
>
|
|
||||||
<p>
|
<p>
|
||||||
<action icon="info" :label="t('buttons.info')" show="info" />
|
<action icon="info" :label="t('buttons.info')" show="info" />
|
||||||
</p>
|
</p>
|
||||||
|
@ -81,8 +76,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref,computed, onMounted, onBeforeUnmount, CSSProperties } from "vue";
|
import { ref, computed, onMounted, onBeforeUnmount, CSSProperties } from "vue";
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
import { useFileStore } from "@/stores/file";
|
import { useFileStore } from "@/stores/file";
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
|
@ -125,10 +120,9 @@ const options = computed(() => {
|
||||||
download: authStore.user?.perm.download ?? false,
|
download: authStore.user?.perm.download ?? false,
|
||||||
delete: fileStore.selectedCount > 0 && authStore.user?.perm.delete,
|
delete: fileStore.selectedCount > 0 && authStore.user?.perm.delete,
|
||||||
edit:
|
edit:
|
||||||
fileStore.selectedCount === 1 && (
|
fileStore.selectedCount === 1 &&
|
||||||
fileStore.req?.items[fileStore.selected[0]].type === "text" ||
|
(fileStore.req?.items[fileStore.selected[0]].type === "text" ||
|
||||||
fileStore.req?.items[fileStore.selected[0]].type === "textImmutable"
|
fileStore.req?.items[fileStore.selected[0]].type === "textImmutable"),
|
||||||
),
|
|
||||||
rename: fileStore.selectedCount === 1 && authStore.user?.perm.rename,
|
rename: fileStore.selectedCount === 1 && authStore.user?.perm.rename,
|
||||||
share: fileStore.selectedCount === 1 && authStore.user?.perm.share,
|
share: fileStore.selectedCount === 1 && authStore.user?.perm.share,
|
||||||
move: fileStore.selectedCount > 0 && authStore.user?.perm.rename,
|
move: fileStore.selectedCount > 0 && authStore.user?.perm.rename,
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
</p>
|
</p>
|
||||||
<p v-else class="name">{{ name }}</p>
|
<p v-else class="name">{{ name }}</p>
|
||||||
|
|
||||||
<p class="size" :data-order="diskUsage?.size || humanSize() || '-1'">{{ usedDiskSize }}</p>
|
<p class="size" :data-order="diskUsage?.size || humanSize() || '-1'">
|
||||||
|
{{ usedDiskSize }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<p class="modified">
|
<p class="modified">
|
||||||
<time :datetime="modified">{{ humanTime() }}</time>
|
<time :datetime="modified">{{ humanTime() }}</time>
|
||||||
|
@ -91,10 +93,14 @@ const diskUsage = ref<DiskUsage | null>(null);
|
||||||
const usedDiskSize = computed((): string => {
|
const usedDiskSize = computed((): string => {
|
||||||
if (props.isDir) {
|
if (props.isDir) {
|
||||||
if (!diskUsage.value) {
|
if (!diskUsage.value) {
|
||||||
return '-';
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
return diskUsage.value.size + ' ' + t("prompts.inodeCount", { count: diskUsage.value.inodes });
|
return (
|
||||||
|
diskUsage.value.size +
|
||||||
|
" " +
|
||||||
|
t("prompts.inodeCount", { count: diskUsage.value.inodes })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return humanSize();
|
return humanSize();
|
||||||
|
@ -109,9 +115,13 @@ const isDraggable = computed(
|
||||||
() => !props.readOnly && authStore.user?.perm.rename
|
() => !props.readOnly && authStore.user?.perm.rename
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(diskUsages, () => {
|
watch(
|
||||||
updateDiskUsage();
|
diskUsages,
|
||||||
}, { deep: true });
|
() => {
|
||||||
|
updateDiskUsage();
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
const canDrop = computed(() => {
|
const canDrop = computed(() => {
|
||||||
if (!props.isDir || props.readOnly) return false;
|
if (!props.isDir || props.readOnly) return false;
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
import { inject, ref } from "vue";
|
import { inject, ref } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { onMounted } from "vue";
|
import { onMounted } from "vue";
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from "vue-router";
|
||||||
import { useFileStore } from "@/stores/file";
|
import { useFileStore } from "@/stores/file";
|
||||||
import { useQuotaStore } from "@/stores/quota";
|
import { useQuotaStore } from "@/stores/quota";
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
|
@ -74,7 +74,7 @@ const archive = async (format: string) => {
|
||||||
let items: string[] = [];
|
let items: string[] = [];
|
||||||
|
|
||||||
for (let i of fileStore.selected) {
|
for (let i of fileStore.selected) {
|
||||||
let item = fileStore.req?.items[i].name
|
let item = fileStore.req?.items[i].name;
|
||||||
if (item) {
|
if (item) {
|
||||||
items.push(item);
|
items.push(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, inject } from "vue";
|
import { computed, inject, onMounted, ref } from "vue";
|
||||||
import { useFileStore } from "@/stores/file";
|
import { useFileStore } from "@/stores/file";
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
@ -130,10 +130,28 @@ const { t } = useI18n();
|
||||||
|
|
||||||
const $showError = inject<IToastError>("$showError")!;
|
const $showError = inject<IToastError>("$showError")!;
|
||||||
|
|
||||||
let loading = false;
|
const loading = ref<boolean>(false);
|
||||||
let recursive = false;
|
const recursive = ref<boolean>(false);
|
||||||
let recursionType = "all";
|
const recursionType = ref<string>("all");
|
||||||
let masks = {
|
const permissions = ref<FilePermissions>({
|
||||||
|
owner: {
|
||||||
|
read: false,
|
||||||
|
write: false,
|
||||||
|
execute: false,
|
||||||
|
},
|
||||||
|
group: {
|
||||||
|
read: false,
|
||||||
|
write: false,
|
||||||
|
execute: false,
|
||||||
|
},
|
||||||
|
others: {
|
||||||
|
read: false,
|
||||||
|
write: false,
|
||||||
|
execute: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const masks = {
|
||||||
permissions: 511,
|
permissions: 511,
|
||||||
owner: {
|
owner: {
|
||||||
read: 256,
|
read: 256,
|
||||||
|
@ -152,46 +170,26 @@ let masks = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const permissions = computed((): FilePermissions => {
|
onMounted(() => {
|
||||||
let permObj = {
|
|
||||||
owner: {
|
|
||||||
read: false,
|
|
||||||
write: false,
|
|
||||||
execute: false,
|
|
||||||
},
|
|
||||||
group: {
|
|
||||||
read: false,
|
|
||||||
write: false,
|
|
||||||
execute: false,
|
|
||||||
},
|
|
||||||
others: {
|
|
||||||
read: false,
|
|
||||||
write: false,
|
|
||||||
execute: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
let item = fileStore.req?.items[fileStore.selected[0]];
|
let item = fileStore.req?.items[fileStore.selected[0]];
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return permObj
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let perms = item.mode & masks.permissions;
|
let perms = item.mode & masks.permissions;
|
||||||
|
|
||||||
// OWNER PERMS
|
// OWNER PERMS
|
||||||
permObj.owner.read = (perms & masks.owner.read) != 0;
|
permissions.value.owner.read = (perms & masks.owner.read) != 0;
|
||||||
permObj.owner.write = (perms & masks.owner.write) != 0;
|
permissions.value.owner.write = (perms & masks.owner.write) != 0;
|
||||||
permObj.owner.execute = (perms & masks.owner.execute) != 0;
|
permissions.value.owner.execute = (perms & masks.owner.execute) != 0;
|
||||||
// GROUP PERMS
|
// GROUP PERMS
|
||||||
permObj.group.read = (perms & masks.group.read) != 0;
|
permissions.value.group.read = (perms & masks.group.read) != 0;
|
||||||
permObj.group.write = (perms & masks.group.write) != 0;
|
permissions.value.group.write = (perms & masks.group.write) != 0;
|
||||||
permObj.group.execute = (perms & masks.group.execute) != 0;
|
permissions.value.group.execute = (perms & masks.group.execute) != 0;
|
||||||
// OTHERS PERMS
|
// OTHERS PERMS
|
||||||
permObj.others.read = (perms & masks.others.read) != 0;
|
permissions.value.others.read = (perms & masks.others.read) != 0;
|
||||||
permObj.others.write = (perms & masks.others.write) != 0;
|
permissions.value.others.write = (perms & masks.others.write) != 0;
|
||||||
permObj.others.execute = (perms & masks.others.execute) != 0;
|
permissions.value.others.execute = (perms & masks.others.execute) != 0;
|
||||||
|
|
||||||
return permObj;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const permMode = computed((): number => {
|
const permMode = computed((): number => {
|
||||||
|
@ -239,21 +237,21 @@ const chmod = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading = true;
|
loading.value = true;
|
||||||
|
|
||||||
await api.chmod(
|
await api.chmod(
|
||||||
item.url,
|
item.url,
|
||||||
permMode.value,
|
permMode.value,
|
||||||
recursive,
|
recursive.value,
|
||||||
recursionType,
|
recursionType.value
|
||||||
);
|
);
|
||||||
|
|
||||||
layoutStore.closeHovers();
|
layoutStore.closeHovers();
|
||||||
fileStore.reload = true
|
fileStore.reload = true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
$showError(e);
|
$showError(e);
|
||||||
} finally {
|
} finally {
|
||||||
loading = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -79,16 +79,9 @@ const overwriteAvailable = computed((): boolean => {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [".zip", ".rar", ".tar", ".bz2", ".gz", ".xz", ".lz4", ".sz"].includes(
|
||||||
".zip",
|
item.extension
|
||||||
".rar",
|
);
|
||||||
".tar",
|
|
||||||
".bz2",
|
|
||||||
".gz",
|
|
||||||
".xz",
|
|
||||||
".lz4",
|
|
||||||
".sz",
|
|
||||||
].includes(item.extension);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default {
|
||||||
ru_RU: "Русский",
|
ru_RU: "Русский",
|
||||||
tr_TR: "Türkçe",
|
tr_TR: "Türkçe",
|
||||||
uk_UA: "Український",
|
uk_UA: "Український",
|
||||||
zh_CN: "中文 (简体)"
|
zh_CN: "中文 (简体)",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vue3 reactivity breaks with this configuration
|
// Vue3 reactivity breaks with this configuration
|
||||||
|
|
|
@ -106,9 +106,9 @@ export const isRtl = (locale?: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function setLocale(locale: string) {
|
export function setLocale(locale: string) {
|
||||||
let normalizedLocale = locale
|
let normalizedLocale = locale;
|
||||||
if (locale.includes("_")) {
|
if (locale.includes("_")) {
|
||||||
normalizedLocale = locale.split("_")[0]
|
normalizedLocale = locale.split("_")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
dayjs.locale(normalizedLocale);
|
dayjs.locale(normalizedLocale);
|
||||||
|
|
|
@ -8,10 +8,10 @@ export const useContextMenuStore = defineStore("context-menu", {
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
show(x: number, y: number) {
|
show(x: number, y: number) {
|
||||||
this.position = { x, y }
|
this.position = { x, y };
|
||||||
},
|
},
|
||||||
hide() {
|
hide() {
|
||||||
this.position = null
|
this.position = null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,8 +33,8 @@ export const useFileStore = defineStore("file", {
|
||||||
return state.isFiles && state?.req?.isDir;
|
return state.isFiles && state?.req?.isDir;
|
||||||
},
|
},
|
||||||
onlyArchivesSelected: (state) => {
|
onlyArchivesSelected: (state) => {
|
||||||
let extensions = [".zip", ".tar", ".gz", ".bz2", ".xz", ".lz4", ".sz"];
|
const extensions = [".zip", ".tar", ".gz", ".bz2", ".xz", ".lz4", ".sz"];
|
||||||
let items = state.req?.items;
|
const items = state.req?.items;
|
||||||
|
|
||||||
if (!items) {
|
if (!items) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -45,7 +45,7 @@ export const useFileStore = defineStore("file", {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const i of state.selected) {
|
for (const i of state.selected) {
|
||||||
let item = items[i];
|
const item = items[i];
|
||||||
if (item.isDir || !extensions.includes(item.extension)) {
|
if (item.isDir || !extensions.includes(item.extension)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ export const useQuotaStore = defineStore("quota", {
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
let data = await api.getQuota();
|
const data = await api.getQuota();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
data !== null &&
|
data !== null &&
|
||||||
|
@ -29,6 +29,6 @@ export const useQuotaStore = defineStore("quota", {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}, delay);
|
}, delay);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
interface ContextMenuPosition {
|
interface ContextMenuPosition {
|
||||||
x: number,
|
x: number;
|
||||||
y: number,
|
y: number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
interface FilePermissions {
|
interface FilePermissions {
|
||||||
owner: PermissionModes,
|
owner: PermissionModes;
|
||||||
group: PermissionModes,
|
group: PermissionModes;
|
||||||
others: PermissionModes,
|
others: PermissionModes;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PermissionModes {
|
interface PermissionModes {
|
||||||
read: boolean,
|
read: boolean;
|
||||||
write: boolean,
|
write: boolean;
|
||||||
execute: boolean,
|
execute: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ watch(route, () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const contextMenuVisible = computed((): boolean =>
|
const contextMenuVisible = computed(
|
||||||
(fileStore.isListing || false) && contextMenuStore.position !== null
|
(): boolean =>
|
||||||
|
(fileStore.isListing || false) && contextMenuStore.position !== null
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -903,13 +903,10 @@ const calculateDirSizes = () => {
|
||||||
Promise.allSettled(promises).then((results) => {
|
Promise.allSettled(promises).then((results) => {
|
||||||
for (let result of results) {
|
for (let result of results) {
|
||||||
if (result.status === "fulfilled") {
|
if (result.status === "fulfilled") {
|
||||||
fileStore.addDiskUsage(
|
fileStore.addDiskUsage(result.value.path, {
|
||||||
result.value.path,
|
size: result.value.diskUsage,
|
||||||
{
|
inodes: result.value.inodes,
|
||||||
size: result.value.diskUsage,
|
});
|
||||||
inodes: result.value.inodes,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue