github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/app/routes/csi/volumes/volume.js (about) 1 import { inject as service } from '@ember/service'; 2 import Route from '@ember/routing/route'; 3 import { collect } from '@ember/object/computed'; 4 import notifyError from 'nomad-ui/utils/notify-error'; 5 import { qpBuilder } from 'nomad-ui/utils/classes/query-params'; 6 import { watchRecord } from 'nomad-ui/utils/properties/watch'; 7 import WithWatchers from 'nomad-ui/mixins/with-watchers'; 8 9 export default Route.extend(WithWatchers, { 10 store: service(), 11 system: service(), 12 13 breadcrumbs: volume => [ 14 { 15 label: 'Volumes', 16 args: [ 17 'csi.volumes', 18 qpBuilder({ volumeNamespace: volume.get('namespace.name') || 'default' }), 19 ], 20 }, 21 { 22 label: volume.name, 23 args: [ 24 'csi.volumes.volume', 25 volume.plainId, 26 qpBuilder({ volumeNamespace: volume.get('namespace.name') || 'default' }), 27 ], 28 }, 29 ], 30 31 startWatchers(controller, model) { 32 if (!model) return; 33 34 controller.set('watchers', { 35 model: this.watch.perform(model), 36 }); 37 }, 38 39 serialize(model) { 40 return { volume_name: model.get('plainId') }; 41 }, 42 43 model(params, transition) { 44 const namespace = transition.to.queryParams.namespace || this.get('system.activeNamespace.id'); 45 const name = params.volume_name; 46 const fullId = JSON.stringify([`csi/${name}`, namespace || 'default']); 47 return this.store.findRecord('volume', fullId, { reload: true }).catch(notifyError(this)); 48 }, 49 50 // Since volume includes embedded records for allocations, 51 // it's possible that allocations that are server-side deleted may 52 // not be removed from the UI while sitting on the volume detail page. 53 watch: watchRecord('volume'), 54 watchers: collect('watch'), 55 });