github.com/outbrain/consul@v1.4.5/ui-v2/app/routes/dc/intentions/create.js (about) 1 import Route from '@ember/routing/route'; 2 import { inject as service } from '@ember/service'; 3 import { hash } from 'rsvp'; 4 import { get, set } from '@ember/object'; 5 import WithIntentionActions from 'consul-ui/mixins/intention/with-actions'; 6 7 export default Route.extend(WithIntentionActions, { 8 templateName: 'dc/intentions/edit', 9 repo: service('repository/intention'), 10 servicesRepo: service('repository/service'), 11 beforeModel: function() { 12 get(this, 'repo').invalidate(); 13 }, 14 model: function(params) { 15 this.item = get(this, 'repo').create(); 16 set(this.item, 'Datacenter', this.modelFor('dc').dc.Name); 17 return hash({ 18 create: true, 19 isLoading: false, 20 item: this.item, 21 items: get(this, 'servicesRepo').findAllByDatacenter(this.modelFor('dc').dc.Name), 22 intents: ['allow', 'deny'], 23 }).then(function(model) { 24 return { 25 ...model, 26 ...{ 27 items: [{ Name: '*' }].concat( 28 model.items.toArray().filter(item => get(item, 'Kind') !== 'connect-proxy') 29 ), 30 }, 31 }; 32 }); 33 }, 34 setupController: function(controller, model) { 35 this._super(...arguments); 36 controller.setProperties(model); 37 }, 38 deactivate: function() { 39 if (get(this.item, 'isNew')) { 40 this.item.destroyRecord(); 41 } 42 }, 43 });