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
574a37e4
Unverified
Commit
574a37e4
authored
Jun 04, 2019
by
Ryan McKinley
Committed by
GitHub
Jun 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
@grafana/runtime: expose location update (#17428)
parent
10a4a899
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
70 additions
and
30 deletions
+70
-30
packages/grafana-runtime/src/services/LocationSrv.ts
+36
-0
packages/grafana-runtime/src/services/index.ts
+1
-0
public/app/core/actions/location.ts
+1
-1
public/app/core/utils/url.ts
+6
-6
public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx
+1
-1
public/app/features/dashboard/state/DashboardModel.ts
+3
-2
public/app/features/datasources/settings/DataSourceSettingsPage.tsx
+2
-1
public/app/features/datasources/state/actions.ts
+2
-1
public/app/features/explore/state/reducers.ts
+1
-1
public/app/features/plugins/AppRootPage.tsx
+2
-1
public/app/features/plugins/PluginPage.tsx
+2
-1
public/app/routes/GrafanaCtrl.ts
+9
-1
public/app/store/configureStore.ts
+3
-1
public/app/types/location.ts
+1
-13
No files found.
packages/grafana-runtime/src/services/LocationSrv.ts
0 → 100644
View file @
574a37e4
export
interface
LocationUpdate
{
path
?:
string
;
query
?:
UrlQueryMap
;
/**
* Add the query argument to the existing URL
*/
partial
?:
boolean
;
/**
* Do not change this unless you are the angular router
*/
routeParams
?:
UrlQueryMap
;
/*
* If true this will replace url state (ie cause no new browser history)
*/
replace
?:
boolean
;
}
export
type
UrlQueryValue
=
string
|
number
|
boolean
|
string
[]
|
number
[]
|
boolean
[];
export
type
UrlQueryMap
=
{
[
s
:
string
]:
UrlQueryValue
};
export
interface
LocationSrv
{
update
(
options
:
LocationUpdate
):
void
;
}
let
singletonInstance
:
LocationSrv
;
export
function
setLocationSrv
(
instance
:
LocationSrv
)
{
singletonInstance
=
instance
;
}
export
function
getLocationSrv
():
LocationSrv
{
return
singletonInstance
;
}
packages/grafana-runtime/src/services/index.ts
View file @
574a37e4
export
*
from
'./backendSrv'
;
export
*
from
'./backendSrv'
;
export
*
from
'./AngularLoader'
;
export
*
from
'./AngularLoader'
;
export
*
from
'./dataSourceSrv'
;
export
*
from
'./dataSourceSrv'
;
export
*
from
'./LocationSrv'
;
public/app/core/actions/location.ts
View file @
574a37e4
import
{
LocationUpdate
}
from
'
app/types
'
;
import
{
LocationUpdate
}
from
'
@grafana/runtime
'
;
import
{
actionCreatorFactory
}
from
'app/core/redux'
;
import
{
actionCreatorFactory
}
from
'app/core/redux'
;
export
const
updateLocation
=
actionCreatorFactory
<
LocationUpdate
>
(
'UPDATE_LOCATION'
).
create
();
export
const
updateLocation
=
actionCreatorFactory
<
LocationUpdate
>
(
'UPDATE_LOCATION'
).
create
();
public/app/core/utils/url.ts
View file @
574a37e4
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @preserve jquery-param (c) 2015 KNOWLEDGECODE | MIT
* @preserve jquery-param (c) 2015 KNOWLEDGECODE | MIT
*/
*/
import
{
UrlQueryMap
}
from
'
app/types
'
;
import
{
UrlQueryMap
}
from
'
@grafana/runtime
'
;
export
function
renderUrl
(
path
:
string
,
query
:
UrlQueryMap
|
undefined
):
string
{
export
function
renderUrl
(
path
:
string
,
query
:
UrlQueryMap
|
undefined
):
string
{
if
(
query
&&
Object
.
keys
(
query
).
length
>
0
)
{
if
(
query
&&
Object
.
keys
(
query
).
length
>
0
)
{
...
@@ -11,7 +11,7 @@ export function renderUrl(path: string, query: UrlQueryMap | undefined): string
...
@@ -11,7 +11,7 @@ export function renderUrl(path: string, query: UrlQueryMap | undefined): string
return
path
;
return
path
;
}
}
export
function
encodeURIComponentAsAngularJS
(
val
,
pctEncodeSpaces
)
{
export
function
encodeURIComponentAsAngularJS
(
val
:
string
,
pctEncodeSpaces
?:
boolean
)
{
return
encodeURIComponent
(
val
)
return
encodeURIComponent
(
val
)
.
replace
(
/%40/gi
,
'@'
)
.
replace
(
/%40/gi
,
'@'
)
.
replace
(
/%3A/gi
,
':'
)
.
replace
(
/%3A/gi
,
':'
)
...
@@ -21,15 +21,15 @@ export function encodeURIComponentAsAngularJS(val, pctEncodeSpaces) {
...
@@ -21,15 +21,15 @@ export function encodeURIComponentAsAngularJS(val, pctEncodeSpaces) {
.
replace
(
/%20/g
,
pctEncodeSpaces
?
'%20'
:
'+'
);
.
replace
(
/%20/g
,
pctEncodeSpaces
?
'%20'
:
'+'
);
}
}
export
function
toUrlParams
(
a
)
{
export
function
toUrlParams
(
a
:
any
)
{
const
s
=
[];
const
s
=
[];
const
rbracket
=
/
\[\]
$/
;
const
rbracket
=
/
\[\]
$/
;
const
isArray
=
obj
=>
{
const
isArray
=
(
obj
:
any
)
=>
{
return
Object
.
prototype
.
toString
.
call
(
obj
)
===
'[object Array]'
;
return
Object
.
prototype
.
toString
.
call
(
obj
)
===
'[object Array]'
;
};
};
const
add
=
(
k
,
v
)
=>
{
const
add
=
(
k
:
string
,
v
:
any
)
=>
{
v
=
typeof
v
===
'function'
?
v
()
:
v
===
null
?
''
:
v
===
undefined
?
''
:
v
;
v
=
typeof
v
===
'function'
?
v
()
:
v
===
null
?
''
:
v
===
undefined
?
''
:
v
;
if
(
typeof
v
!==
'boolean'
)
{
if
(
typeof
v
!==
'boolean'
)
{
s
[
s
.
length
]
=
encodeURIComponentAsAngularJS
(
k
,
true
)
+
'='
+
encodeURIComponentAsAngularJS
(
v
,
true
);
s
[
s
.
length
]
=
encodeURIComponentAsAngularJS
(
k
,
true
)
+
'='
+
encodeURIComponentAsAngularJS
(
v
,
true
);
...
@@ -38,7 +38,7 @@ export function toUrlParams(a) {
...
@@ -38,7 +38,7 @@ export function toUrlParams(a) {
}
}
};
};
const
buildParams
=
(
prefix
,
obj
)
=>
{
const
buildParams
=
(
prefix
:
string
,
obj
:
any
)
=>
{
let
i
,
len
,
key
;
let
i
,
len
,
key
;
if
(
prefix
)
{
if
(
prefix
)
{
...
...
public/app/features/dashboard/components/AddPanelWidget/AddPanelWidget.tsx
View file @
574a37e4
...
@@ -14,7 +14,7 @@ import { updateLocation } from 'app/core/actions';
...
@@ -14,7 +14,7 @@ import { updateLocation } from 'app/core/actions';
import
{
PanelModel
}
from
'../../state'
;
import
{
PanelModel
}
from
'../../state'
;
import
{
DashboardModel
}
from
'../../state'
;
import
{
DashboardModel
}
from
'../../state'
;
import
{
LS_PANEL_COPY_KEY
}
from
'app/core/constants'
;
import
{
LS_PANEL_COPY_KEY
}
from
'app/core/constants'
;
import
{
LocationUpdate
}
from
'
app/types
'
;
import
{
LocationUpdate
}
from
'
@grafana/runtime
'
;
export
interface
Props
{
export
interface
Props
{
panel
:
PanelModel
;
panel
:
PanelModel
;
...
...
public/app/features/dashboard/state/DashboardModel.ts
View file @
574a37e4
...
@@ -13,8 +13,9 @@ import sortByKeys from 'app/core/utils/sort_by_keys';
...
@@ -13,8 +13,9 @@ import sortByKeys from 'app/core/utils/sort_by_keys';
// Types
// Types
import
{
PanelModel
,
GridPos
}
from
'./PanelModel'
;
import
{
PanelModel
,
GridPos
}
from
'./PanelModel'
;
import
{
DashboardMigrator
}
from
'./DashboardMigrator'
;
import
{
DashboardMigrator
}
from
'./DashboardMigrator'
;
import
{
TimeRange
}
from
'@grafana/ui/src'
;
import
{
TimeRange
}
from
'@grafana/ui'
;
import
{
UrlQueryValue
,
KIOSK_MODE_TV
,
DashboardMeta
}
from
'app/types'
;
import
{
UrlQueryValue
}
from
'@grafana/runtime'
;
import
{
KIOSK_MODE_TV
,
DashboardMeta
}
from
'app/types'
;
import
{
toUtc
,
DateTimeInput
,
dateTime
,
isDateTime
}
from
'@grafana/ui/src/utils/moment_wrapper'
;
import
{
toUtc
,
DateTimeInput
,
dateTime
,
isDateTime
}
from
'@grafana/ui/src/utils/moment_wrapper'
;
export
interface
CloneOptions
{
export
interface
CloneOptions
{
...
...
public/app/features/datasources/settings/DataSourceSettingsPage.tsx
View file @
574a37e4
...
@@ -22,7 +22,8 @@ import { getNavModel } from 'app/core/selectors/navModel';
...
@@ -22,7 +22,8 @@ import { getNavModel } from 'app/core/selectors/navModel';
import
{
getRouteParamsId
}
from
'app/core/selectors/location'
;
import
{
getRouteParamsId
}
from
'app/core/selectors/location'
;
// Types
// Types
import
{
StoreState
,
UrlQueryMap
}
from
'app/types/'
;
import
{
StoreState
}
from
'app/types/'
;
import
{
UrlQueryMap
}
from
'@grafana/runtime'
;
import
{
NavModel
,
DataSourceSettings
,
DataSourcePluginMeta
}
from
'@grafana/ui'
;
import
{
NavModel
,
DataSourceSettings
,
DataSourcePluginMeta
}
from
'@grafana/ui'
;
import
{
getDataSourceLoadingNav
}
from
'../state/navModel'
;
import
{
getDataSourceLoadingNav
}
from
'../state/navModel'
;
import
PluginStateinfo
from
'app/features/plugins/PluginStateInfo'
;
import
PluginStateinfo
from
'app/features/plugins/PluginStateInfo'
;
...
...
public/app/features/datasources/state/actions.ts
View file @
574a37e4
...
@@ -6,7 +6,8 @@ import { LayoutMode } from 'app/core/components/LayoutSelector/LayoutSelector';
...
@@ -6,7 +6,8 @@ import { LayoutMode } from 'app/core/components/LayoutSelector/LayoutSelector';
import
{
updateLocation
,
updateNavIndex
,
UpdateNavIndexAction
}
from
'app/core/actions'
;
import
{
updateLocation
,
updateNavIndex
,
UpdateNavIndexAction
}
from
'app/core/actions'
;
import
{
buildNavModel
}
from
'./navModel'
;
import
{
buildNavModel
}
from
'./navModel'
;
import
{
DataSourceSettings
,
DataSourcePluginMeta
}
from
'@grafana/ui'
;
import
{
DataSourceSettings
,
DataSourcePluginMeta
}
from
'@grafana/ui'
;
import
{
StoreState
,
LocationUpdate
}
from
'app/types'
;
import
{
StoreState
}
from
'app/types'
;
import
{
LocationUpdate
}
from
'@grafana/runtime'
;
import
{
actionCreatorFactory
}
from
'app/core/redux'
;
import
{
actionCreatorFactory
}
from
'app/core/redux'
;
import
{
ActionOf
,
noPayloadActionCreatorFactory
}
from
'app/core/redux/actionCreatorFactory'
;
import
{
ActionOf
,
noPayloadActionCreatorFactory
}
from
'app/core/redux/actionCreatorFactory'
;
import
{
getPluginSettings
}
from
'app/features/plugins/PluginSettingsCache'
;
import
{
getPluginSettings
}
from
'app/features/plugins/PluginSettingsCache'
;
...
...
public/app/features/explore/state/reducers.ts
View file @
574a37e4
...
@@ -55,7 +55,7 @@ import {
...
@@ -55,7 +55,7 @@ import {
toggleLogLevelAction
,
toggleLogLevelAction
,
}
from
'./actionTypes'
;
}
from
'./actionTypes'
;
import
{
updateLocation
}
from
'app/core/actions/location'
;
import
{
updateLocation
}
from
'app/core/actions/location'
;
import
{
LocationUpdate
}
from
'
app/types
'
;
import
{
LocationUpdate
}
from
'
@grafana/runtime
'
;
import
TableModel
from
'app/core/table_model'
;
import
TableModel
from
'app/core/table_model'
;
import
{
isLive
}
from
'@grafana/ui/src/components/RefreshPicker/RefreshPicker'
;
import
{
isLive
}
from
'@grafana/ui/src/components/RefreshPicker/RefreshPicker'
;
...
...
public/app/features/plugins/AppRootPage.tsx
View file @
574a37e4
...
@@ -4,7 +4,8 @@ import { hot } from 'react-hot-loader';
...
@@ -4,7 +4,8 @@ import { hot } from 'react-hot-loader';
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
// Types
// Types
import
{
StoreState
,
UrlQueryMap
}
from
'app/types'
;
import
{
StoreState
}
from
'app/types'
;
import
{
UrlQueryMap
}
from
'@grafana/runtime'
;
import
Page
from
'app/core/components/Page/Page'
;
import
Page
from
'app/core/components/Page/Page'
;
import
{
getPluginSettings
}
from
'./PluginSettingsCache'
;
import
{
getPluginSettings
}
from
'./PluginSettingsCache'
;
...
...
public/app/features/plugins/PluginPage.tsx
View file @
574a37e4
...
@@ -5,7 +5,8 @@ import { connect } from 'react-redux';
...
@@ -5,7 +5,8 @@ import { connect } from 'react-redux';
import
find
from
'lodash/find'
;
import
find
from
'lodash/find'
;
// Types
// Types
import
{
StoreState
,
UrlQueryMap
}
from
'app/types'
;
import
{
UrlQueryMap
}
from
'@grafana/runtime'
;
import
{
StoreState
}
from
'app/types'
;
import
{
import
{
NavModel
,
NavModel
,
NavModelItem
,
NavModelItem
,
...
...
public/app/routes/GrafanaCtrl.ts
View file @
574a37e4
...
@@ -16,6 +16,9 @@ import { KeybindingSrv, setKeybindingSrv } from 'app/core/services/keybindingSrv
...
@@ -16,6 +16,9 @@ import { KeybindingSrv, setKeybindingSrv } from 'app/core/services/keybindingSrv
import
{
AngularLoader
,
setAngularLoader
}
from
'app/core/services/AngularLoader'
;
import
{
AngularLoader
,
setAngularLoader
}
from
'app/core/services/AngularLoader'
;
import
{
configureStore
}
from
'app/store/configureStore'
;
import
{
configureStore
}
from
'app/store/configureStore'
;
import
{
LocationUpdate
,
setLocationSrv
}
from
'@grafana/runtime'
;
import
{
updateLocation
}
from
'app/core/actions'
;
// Types
// Types
import
{
KioskUrlValue
}
from
'app/types'
;
import
{
KioskUrlValue
}
from
'app/types'
;
...
@@ -40,7 +43,12 @@ export class GrafanaCtrl {
...
@@ -40,7 +43,12 @@ export class GrafanaCtrl {
setDataSourceSrv
(
datasourceSrv
);
setDataSourceSrv
(
datasourceSrv
);
setTimeSrv
(
timeSrv
);
setTimeSrv
(
timeSrv
);
setKeybindingSrv
(
keybindingSrv
);
setKeybindingSrv
(
keybindingSrv
);
configureStore
();
const
store
=
configureStore
();
setLocationSrv
({
update
:
(
opt
:
LocationUpdate
)
=>
{
store
.
dispatch
(
updateLocation
(
opt
));
},
});
$scope
.
init
=
()
=>
{
$scope
.
init
=
()
=>
{
$scope
.
contextSrv
=
contextSrv
;
$scope
.
contextSrv
=
contextSrv
;
...
...
public/app/store/configureStore.ts
View file @
574a37e4
...
@@ -89,6 +89,8 @@ export function configureStore() {
...
@@ -89,6 +89,8 @@ export function configureStore() {
?
applyMiddleware
(
toggleLogActionsMiddleware
,
thunk
,
epicMiddleware
,
logger
)
?
applyMiddleware
(
toggleLogActionsMiddleware
,
thunk
,
epicMiddleware
,
logger
)
:
applyMiddleware
(
thunk
,
epicMiddleware
);
:
applyMiddleware
(
thunk
,
epicMiddleware
);
setStore
(
createStore
(
rootReducer
,
{},
composeEnhancers
(
storeEnhancers
)));
const
store
=
createStore
(
rootReducer
,
{},
composeEnhancers
(
storeEnhancers
));
setStore
(
store
);
epicMiddleware
.
run
(
rootEpic
);
epicMiddleware
.
run
(
rootEpic
);
return
store
;
}
}
public/app/types/location.ts
View file @
574a37e4
export
interface
LocationUpdate
{
import
{
UrlQueryMap
}
from
'@grafana/runtime'
;
path
?:
string
;
query
?:
UrlQueryMap
;
routeParams
?:
UrlQueryMap
;
partial
?:
boolean
;
/*
* If true this will replace url state (ie cause no new browser history)
*/
replace
?:
boolean
;
}
export
interface
LocationState
{
export
interface
LocationState
{
url
:
string
;
url
:
string
;
...
@@ -17,6 +8,3 @@ export interface LocationState {
...
@@ -17,6 +8,3 @@ export interface LocationState {
replace
:
boolean
;
replace
:
boolean
;
lastUpdated
:
number
;
lastUpdated
:
number
;
}
}
export
type
UrlQueryValue
=
string
|
number
|
boolean
|
string
[]
|
number
[]
|
boolean
[];
export
type
UrlQueryMap
=
{
[
s
:
string
]:
UrlQueryValue
};
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