github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/routes/allocations/allocation/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 allocation = this.modelFor('allocations.allocation');
     9  
    10      if (!allocation) return;
    11  
    12      return RSVP.all([allocation.stat(decodedPath), allocation.get('node')])
    13        .then(([statJson]) => {
    14          if (statJson.IsDir) {
    15            return RSVP.hash({
    16              path: decodedPath,
    17              allocation,
    18              directoryEntries: allocation.ls(decodedPath).catch(notifyError(this)),
    19              isFile: false,
    20            });
    21          } else {
    22            return {
    23              path: decodedPath,
    24              allocation,
    25              isFile: true,
    26              stat: statJson,
    27            };
    28          }
    29        })
    30        .catch(notifyError(this));
    31    }
    32  
    33    setupController(controller, { path, allocation, directoryEntries, isFile, stat } = {}) {
    34      super.setupController(...arguments);
    35      controller.setProperties({ path, allocation, directoryEntries, isFile, stat });
    36    }
    37  }