4c3fbebefd
* ui: Move components to the new nested structure * Move data-test attribute to the correct HTML element We don't currently rely on this, but was incorrectly placed on the input rather than the label tag * Fix up left over curly bracket components that were causing issues For some reason the combination of: 1. Old style curly bracket components 2. data-test-* attributes 3. Moving to the new component file structure Meant that our data-test-* selectors where no longer being rendered. Whilst this had no effect on the app, it meant our tests suite could no longer select DOM elements in order to assert various things. Moving the old style curly bracket components to the new style XML/Angle bracket format fixes the issue * Update ui-v2/app/templates/dc/nodes/-services.hbs Co-Authored-By: Greg Hoin <1416421+gregone@users.noreply.github.com> * Update ui-v2/app/templates/dc/nodes/-services.hbs Co-Authored-By: Greg Hoin <1416421+gregone@users.noreply.github.com> Co-authored-by: Greg Hoin <1416421+gregone@users.noreply.github.com>
79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
import { inject as service } from '@ember/service';
|
|
import { computed, get, set } from '@ember/object';
|
|
import Component from 'ember-collection/components/ember-collection';
|
|
import PercentageColumns from 'ember-collection/layouts/percentage-columns';
|
|
import style from 'ember-computed-style';
|
|
import WithResizing from 'consul-ui/mixins/with-resizing';
|
|
|
|
export default Component.extend(WithResizing, {
|
|
dom: service('dom'),
|
|
tagName: 'div',
|
|
attributeBindings: ['style'],
|
|
height: 500,
|
|
cellHeight: 113,
|
|
style: style('getStyle'),
|
|
classNames: ['list-collection'],
|
|
init: function() {
|
|
this._super(...arguments);
|
|
this.columns = [25, 25, 25, 25];
|
|
},
|
|
didReceiveAttrs: function() {
|
|
this._super(...arguments);
|
|
this._cellLayout = this['cell-layout'] = new PercentageColumns(
|
|
get(this, 'items.length'),
|
|
get(this, 'columns'),
|
|
get(this, 'cellHeight')
|
|
);
|
|
},
|
|
getStyle: computed('height', function() {
|
|
return {
|
|
height: get(this, 'height'),
|
|
};
|
|
}),
|
|
resize: function(e) {
|
|
// TODO: This top part is very similar to resize in tabular-collection
|
|
// see if it make sense to DRY out
|
|
const dom = get(this, 'dom');
|
|
const $appContent = dom.element('main > div');
|
|
if ($appContent) {
|
|
const rect = this.element.getBoundingClientRect();
|
|
const $footer = dom.element('footer[role="contentinfo"]');
|
|
const space = rect.top + $footer.clientHeight;
|
|
const height = e.detail.height - space;
|
|
this.set('height', Math.max(0, height));
|
|
this.updateItems();
|
|
this.updateScrollPosition();
|
|
}
|
|
const width = e.detail.width;
|
|
const len = get(this, 'columns.length');
|
|
switch (true) {
|
|
case width > 1013:
|
|
if (len != 4) {
|
|
set(this, 'columns', [25, 25, 25, 25]);
|
|
}
|
|
break;
|
|
case width > 744:
|
|
if (len != 3) {
|
|
set(this, 'columns', [33, 33, 34]);
|
|
}
|
|
break;
|
|
case width > 487:
|
|
if (len != 2) {
|
|
set(this, 'columns', [50, 50]);
|
|
}
|
|
break;
|
|
case width < 488:
|
|
if (len != 1) {
|
|
set(this, 'columns', [100]);
|
|
}
|
|
}
|
|
if (len !== get(this, 'columns.length')) {
|
|
this._cellLayout = this['cell-layout'] = new PercentageColumns(
|
|
get(this, 'items.length'),
|
|
get(this, 'columns'),
|
|
get(this, 'cellHeight')
|
|
);
|
|
}
|
|
},
|
|
});
|