open-nomad/ui/app/components/client-node-row.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

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';
import WithVisibilityDetection from 'nomad-ui/mixins/with-component-visibility-detection';
2017-09-19 14:47:10 +00:00
export default Component.extend(WithVisibilityDetection, {
store: service(),
2017-09-19 14:47:10 +00:00
tagName: 'tr',
classNames: ['client-node-row', 'is-interactive'],
node: null,
onClick() {},
click(event) {
lazyClick([this.get('onClick'), event]);
2017-09-19 14:47:10 +00:00
},
didReceiveAttrs() {
// Reload the node in order to get detail information
const node = this.get('node');
if (node) {
node.reload().then(() => {
this.get('watch').perform(node, 100);
});
2017-09-19 14:47:10 +00:00
}
},
visibilityHandler() {
if (document.hidden) {
this.get('watch').cancelAll();
} else {
const node = this.get('node');
if (node) {
this.get('watch').perform(node, 100);
}
}
},
willDestroy() {
this.get('watch').cancelAll();
this._super(...arguments);
},
watch: watchRelationship('allocations'),
2017-09-19 14:47:10 +00:00
});