mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
refactoring: simplified backend_srv and subUrl handling, #8122
This commit is contained in:
parent
b77991f69b
commit
aa47b9bf5c
@ -66,16 +66,14 @@ export class BackendSrv {
|
|||||||
var requestIsLocal = !options.url.match(/^http/);
|
var requestIsLocal = !options.url.match(/^http/);
|
||||||
var firstAttempt = options.retry === 0;
|
var firstAttempt = options.retry === 0;
|
||||||
|
|
||||||
|
|
||||||
if (requestIsLocal) {
|
if (requestIsLocal) {
|
||||||
if (this.contextSrv.user && this.contextSrv.user.orgId) {
|
if (this.contextSrv.user && this.contextSrv.user.orgId) {
|
||||||
options.headers = options.headers || {};
|
options.headers = options.headers || {};
|
||||||
options.headers['X-Grafana-Org-Id'] = this.contextSrv.user.orgId;
|
options.headers['X-Grafana-Org-Id'] = this.contextSrv.user.orgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.hasSubUrl) {
|
if (options.url.indexOf("/") === 0) {
|
||||||
options.url = config.appSubUrl + options.url;
|
options.url = options.url.substring(1);
|
||||||
options.hasSubUrl = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +140,8 @@ export class BackendSrv {
|
|||||||
options.headers['X-Grafana-Org-Id'] = this.contextSrv.user.orgId;
|
options.headers['X-Grafana-Org-Id'] = this.contextSrv.user.orgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.hasSubUrl && options.retry === 0) {
|
if (options.url.indexOf("/") === 0) {
|
||||||
options.url = config.appSubUrl + options.url;
|
options.url = options.url.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.headers && options.headers.Authorization) {
|
if (options.headers && options.headers.Authorization) {
|
||||||
|
@ -58,7 +58,7 @@ class GettingStartedPanelCtrl extends PanelCtrl {
|
|||||||
icon: 'icon-gf icon-gf-users',
|
icon: 'icon-gf icon-gf-users',
|
||||||
href: 'org/users?gettingstarted',
|
href: 'org/users?gettingstarted',
|
||||||
check: () => {
|
check: () => {
|
||||||
return this.backendSrv.get('api/org/users').then(res => {
|
return this.backendSrv.get('/api/org/users').then(res => {
|
||||||
return res.length > 1;
|
return res.length > 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ class GettingStartedPanelCtrl extends PanelCtrl {
|
|||||||
icon: 'icon-gf icon-gf-apps',
|
icon: 'icon-gf icon-gf-apps',
|
||||||
href: 'https://grafana.com/plugins?utm_source=grafana_getting_started',
|
href: 'https://grafana.com/plugins?utm_source=grafana_getting_started',
|
||||||
check: () => {
|
check: () => {
|
||||||
return this.backendSrv.get('api/plugins', {embedded: 0, core: 0}).then(plugins => {
|
return this.backendSrv.get('/api/plugins', {embedded: 0, core: 0}).then(plugins => {
|
||||||
return plugins.length > 0;
|
return plugins.length > 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user