github.com/outbrain/consul@v1.4.5/ui-v2/app/routes/dc/kv/edit.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 } from '@ember/object'; 5 import WithKvActions from 'consul-ui/mixins/kv/with-actions'; 6 7 import ascend from 'consul-ui/utils/ascend'; 8 9 export default Route.extend(WithKvActions, { 10 repo: service('repository/kv'), 11 sessionRepo: service('repository/session'), 12 model: function(params) { 13 const key = params.key; 14 const dc = this.modelFor('dc').dc.Name; 15 const repo = get(this, 'repo'); 16 return hash({ 17 isLoading: false, 18 parent: repo.findBySlug(ascend(key, 1) || '/', dc), 19 item: repo.findBySlug(key, dc), 20 }).then(model => { 21 // TODO: Consider loading this after initial page load 22 const session = get(model.item, 'Session'); 23 if (session) { 24 return hash({ 25 ...model, 26 ...{ 27 session: get(this, 'sessionRepo').findByKey(session, dc), 28 }, 29 }); 30 } 31 return model; 32 }); 33 }, 34 setupController: function(controller, model) { 35 this._super(...arguments); 36 controller.setProperties(model); 37 }, 38 });