github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/ui/app/utils/classes/abstract-logger.js (about) 1 import Ember from 'ember'; 2 import queryString from 'npm:query-string'; 3 4 const { Mixin, computed, assign } = Ember; 5 const MAX_OUTPUT_LENGTH = 50000; 6 7 export default Mixin.create({ 8 url: '', 9 params: computed(() => ({})), 10 logFetch() { 11 Ember.assert( 12 'Loggers need a logFetch method, which should have an interface like window.fetch' 13 ); 14 }, 15 16 endOffset: null, 17 18 offsetParams: computed('endOffset', function() { 19 const endOffset = this.get('endOffset'); 20 return endOffset 21 ? { origin: 'start', offset: endOffset } 22 : { origin: 'end', offset: MAX_OUTPUT_LENGTH }; 23 }), 24 25 additionalParams: computed(() => ({})), 26 27 fullUrl: computed('url', 'params', 'offsetParams', 'additionalParams', function() { 28 const queryParams = queryString.stringify( 29 assign({}, this.get('params'), this.get('offsetParams'), this.get('additionalParams')) 30 ); 31 return `${this.get('url')}?${queryParams}`; 32 }), 33 });