Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { uiModules } from '../modules';
- uiModules.get('kibana')
- .factory('filterApp', function (getAppState) {
- /**
- * Create filter
- *
- * @method createFilter
- * @param options {Object} options object
- * @returns {Object} filter
- */
- const createFilter = (options) => {
- const {
- alias = null,
- disabled = false,
- index = '',
- key = 'name',
- negate = false,
- label = '',
- type = 'phrase',
- store = 'appState'
- } = options;
- return {
- $state: {
- store: store
- },
- meta: {
- alias,
- disabled,
- index,
- key,
- negate,
- params: {
- query: label,
- type: type
- },
- type: type,
- value: label
- },
- 'query': {
- 'match': {
- 'name': {
- 'query': label,
- 'type': type
- }
- }
- }
- };
- };
- /**
- * Add filter to appState filters
- *
- * @method addToFilters
- * @param {Object} filter
- */
- const addToFilters = (filter) => {
- const appState = getAppState();
- appState.filters.push(filter);
- };
- return {
- createFilter,
- addToFilters
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement