Skip to content

Commit

Permalink
admin/drive hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Feb 23, 2022
1 parent 8e02e80 commit ea55be7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/client/app/admin/views/drive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<option value="local">{{ $t('origin.local') }}</option>
<option value="remote">{{ $t('origin.remote') }}</option>
</ui-select>
<ui-input v-model="hostname" type="text" spellcheck="false" :disabled="origin === 'local'">
<span>{{ $t('host') }}</span>
</ui-input>
</ui-horizon-group>
<sequential-entrance animation="entranceFromTop" delay="25">
<div class="kidvdlkg" v-for="file in files">
Expand Down Expand Up @@ -82,6 +85,7 @@ export default Vue.extend({
file: null,
target: null,
origin: 'local',
hostname: '',
limit: 10,
offset: 0,
files: [],
Expand All @@ -92,6 +96,13 @@ export default Vue.extend({
watch: {
origin() {
if (this.origin === 'local') this.hostname = '';
this.files = [];
this.offset = 0;
this.fetch();
},
hostname() {
this.files = [];
this.offset = 0;
this.fetch();
Expand All @@ -117,6 +128,7 @@ export default Vue.extend({
fetch() {
this.$root.api('admin/drive/files', {
origin: this.origin,
hostname: this.hostname,
offset: this.offset,
limit: this.limit + 1
}).then(files => {
Expand Down
6 changes: 4 additions & 2 deletions src/server/api/endpoints/admin/drive/files.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import $ from 'cafy';
import { toDbHost } from '../../../../../misc/convert-host';
import File, { packMany } from '../../../../../models/drive-file';
import define from '../../../define';

Expand Down Expand Up @@ -40,8 +41,8 @@ export default define(meta, async (ps, me) => {
'metadata.deletedAt': { $exists: false },
} as any;

if (ps.hostname != null) {
q['metadata._user.host'] = ps.hostname; // TODO:normalize
if (ps.hostname != null && ps.hostname.length > 0) {
q['metadata._user.host'] = toDbHost(ps.hostname);
} else {
if (ps.origin == 'local') q['metadata._user.host'] = null;
if (ps.origin == 'remote') q['metadata._user.host'] = { $ne: null };
Expand All @@ -50,6 +51,7 @@ export default define(meta, async (ps, me) => {
const files = await File
.find(q, {
limit: ps.limit,
sort: { _id: -1 },
skip: ps.offset
});

Expand Down

0 comments on commit ea55be7

Please sign in to comment.