Skip to content

Commit

Permalink
Fix calls to /api/watcher/watches
Browse files Browse the repository at this point in the history
Seen on page: /app/kibana#/management/elasticsearch/watcher/watches
  • Loading branch information
jportner committed Feb 18, 2021
1 parent 085a221 commit 76ea7df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ app.directive('watchList', function ($injector, i18n) {
this.pager = pagerFactory.create(this.watches.length, PAGINATION.PAGE_SIZE, 1);

// Reload watches periodically
const refreshInterval = $interval(() => this.loadWatches(), REFRESH_INTERVALS.WATCH_LIST);
const refreshInterval = $interval(() => this.loadWatches({
asSystemRequest: true,
}), REFRESH_INTERVALS.WATCH_LIST);
$scope.$on('$destroy', () => $interval.cancel(refreshInterval));

// react to watch and ui changes
Expand All @@ -81,8 +83,8 @@ app.directive('watchList', function ($injector, i18n) {
return this.selectedWatches.length > 0;
}

loadWatches = () => {
watchesService.getWatchList()
loadWatches = ({ asSystemRequest } = {}) => {
watchesService.getWatchList({ asSystemRequest })
.then(watches => {
this.watches = watches;
this.forbidden = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import chrome from 'ui/chrome';
import { addSystemApiHeader } from 'ui/system_api';
import { ROUTES } from '../../../common/constants';
import { Watch } from 'plugins/watcher/models/watch';

Expand All @@ -14,8 +15,9 @@ export class WatchesService {
this.basePath = chrome.addBasePath(ROUTES.API_ROOT);
}

getWatchList() {
return this.$http.get(`${this.basePath}/watches`)
getWatchList({ asSystemRequest } = {}) {
const headers = asSystemRequest ? addSystemApiHeader({}) : undefined;
return this.$http.get(`${this.basePath}/watches`, { headers })
.then(response => response.data.watches)
.then(watches => watches.map(watch => {
return Watch.fromUpstreamJson(watch);
Expand Down

0 comments on commit 76ea7df

Please sign in to comment.