Show listings of a path

This commit is contained in:
2017-11-12 04:03:13 +01:00
parent ff2f44df18
commit 0607d82e50
13 changed files with 106 additions and 23 deletions

View File

@@ -1,8 +1,39 @@
import Route from '@ember/routing/route';
import EmberObject from '@ember/object';
import { inject as service } from '@ember/service';
import { isEmpty } from '@ember/utils';
export default Route.extend({
storage: service()
storage: service(),
queryParams: {
path: {
refreshModel: true
}
},
model(params) {
let path = params.path;
let items = [];
if (isEmpty(params.path)) { return null; }
if (path.substr(-1) !== '/') { path += '/'; }
return this.get('storage.client').getListing(path).then(listing => {
Object.keys(listing).forEach(name => {
let item = listing[name];
items.push(EmberObject.create({
name: name,
type: item['Content-Type'] || 'folder',
size: item['Content-Length'] || null
}));
});
return items;
});
}
});