How to use conseiljs - 10 common examples

To help you get started, we’ve selected a few conseiljs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cryptonomic / Arronax / src / components / ValueInput / index.tsx View on Github external
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)}
        /&gt;
github Cryptonomic / Arronax / src / utils / general.ts View on Github external
} else if (value &lt; 100000) {
            minimumFractionDigits = 4;
            maximumFractionDigits = 4;
        } else if (value &lt; 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;
}
github Cryptonomic / Arronax / src / utils / general.ts View on Github external
if (!truncate) {
            minimumFractionDigits = 6;
            maximumFractionDigits = 6;
        } else if (value &lt; 10000) {
            minimumFractionDigits = 6;
            maximumFractionDigits = 6;
        } else if (value &lt; 100000) {
            minimumFractionDigits = 4;
            maximumFractionDigits = 4;
        } else if (value &lt; 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}`;
        }
    }
github Cryptonomic / Arronax / src / reducers / app / thunks.ts View on Github external
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);
github Cryptonomic / Arronax / src / reducers / app / thunks.ts View on Github external
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);
github Cryptonomic / Arronax / src / reducers / app / thunks.ts View on Github external
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);
    }
  });
github Cryptonomic / Arronax / src / reducers / app / thunks.ts View on Github external
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);
    }
  });
github Cryptonomic / Arronax / src / reducers / app / thunks.ts View on Github external
}

    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);
    }
  });
github Cryptonomic / Arronax / src / reducers / app / thunks.ts View on Github external
if (fields.length &gt; 0) {
      fields.forEach(field=&gt; {
        const column = attributes.find(attr =&gt; attr.name === field);
        if (column) { columns.push(column); }
      });
    } else {
      columns = [...sortedAttributes];
    }

    if (orderBy.length &gt; 0) {
      sorts = orderBy.map(o =&gt; { 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 =&gt; {
      const selectedAttribute = attributes.find(attr =&gt; attr.name === predicate.field);
      const isLowCardinality = selectedAttribute.cardinality !== undefined &amp;&amp; selectedAttribute.cardinality &lt; 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) {
github Cryptonomic / Arronax / src / reducers / app / thunks.ts View on Github external
) => 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);