2018-02-16 16:36:28 +01:00
|
|
|
<template>
|
2018-09-01 05:05:25 +02:00
|
|
|
<div class="kmmwchoexgckptowjmjgfsygeltxfeqs">
|
2017-11-01 05:11:40 +01:00
|
|
|
<nav ref="nav">
|
2018-10-25 04:30:30 +02:00
|
|
|
<a @click.prevent="goRoot()" href="/i/drive">%fa:cloud%%i18n:common.drive%</a>
|
2018-02-16 16:36:28 +01:00
|
|
|
<template v-for="folder in hierarchyFolders">
|
|
|
|
<span :key="folder.id + '>'">%fa:angle-right%</span>
|
|
|
|
<a :key="folder.id" @click.prevent="cd(folder)" :href="`/i/drive/folder/${folder.id}`">{{ folder.name }}</a>
|
2018-02-08 06:50:18 +01:00
|
|
|
</template>
|
|
|
|
<template v-if="folder != null">
|
2017-12-07 18:44:50 +01:00
|
|
|
<span>%fa:angle-right%</span>
|
2018-02-16 16:36:28 +01:00
|
|
|
<p>{{ folder.name }}</p>
|
2018-02-08 06:50:18 +01:00
|
|
|
</template>
|
|
|
|
<template v-if="file != null">
|
2017-12-07 18:44:50 +01:00
|
|
|
<span>%fa:angle-right%</span>
|
2018-02-16 16:36:28 +01:00
|
|
|
<p>{{ file.name }}</p>
|
2018-02-08 06:50:18 +01:00
|
|
|
</template>
|
2017-01-11 21:55:38 +01:00
|
|
|
</nav>
|
2017-06-07 08:43:29 +02:00
|
|
|
<mk-uploader ref="uploader"/>
|
2018-02-16 16:36:28 +01:00
|
|
|
<div class="browser" :class="{ fetching }" v-if="file == null">
|
2018-02-07 10:34:43 +01:00
|
|
|
<div class="info" v-if="info">
|
2018-04-14 18:04:40 +02:00
|
|
|
<p v-if="folder == null">{{ (info.usage / info.capacity * 100).toFixed(1) }}% %i18n:@used%</p>
|
2018-03-29 07:48:47 +02:00
|
|
|
<p v-if="folder != null && (folder.foldersCount > 0 || folder.filesCount > 0)">
|
2018-04-14 18:04:40 +02:00
|
|
|
<template v-if="folder.foldersCount > 0">{{ folder.foldersCount }} %i18n:@folder-count%</template>
|
|
|
|
<template v-if="folder.foldersCount > 0 && folder.filesCount > 0">%i18n:@count-separator%</template>
|
|
|
|
<template v-if="folder.filesCount > 0">{{ folder.filesCount }} %i18n:@file-count%</template>
|
2017-03-18 16:02:45 +01:00
|
|
|
</p>
|
|
|
|
</div>
|
2018-02-07 10:34:43 +01:00
|
|
|
<div class="folders" v-if="folders.length > 0">
|
2018-09-01 05:05:25 +02:00
|
|
|
<x-folder class="folder" v-for="folder in folders" :key="folder.id" :folder="folder"/>
|
2018-04-14 18:04:40 +02:00
|
|
|
<p v-if="moreFolders">%i18n:@load-more%</p>
|
2017-01-11 21:55:38 +01:00
|
|
|
</div>
|
2018-02-07 10:34:43 +01:00
|
|
|
<div class="files" v-if="files.length > 0">
|
2018-09-01 05:05:25 +02:00
|
|
|
<x-file class="file" v-for="file in files" :key="file.id" :file="file"/>
|
2018-02-07 10:34:43 +01:00
|
|
|
<button class="more" v-if="moreFiles" @click="fetchMoreFiles">
|
2018-05-20 13:26:38 +02:00
|
|
|
{{ fetchingMoreFiles ? '%i18n:common.loading%' : '%i18n:@load-more%' }}
|
2017-03-25 08:01:36 +01:00
|
|
|
</button>
|
2017-01-11 21:55:38 +01:00
|
|
|
</div>
|
2018-02-07 10:34:43 +01:00
|
|
|
<div class="empty" v-if="files.length == 0 && folders.length == 0 && !fetching">
|
2018-04-14 18:04:40 +02:00
|
|
|
<p v-if="folder == null">%i18n:@nothing-in-drive%</p>
|
|
|
|
<p v-if="folder != null">%i18n:@folder-is-empty%</p>
|
2017-01-11 21:55:38 +01:00
|
|
|
</div>
|
2017-03-18 16:02:45 +01:00
|
|
|
</div>
|
2018-02-07 10:34:43 +01:00
|
|
|
<div class="fetching" v-if="fetching && file == null && files.length == 0 && folders.length == 0">
|
2017-03-18 16:02:45 +01:00
|
|
|
<div class="spinner">
|
|
|
|
<div class="dot1"></div>
|
|
|
|
<div class="dot2"></div>
|
2017-01-11 21:55:38 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-02-21 23:06:47 +01:00
|
|
|
<input ref="file" class="file" type="file" multiple="multiple" @change="onChangeLocalFile"/>
|
|
|
|
<x-file-detail v-if="file != null" :file="file"/>
|
2018-02-16 16:36:28 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-02-21 23:06:47 +01:00
|
|
|
import XFolder from './drive.folder.vue';
|
|
|
|
import XFile from './drive.file.vue';
|
|
|
|
import XFileDetail from './drive.file-detail.vue';
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-02-21 23:06:47 +01:00
|
|
|
components: {
|
|
|
|
XFolder,
|
|
|
|
XFile,
|
|
|
|
XFileDetail
|
|
|
|
},
|
2018-02-16 16:36:28 +01:00
|
|
|
props: ['initFolder', 'initFile', 'selectFile', 'multiple', 'isNaked', 'top'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* 現在の階層(フォルダ)
|
|
|
|
* * null でルートを表す
|
|
|
|
*/
|
|
|
|
folder: null,
|
|
|
|
|
|
|
|
file: null,
|
|
|
|
|
|
|
|
files: [],
|
|
|
|
folders: [],
|
|
|
|
moreFiles: false,
|
|
|
|
moreFolders: false,
|
|
|
|
hierarchyFolders: [],
|
|
|
|
selectedFiles: [],
|
|
|
|
info: null,
|
2018-10-07 04:06:17 +02:00
|
|
|
connection: null
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
fetching: true,
|
|
|
|
fetchingMoreFiles: false,
|
|
|
|
fetchingMoreFolders: false
|
2017-02-21 17:05:23 +01:00
|
|
|
};
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isFileSelectMode(): boolean {
|
|
|
|
return this.selectFile;
|
|
|
|
}
|
|
|
|
},
|
2018-09-01 05:05:25 +02:00
|
|
|
watch: {
|
|
|
|
top() {
|
|
|
|
if (this.isNaked) {
|
|
|
|
(this.$refs.nav as any).style.top = `${this.top}px`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-02-16 16:36:28 +01:00
|
|
|
mounted() {
|
2018-10-07 04:06:17 +02:00
|
|
|
this.connection = (this as any).os.stream.useSharedConnection('drive');
|
2018-02-16 16:36:28 +01:00
|
|
|
|
2018-10-23 00:01:43 +02:00
|
|
|
this.connection.on('fileCreated', this.onStreamDriveFileCreated);
|
|
|
|
this.connection.on('fileUpdated', this.onStreamDriveFileUpdated);
|
|
|
|
this.connection.on('fileDeleted', this.onStreamDriveFileDeleted);
|
|
|
|
this.connection.on('folderCreated', this.onStreamDriveFolderCreated);
|
|
|
|
this.connection.on('folderUpdated', this.onStreamDriveFolderUpdated);
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
if (this.initFolder) {
|
|
|
|
this.cd(this.initFolder, true);
|
|
|
|
} else if (this.initFile) {
|
|
|
|
this.cf(this.initFile, true);
|
|
|
|
} else {
|
|
|
|
this.fetch();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.isNaked) {
|
|
|
|
(this.$refs.nav as any).style.top = `${this.top}px`;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-10-07 04:06:17 +02:00
|
|
|
this.connection.dispose();
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onStreamDriveFileCreated(file) {
|
|
|
|
this.addFile(file, true);
|
|
|
|
},
|
2017-02-21 17:05:23 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
onStreamDriveFileUpdated(file) {
|
2017-02-21 17:05:23 +01:00
|
|
|
const current = this.folder ? this.folder.id : null;
|
2018-03-29 07:48:47 +02:00
|
|
|
if (current != file.folderId) {
|
2017-02-21 17:05:23 +01:00
|
|
|
this.removeFile(file);
|
|
|
|
} else {
|
|
|
|
this.addFile(file, true);
|
|
|
|
}
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-02-21 17:05:23 +01:00
|
|
|
|
2018-06-15 02:53:30 +02:00
|
|
|
onStreamDriveFileDeleted(fileId) {
|
|
|
|
this.removeFile(fileId);
|
|
|
|
},
|
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
onStreamDriveFolderCreated(folder) {
|
2017-02-21 17:05:23 +01:00
|
|
|
this.addFolder(folder, true);
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-02-21 17:05:23 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
onStreamDriveFolderUpdated(folder) {
|
2017-02-21 17:05:23 +01:00
|
|
|
const current = this.folder ? this.folder.id : null;
|
2018-03-29 07:48:47 +02:00
|
|
|
if (current != folder.parentId) {
|
2017-02-21 17:05:23 +01:00
|
|
|
this.removeFolder(folder);
|
|
|
|
} else {
|
|
|
|
this.addFolder(folder, true);
|
|
|
|
}
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-02-21 17:05:23 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
dive(folder) {
|
|
|
|
this.hierarchyFolders.unshift(folder);
|
|
|
|
if (folder.parent) this.dive(folder.parent);
|
|
|
|
},
|
2017-02-21 17:05:23 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
cd(target, silent = false) {
|
2017-02-21 17:05:23 +01:00
|
|
|
this.file = null;
|
|
|
|
|
|
|
|
if (target == null) {
|
2018-02-22 10:37:47 +01:00
|
|
|
this.goRoot(silent);
|
2017-02-21 17:05:23 +01:00
|
|
|
return;
|
2018-02-16 16:36:28 +01:00
|
|
|
} else if (typeof target == 'object') {
|
|
|
|
target = target.id;
|
|
|
|
}
|
2017-02-21 17:05:23 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
this.fetching = true;
|
2016-12-28 23:49:51 +01:00
|
|
|
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/folders/show', {
|
2018-03-29 07:48:47 +02:00
|
|
|
folderId: target
|
2017-02-21 17:05:23 +01:00
|
|
|
}).then(folder => {
|
|
|
|
this.folder = folder;
|
|
|
|
this.hierarchyFolders = [];
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
if (folder.parent) this.dive(folder.parent);
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2018-02-09 05:11:30 +01:00
|
|
|
this.$emit('open-folder', this.folder, silent);
|
2017-02-26 09:36:54 +01:00
|
|
|
this.fetch();
|
2017-02-21 17:05:23 +01:00
|
|
|
});
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
addFolder(folder, unshift = false) {
|
2017-02-21 17:05:23 +01:00
|
|
|
const current = this.folder ? this.folder.id : null;
|
|
|
|
// 追加しようとしているフォルダが、今居る階層とは違う階層のものだったら中断
|
2018-03-29 07:48:47 +02:00
|
|
|
if (current != folder.parentId) return;
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2017-02-21 17:05:23 +01:00
|
|
|
// 追加しようとしているフォルダを既に所有してたら中断
|
|
|
|
if (this.folders.some(f => f.id == folder.id)) return;
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2017-02-21 17:05:23 +01:00
|
|
|
if (unshift) {
|
|
|
|
this.folders.unshift(folder);
|
|
|
|
} else {
|
|
|
|
this.folders.push(folder);
|
|
|
|
}
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2016-12-28 23:49:51 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
addFile(file, unshift = false) {
|
2017-02-21 17:05:23 +01:00
|
|
|
const current = this.folder ? this.folder.id : null;
|
|
|
|
// 追加しようとしているファイルが、今居る階層とは違う階層のものだったら中断
|
2018-03-29 07:48:47 +02:00
|
|
|
if (current != file.folderId) return;
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2017-02-21 17:05:23 +01:00
|
|
|
if (this.files.some(f => f.id == file.id)) {
|
|
|
|
const exist = this.files.map(f => f.id).indexOf(file.id);
|
2018-02-20 17:23:25 +01:00
|
|
|
Vue.set(this.files, exist, file);
|
2017-02-21 17:05:23 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-12-28 23:49:51 +01:00
|
|
|
|
2017-02-21 17:05:23 +01:00
|
|
|
if (unshift) {
|
|
|
|
this.files.unshift(file);
|
|
|
|
} else {
|
|
|
|
this.files.push(file);
|
|
|
|
}
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
removeFolder(folder) {
|
2017-02-21 17:05:23 +01:00
|
|
|
if (typeof folder == 'object') folder = folder.id;
|
|
|
|
this.folders = this.folders.filter(f => f.id != folder);
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
removeFile(file) {
|
2017-02-21 17:05:23 +01:00
|
|
|
if (typeof file == 'object') file = file.id;
|
|
|
|
this.files = this.files.filter(f => f.id != file);
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
appendFile(file) {
|
|
|
|
this.addFile(file);
|
|
|
|
},
|
|
|
|
appendFolder(folder) {
|
|
|
|
this.addFolder(folder);
|
|
|
|
},
|
|
|
|
prependFile(file) {
|
|
|
|
this.addFile(file, true);
|
|
|
|
},
|
|
|
|
prependFolder(folder) {
|
|
|
|
this.addFolder(folder, true);
|
|
|
|
},
|
2017-12-08 18:11:48 +01:00
|
|
|
|
2018-02-22 10:37:47 +01:00
|
|
|
goRoot(silent = false) {
|
2017-02-21 17:05:23 +01:00
|
|
|
if (this.folder || this.file) {
|
2018-02-16 16:36:28 +01:00
|
|
|
this.file = null;
|
|
|
|
this.folder = null;
|
|
|
|
this.hierarchyFolders = [];
|
2018-02-22 10:37:47 +01:00
|
|
|
this.$emit('move-root', silent);
|
2017-02-26 09:36:54 +01:00
|
|
|
this.fetch();
|
2017-02-21 17:05:23 +01:00
|
|
|
}
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-12-08 17:51:05 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
fetch() {
|
|
|
|
this.folders = [];
|
|
|
|
this.files = [];
|
|
|
|
this.moreFolders = false;
|
|
|
|
this.moreFiles = false;
|
|
|
|
this.fetching = true;
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2018-02-09 05:11:30 +01:00
|
|
|
this.$emit('begin-fetch');
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2017-02-21 17:05:23 +01:00
|
|
|
let fetchedFolders = null;
|
|
|
|
let fetchedFiles = null;
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2017-02-21 17:05:23 +01:00
|
|
|
const foldersMax = 20;
|
|
|
|
const filesMax = 20;
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2017-02-20 01:53:57 +01:00
|
|
|
// フォルダ一覧取得
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/folders', {
|
2018-03-29 07:48:47 +02:00
|
|
|
folderId: this.folder ? this.folder.id : null,
|
2017-02-21 17:05:23 +01:00
|
|
|
limit: foldersMax + 1
|
|
|
|
}).then(folders => {
|
|
|
|
if (folders.length == foldersMax + 1) {
|
|
|
|
this.moreFolders = true;
|
|
|
|
folders.pop();
|
|
|
|
}
|
|
|
|
fetchedFolders = folders;
|
|
|
|
complete();
|
|
|
|
});
|
2017-01-11 21:55:38 +01:00
|
|
|
|
2017-02-20 01:53:57 +01:00
|
|
|
// ファイル一覧取得
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/files', {
|
2018-03-29 07:48:47 +02:00
|
|
|
folderId: this.folder ? this.folder.id : null,
|
2017-02-21 17:05:23 +01:00
|
|
|
limit: filesMax + 1
|
|
|
|
}).then(files => {
|
|
|
|
if (files.length == filesMax + 1) {
|
|
|
|
this.moreFiles = true;
|
|
|
|
files.pop();
|
|
|
|
}
|
|
|
|
fetchedFiles = files;
|
|
|
|
complete();
|
|
|
|
});
|
|
|
|
|
|
|
|
let flag = false;
|
2017-02-21 18:05:44 +01:00
|
|
|
const complete = () => {
|
2017-02-21 17:05:23 +01:00
|
|
|
if (flag) {
|
2017-02-23 16:18:33 +01:00
|
|
|
fetchedFolders.forEach(this.appendFolder);
|
|
|
|
fetchedFiles.forEach(this.appendFile);
|
2018-02-16 16:36:28 +01:00
|
|
|
this.fetching = false;
|
|
|
|
|
2017-02-21 17:05:23 +01:00
|
|
|
// 一連の読み込みが完了したイベントを発行
|
2018-02-09 05:11:30 +01:00
|
|
|
this.$emit('fetched');
|
2017-02-21 17:05:23 +01:00
|
|
|
} else {
|
|
|
|
flag = true;
|
|
|
|
// 一連の読み込みが半分完了したイベントを発行
|
2018-02-09 05:11:30 +01:00
|
|
|
this.$emit('fetch-mid');
|
2017-02-21 17:05:23 +01:00
|
|
|
}
|
|
|
|
};
|
2017-03-18 16:02:45 +01:00
|
|
|
|
|
|
|
if (this.folder == null) {
|
|
|
|
// Fetch addtional drive info
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive').then(info => {
|
2018-02-16 16:36:28 +01:00
|
|
|
this.info = info;
|
2017-03-18 16:02:45 +01:00
|
|
|
});
|
|
|
|
}
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-02-21 17:05:23 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
fetchMoreFiles() {
|
|
|
|
this.fetching = true;
|
|
|
|
this.fetchingMoreFiles = true;
|
2017-02-26 09:36:54 +01:00
|
|
|
|
|
|
|
const max = 30;
|
|
|
|
|
|
|
|
// ファイル一覧取得
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/files', {
|
2018-03-29 07:48:47 +02:00
|
|
|
folderId: this.folder ? this.folder.id : null,
|
2017-06-06 18:55:02 +02:00
|
|
|
limit: max + 1,
|
2018-03-29 07:48:47 +02:00
|
|
|
untilId: this.files[this.files.length - 1].id
|
2017-02-26 09:36:54 +01:00
|
|
|
}).then(files => {
|
|
|
|
if (files.length == max + 1) {
|
|
|
|
this.moreFiles = true;
|
|
|
|
files.pop();
|
|
|
|
} else {
|
|
|
|
this.moreFiles = false;
|
|
|
|
}
|
|
|
|
files.forEach(this.appendFile);
|
2018-02-16 16:36:28 +01:00
|
|
|
this.fetching = false;
|
|
|
|
this.fetchingMoreFiles = false;
|
2017-02-26 09:36:54 +01:00
|
|
|
});
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-02-26 09:36:54 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
chooseFile(file) {
|
2017-03-12 11:27:54 +01:00
|
|
|
if (this.isFileSelectMode) {
|
2017-08-28 13:23:47 +02:00
|
|
|
if (this.multiple) {
|
|
|
|
if (this.selectedFiles.some(f => f.id == file.id)) {
|
|
|
|
this.selectedFiles = this.selectedFiles.filter(f => f.id != file.id);
|
|
|
|
} else {
|
|
|
|
this.selectedFiles.push(file);
|
|
|
|
}
|
2018-02-09 05:11:30 +01:00
|
|
|
this.$emit('change-selection', this.selectedFiles);
|
2017-02-21 17:05:23 +01:00
|
|
|
} else {
|
2018-02-09 05:11:30 +01:00
|
|
|
this.$emit('selected', file);
|
2017-02-21 17:05:23 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.cf(file);
|
|
|
|
}
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-02-16 09:20:45 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
cf(file, silent = false) {
|
2017-02-21 17:05:23 +01:00
|
|
|
if (typeof file == 'object') file = file.id;
|
2017-02-16 09:20:45 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
this.fetching = true;
|
2017-02-16 09:20:45 +01:00
|
|
|
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/files/show', {
|
2018-03-29 07:48:47 +02:00
|
|
|
fileId: file
|
2017-02-21 17:05:23 +01:00
|
|
|
}).then(file => {
|
|
|
|
this.file = file;
|
|
|
|
this.folder = null;
|
|
|
|
this.hierarchyFolders = [];
|
2017-02-16 09:20:45 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
if (file.folder) this.dive(file.folder);
|
2017-02-16 09:20:45 +01:00
|
|
|
|
2018-02-19 15:37:09 +01:00
|
|
|
this.fetching = false;
|
|
|
|
|
2018-02-09 05:11:30 +01:00
|
|
|
this.$emit('open-file', this.file, silent);
|
2017-02-21 17:05:23 +01:00
|
|
|
});
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-03-13 06:56:53 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
openContextMenu() {
|
2018-05-27 14:51:57 +02:00
|
|
|
const fn = window.prompt('%i18n:@prompt%');
|
2017-03-13 06:56:53 +01:00
|
|
|
if (fn == null || fn == '') return;
|
|
|
|
switch (fn) {
|
|
|
|
case '1':
|
2017-10-31 19:31:36 +01:00
|
|
|
this.selectLocalFile();
|
2017-03-13 06:56:53 +01:00
|
|
|
break;
|
|
|
|
case '2':
|
|
|
|
this.urlUpload();
|
|
|
|
break;
|
|
|
|
case '3':
|
|
|
|
this.createFolder();
|
|
|
|
break;
|
|
|
|
case '4':
|
|
|
|
this.renameFolder();
|
|
|
|
break;
|
|
|
|
case '5':
|
|
|
|
this.moveFolder();
|
|
|
|
break;
|
|
|
|
case '6':
|
2018-05-27 14:51:57 +02:00
|
|
|
alert('%i18n:@deletion-alert%');
|
2017-03-13 06:56:53 +01:00
|
|
|
break;
|
|
|
|
}
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-03-13 06:56:53 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
selectLocalFile() {
|
|
|
|
(this.$refs.file as any).click();
|
|
|
|
},
|
2017-10-31 19:31:36 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
createFolder() {
|
2018-05-27 14:51:57 +02:00
|
|
|
const name = window.prompt('%i18n:@folder-name%');
|
2017-03-13 06:56:53 +01:00
|
|
|
if (name == null || name == '') return;
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/folders/create', {
|
2017-03-13 06:56:53 +01:00
|
|
|
name: name,
|
2018-03-29 07:48:47 +02:00
|
|
|
parentId: this.folder ? this.folder.id : undefined
|
2017-03-13 06:56:53 +01:00
|
|
|
}).then(folder => {
|
|
|
|
this.addFolder(folder, true);
|
|
|
|
});
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-03-13 06:56:53 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
renameFolder() {
|
2017-03-13 06:56:53 +01:00
|
|
|
if (this.folder == null) {
|
2018-05-27 14:51:57 +02:00
|
|
|
alert('%i18n:@root-rename-alert%');
|
2017-03-13 06:56:53 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-05-27 14:51:57 +02:00
|
|
|
const name = window.prompt('%i18n:@folder-name%', this.folder.name);
|
2017-03-13 06:56:53 +01:00
|
|
|
if (name == null || name == '') return;
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/folders/update', {
|
2017-03-13 06:56:53 +01:00
|
|
|
name: name,
|
2018-03-29 07:48:47 +02:00
|
|
|
folderId: this.folder.id
|
2017-03-13 06:56:53 +01:00
|
|
|
}).then(folder => {
|
|
|
|
this.cd(folder);
|
|
|
|
});
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-03-13 06:56:53 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
moveFolder() {
|
2017-03-13 06:56:53 +01:00
|
|
|
if (this.folder == null) {
|
2018-05-27 14:51:57 +02:00
|
|
|
alert('%i18n:@root-move-alert%');
|
2017-03-13 06:56:53 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-02-21 23:06:47 +01:00
|
|
|
(this as any).apis.chooseDriveFolder().then(folder => {
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/folders/update', {
|
2018-03-29 07:48:47 +02:00
|
|
|
parentId: folder ? folder.id : null,
|
|
|
|
folderId: this.folder.id
|
2017-03-13 06:56:53 +01:00
|
|
|
}).then(folder => {
|
|
|
|
this.cd(folder);
|
|
|
|
});
|
|
|
|
});
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
2017-03-13 06:56:53 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
urlUpload() {
|
2018-05-27 14:51:57 +02:00
|
|
|
const url = window.prompt('%i18n:@url-prompt%');
|
2017-03-13 06:56:53 +01:00
|
|
|
if (url == null || url == '') return;
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('drive/files/upload_from_url', {
|
2017-03-13 06:56:53 +01:00
|
|
|
url: url,
|
2018-03-29 07:48:47 +02:00
|
|
|
folderId: this.folder ? this.folder.id : undefined
|
2017-03-13 06:56:53 +01:00
|
|
|
});
|
2018-05-27 14:51:57 +02:00
|
|
|
alert('%i18n:@uploading%');
|
2018-02-16 16:36:28 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
onChangeLocalFile() {
|
|
|
|
Array.from((this.$refs.file as any).files)
|
|
|
|
.forEach(f => (this.$refs.uploader as any).upload(f, this.folder));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 07:03:55 +02:00
|
|
|
.kmmwchoexgckptowjmjgfsygeltxfeqs
|
2018-09-26 13:28:13 +02:00
|
|
|
background var(--face)
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
> nav
|
|
|
|
display block
|
|
|
|
position sticky
|
|
|
|
position -webkit-sticky
|
|
|
|
top 0
|
|
|
|
z-index 1
|
|
|
|
width 100%
|
|
|
|
padding 10px 12px
|
|
|
|
overflow auto
|
|
|
|
white-space nowrap
|
|
|
|
font-size 0.9em
|
2018-09-28 07:03:55 +02:00
|
|
|
color var(--text)
|
2018-02-16 16:36:28 +01:00
|
|
|
-webkit-backdrop-filter blur(12px)
|
|
|
|
backdrop-filter blur(12px)
|
2018-09-28 07:03:55 +02:00
|
|
|
background-color var(--mobileDriveNavBg)
|
2018-04-29 01:51:17 +02:00
|
|
|
border-bottom solid 1px rgba(#000, 0.13)
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
> p
|
|
|
|
> a
|
|
|
|
display inline
|
|
|
|
margin 0
|
|
|
|
padding 0
|
|
|
|
text-decoration none !important
|
|
|
|
color inherit
|
|
|
|
|
|
|
|
&:last-child
|
|
|
|
font-weight bold
|
|
|
|
|
|
|
|
> [data-fa]
|
|
|
|
margin-right 4px
|
|
|
|
|
|
|
|
> span
|
|
|
|
margin 0 8px
|
|
|
|
opacity 0.5
|
|
|
|
|
|
|
|
> .browser
|
|
|
|
&.fetching
|
|
|
|
opacity 0.5
|
|
|
|
|
|
|
|
> .info
|
2018-09-28 07:03:55 +02:00
|
|
|
border-bottom solid 1px var(--faceDivider)
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
&:empty
|
|
|
|
display none
|
2017-03-13 06:56:53 +01:00
|
|
|
|
2018-02-16 16:36:28 +01:00
|
|
|
> p
|
|
|
|
display block
|
|
|
|
max-width 500px
|
|
|
|
margin 0 auto
|
|
|
|
padding 4px 16px
|
|
|
|
font-size 10px
|
2018-09-28 07:03:55 +02:00
|
|
|
color var(--text)
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
> .folders
|
2018-02-21 23:06:47 +01:00
|
|
|
> .folder
|
2018-09-28 07:03:55 +02:00
|
|
|
border-bottom solid 1px var(--faceDivider)
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
> .files
|
2018-02-21 23:06:47 +01:00
|
|
|
> .file
|
2018-09-28 07:03:55 +02:00
|
|
|
border-bottom solid 1px var(--faceDivider)
|
2018-02-16 16:36:28 +01:00
|
|
|
|
|
|
|
> .more
|
|
|
|
display block
|
|
|
|
width 100%
|
|
|
|
padding 16px
|
|
|
|
font-size 16px
|
|
|
|
color #555
|
|
|
|
|
|
|
|
> .empty
|
|
|
|
padding 16px
|
|
|
|
text-align center
|
|
|
|
color #999
|
|
|
|
pointer-events none
|
|
|
|
|
|
|
|
> p
|
|
|
|
margin 0
|
|
|
|
|
|
|
|
> .fetching
|
|
|
|
.spinner
|
|
|
|
margin 100px auto
|
|
|
|
width 40px
|
|
|
|
height 40px
|
|
|
|
text-align center
|
|
|
|
|
|
|
|
animation sk-rotate 2.0s infinite linear
|
|
|
|
|
|
|
|
.dot1, .dot2
|
|
|
|
width 60%
|
|
|
|
height 60%
|
|
|
|
display inline-block
|
|
|
|
position absolute
|
|
|
|
top 0
|
2018-04-29 01:51:17 +02:00
|
|
|
background rgba(#000, 0.2)
|
2018-02-16 16:36:28 +01:00
|
|
|
border-radius 100%
|
|
|
|
|
|
|
|
animation sk-bounce 2.0s infinite ease-in-out
|
|
|
|
|
|
|
|
.dot2
|
|
|
|
top auto
|
|
|
|
bottom 0
|
|
|
|
animation-delay -1.0s
|
|
|
|
|
|
|
|
@keyframes sk-rotate { 100% { transform: rotate(360deg); }}
|
|
|
|
|
|
|
|
@keyframes sk-bounce {
|
|
|
|
0%, 100% {
|
|
|
|
transform: scale(0.0);
|
|
|
|
} 50% {
|
|
|
|
transform: scale(1.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-21 23:06:47 +01:00
|
|
|
> .file
|
2018-02-16 16:36:28 +01:00
|
|
|
display none
|
|
|
|
|
|
|
|
</style>
|