github.com/hernad/nomad@v1.6.112/ui/app/routes/allocations/allocation/fs.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import Route from '@ember/routing/route'; 7 import RSVP from 'rsvp'; 8 import notifyError from 'nomad-ui/utils/notify-error'; 9 10 export default class FsRoute extends Route { 11 model({ path = '/' }) { 12 const decodedPath = decodeURIComponent(path); 13 const allocation = this.modelFor('allocations.allocation'); 14 15 if (!allocation) return; 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 24 .ls(decodedPath) 25 .catch(notifyError(this)), 26 isFile: false, 27 }); 28 } else { 29 return { 30 path: decodedPath, 31 allocation, 32 isFile: true, 33 stat: statJson, 34 }; 35 } 36 }) 37 .catch(notifyError(this)); 38 } 39 40 setupController( 41 controller, 42 { path, allocation, directoryEntries, isFile, stat } = {} 43 ) { 44 super.setupController(...arguments); 45 controller.setProperties({ 46 path, 47 allocation, 48 directoryEntries, 49 isFile, 50 stat, 51 }); 52 } 53 }