2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="xrmjdkdw">
|
|
|
|
<div class="_section">
|
|
|
|
<div class="_content">
|
2020-12-26 01:47:36 +00:00
|
|
|
<MkButton primary @click="clear()"><Fa :icon="faTrashAlt"/> {{ $ts.clearCachedFiles }}</MkButton>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
<div class="_section lookup">
|
2020-12-26 01:47:36 +00:00
|
|
|
<div class="_title"><Fa :icon="faSearch"/> {{ $ts.lookup }}</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="_content">
|
|
|
|
<MkInput class="target" v-model:value="q" type="text" @enter="find()">
|
2020-12-26 01:47:36 +00:00
|
|
|
<span>{{ $ts.fileIdOrUrl }}</span>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkInput>
|
2020-12-26 01:47:36 +00:00
|
|
|
<MkButton @click="find()" primary><Fa :icon="faSearch"/> {{ $ts.lookup }}</MkButton>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="_section">
|
|
|
|
<div class="_content">
|
|
|
|
<div class="inputs" style="display: flex;">
|
|
|
|
<MkSelect v-model:value="origin" style="margin: 0; flex: 1;">
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #label>{{ $ts.instance }}</template>
|
|
|
|
<option value="combined">{{ $ts.all }}</option>
|
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkSelect>
|
|
|
|
<MkInput v-model:value="searchHost" :debounce="true" type="search" style="margin: 0; flex: 1;" :disabled="pagination.params().origin === 'local'">
|
2020-12-26 01:47:36 +00:00
|
|
|
<span>{{ $ts.host }}</span>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkInput>
|
|
|
|
</div>
|
|
|
|
<div class="inputs" style="display: flex; padding-top: 1.2em;">
|
|
|
|
<MkInput v-model:value="type" :debounce="true" type="search" style="margin: 0; flex: 1;">
|
2020-12-26 01:47:36 +00:00
|
|
|
<span>{{ $ts.type }}</span>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkInput>
|
|
|
|
</div>
|
2020-11-08 02:25:28 +00:00
|
|
|
<MkPagination :pagination="pagination" #default="{items}" class="urempief" ref="files">
|
2020-10-17 11:12:00 +00:00
|
|
|
<button class="file _panel _button _vMargin" v-for="file in items" :key="file.id" @click="show(file, $event)">
|
|
|
|
<MkDriveFileThumbnail class="thumbnail" :file="file" fit="contain"/>
|
|
|
|
<div class="body">
|
|
|
|
<div>
|
|
|
|
<small style="opacity: 0.7;">{{ file.name }}</small>
|
|
|
|
</div>
|
|
|
|
<div>
|
2020-10-28 13:24:16 +00:00
|
|
|
<MkAcct v-if="file.user" :user="file.user"/>
|
2020-12-26 01:47:36 +00:00
|
|
|
<div v-else>{{ $ts.system }}</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<span style="margin-right: 1em;">{{ file.type }}</span>
|
|
|
|
<span>{{ bytes(file.size) }}</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
2020-12-26 01:47:36 +00:00
|
|
|
<span>{{ $ts.registeredDate }}: <MkTime :time="file.createdAt" mode="detail"/></span>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import { faCloud, faSearch } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 19:37:25 +00:00
|
|
|
import { faTrashAlt } from '@fortawesome/free-regular-svg-icons';
|
2021-03-23 08:30:14 +00:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import MkInput from '@client/components/ui/input.vue';
|
|
|
|
import MkSelect from '@client/components/ui/select.vue';
|
|
|
|
import MkPagination from '@client/components/ui/pagination.vue';
|
|
|
|
import MkDriveFileThumbnail from '@client/components/drive-file-thumbnail.vue';
|
|
|
|
import bytes from '@client/filters/bytes';
|
|
|
|
import * as os from '@client/os';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
|
|
|
MkButton,
|
2020-10-17 11:12:00 +00:00
|
|
|
MkInput,
|
|
|
|
MkSelect,
|
2020-01-29 19:37:25 +00:00
|
|
|
MkPagination,
|
2020-10-17 11:12:00 +00:00
|
|
|
MkDriveFileThumbnail,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-10-17 11:12:00 +00:00
|
|
|
INFO: {
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts.files,
|
2020-11-03 11:36:12 +00:00
|
|
|
icon: faCloud
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
q: null,
|
|
|
|
origin: 'local',
|
|
|
|
type: null,
|
|
|
|
searchHost: '',
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'admin/drive/files',
|
|
|
|
limit: 10,
|
|
|
|
params: () => ({
|
|
|
|
type: (this.type && this.type !== '') ? this.type : null,
|
|
|
|
origin: this.origin,
|
|
|
|
hostname: (this.hostname && this.hostname !== '') ? this.hostname : null,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
faTrashAlt, faCloud, faSearch,
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
watch: {
|
|
|
|
type() {
|
|
|
|
this.$refs.files.reload();
|
|
|
|
},
|
|
|
|
origin() {
|
|
|
|
this.$refs.files.reload();
|
|
|
|
},
|
|
|
|
searchHost() {
|
|
|
|
this.$refs.files.reload();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
methods: {
|
|
|
|
clear() {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.dialog({
|
2020-01-29 19:37:25 +00:00
|
|
|
type: 'warning',
|
2020-12-26 01:47:36 +00:00
|
|
|
text: this.$ts.clearCachedFilesConfirm,
|
2020-01-29 19:37:25 +00:00
|
|
|
showCancelButton: true
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
os.apiWithDialog('admin/drive/clean-remote-files', {});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-11-03 06:22:55 +00:00
|
|
|
show(file, ev) {
|
|
|
|
os.popup(import('./file-dialog.vue'), {
|
2020-10-17 11:12:00 +00:00
|
|
|
fileId: file.id
|
|
|
|
}, {}, 'closed');
|
|
|
|
},
|
|
|
|
|
|
|
|
find() {
|
|
|
|
os.api('admin/drive/show-file', this.q.startsWith('http://') || this.q.startsWith('https://') ? { url: this.q.trim() } : { fileId: this.q.trim() }).then(file => {
|
|
|
|
this.show(file);
|
|
|
|
}).catch(e => {
|
|
|
|
if (e.code === 'NO_SUCH_FILE') {
|
|
|
|
os.dialog({
|
|
|
|
type: 'error',
|
2020-12-26 01:47:36 +00:00
|
|
|
text: this.$ts.notFound
|
2020-01-29 19:37:25 +00:00
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
});
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
bytes
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xrmjdkdw {
|
|
|
|
.urempief {
|
|
|
|
margin-top: var(--margin);
|
|
|
|
|
|
|
|
> .file {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
text-align: left;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .thumbnail {
|
|
|
|
width: 128px;
|
|
|
|
height: 128px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
margin-left: 0.3em;
|
|
|
|
padding: 8px;
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
@media (max-width: 500px) {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|