github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/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 class FsRoute extends Route { 6 model({ path = '/' }) { 7 const decodedPath = decodeURIComponent(path); 8 const taskState = this.modelFor('allocations.allocation.task'); 9 10 if (!taskState || !taskState.allocation) return; 11 12 const allocation = taskState.allocation; 13 const pathWithTaskName = `${taskState.name}${ 14 decodedPath.startsWith('/') ? '' : '/' 15 }${decodedPath}`; 16 17 return RSVP.all([ 18 allocation.stat(pathWithTaskName), 19 taskState.get('allocation.node'), 20 ]) 21 .then(([statJson]) => { 22 if (statJson.IsDir) { 23 return RSVP.hash({ 24 path: decodedPath, 25 taskState, 26 directoryEntries: allocation 27 .ls(pathWithTaskName) 28 .catch(notifyError(this)), 29 isFile: false, 30 }); 31 } else { 32 return { 33 path: decodedPath, 34 taskState, 35 isFile: true, 36 stat: statJson, 37 }; 38 } 39 }) 40 .catch(notifyError(this)); 41 } 42 43 setupController( 44 controller, 45 { path, taskState, directoryEntries, isFile, stat } = {} 46 ) { 47 super.setupController(...arguments); 48 controller.setProperties({ 49 path, 50 taskState, 51 directoryEntries, 52 isFile, 53 stat, 54 }); 55 } 56 }