diff --git a/ui/app/adapters/node.js b/ui/app/adapters/node.js index 349e44b82..5d77bebd2 100644 --- a/ui/app/adapters/node.js +++ b/ui/app/adapters/node.js @@ -1,6 +1,6 @@ -import ApplicationAdapter from './application'; +import Watchable from './watchable'; -export default ApplicationAdapter.extend({ +export default Watchable.extend({ findAllocations(node) { const url = `${this.buildURL('node', node.get('id'), node, 'findRecord')}/allocations`; return this.ajax(url, 'GET').then(allocs => { diff --git a/ui/app/components/client-node-row.js b/ui/app/components/client-node-row.js index 2775ed58f..7d9d7f828 100644 --- a/ui/app/components/client-node-row.js +++ b/ui/app/components/client-node-row.js @@ -1,7 +1,11 @@ +import { inject as service } from '@ember/service'; import Component from '@ember/component'; import { lazyClick } from '../helpers/lazy-click'; +import { watchRelationship } from 'nomad-ui/utils/properties/watch'; export default Component.extend({ + store: service(), + tagName: 'tr', classNames: ['client-node-row', 'is-interactive'], @@ -17,7 +21,16 @@ export default Component.extend({ // Reload the node in order to get detail information const node = this.get('node'); if (node) { - node.reload(); + node.reload().then(() => { + this.get('watch').perform(node, 100); + }); } }, + + willDestroy() { + this.get('watch').cancelAll(); + this._super(...arguments); + }, + + watch: watchRelationship('allocations'), }); diff --git a/ui/app/routes/clients.js b/ui/app/routes/clients.js index 49559c8c9..3b94e4fd5 100644 --- a/ui/app/routes/clients.js +++ b/ui/app/routes/clients.js @@ -3,6 +3,7 @@ import Route from '@ember/routing/route'; import RSVP from 'rsvp'; import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state'; import notifyForbidden from 'nomad-ui/utils/notify-forbidden'; +import { watchAll } from 'nomad-ui/utils/properties/watch'; export default Route.extend(WithForbiddenState, { store: service(), @@ -18,4 +19,16 @@ export default Route.extend(WithForbiddenState, { agents: this.get('store').findAll('agent'), }).catch(notifyForbidden(this)); }, + + setupController(controller) { + controller.set('modelWatch', this.get('watch').perform()); + return this._super(...arguments); + }, + + deactivate() { + this.get('watch').cancelAll(); + this._super(...arguments); + }, + + watch: watchAll('node'), });