Watch nodes and allocs on the nodes list page

This commit is contained in:
Michael Lange
2018-02-16 11:02:43 -08:00
parent 2f93deaeb9
commit a2976dae85
3 changed files with 29 additions and 3 deletions

View File

@@ -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 => {

View File

@@ -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'),
});

View File

@@ -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'),
});