mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[kibana] rely on basePath rather than scattered relative paths
This commit is contained in:
parent
0e8d481902
commit
645272e225
9 changed files with 60 additions and 8 deletions
|
@ -3,7 +3,7 @@
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li ng-repeat="section in sections" ng-class="section.class">
|
<li ng-repeat="section in sections" ng-class="section.class">
|
||||||
<a class="navbar-link" ng-href="{{section.url}}">{{section.display}}</a>
|
<a class="navbar-link" kbn-href="{{section.url}}">{{section.display}}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="kbn-settings-about container" ng-controller="settingsAbout">
|
<div class="kbn-settings-about container" ng-controller="settingsAbout">
|
||||||
<div class="col-md-4 col-md-offset-4 jumbotron">
|
<div class="col-md-4 col-md-offset-4 jumbotron">
|
||||||
<center>
|
<center>
|
||||||
<img src='../plugins/kibana/settings/sections/about/barcode.svg' alt="Kibana Barcode Logo" width="128" height="128"><br>
|
<img kbn-src="/plugins/kibana/settings/sections/about/barcode.svg" alt="Kibana Barcode Logo" width="128" height="128"><br>
|
||||||
<h1>Kibana</h1>
|
<h1>Kibana</h1>
|
||||||
<p>
|
<p>
|
||||||
<table class="table table-condensed kbn-settings-about-versions">
|
<table class="table table-condensed kbn-settings-about-versions">
|
||||||
|
|
|
@ -5,6 +5,6 @@ define(function (require) {
|
||||||
order: 3,
|
order: 3,
|
||||||
name: 'status',
|
name: 'status',
|
||||||
display: 'Status',
|
display: 'Status',
|
||||||
url: '../status'
|
url: '/status'
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ var notify = require('ui/notify');
|
||||||
require('plugins/statusPage/statusPageMetric');
|
require('plugins/statusPage/statusPageMetric');
|
||||||
require('plugins/statusPage/statusPage.less');
|
require('plugins/statusPage/statusPage.less');
|
||||||
|
|
||||||
require('ui/chrome')
|
var chrome = require('ui/chrome')
|
||||||
.setTabs([
|
.setTabs([
|
||||||
{
|
{
|
||||||
id: '',
|
id: '',
|
||||||
|
@ -23,7 +23,7 @@ require('ui/chrome')
|
||||||
|
|
||||||
// go ahead and get the info you want
|
// go ahead and get the info you want
|
||||||
return $http
|
return $http
|
||||||
.get('./api/status')
|
.get(chrome.addBasePath('/api/status'))
|
||||||
.then(function (resp) {
|
.then(function (resp) {
|
||||||
|
|
||||||
if (ui.fetchError) {
|
if (ui.fetchError) {
|
||||||
|
|
2
src/ui/public/chrome/api/angular.js
vendored
2
src/ui/public/chrome/api/angular.js
vendored
|
@ -21,7 +21,7 @@ module.exports = function (chrome, internals) {
|
||||||
.value('sessionId', Date.now())
|
.value('sessionId', Date.now())
|
||||||
.value('esUrl', (function () {
|
.value('esUrl', (function () {
|
||||||
var a = document.createElement('a');
|
var a = document.createElement('a');
|
||||||
a.href = '../elasticsearch';
|
a.href = chrome.addBasePath('/elasticsearch');
|
||||||
return a.href;
|
return a.href;
|
||||||
}()))
|
}()))
|
||||||
.directive('kbnChrome', function ($rootScope) {
|
.directive('kbnChrome', function ($rootScope) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module.exports = function (chrome, internals) {
|
const { startsWith, isString } = require('lodash');
|
||||||
const { startsWith } = require('lodash');
|
import { parse, format } from 'url';
|
||||||
|
|
||||||
|
export default function (chrome, internals) {
|
||||||
chrome.getNavLinks = function () {
|
chrome.getNavLinks = function () {
|
||||||
return internals.nav;
|
return internals.nav;
|
||||||
};
|
};
|
||||||
|
@ -9,6 +10,30 @@ module.exports = function (chrome, internals) {
|
||||||
return internals.appUrlStore.getItem(`lastSubUrl:${url}`);
|
return internals.appUrlStore.getItem(`lastSubUrl:${url}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
chrome.getBasePath = function () {
|
||||||
|
return internals.basePath || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
chrome.addBasePath = function (url) {
|
||||||
|
var isUrl = url && isString(url);
|
||||||
|
if (!isUrl) return url;
|
||||||
|
|
||||||
|
var parsed = parse(url);
|
||||||
|
if (!parsed.host && parsed.pathname) {
|
||||||
|
if (parsed.pathname[0] === '/') {
|
||||||
|
parsed.pathname = chrome.getBasePath() + parsed.pathname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return format({
|
||||||
|
protocol: parsed.protocol,
|
||||||
|
host: parsed.host,
|
||||||
|
pathname: parsed.pathname,
|
||||||
|
query: parsed.query,
|
||||||
|
hash: parsed.hash,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
internals.trackPossibleSubUrl = function (url) {
|
internals.trackPossibleSubUrl = function (url) {
|
||||||
for (const link of internals.nav) {
|
for (const link of internals.nav) {
|
||||||
if (startsWith(url, link.url)) {
|
if (startsWith(url, link.url)) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ var chrome = {};
|
||||||
var internals = _.defaults(
|
var internals = _.defaults(
|
||||||
_.cloneDeep(metadata),
|
_.cloneDeep(metadata),
|
||||||
{
|
{
|
||||||
|
basePath: '',
|
||||||
rootController: null,
|
rootController: null,
|
||||||
rootTemplate: null,
|
rootTemplate: null,
|
||||||
showAppsLink: null,
|
showAppsLink: null,
|
||||||
|
|
23
src/ui/public/directives/kbnHref.js
Normal file
23
src/ui/public/directives/kbnHref.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import UiModules from 'ui/modules';
|
||||||
|
import chrome from 'ui/chrome';
|
||||||
|
import { words, camelCase, kebabCase } from 'lodash';
|
||||||
|
|
||||||
|
export function kbnUrlDirective(name) {
|
||||||
|
const srcAttr = kebabCase(name);
|
||||||
|
const attr = kebabCase(words(name).slice(1));
|
||||||
|
|
||||||
|
UiModules
|
||||||
|
.get('kibana')
|
||||||
|
.directive(name, function (Private) {
|
||||||
|
return {
|
||||||
|
restrict: 'A',
|
||||||
|
link: function ($scope, $el, $attr) {
|
||||||
|
$attr.$observe(name, function (val) {
|
||||||
|
$attr.$set(attr, chrome.addBasePath(val));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
kbnUrlDirective('kbnHref');
|
3
src/ui/public/directives/kbnSrc.js
Normal file
3
src/ui/public/directives/kbnSrc.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import { kbnUrlDirective } from './kbnHref';
|
||||||
|
|
||||||
|
kbnUrlDirective('kbnSrc');
|
Loading…
Add table
Add a link
Reference in a new issue