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