github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/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 import classic from 'ember-classic-decorator'; 9 10 @classic 11 export default class VolumeRoute extends Route.extend(WithWatchers) { 12 @service store; 13 @service system; 14 15 breadcrumbs = volume => [ 16 { 17 label: 'Volumes', 18 args: [ 19 'csi.volumes', 20 qpBuilder({ volumeNamespace: volume.get('namespace.name') || 'default' }), 21 ], 22 }, 23 { 24 label: volume.name, 25 args: [ 26 'csi.volumes.volume', 27 volume.plainId, 28 qpBuilder({ volumeNamespace: volume.get('namespace.name') || 'default' }), 29 ], 30 }, 31 ]; 32 33 startWatchers(controller, model) { 34 if (!model) return; 35 36 controller.set('watchers', { 37 model: this.watch.perform(model), 38 }); 39 } 40 41 serialize(model) { 42 return { volume_name: model.get('plainId') }; 43 } 44 45 model(params, transition) { 46 const namespace = transition.to.queryParams.namespace || this.get('system.activeNamespace.id'); 47 const name = params.volume_name; 48 const fullId = JSON.stringify([`csi/${name}`, namespace || 'default']); 49 return this.store.findRecord('volume', fullId, { reload: true }).catch(notifyError(this)); 50 } 51 52 // Since volume includes embedded records for allocations, 53 // it's possible that allocations that are server-side deleted may 54 // not be removed from the UI while sitting on the volume detail page. 55 @watchRecord('volume') watch; 56 @collect('watch') watchers; 57 }