SHARE
TWEET

Untitled

a guest Apr 19th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { uiModules } from '../modules';
  2.  
  3. uiModules.get('kibana')
  4.   .factory('filterApp', function (getAppState) {
  5.  
  6.     /**
  7.      * Create filter
  8.      *
  9.      * @method createFilter
  10.      * @param options {Object} options object
  11.      * @returns {Object} filter
  12.      */
  13.     const createFilter = (options) => {
  14.  
  15.       const {
  16.         alias = null,
  17.         disabled = false,
  18.         index = '',
  19.         key = 'name',
  20.         negate = false,
  21.         label = '',
  22.         type = 'phrase',
  23.         store = 'appState'
  24.       } = options;
  25.  
  26.       return {
  27.         $state: {
  28.           store: store
  29.         },
  30.         meta: {
  31.           alias,
  32.           disabled,
  33.           index,
  34.           key,
  35.           negate,
  36.           params: {
  37.             query: label,
  38.             type: type
  39.           },
  40.           type: type,
  41.           value: label
  42.         },
  43.         'query': {
  44.           'match': {
  45.             'name': {
  46.               'query': label,
  47.               'type': type
  48.             }
  49.           }
  50.         }
  51.       };
  52.     };
  53.  
  54.     /**
  55.      * Add filter to appState filters
  56.      *
  57.      * @method addToFilters
  58.      * @param {Object} filter
  59.      */
  60.     const addToFilters = (filter) => {
  61.       const appState = getAppState();
  62.       appState.filters.push(filter);
  63.     };
  64.  
  65.     return {
  66.       createFilter,
  67.       addToFilters
  68.     };
  69.  
  70.   });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top