github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/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 RSVP from 'rsvp'; 5 import notifyError from 'nomad-ui/utils/notify-error'; 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 startWatchers(controller, model) { 16 if (!model) return; 17 18 controller.set('watchers', { 19 model: this.watch.perform(model), 20 }); 21 } 22 23 serialize(model) { 24 return { volume_name: JSON.parse(model.get('id')).join('@') }; 25 } 26 27 model(params) { 28 // Issue with naming collissions 29 const url = params.volume_name.split('@'); 30 const namespace = url.pop(); 31 const name = url.join(''); 32 33 const fullId = JSON.stringify([`csi/${name}`, namespace || 'default']); 34 35 return RSVP.hash({ 36 volume: this.store.findRecord('volume', fullId, { reload: true }), 37 namespaces: this.store.findAll('namespace'), 38 }) 39 .then((hash) => hash.volume) 40 .catch(notifyError(this)); 41 } 42 43 // Since volume includes embedded records for allocations, 44 // it's possible that allocations that are server-side deleted may 45 // not be removed from the UI while sitting on the volume detail page. 46 @watchRecord('volume') watch; 47 @collect('watch') watchers; 48 }