angular_wrappers.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import {
  2. ClipboardButton,
  3. ColorPicker,
  4. DataLinksInlineEditor,
  5. DataSourceHttpSettings,
  6. GraphContextMenu,
  7. Icon,
  8. LegacyForms,
  9. SeriesColorPickerPopoverWithTheme,
  10. Spinner,
  11. UnitPicker,
  12. } from '@grafana/ui';
  13. import { react2AngularDirective } from 'app/angular/react2angular';
  14. import { FolderPicker } from 'app/core/components/Select/FolderPicker';
  15. import { TimePickerSettings } from 'app/features/dashboard/components/DashboardSettings/TimePickerSettings';
  16. import { QueryEditor as CloudMonitoringQueryEditor } from 'app/plugins/datasource/cloud-monitoring/components/QueryEditor';
  17. import EmptyListCTA from '../core/components/EmptyListCTA/EmptyListCTA';
  18. import { Footer } from '../core/components/Footer/Footer';
  19. import PageHeader from '../core/components/PageHeader/PageHeader';
  20. import { MetricSelect } from '../core/components/Select/MetricSelect';
  21. import { TagFilter } from '../core/components/TagFilter/TagFilter';
  22. import { HelpModal } from '../core/components/help/HelpModal';
  23. import { SearchField, SearchResults, SearchResultsFilter } from '../features/search';
  24. import { LokiAnnotationsQueryEditor } from '../plugins/datasource/loki/components/AnnotationsQueryEditor';
  25. const { SecretFormField } = LegacyForms;
  26. export function registerAngularDirectives() {
  27. react2AngularDirective('footer', Footer, []);
  28. react2AngularDirective('icon', Icon, [
  29. 'name',
  30. 'size',
  31. 'type',
  32. ['onClick', { watchDepth: 'reference', wrapApply: true }],
  33. ]);
  34. react2AngularDirective('spinner', Spinner, ['inline']);
  35. react2AngularDirective('helpModal', HelpModal, []);
  36. react2AngularDirective('pageHeader', PageHeader, ['model', 'noTabs']);
  37. react2AngularDirective('emptyListCta', EmptyListCTA, [
  38. 'title',
  39. 'buttonIcon',
  40. 'buttonLink',
  41. 'buttonTitle',
  42. ['onClick', { watchDepth: 'reference', wrapApply: true }],
  43. 'proTip',
  44. 'proTipLink',
  45. 'proTipLinkTitle',
  46. 'proTipTarget',
  47. 'infoBox',
  48. 'infoBoxTitle',
  49. ]);
  50. //Search
  51. react2AngularDirective('searchField', SearchField, [
  52. 'query',
  53. 'autoFocus',
  54. ['onChange', { watchDepth: 'reference' }],
  55. ['onKeyDown', { watchDepth: 'reference' }],
  56. ]);
  57. react2AngularDirective('searchResults', SearchResults, [
  58. 'results',
  59. 'editable',
  60. 'selectors',
  61. ['onSelectionChanged', { watchDepth: 'reference' }],
  62. ['onTagSelected', { watchDepth: 'reference' }],
  63. ['onFolderExpanding', { watchDepth: 'reference' }],
  64. ['onToggleSelection', { watchDepth: 'reference' }],
  65. ]);
  66. react2AngularDirective('searchFilters', SearchResultsFilter, [
  67. 'allChecked',
  68. 'canMove',
  69. 'canDelete',
  70. 'tagFilterOptions',
  71. 'selectedStarredFilter',
  72. 'selectedTagFilter',
  73. ['onSelectAllChanged', { watchDepth: 'reference' }],
  74. ['deleteItem', { watchDepth: 'reference' }],
  75. ['moveTo', { watchDepth: 'reference' }],
  76. ['onStarredFilterChange', { watchDepth: 'reference' }],
  77. ['onTagFilterChange', { watchDepth: 'reference' }],
  78. ]);
  79. react2AngularDirective('tagFilter', TagFilter, [
  80. 'tags',
  81. ['onChange', { watchDepth: 'reference' }],
  82. ['tagOptions', { watchDepth: 'reference' }],
  83. ]);
  84. react2AngularDirective('colorPicker', ColorPicker, [
  85. 'color',
  86. ['onChange', { watchDepth: 'reference', wrapApply: true }],
  87. ]);
  88. react2AngularDirective('seriesColorPickerPopover', SeriesColorPickerPopoverWithTheme, [
  89. 'color',
  90. 'series',
  91. 'onColorChange',
  92. 'onToggleAxis',
  93. ]);
  94. react2AngularDirective('unitPicker', UnitPicker, [
  95. 'value',
  96. 'width',
  97. ['onChange', { watchDepth: 'reference', wrapApply: true }],
  98. ]);
  99. react2AngularDirective('metricSelect', MetricSelect, [
  100. 'options',
  101. 'onChange',
  102. 'value',
  103. 'isSearchable',
  104. 'className',
  105. 'placeholder',
  106. ['variables', { watchDepth: 'reference' }],
  107. ]);
  108. react2AngularDirective('cloudMonitoringQueryEditor', CloudMonitoringQueryEditor, [
  109. 'target',
  110. 'onQueryChange',
  111. 'onExecuteQuery',
  112. ['events', { watchDepth: 'reference' }],
  113. ['datasource', { watchDepth: 'reference' }],
  114. ['templateSrv', { watchDepth: 'reference' }],
  115. ]);
  116. react2AngularDirective('secretFormField', SecretFormField, [
  117. 'value',
  118. 'isConfigured',
  119. 'inputWidth',
  120. 'labelWidth',
  121. 'aria-label',
  122. ['onReset', { watchDepth: 'reference', wrapApply: true }],
  123. ['onChange', { watchDepth: 'reference', wrapApply: true }],
  124. ]);
  125. react2AngularDirective('graphContextMenu', GraphContextMenu, [
  126. 'x',
  127. 'y',
  128. 'itemsGroup',
  129. ['onClose', { watchDepth: 'reference', wrapApply: true }],
  130. ['getContextMenuSource', { watchDepth: 'reference', wrapApply: true }],
  131. ['timeZone', { watchDepth: 'reference', wrapApply: true }],
  132. ]);
  133. // We keep the drilldown terminology here because of as using data-* directive
  134. // being in conflict with HTML data attributes
  135. react2AngularDirective('drilldownLinksEditor', DataLinksInlineEditor, [
  136. 'value',
  137. 'links',
  138. 'suggestions',
  139. ['onChange', { watchDepth: 'reference', wrapApply: true }],
  140. ]);
  141. react2AngularDirective('lokiAnnotationsQueryEditor', LokiAnnotationsQueryEditor, [
  142. 'expr',
  143. 'maxLines',
  144. 'instant',
  145. 'onChange',
  146. ['datasource', { watchDepth: 'reference' }],
  147. ]);
  148. react2AngularDirective('datasourceHttpSettingsNext', DataSourceHttpSettings, [
  149. 'defaultUrl',
  150. 'showAccessOptions',
  151. 'dataSourceConfig',
  152. 'showForwardOAuthIdentityOption',
  153. ['onChange', { watchDepth: 'reference', wrapApply: true }],
  154. ]);
  155. react2AngularDirective('folderPicker', FolderPicker, [
  156. 'labelClass',
  157. 'rootName',
  158. 'enableCreateNew',
  159. 'enableReset',
  160. 'initialTitle',
  161. 'initialFolderId',
  162. 'dashboardId',
  163. 'onCreateFolder',
  164. ['enterFolderCreation', { watchDepth: 'reference', wrapApply: true }],
  165. ['exitFolderCreation', { watchDepth: 'reference', wrapApply: true }],
  166. ['onLoad', { watchDepth: 'reference', wrapApply: true }],
  167. ['onChange', { watchDepth: 'reference', wrapApply: true }],
  168. ]);
  169. react2AngularDirective('timePickerSettings', TimePickerSettings, [
  170. 'renderCount',
  171. 'refreshIntervals',
  172. 'timePickerHidden',
  173. 'nowDelay',
  174. 'timezone',
  175. ['onTimeZoneChange', { watchDepth: 'reference', wrapApply: true }],
  176. ['onRefreshIntervalChange', { watchDepth: 'reference', wrapApply: true }],
  177. ['onNowDelayChange', { watchDepth: 'reference', wrapApply: true }],
  178. ['onHideTimePickerChange', { watchDepth: 'reference', wrapApply: true }],
  179. ]);
  180. react2AngularDirective('clipboardButton', ClipboardButton, [
  181. ['getText', { watchDepth: 'reference', wrapApply: true }],
  182. ]);
  183. }