github.com/emate/nomad@v0.8.2-wo-binpacking/ui/app/components/client-node-row.js (about) 1 import { inject as service } from '@ember/service'; 2 import Component from '@ember/component'; 3 import { lazyClick } from '../helpers/lazy-click'; 4 import { watchRelationship } from 'nomad-ui/utils/properties/watch'; 5 import WithVisibilityDetection from 'nomad-ui/mixins/with-component-visibility-detection'; 6 7 export default Component.extend(WithVisibilityDetection, { 8 store: service(), 9 10 tagName: 'tr', 11 classNames: ['client-node-row', 'is-interactive'], 12 13 node: null, 14 15 onClick() {}, 16 17 click(event) { 18 lazyClick([this.get('onClick'), event]); 19 }, 20 21 didReceiveAttrs() { 22 // Reload the node in order to get detail information 23 const node = this.get('node'); 24 if (node) { 25 node.reload().then(() => { 26 this.get('watch').perform(node, 100); 27 }); 28 } 29 }, 30 31 visibilityHandler() { 32 if (document.hidden) { 33 this.get('watch').cancelAll(); 34 } else { 35 const node = this.get('node'); 36 if (node) { 37 this.get('watch').perform(node, 100); 38 } 39 } 40 }, 41 42 willDestroy() { 43 this.get('watch').cancelAll(); 44 this._super(...arguments); 45 }, 46 47 watch: watchRelationship('allocations'), 48 });