open-nomad/ui/app/utils/classes/abstract-logger.js
Buck Doyle 9b2fb14e51
UI: Update Ember to 3.12 LTS (#6419)
This is mostly deprecation fixes and blueprint changes. There
are some dependency updates too; the changes to Ember
Basic Dropdown necessitated changing it to angle bracket
component invocation. The conversion of the rest of the
templates will happen separately.
2019-10-15 13:32:58 -05:00

35 lines
1 KiB
JavaScript

import { assert } from '@ember/debug';
import Mixin from '@ember/object/mixin';
import { computed } from '@ember/object';
import { computed as overridable } from 'ember-overridable-computed';
import { assign } from '@ember/polyfills';
import queryString from 'query-string';
const MAX_OUTPUT_LENGTH = 50000;
export default Mixin.create({
url: '',
params: overridable(() => ({})),
logFetch() {
assert('Loggers need a logFetch method, which should have an interface like window.fetch');
},
endOffset: null,
offsetParams: computed('endOffset', function() {
const endOffset = this.endOffset;
return endOffset
? { origin: 'start', offset: endOffset }
: { origin: 'end', offset: MAX_OUTPUT_LENGTH };
}),
additionalParams: overridable(() => ({})),
fullUrl: computed('url', 'params', 'offsetParams', 'additionalParams', function() {
const queryParams = queryString.stringify(
assign({}, this.params, this.offsetParams, this.additionalParams)
);
return `${this.url}?${queryParams}`;
}),
});