github.com/manicqin/nomad@v0.9.5/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 import { computed } from '@ember/object'; 7 8 export default Component.extend(WithVisibilityDetection, { 9 store: service(), 10 11 tagName: 'tr', 12 classNames: ['client-node-row', 'is-interactive'], 13 14 node: null, 15 16 onClick() {}, 17 18 click(event) { 19 lazyClick([this.onClick, event]); 20 }, 21 22 didReceiveAttrs() { 23 // Reload the node in order to get detail information 24 const node = this.node; 25 if (node) { 26 node.reload().then(() => { 27 this.watch.perform(node, 100); 28 }); 29 } 30 }, 31 32 visibilityHandler() { 33 if (document.hidden) { 34 this.watch.cancelAll(); 35 } else { 36 const node = this.node; 37 if (node) { 38 this.watch.perform(node, 100); 39 } 40 } 41 }, 42 43 willDestroy() { 44 this.watch.cancelAll(); 45 this._super(...arguments); 46 }, 47 48 watch: watchRelationship('allocations'), 49 50 compositeStatusClass: computed('node.compositeStatus', function() { 51 let compositeStatus = this.get('node.compositeStatus'); 52 53 if (compositeStatus === 'draining') { 54 return 'status-text is-info'; 55 } else if (compositeStatus === 'ineligible') { 56 return 'status-text is-warning'; 57 } else { 58 return ''; 59 } 60 }), 61 });