Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3db328f5
Commit
3db328f5
authored
Feb 01, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for dashboard/folder url's when having a sub path in root_url config
parent
d8d82c17
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
33 deletions
+40
-33
public/app/containers/ManageDashboards/FolderPermissions.tsx
+1
-0
public/app/core/services/bridge_srv.ts
+6
-17
public/app/core/specs/location_util.jest.ts
+3
-9
public/app/core/utils/location_util.ts
+14
-0
public/app/features/dashboard/folder_dashboards_ctrl.ts
+5
-2
public/app/features/panel/solo_panel_ctrl.ts
+3
-1
public/app/routes/dashboard_loaders.ts
+8
-4
No files found.
public/app/containers/ManageDashboards/FolderPermissions.tsx
View file @
3db328f5
...
@@ -17,6 +17,7 @@ export class FolderPermissions extends Component<IContainerProps, any> {
...
@@ -17,6 +17,7 @@ export class FolderPermissions extends Component<IContainerProps, any> {
loadStore
()
{
loadStore
()
{
const
{
nav
,
folder
,
view
}
=
this
.
props
;
const
{
nav
,
folder
,
view
}
=
this
.
props
;
return
folder
.
load
(
view
.
routeParams
.
get
(
'uid'
)
as
string
).
then
(
res
=>
{
return
folder
.
load
(
view
.
routeParams
.
get
(
'uid'
)
as
string
).
then
(
res
=>
{
view
.
updatePathAndQuery
(
`
${
res
.
meta
.
url
}
/permissions`
,
{},
{});
return
nav
.
initFolderNav
(
toJS
(
folder
.
folder
),
'manage-folder-permissions'
);
return
nav
.
initFolderNav
(
toJS
(
folder
.
folder
),
'manage-folder-permissions'
);
});
});
}
}
...
...
public/app/core/services/bridge_srv.ts
View file @
3db328f5
import
coreModule
from
'app/core/core_module'
;
import
coreModule
from
'app/core/core_module'
;
import
config
from
'app/core/config'
;
import
appEvents
from
'app/core/app_events'
;
import
appEvents
from
'app/core/app_events'
;
import
{
store
}
from
'app/stores/store'
;
import
{
store
}
from
'app/stores/store'
;
import
{
reaction
}
from
'mobx'
;
import
{
reaction
}
from
'mobx'
;
import
locationUtil
from
'app/core/utils/location_util'
;
// Services that handles angular -> mobx store sync & other react <-> angular sync
// Services that handles angular -> mobx store sync & other react <-> angular sync
export
class
BridgeSrv
{
export
class
BridgeSrv
{
private
appSubUrl
;
private
fullPageReloadRoutes
;
private
fullPageReloadRoutes
;
/** @ngInject */
/** @ngInject */
constructor
(
private
$location
,
private
$timeout
,
private
$window
,
private
$rootScope
,
private
$route
)
{
constructor
(
private
$location
,
private
$timeout
,
private
$window
,
private
$rootScope
,
private
$route
)
{
this
.
appSubUrl
=
config
.
appSubUrl
;
this
.
fullPageReloadRoutes
=
[
'/logout'
];
this
.
fullPageReloadRoutes
=
[
'/logout'
];
}
}
// Angular's $location does not like <base href...> and absolute urls
stripBaseFromUrl
(
url
=
''
)
{
const
appSubUrl
=
this
.
appSubUrl
;
const
stripExtraChars
=
appSubUrl
.
endsWith
(
'/'
)
?
1
:
0
;
const
urlWithoutBase
=
url
.
length
>
0
&&
url
.
indexOf
(
appSubUrl
)
===
0
?
url
.
slice
(
appSubUrl
.
length
-
stripExtraChars
)
:
url
;
return
urlWithoutBase
;
}
init
()
{
init
()
{
this
.
$rootScope
.
$on
(
'$routeUpdate'
,
(
evt
,
data
)
=>
{
this
.
$rootScope
.
$on
(
'$routeUpdate'
,
(
evt
,
data
)
=>
{
let
angularUrl
=
this
.
$location
.
url
();
let
angularUrl
=
this
.
$location
.
url
();
...
@@ -41,17 +29,18 @@ export class BridgeSrv {
...
@@ -41,17 +29,18 @@ export class BridgeSrv {
()
=>
store
.
view
.
currentUrl
,
()
=>
store
.
view
.
currentUrl
,
currentUrl
=>
{
currentUrl
=>
{
let
angularUrl
=
this
.
$location
.
url
();
let
angularUrl
=
this
.
$location
.
url
();
if
(
angularUrl
!==
currentUrl
)
{
const
url
=
locationUtil
.
stripBaseFromUrl
(
currentUrl
);
if
(
angularUrl
!==
url
)
{
this
.
$timeout
(()
=>
{
this
.
$timeout
(()
=>
{
this
.
$location
.
url
(
currentU
rl
);
this
.
$location
.
url
(
u
rl
);
});
});
console
.
log
(
'store updating angular $location.url'
,
currentU
rl
);
console
.
log
(
'store updating angular $location.url'
,
u
rl
);
}
}
}
}
);
);
appEvents
.
on
(
'location-change'
,
payload
=>
{
appEvents
.
on
(
'location-change'
,
payload
=>
{
const
urlWithoutBase
=
this
.
stripBaseFromUrl
(
payload
.
href
);
const
urlWithoutBase
=
locationUtil
.
stripBaseFromUrl
(
payload
.
href
);
if
(
this
.
fullPageReloadRoutes
.
indexOf
(
urlWithoutBase
)
>
-
1
)
{
if
(
this
.
fullPageReloadRoutes
.
indexOf
(
urlWithoutBase
)
>
-
1
)
{
this
.
$window
.
location
.
href
=
payload
.
href
;
this
.
$window
.
location
.
href
=
payload
.
href
;
return
;
return
;
...
...
public/app/core/specs/
bridge_srv
.jest.ts
→
public/app/core/specs/
location_util
.jest.ts
View file @
3db328f5
import
{
BridgeSrv
}
from
'app/core/services/bridge_srv
'
;
import
locationUtil
from
'app/core/utils/location_util
'
;
jest
.
mock
(
'app/core/config'
,
()
=>
{
jest
.
mock
(
'app/core/config'
,
()
=>
{
return
{
return
{
...
@@ -6,16 +6,10 @@ jest.mock('app/core/config', () => {
...
@@ -6,16 +6,10 @@ jest.mock('app/core/config', () => {
};
};
});
});
describe
(
'BridgeSrv'
,
()
=>
{
describe
(
'locationUtil'
,
()
=>
{
let
searchSrv
;
beforeEach
(()
=>
{
searchSrv
=
new
BridgeSrv
(
null
,
null
,
null
,
null
,
null
);
});
describe
(
'With /subUrl as appSubUrl'
,
()
=>
{
describe
(
'With /subUrl as appSubUrl'
,
()
=>
{
it
(
'/subUrl should be stripped'
,
()
=>
{
it
(
'/subUrl should be stripped'
,
()
=>
{
const
urlWithoutMaster
=
searchSrv
.
stripBaseFromUrl
(
'/subUrl/grafana/'
);
const
urlWithoutMaster
=
locationUtil
.
stripBaseFromUrl
(
'/subUrl/grafana/'
);
expect
(
urlWithoutMaster
).
toBe
(
'/grafana/'
);
expect
(
urlWithoutMaster
).
toBe
(
'/grafana/'
);
});
});
});
});
...
...
public/app/core/utils/location_util.ts
0 → 100644
View file @
3db328f5
import
config
from
'app/core/config'
;
const
_stripBaseFromUrl
=
url
=>
{
const
appSubUrl
=
config
.
appSubUrl
;
const
stripExtraChars
=
appSubUrl
.
endsWith
(
'/'
)
?
1
:
0
;
const
urlWithoutBase
=
url
.
length
>
0
&&
url
.
indexOf
(
appSubUrl
)
===
0
?
url
.
slice
(
appSubUrl
.
length
-
stripExtraChars
)
:
url
;
return
urlWithoutBase
;
};
export
default
{
stripBaseFromUrl
:
_stripBaseFromUrl
,
};
public/app/features/dashboard/folder_dashboards_ctrl.ts
View file @
3db328f5
import
{
FolderPageLoader
}
from
'./folder_page_loader'
;
import
{
FolderPageLoader
}
from
'./folder_page_loader'
;
import
locationUtil
from
'app/core/utils/location_util'
;
export
class
FolderDashboardsCtrl
{
export
class
FolderDashboardsCtrl
{
navModel
:
any
;
navModel
:
any
;
...
@@ -13,8 +14,10 @@ export class FolderDashboardsCtrl {
...
@@ -13,8 +14,10 @@ export class FolderDashboardsCtrl {
const
loader
=
new
FolderPageLoader
(
this
.
backendSrv
);
const
loader
=
new
FolderPageLoader
(
this
.
backendSrv
);
loader
.
load
(
this
,
this
.
uid
,
'manage-folder-dashboards'
).
then
(
folder
=>
{
loader
.
load
(
this
,
this
.
uid
,
'manage-folder-dashboards'
).
then
(
folder
=>
{
if
(
$location
.
path
()
!==
folder
.
meta
.
url
)
{
const
url
=
locationUtil
.
stripBaseFromUrl
(
folder
.
meta
.
url
);
$location
.
path
(
folder
.
meta
.
url
).
replace
();
if
(
url
!==
$location
.
path
())
{
$location
.
path
(
url
).
replace
();
}
}
});
});
}
}
...
...
public/app/features/panel/solo_panel_ctrl.ts
View file @
3db328f5
import
angular
from
'angular'
;
import
angular
from
'angular'
;
import
locationUtil
from
'app/core/utils/location_util'
;
export
class
SoloPanelCtrl
{
export
class
SoloPanelCtrl
{
/** @ngInject */
/** @ngInject */
...
@@ -17,7 +18,8 @@ export class SoloPanelCtrl {
...
@@ -17,7 +18,8 @@ export class SoloPanelCtrl {
if
(
!
(
$routeParams
.
type
===
'script'
||
$routeParams
.
type
===
'snapshot'
)
&&
!
$routeParams
.
uid
)
{
if
(
!
(
$routeParams
.
type
===
'script'
||
$routeParams
.
type
===
'snapshot'
)
&&
!
$routeParams
.
uid
)
{
backendSrv
.
get
(
`/api/dashboards/db/
${
$routeParams
.
slug
}
`
).
then
(
res
=>
{
backendSrv
.
get
(
`/api/dashboards/db/
${
$routeParams
.
slug
}
`
).
then
(
res
=>
{
if
(
res
)
{
if
(
res
)
{
$location
.
path
(
res
.
meta
.
url
.
replace
(
'/d/'
,
'/d-solo/'
));
const
url
=
locationUtil
.
stripBaseFromUrl
(
res
.
meta
.
url
.
replace
(
'/d/'
,
'/d-solo/'
));
$location
.
path
(
url
).
replace
();
}
}
});
});
return
;
return
;
...
...
public/app/routes/dashboard_loaders.ts
View file @
3db328f5
import
coreModule
from
'app/core/core_module'
;
import
coreModule
from
'app/core/core_module'
;
import
locationUtil
from
'app/core/utils/location_util'
;
export
class
LoadDashboardCtrl
{
export
class
LoadDashboardCtrl
{
/** @ngInject */
/** @ngInject */
constructor
(
$scope
,
$routeParams
,
dashboardLoaderSrv
,
backendSrv
,
$location
)
{
constructor
(
$scope
,
$routeParams
,
dashboardLoaderSrv
,
backendSrv
,
$location
,
$browser
)
{
$scope
.
appEvent
(
'dashboard-fetch-start'
);
$scope
.
appEvent
(
'dashboard-fetch-start'
);
if
(
!
$routeParams
.
uid
&&
!
$routeParams
.
slug
)
{
if
(
!
$routeParams
.
uid
&&
!
$routeParams
.
slug
)
{
...
@@ -22,15 +23,18 @@ export class LoadDashboardCtrl {
...
@@ -22,15 +23,18 @@ export class LoadDashboardCtrl {
if
(
!
(
$routeParams
.
type
===
'script'
||
$routeParams
.
type
===
'snapshot'
)
&&
!
$routeParams
.
uid
)
{
if
(
!
(
$routeParams
.
type
===
'script'
||
$routeParams
.
type
===
'snapshot'
)
&&
!
$routeParams
.
uid
)
{
backendSrv
.
get
(
`/api/dashboards/db/
${
$routeParams
.
slug
}
`
).
then
(
res
=>
{
backendSrv
.
get
(
`/api/dashboards/db/
${
$routeParams
.
slug
}
`
).
then
(
res
=>
{
if
(
res
)
{
if
(
res
)
{
$location
.
path
(
res
.
meta
.
url
).
replace
();
const
url
=
locationUtil
.
stripBaseFromUrl
(
res
.
meta
.
url
);
$location
.
path
(
url
).
replace
();
}
}
});
});
return
;
return
;
}
}
dashboardLoaderSrv
.
loadDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
,
$routeParams
.
uid
).
then
(
function
(
result
)
{
dashboardLoaderSrv
.
loadDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
,
$routeParams
.
uid
).
then
(
function
(
result
)
{
if
(
$location
.
path
()
!==
result
.
meta
.
url
)
{
const
url
=
locationUtil
.
stripBaseFromUrl
(
result
.
meta
.
url
);
$location
.
path
(
result
.
meta
.
url
).
replace
();
if
(
url
!==
$location
.
path
())
{
$location
.
path
(
url
).
replace
();
}
}
if
(
$routeParams
.
keepRows
)
{
if
(
$routeParams
.
keepRows
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment