diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-13 14:56:53 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-13 14:56:53 +0900 |
| commit | 3dd3d06b1925c9c4cbfc0e9a3cb3205af17e3e9f (patch) | |
| tree | 380e0a0ecbfe17aa28570da67bb7f0c6e425af0e | |
| parent | [Client] :v: (diff) | |
| download | sharkey-3dd3d06b1925c9c4cbfc0e9a3cb3205af17e3e9f.tar.gz sharkey-3dd3d06b1925c9c4cbfc0e9a3cb3205af17e3e9f.tar.bz2 sharkey-3dd3d06b1925c9c4cbfc0e9a3cb3205af17e3e9f.zip | |
[Client] :v:
| -rw-r--r-- | src/web/app/common/tags/uploader.tag | 2 | ||||
| -rw-r--r-- | src/web/app/mobile/tags/drive.tag | 87 | ||||
| -rw-r--r-- | src/web/app/mobile/tags/drive/file-viewer.tag | 4 | ||||
| -rw-r--r-- | src/web/app/mobile/tags/page/drive.tag | 4 |
4 files changed, 94 insertions, 3 deletions
diff --git a/src/web/app/common/tags/uploader.tag b/src/web/app/common/tags/uploader.tag index d40ac0a6a0..845cd9d127 100644 --- a/src/web/app/common/tags/uploader.tag +++ b/src/web/app/common/tags/uploader.tag @@ -145,6 +145,8 @@ this.uploads = []; this.upload = (file, folder) => { + if (folder && typeof folder == 'object') folder = folder.id; + const id = Math.random(); const ctx = { diff --git a/src/web/app/mobile/tags/drive.tag b/src/web/app/mobile/tags/drive.tag index 307caa4707..f1a9bf9f43 100644 --- a/src/web/app/mobile/tags/drive.tag +++ b/src/web/app/mobile/tags/drive.tag @@ -14,6 +14,7 @@ <p>{ file.name }</p> </virtual> </nav> + <mk-uploader ref="uploader"></mk-uploader> <div class="browser { fetching: fetching }" if={ file == null }> <div class="folders" if={ folders.length > 0 }> <virtual each={ folder in folders }> @@ -38,6 +39,7 @@ </div> </div> </div> + <input ref="file" type="file" multiple="multiple" onchange={ changeLocalFile }/> <mk-drive-file-viewer if={ file != null } file={ file }></mk-drive-file-viewer> <style> :scope @@ -126,6 +128,9 @@ } } + > [ref='file'] + display none + </style> <script> this.mixin('api'); @@ -419,5 +424,87 @@ this.hierarchyFolders.unshift(folder); if (folder.parent) dive(folder.parent); }; + + this.openContextMenu = () => { + const fn = window.prompt('何をしますか?(数字を入力してください): <1 → ファイルをアップロード | 2 → ファイルをURLでアップロード | 3 → フォルダ作成 | 4 → このフォルダ名を変更 | 5 → このフォルダを移動 | 6 → このフォルダを削除>'); + if (fn == null || fn == '') return; + switch (fn) { + case '1': + this.refs.file.click(); + break; + case '2': + this.urlUpload(); + break; + case '3': + this.createFolder(); + break; + case '4': + this.renameFolder(); + break; + case '5': + this.moveFolder(); + break; + case '6': + alert('ごめんなさい!フォルダの削除は未実装です...。'); + break; + } + }; + + this.createFolder = () => { + const name = window.prompt('フォルダー名'); + if (name == null || name == '') return; + this.api('drive/folders/create', { + name: name, + folder_id: this.folder ? this.folder.id : undefined + }).then(folder => { + this.addFolder(folder, true); + this.update(); + }); + }; + + this.renameFolder = () => { + if (this.folder == null) { + alert('現在いる場所はルートで、フォルダではないため名前の変更はできません。名前を変更したいフォルダに移動してからやってください。'); + return; + } + const name = window.prompt('フォルダー名', this.folder.name); + if (name == null || name == '') return; + this.api('drive/folders/update', { + name: name, + folder_id: this.folder.id + }).then(folder => { + this.cd(folder); + }); + }; + + this.moveFolder = () => { + if (this.folder == null) { + alert('現在いる場所はルートで、フォルダではないため移動はできません。移動したいフォルダに移動してからやってください。'); + return; + } + const dialog = riot.mount(document.body.appendChild(document.createElement('mk-drive-folder-selector')))[0]; + dialog.one('selected', folder => { + this.api('drive/folders/update', { + parent_id: folder.id, + folder_id: this.folder.id + }).then(folder => { + this.cd(folder); + }); + }); + }; + + this.urlUpload = () => { + const url = window.prompt('アップロードしたいファイルのURL'); + if (url == null || url == '') return; + this.api('drive/files/upload_from_url', { + url: url, + folder_id: this.folder ? this.folder.id : undefined + }); + alert('アップロードをリクエストしました。アップロードが完了するまで時間がかかる場合があります。'); + }; + + this.changeLocalFile = () => { + this.refs.file.files.forEach(f => this.refs.uploader.upload(f, this.folder)); + }; </script> </mk-drive> diff --git a/src/web/app/mobile/tags/drive/file-viewer.tag b/src/web/app/mobile/tags/drive/file-viewer.tag index ca8d912c67..cfa77dcb91 100644 --- a/src/web/app/mobile/tags/drive/file-viewer.tag +++ b/src/web/app/mobile/tags/drive/file-viewer.tag @@ -203,9 +203,7 @@ }; this.move = () => { - const dialog = riot.mount(document.body.appendChild(document.createElement('mk-drive-folder-selector')), { - multiple: true - })[0]; + const dialog = riot.mount(document.body.appendChild(document.createElement('mk-drive-folder-selector')))[0]; dialog.one('selected', folder => { this.api('drive/files/update', { file_id: this.file.id, diff --git a/src/web/app/mobile/tags/page/drive.tag b/src/web/app/mobile/tags/page/drive.tag index 577f47ec78..bacfa25826 100644 --- a/src/web/app/mobile/tags/page/drive.tag +++ b/src/web/app/mobile/tags/page/drive.tag @@ -14,6 +14,10 @@ document.title = 'Misskey Drive'; this.ui.trigger('title', '<i class="fa fa-cloud"></i>ドライブ'); + this.ui.trigger('func', () => { + this.refs.ui.refs.browser.openContextMenu(); + }, 'ellipsis-h'); + this.refs.ui.refs.browser.on('begin-fetch', () => { this.Progress.start(); }); |