2018-02-16 19:02:43 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2017-12-15 21:39:18 +00:00
|
|
|
import Component from '@ember/component';
|
2017-09-26 18:57:46 +00:00
|
|
|
import { lazyClick } from '../helpers/lazy-click';
|
2018-02-16 19:02:43 +00:00
|
|
|
import { watchRelationship } from 'nomad-ui/utils/properties/watch';
|
2018-03-06 22:16:43 +00:00
|
|
|
import WithVisibilityDetection from 'nomad-ui/mixins/with-component-visibility-detection';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2018-03-06 22:16:43 +00:00
|
|
|
export default Component.extend(WithVisibilityDetection, {
|
2018-02-16 19:02:43 +00:00
|
|
|
store: service(),
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
tagName: 'tr',
|
|
|
|
classNames: ['client-node-row', 'is-interactive'],
|
|
|
|
|
|
|
|
node: null,
|
|
|
|
|
|
|
|
onClick() {},
|
|
|
|
|
|
|
|
click(event) {
|
2017-09-26 18:57:46 +00:00
|
|
|
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) {
|
2018-02-16 19:02:43 +00:00
|
|
|
node.reload().then(() => {
|
|
|
|
this.get('watch').perform(node, 100);
|
|
|
|
});
|
2017-09-19 14:47:10 +00:00
|
|
|
}
|
|
|
|
},
|
2018-02-16 19:02:43 +00:00
|
|
|
|
2018-03-06 22:16:43 +00:00
|
|
|
visibilityHandler() {
|
2018-03-06 22:27:01 +00:00
|
|
|
if (document.hidden) {
|
2018-03-06 22:16:43 +00:00
|
|
|
this.get('watch').cancelAll();
|
|
|
|
} else {
|
|
|
|
const node = this.get('node');
|
|
|
|
if (node) {
|
|
|
|
this.get('watch').perform(node, 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-02-16 19:02:43 +00:00
|
|
|
willDestroy() {
|
|
|
|
this.get('watch').cancelAll();
|
|
|
|
this._super(...arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: watchRelationship('allocations'),
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|