github.com/aminovpavel/nomad@v0.11.8/ui/app/routes/allocations/allocation/fs.js (about) 1 import Route from '@ember/routing/route'; 2 import RSVP from 'rsvp'; 3 import notifyError from 'nomad-ui/utils/notify-error'; 4 5 export default Route.extend({ 6 model({ path = '/' }) { 7 const decodedPath = decodeURIComponent(path); 8 const allocation = this.modelFor('allocations.allocation'); 9 10 if (!allocation.isRunning) { 11 return { 12 path: decodedPath, 13 allocation, 14 }; 15 } 16 17 return RSVP.all([allocation.stat(decodedPath), allocation.get('node')]) 18 .then(([statJson]) => { 19 if (statJson.IsDir) { 20 return RSVP.hash({ 21 path: decodedPath, 22 allocation, 23 directoryEntries: allocation.ls(decodedPath).catch(notifyError(this)), 24 isFile: false, 25 }); 26 } else { 27 return { 28 path: decodedPath, 29 allocation, 30 isFile: true, 31 stat: statJson, 32 }; 33 } 34 }) 35 .catch(notifyError(this)); 36 }, 37 38 setupController(controller, { path, allocation, directoryEntries, isFile, stat } = {}) { 39 this._super(...arguments); 40 controller.setProperties({ path, allocation, directoryEntries, isFile, stat }); 41 }, 42 });