github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/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
    19                .ls(decodedPath)
    20                .catch(notifyError(this)),
    21              isFile: false,
    22            });
    23          } else {
    24            return {
    25              path: decodedPath,
    26              allocation,
    27              isFile: true,
    28              stat: statJson,
    29            };
    30          }
    31        })
    32        .catch(notifyError(this));
    33    }
    34  
    35    setupController(
    36      controller,
    37      { path, allocation, directoryEntries, isFile, stat } = {}
    38    ) {
    39      super.setupController(...arguments);
    40      controller.setProperties({
    41        path,
    42        allocation,
    43        directoryEntries,
    44        isFile,
    45        stat,
    46      });
    47    }
    48  }