kibana-riya
Version:
Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic
66 lines (51 loc) • 2.02 kB
JavaScript
import $ from 'jquery';
import { remove } from 'lodash';
import './kbn_chrome.less';
import UiModules from 'ui/modules';
import { isSystemApiRequest } from 'ui/system_api';
import {
getUnhashableStatesProvider,
unhashUrl,
} from 'ui/state_management/state_hashing';
export default function (chrome, internals) {
UiModules
.get('kibana')
.directive('kbnChrome', $rootScope => {
return {
template($el) {
const $content = $(require('./kbn_chrome.html'));
const $app = $content.find('.application');
if (internals.rootController) {
$app.attr('ng-controller', internals.rootController);
}
if (internals.rootTemplate) {
$app.removeAttr('ng-view');
$app.html(internals.rootTemplate);
}
return $content;
},
controllerAs: 'chrome',
controller($scope, $rootScope, $location, $http, Private) {
const getUnhashableStates = Private(getUnhashableStatesProvider);
// are we showing the embedded version of the chrome?
internals.setVisibleDefault(!$location.search().embed);
// listen for route changes, propogate to tabs
const onRouteChange = function () {
const urlWithHashes = window.location.href;
const urlWithStates = unhashUrl(urlWithHashes, getUnhashableStates());
internals.trackPossibleSubUrl(urlWithStates);
};
$rootScope.$on('$routeChangeSuccess', onRouteChange);
$rootScope.$on('$routeUpdate', onRouteChange);
onRouteChange();
const allPendingHttpRequests = () => $http.pendingRequests;
const removeSystemApiRequests = (pendingHttpRequests = []) => remove(pendingHttpRequests, isSystemApiRequest);
$scope.$watchCollection(allPendingHttpRequests, removeSystemApiRequests);
// and some local values
chrome.httpActive = $http.pendingRequests;
$scope.notifList = require('ui/notify')._notifs;
return chrome;
}
};
});
}