github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/controllers/allocations/allocation/task/index.js (about)

     1  import Controller from '@ember/controller';
     2  import { computed as overridable } from 'ember-overridable-computed';
     3  import { task } from 'ember-concurrency';
     4  import classic from 'ember-classic-decorator';
     5  import messageForError from 'nomad-ui/utils/message-from-adapter-error';
     6  
     7  @classic
     8  export default class IndexController extends Controller {
     9    @overridable(() => {
    10      // { title, description }
    11      return null;
    12    })
    13    error;
    14  
    15    onDismiss() {
    16      this.set('error', null);
    17    }
    18  
    19    @task(function* () {
    20      try {
    21        yield this.model.restart();
    22      } catch (err) {
    23        this.set('error', {
    24          title: 'Could Not Restart Task',
    25          description: messageForError(err, 'manage allocation lifecycle'),
    26        });
    27      }
    28    })
    29    restartTask;
    30  }