github.com/manicqin/nomad@v0.9.5/ui/app/routes/allocations/allocation/task/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 task = this.modelFor('allocations.allocation.task'); 9 10 const pathWithTaskName = `${task.name}${decodedPath.startsWith('/') ? '' : '/'}${decodedPath}`; 11 12 if (!task.isRunning) { 13 return { 14 path: decodedPath, 15 task, 16 }; 17 } 18 19 return RSVP.all([task.stat(pathWithTaskName), task.get('allocation.node')]) 20 .then(([statJson]) => { 21 if (statJson.IsDir) { 22 return RSVP.hash({ 23 path: decodedPath, 24 task, 25 directoryEntries: task.ls(pathWithTaskName).catch(notifyError(this)), 26 isFile: false, 27 }); 28 } else { 29 return { 30 path: decodedPath, 31 task, 32 isFile: true, 33 stat: statJson, 34 }; 35 } 36 }) 37 .catch(notifyError(this)); 38 }, 39 40 setupController(controller, { path, task, directoryEntries, isFile, stat } = {}) { 41 this._super(...arguments); 42 controller.setProperties({ path, task, directoryEntries, isFile, stat }); 43 }, 44 });