Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  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. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement