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