Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
add filetransfer lock.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Apr 20, 2024
1 parent fb0af48 commit bc26fde
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/page/plugins/filetransfer/component.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template>
<div style="width: 100%">
<div class="files" v-if="tab === 'filetransfer'">
<div class="files-cwd">
<p>Filetransfer is {{ isLocked ? 'locked' : 'unlocked' }} for users</p>
<i :class="['fas', isLocked ? 'fa-lock' : 'fa-unlock', 'refresh']" @click="setLock(!isLocked)" :title="isLocked ? 'Unlock' : 'Lock'" />
</div>
<div class="files-cwd">
<p>{{ enabled ? cwd : 'Filetransfer is disabled' }}</p>
<i class="fas fa-rotate-right refresh" @click="refresh" />
Expand All @@ -10,10 +14,10 @@
<i :class="fileIcon(item)" />
<p class="file-name" :title="item.name">{{ item.name }}</p>
<p class="file-size">{{ fileSize(item.size) }}</p>
<i v-if="item.type !== 'dir'" class="fas fa-download download" @click="download(item)" />
<i v-if="item.type !== 'dir' && enabledForMe" class="fas fa-download download" @click="download(item)" />
</div>
</div>
<div class="transfer-area" v-if="enabled">
<div class="transfer-area" v-if="enabledForMe">
<div class="transfers" v-if="transfers.length > 0">
<p v-if="downloads.length > 0" class="transfers-list-header">
<span> Downloads </span>
Expand Down Expand Up @@ -284,6 +288,7 @@ const props = defineProps<{
const api = props.neko.withApi(FiletransferApi) as FiletransferApi
const enabled = ref(false)
const enabledForMe = computed(() => enabled && (props.neko.is_admin || (!props.neko.is_admin && !isLocked.value)))
const cwd = ref('')
const files = ref<Item[]>([])
const transfers = reactive<FileTransfer[]>([])
Expand Down Expand Up @@ -519,4 +524,14 @@ function fileSize(size: number) {
}
return Math.round(size / (1024 * 1024 * 1024 * 1024)) + ' TB'
}
const isLocked = computed(() => props.neko.state.settings?.plugins?.filetransfer === true)
async function setLock(isLocked = true) {
try {
await props.neko.room.settingsSet({ plugins: { filetransfer: isLocked } })
} catch (e: any) {
alert(e.response ? e.response.data.message : e)
}
}
</script>

0 comments on commit bc26fde

Please sign in to comment.