Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function validateModelMemoryLimit(job, limits) {
const messages = [];
let valid = true;
// model memory limit
if (typeof job.analysis_limits !== 'undefined' && typeof job.analysis_limits.model_memory_limit !== 'undefined') {
if (typeof limits === 'object' && typeof limits.max_model_memory_limit !== 'undefined') {
const max = limits.max_model_memory_limit.toUpperCase();
const mml = job.analysis_limits.model_memory_limit.toUpperCase();
const mmlBytes = numeral(mml).value();
const maxBytes = numeral(max).value();
if(mmlBytes > maxBytes) {
messages.push({ id: 'model_memory_limit_invalid' });
valid = false;
} else {
messages.push({ id: 'model_memory_limit_valid' });
}
}
}
return {
valid,
messages,
contains: id => (messages.some(m => id === m.id)),
find: id => (messages.find(m => id === m.id)),
};
}
export function validateModelMemoryLimit(job, limits) {
const messages = [];
let valid = true;
// model memory limit
if (typeof job.analysis_limits !== 'undefined' && typeof job.analysis_limits.model_memory_limit !== 'undefined') {
if (typeof limits === 'object' && typeof limits.max_model_memory_limit !== 'undefined') {
const max = limits.max_model_memory_limit.toUpperCase();
const mml = job.analysis_limits.model_memory_limit.toUpperCase();
const mmlBytes = numeral(mml).value();
const maxBytes = numeral(max).value();
if(mmlBytes > maxBytes) {
messages.push({ id: 'model_memory_limit_invalid' });
valid = false;
} else {
messages.push({ id: 'model_memory_limit_valid' });
}
}
}
return {
valid,
messages,
contains: id => (messages.some(m => id === m.id)),
find: id => (messages.find(m => id === m.id)),
};
export function FileTooLarge({ fileSize, maxFileSize }) {
const fileSizeFormatted = numeral(fileSize).format(FILE_SIZE_DISPLAY_FORMAT);
const maxFileSizeFormatted = numeral(maxFileSize).format(FILE_SIZE_DISPLAY_FORMAT);
// Format the byte values, using the second format if the difference between
// the file size and the max is so small that the formatted values are identical
// e.g. 100.01 MB and 100.0 MB
let errorText;
if (fileSizeFormatted !== maxFileSizeFormatted) {
errorText = (
<p>
</p>
tickFormat={value => numeral(value.toPrecision(3)).format('0[.][00]a')} // https://github.com/adamwdraper/Numeral-js/issues/194
/>
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// @ts-ignore
import numeral from '@elastic/numeral';
// @ts-ignore
import numeralLanguages from '@elastic/numeral/languages';
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
import { FieldFormat } from '../field_format';
import { TextContextTypeConvert } from '../types';
const numeralInst = numeral();
numeralLanguages.forEach((numeralLanguage: Record) => {
numeral.language(numeralLanguage.id, numeralLanguage.lang);
});
export abstract class NumeralFormat extends FieldFormat {
static fieldType = KBN_FIELD_TYPES.NUMBER;
abstract id: string;
abstract title: string;
getParamDefaults = () => ({
pattern: this.getConfig!(`format:${this.id}:defaultPattern`),
});
protected getConvertedValue(val: any): string {
if (val === -Infinity) return '-∞';
if (val === +Infinity) return '+∞';
export function getUiSettingDefaults() {
const weekdays = moment.weekdays().slice();
const [defaultWeekday] = weekdays;
// We add the `en` key manually here, since that's not a real numeral locale, but the
// default fallback in case the locale is not found.
const numeralLanguageIds = [
'en',
...numeralLanguages.map(function(numeralLanguage) {
return numeralLanguage.id;
}),
];
const luceneQueryLanguageLabel = i18n.translate(
'kbn.advancedSettings.searchQueryLanguageLucene',
{
defaultMessage: 'Lucene',
}
);
const queryLanguageSettingName = i18n.translate('kbn.advancedSettings.searchQueryLanguageTitle', {
defaultMessage: 'Query language',
});
const requestPreferenceOptionLabels = {
id: 'filebeatSuricata',
},
{
description:
has('filebeatZeek', data) && data.filebeatZeek !== null
? numeral(data.filebeatZeek).format('0,0')
: getEmptyTagValue(),
title: (
),
id: 'filebeatZeek',
},
{
description:
has('packetbeatDNS', data) && data.packetbeatDNS !== null
? numeral(data.packetbeatDNS).format('0,0')
: getEmptyTagValue(),
title: (
),
id: 'packetbeatDNS',
},
{
description:
has('packetbeatFlow', data) && data.packetbeatFlow !== null
? numeral(data.packetbeatFlow).format('0,0')
: getEmptyTagValue(),
title: (
data.res = {
statusCode: event.statusCode,
responseTime: event.responseTime,
contentLength: contentLength
};
const query = querystring.stringify(event.query);
if (query) data.req.url += '?' + query;
data.message = data.req.method.toUpperCase() + ' ';
data.message += data.req.url;
data.message += ' ';
data.message += levelColor(data.res.statusCode);
data.message += ' ';
data.message += chalk.gray(data.res.responseTime + 'ms');
data.message += chalk.gray(' - ' + numeral(contentLength).format('0.0b'));
}
else if (data.type === 'ops') {
_.defaults(data, _.pick(event, [
'pid',
'os',
'proc',
'load'
]));
data.message = chalk.gray('memory: ');
data.message += numeral(get(data, 'proc.mem.heapUsed')).format('0.0b');
data.message += ' ';
data.message += chalk.gray('uptime: ');
data.message += numeral(get(data, 'proc.uptime')).format('00:00:00');
data.message += ' ';
data.message += chalk.gray('load: [');
data.message += get(data, 'os.load', []).map(function (val) {
export function asDecimal(value: number) {
return numeral(value).format('0,0.0');
}
description:
has('filebeatPanw', data) && data.filebeatPanw !== null
? numeral(data.filebeatPanw).format('0,0')
: getEmptyTagValue(),
title: (
),
id: 'filebeatPanw',
},
{
description:
has('filebeatSuricata', data) && data.filebeatSuricata !== null
? numeral(data.filebeatSuricata).format('0,0')
: getEmptyTagValue(),
title: (
),
id: 'filebeatSuricata',
},
{
description:
has('filebeatZeek', data) && data.filebeatZeek !== null
? numeral(data.filebeatZeek).format('0,0')
: getEmptyTagValue(),
title: (