Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function changeSingle (val: string) {
const l = val.split(',').map(v => v.trim());
onChange([l[0]]);
}
function changeRange(val: string, index: number) {
values[index] = val;
onChange(values);
}
function changeList(val: string) {
onChange([...(new Set(val.split(',').map(v => v.trim())))]);
}
// Render specific input type based on operators
if (operator === ConseilOperator.BETWEEN) {
return (
changeRange(val, 0)}
/>
<hr>
{t('components.valueInput.and')}
<hr>
changeRange(val, 1)}
/>
} else if (value < 100000) {
minimumFractionDigits = 4;
maximumFractionDigits = 4;
} else if (value < 1000000000) {
minimumFractionDigits = 2;
maximumFractionDigits = 2;
}
t = (new Intl.NumberFormat(window.navigator.languages[0], { style: 'decimal', minimumFractionDigits, maximumFractionDigits })).format(d);
} else if (attribute.dataType === AttrbuteDataType.DECIMAL) {
if (Number.isInteger(value)) { // HACK: until accounts.block_level reports as 'Int'
t = (new Intl.NumberFormat(window.navigator.languages[0], { style: 'decimal', useGrouping: false, minimumFractionDigits: 0, maximumFractionDigits: 1 })).format(value);
} else {
t = (new Intl.NumberFormat(window.navigator.languages[0], { style: 'decimal', minimumFractionDigits: 6, maximumFractionDigits: 6 })).format(value);
}
} else if (attribute.dataType === AttrbuteDataType.CURRENCY) {
t = (new Intl.NumberFormat(window.navigator.languages[0], { style: 'decimal', minimumFractionDigits: 6, maximumFractionDigits: 6 })).format(value);
}
if (attribute.dataType === AttrbuteDataType.CURRENCY) {
if (attribute.currencySymbol !== undefined) {
t = `${attribute.currencySymbol} ${t}`;
} else if (attribute.currencySymbolCode !== undefined) {
t = `${String.fromCharCode(attribute.currencySymbolCode)} ${t}`;
}
}
return t;
}
if (!truncate) {
minimumFractionDigits = 6;
maximumFractionDigits = 6;
} else if (value < 10000) {
minimumFractionDigits = 6;
maximumFractionDigits = 6;
} else if (value < 100000) {
minimumFractionDigits = 4;
maximumFractionDigits = 4;
} else if (value < 1000000000) {
minimumFractionDigits = 2;
maximumFractionDigits = 2;
}
t = (new Intl.NumberFormat(window.navigator.languages[0], { style: 'decimal', minimumFractionDigits, maximumFractionDigits })).format(d);
} else if (attribute.dataType === AttrbuteDataType.DECIMAL) {
if (Number.isInteger(value)) { // HACK: until accounts.block_level reports as 'Int'
t = (new Intl.NumberFormat(window.navigator.languages[0], { style: 'decimal', useGrouping: false, minimumFractionDigits: 0, maximumFractionDigits: 1 })).format(value);
} else {
t = (new Intl.NumberFormat(window.navigator.languages[0], { style: 'decimal', minimumFractionDigits: 6, maximumFractionDigits: 6 })).format(value);
}
} else if (attribute.dataType === AttrbuteDataType.CURRENCY) {
t = (new Intl.NumberFormat(window.navigator.languages[0], { style: 'decimal', minimumFractionDigits: 6, maximumFractionDigits: 6 })).format(value);
}
if (attribute.dataType === AttrbuteDataType.CURRENCY) {
if (attribute.currencySymbol !== undefined) {
t = `${attribute.currencySymbol} ${t}`;
} else if (attribute.currencySymbolCode !== undefined) {
t = `${String.fromCharCode(attribute.currencySymbolCode)} ${t}`;
}
}
selectedFilters.forEach((filter: Filter) => {
if ((filter.operator === ConseilOperator.BETWEEN || filter.operator === ConseilOperator.IN || filter.operator === 'notin') && filter.values.length === 1) {
return true;
}
if (filter.operator !== ConseilOperator.ISNULL && filter.operator !== 'isnotnull' && (filter.values.length === 0 || filter.values[0].length === 0)) {
return true;
}
let isInvert = false;
let operator: any = filter.operator;
if (filter.operator === 'isnotnull') {
isInvert = true;
operator = ConseilOperator.ISNULL;
} else if (filter.operator === 'noteq') {
operator = ConseilOperator.EQ;
isInvert = true;
} else if (filter.operator === 'notstartWith') {
operator = ConseilOperator.STARTSWITH;
isInvert = true;
} else if (filter.operator === 'notendWith') {
operator = ConseilOperator.ENDSWITH;
isInvert = true;
} else if (filter.operator === 'notin') {
operator = ConseilOperator.IN;
isInvert = true;
}
if (filter.operatorType === 'dateTime') { // HACK
query = addPredicate(query, filter.name, operator, filter.values.map(v => parseInt(v)), isInvert);
} else {
query = addPredicate(query, filter.name, operator, filter.values, isInvert);
selectedFilters.forEach((filter: Filter) => {
if ((filter.operator === ConseilOperator.BETWEEN || filter.operator === ConseilOperator.IN || filter.operator === 'notin') && filter.values.length === 1) {
return true;
}
if (filter.operator !== ConseilOperator.ISNULL && filter.operator !== 'isnotnull' && (filter.values.length === 0 || filter.values[0].length === 0)) {
return true;
}
let isInvert = false;
let operator: any = filter.operator;
if (filter.operator === 'isnotnull') {
isInvert = true;
operator = ConseilOperator.ISNULL;
} else if (filter.operator === 'noteq') {
operator = ConseilOperator.EQ;
isInvert = true;
} else if (filter.operator === 'notstartWith') {
operator = ConseilOperator.STARTSWITH;
isInvert = true;
} else if (filter.operator === 'notendWith') {
operator = ConseilOperator.ENDSWITH;
isInvert = true;
} else if (filter.operator === 'notin') {
operator = ConseilOperator.IN;
isInvert = true;
}
if (filter.operatorType === 'dateTime') { // HACK
query = addPredicate(query, filter.name, operator, filter.values.map(v => parseInt(v)), isInvert);
let isInvert = false;
let operator: any = filter.operator;
if (filter.operator === 'isnotnull') {
isInvert = true;
operator = ConseilOperator.ISNULL;
} else if (filter.operator === 'noteq') {
operator = ConseilOperator.EQ;
isInvert = true;
} else if (filter.operator === 'notstartWith') {
operator = ConseilOperator.STARTSWITH;
isInvert = true;
} else if (filter.operator === 'notendWith') {
operator = ConseilOperator.ENDSWITH;
isInvert = true;
} else if (filter.operator === 'notin') {
operator = ConseilOperator.IN;
isInvert = true;
}
if (filter.operatorType === 'dateTime') { // HACK
query = addPredicate(query, filter.name, operator, filter.values.map(v => parseInt(v)), isInvert);
} else {
query = addPredicate(query, filter.name, operator, filter.values, isInvert);
}
});
return true;
}
let isInvert = false;
let operator: any = filter.operator;
if (filter.operator === 'isnotnull') {
isInvert = true;
operator = ConseilOperator.ISNULL;
} else if (filter.operator === 'noteq') {
operator = ConseilOperator.EQ;
isInvert = true;
} else if (filter.operator === 'notstartWith') {
operator = ConseilOperator.STARTSWITH;
isInvert = true;
} else if (filter.operator === 'notendWith') {
operator = ConseilOperator.ENDSWITH;
isInvert = true;
} else if (filter.operator === 'notin') {
operator = ConseilOperator.IN;
isInvert = true;
}
if (filter.operatorType === 'dateTime') { // HACK
query = addPredicate(query, filter.name, operator, filter.values.map(v => parseInt(v)), isInvert);
} else {
query = addPredicate(query, filter.name, operator, filter.values, isInvert);
}
});
}
if (filter.operator !== ConseilOperator.ISNULL && filter.operator !== 'isnotnull' && (filter.values.length === 0 || filter.values[0].length === 0)) {
return true;
}
let isInvert = false;
let operator: any = filter.operator;
if (filter.operator === 'isnotnull') {
isInvert = true;
operator = ConseilOperator.ISNULL;
} else if (filter.operator === 'noteq') {
operator = ConseilOperator.EQ;
isInvert = true;
} else if (filter.operator === 'notstartWith') {
operator = ConseilOperator.STARTSWITH;
isInvert = true;
} else if (filter.operator === 'notendWith') {
operator = ConseilOperator.ENDSWITH;
isInvert = true;
} else if (filter.operator === 'notin') {
operator = ConseilOperator.IN;
isInvert = true;
}
if (filter.operatorType === 'dateTime') { // HACK
query = addPredicate(query, filter.name, operator, filter.values.map(v => parseInt(v)), isInvert);
} else {
query = addPredicate(query, filter.name, operator, filter.values, isInvert);
}
});
if (fields.length > 0) {
fields.forEach(field=> {
const column = attributes.find(attr => attr.name === field);
if (column) { columns.push(column); }
});
} else {
columns = [...sortedAttributes];
}
if (orderBy.length > 0) {
sorts = orderBy.map(o => { return { orderBy: o.field, order: o.direction } });
} else {
// adding the default sort
sorts = [{
orderBy: levelColumn.name,
order: ConseilSortDirection.DESC
}];
query = addOrdering(query, sorts[0].orderBy, sorts[0].order);
}
// initFilters
filters = predicates.map(predicate => {
const selectedAttribute = attributes.find(attr => attr.name === predicate.field);
const isLowCardinality = selectedAttribute.cardinality !== undefined && selectedAttribute.cardinality < CARDINALITY_NUMBER;
if (isLowCardinality) {
cardinalityPromises.push(
dispatch(initCardinalityValues(platform, entity, network, selectedAttribute.name, serverInfo))
);
}
const operatorType = getOperatorType(selectedAttribute.dataType);
let operator = predicate.operation;
if (predicate.inverse) {
) => async (dispatch: any) => {
let defaultQuery = (urlEntity === entity && urlQuery) ? JSON.parse(base64url.decode(urlQuery)) : defaultQueries[entity];
defaultQuery = {...ConseilQueryBuilder.blankQuery(), ...defaultQuery};
let columns: any[] = [];
let sorts: Sort[];
let filters: Filter[] = [];
let aggregations: Aggregation[] = [];
let cardinalityPromises: any[] = [];
let query = blankQuery();
const sortedAttributes = sortAttributes(attributes);
const levelColumn = attributes.find(column => column.name === 'level' || column.name === 'block_level' || column.name === 'timestamp') || sortedAttributes[0];
if (defaultQuery) {
const { fields, predicates, orderBy } = defaultQuery;
query = defaultQuery;
// initColumns
if (fields.length > 0) {
fields.forEach(field=> {
const column = attributes.find(attr => attr.name === field);