github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/ui/app/controllers/allocations/allocation/task/index.js (about) 1 import Controller from '@ember/controller'; 2 import { computed } from '@ember/object'; 3 import { alias } from '@ember/object/computed'; 4 import { task } from 'ember-concurrency'; 5 6 export default Controller.extend({ 7 network: alias('model.resources.networks.firstObject'), 8 ports: computed('network.reservedPorts.[]', 'network.dynamicPorts.[]', function() { 9 return (this.get('network.reservedPorts') || []) 10 .map(port => ({ 11 name: port.Label, 12 port: port.Value, 13 isDynamic: false, 14 })) 15 .concat( 16 (this.get('network.dynamicPorts') || []).map(port => ({ 17 name: port.Label, 18 port: port.Value, 19 isDynamic: true, 20 })) 21 ) 22 .sortBy('name'); 23 }), 24 25 error: computed(() => { 26 // { title, description } 27 return null; 28 }), 29 30 onDismiss() { 31 this.set('error', null); 32 }, 33 34 restartTask: task(function*() { 35 try { 36 yield this.model.restart(); 37 } catch (err) { 38 this.set('error', { 39 title: 'Could Not Restart Task', 40 description: 'Your ACL token does not grant allocation lifecycle permissions.', 41 }); 42 } 43 }), 44 });