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