2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="xrmjdkdw">
|
2021-10-02 14:11:21 +00:00
|
|
|
<MkContainer :foldable="true" class="lookup">
|
|
|
|
<template #header><i class="fas fa-search"></i> {{ $ts.lookup }}</template>
|
|
|
|
<div class="xrmjdkdw-lookup">
|
2021-11-19 10:36:12 +00:00
|
|
|
<MkInput v-model="q" class="item" type="text" @enter="find()">
|
2021-08-06 13:29:19 +00:00
|
|
|
<template #label>{{ $ts.fileIdOrUrl }}</template>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkInput>
|
2021-11-19 10:36:12 +00:00
|
|
|
<MkButton primary @click="find()"><i class="fas fa-search"></i> {{ $ts.lookup }}</MkButton>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
2021-10-02 14:11:21 +00:00
|
|
|
</MkContainer>
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
<div class="_section">
|
|
|
|
<div class="_content">
|
|
|
|
<div class="inputs" style="display: flex;">
|
2021-08-06 13:29:19 +00:00
|
|
|
<MkSelect v-model="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>
|
2021-08-06 13:29:19 +00:00
|
|
|
<MkInput v-model="searchHost" :debounce="true" type="search" style="margin: 0; flex: 1;" :disabled="pagination.params().origin === 'local'">
|
|
|
|
<template #label>{{ $ts.host }}</template>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkInput>
|
|
|
|
</div>
|
|
|
|
<div class="inputs" style="display: flex; padding-top: 1.2em;">
|
2021-08-06 13:29:19 +00:00
|
|
|
<MkInput v-model="type" :debounce="true" type="search" style="margin: 0; flex: 1;">
|
2021-10-02 14:11:21 +00:00
|
|
|
<template #label>MIME type</template>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkInput>
|
|
|
|
</div>
|
2021-12-02 11:09:12 +00:00
|
|
|
<MkPagination v-slot="{items}" ref="files" :pagination="pagination" class="urempief">
|
2021-11-19 10:36:12 +00:00
|
|
|
<button v-for="file in items" :key="file.id" class="file _panel _button _gap" @click="show(file, $event)">
|
2020-10-17 11:12:00 +00:00
|
|
|
<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';
|
2021-11-11 17:02:25 +00:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkSelect from '@/components/form/select.vue';
|
|
|
|
import MkPagination from '@/components/ui/pagination.vue';
|
|
|
|
import MkContainer from '@/components/ui/container.vue';
|
|
|
|
import MkDriveFileThumbnail from '@/components/drive-file-thumbnail.vue';
|
|
|
|
import bytes from '@/filters/bytes';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
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,
|
2021-10-02 14:11:21 +00:00
|
|
|
MkContainer,
|
2020-10-17 11:12:00 +00:00
|
|
|
MkDriveFileThumbnail,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 03:54:12 +00:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts.files,
|
2021-10-02 14:11:21 +00:00
|
|
|
icon: 'fas fa-cloud',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
actions: [{
|
|
|
|
text: this.$ts.clearCachedFiles,
|
|
|
|
icon: 'fas fa-trash-alt',
|
|
|
|
handler: this.clear
|
|
|
|
}]
|
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,
|
|
|
|
}),
|
|
|
|
},
|
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();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
|
|
|
},
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
methods: {
|
|
|
|
clear() {
|
2021-11-18 09:45:58 +00:00
|
|
|
os.confirm({
|
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
|
|
|
}).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') {
|
2021-11-18 09:45:58 +00:00
|
|
|
os.alert({
|
2020-10-17 11:12:00 +00:00
|
|
|
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 {
|
2021-04-22 13:29:33 +00:00
|
|
|
margin: var(--margin);
|
|
|
|
|
2021-10-02 14:11:21 +00:00
|
|
|
> .lookup {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
.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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-02 14:11:21 +00:00
|
|
|
|
|
|
|
.xrmjdkdw-lookup {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> .item {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
</style>
|