89136cbf6a
Manual interventions: • decorators on the same line for service and controller injections and most computed property macros • preserving import order when possible, both per-line and intra-line • moving new imports to the bottom • removal of classic decorator for trivial cases • conversion of init to constructor when appropriate
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import Route from '@ember/routing/route';
|
|
import RSVP from 'rsvp';
|
|
import notifyError from 'nomad-ui/utils/notify-error';
|
|
|
|
export default class FsRoute extends Route {
|
|
model({ path = '/' }) {
|
|
const decodedPath = decodeURIComponent(path);
|
|
const taskState = this.modelFor('allocations.allocation.task');
|
|
const allocation = taskState.allocation;
|
|
|
|
const pathWithTaskName = `${taskState.name}${
|
|
decodedPath.startsWith('/') ? '' : '/'
|
|
}${decodedPath}`;
|
|
|
|
if (!taskState.isRunning) {
|
|
return {
|
|
path: decodedPath,
|
|
taskState,
|
|
};
|
|
}
|
|
|
|
return RSVP.all([allocation.stat(pathWithTaskName), taskState.get('allocation.node')])
|
|
.then(([statJson]) => {
|
|
if (statJson.IsDir) {
|
|
return RSVP.hash({
|
|
path: decodedPath,
|
|
taskState,
|
|
directoryEntries: allocation.ls(pathWithTaskName).catch(notifyError(this)),
|
|
isFile: false,
|
|
});
|
|
} else {
|
|
return {
|
|
path: decodedPath,
|
|
taskState,
|
|
isFile: true,
|
|
stat: statJson,
|
|
};
|
|
}
|
|
})
|
|
.catch(notifyError(this));
|
|
}
|
|
|
|
setupController(controller, { path, taskState, directoryEntries, isFile, stat } = {}) {
|
|
super.setupController(...arguments);
|
|
controller.setProperties({ path, taskState, directoryEntries, isFile, stat });
|
|
}
|
|
}
|