diff options
-rw-r--r-- | frontend/index.html | 1 | ||||
-rw-r--r-- | frontend/js/app.js | 7 | ||||
-rw-r--r-- | src/files.js | 2 |
3 files changed, 9 insertions, 1 deletions
diff --git a/frontend/index.html b/frontend/index.html index 5374339..a6d0eb0 100644 --- a/frontend/index.html +++ b/frontend/index.html | |||
@@ -183,6 +183,7 @@ | |||
183 | <th><span v-my-tooltip="foobar" data-toggle="tooltip" title="{{ entry.mtime }}">{{ entry.mtime | prettyDate }}</span></th> | 183 | <th><span v-my-tooltip="foobar" data-toggle="tooltip" title="{{ entry.mtime }}">{{ entry.mtime | prettyDate }}</span></th> |
184 | <th style="text-align: right;"> | 184 | <th style="text-align: right;"> |
185 | <span class="entry-toolbar"> | 185 | <span class="entry-toolbar"> |
186 | <button class="btn btn-sm btn-default" v-on:click.stop="download(entry)" title="Download" v-show="entry.isFile"><i class="fa fa-download"></i></button> | ||
186 | <button class="btn btn-sm btn-default" v-on:click.stop="renameAsk(entry)" title="Rename"><i class="fa fa-pencil"></i></button> | 187 | <button class="btn btn-sm btn-default" v-on:click.stop="renameAsk(entry)" title="Rename"><i class="fa fa-pencil"></i></button> |
187 | <button class="btn btn-sm btn-danger" v-on:click.stop="delAsk(entry)" title="Delete"><i class="fa fa-trash"></i></button> | 188 | <button class="btn btn-sm btn-danger" v-on:click.stop="delAsk(entry)" title="Delete"><i class="fa fa-trash"></i></button> |
188 | </span> | 189 | </span> |
diff --git a/frontend/js/app.js b/frontend/js/app.js index befed24..bf9b534 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js | |||
@@ -135,6 +135,12 @@ function open(entry) { | |||
135 | window.open(encode(path)); | 135 | window.open(encode(path)); |
136 | } | 136 | } |
137 | 137 | ||
138 | function download(entry) { | ||
139 | if (entry.isDirectory) return; | ||
140 | |||
141 | window.open(encode('/api/files/' + sanitize(app.path + '/' + entry.filePath)) + '?access_token=' + localStorage.accessToken); | ||
142 | } | ||
143 | |||
138 | function up() { | 144 | function up() { |
139 | window.location.hash = sanitize(app.path.split('/').slice(0, -1).filter(function (p) { return !!p; }).join('/')); | 145 | window.location.hash = sanitize(app.path.split('/').slice(0, -1).filter(function (p) { return !!p; }).join('/')); |
140 | } | 146 | } |
@@ -329,6 +335,7 @@ var app = new Vue({ | |||
329 | logout: logout, | 335 | logout: logout, |
330 | loadDirectory: loadDirectory, | 336 | loadDirectory: loadDirectory, |
331 | open: open, | 337 | open: open, |
338 | download: download, | ||
332 | up: up, | 339 | up: up, |
333 | upload: upload, | 340 | upload: upload, |
334 | delAsk: delAsk, | 341 | delAsk: delAsk, |
diff --git a/src/files.js b/src/files.js index 876ff4e..1af4a18 100644 --- a/src/files.js +++ b/src/files.js | |||
@@ -88,7 +88,7 @@ function get(req, res, next) { | |||
88 | debug('get', absoluteFilePath); | 88 | debug('get', absoluteFilePath); |
89 | 89 | ||
90 | if (!result.isDirectory() && !result.isFile()) return next(new HttpError(500, 'unsupported type')); | 90 | if (!result.isDirectory() && !result.isFile()) return next(new HttpError(500, 'unsupported type')); |
91 | if (result.isFile()) return res.sendFile(absoluteFilePath); | 91 | if (result.isFile()) return res.download(absoluteFilePath); |
92 | 92 | ||
93 | async.map(fs.readdirSync(absoluteFilePath), function (filePath, callback) { | 93 | async.map(fs.readdirSync(absoluteFilePath), function (filePath, callback) { |
94 | fs.stat(path.join(absoluteFilePath, filePath), function (error, result) { | 94 | fs.stat(path.join(absoluteFilePath, filePath), function (error, result) { |