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
d845aacb
Commit
d845aacb
authored
Mar 19, 2019
by
Hugo Häggmark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: merged types and updated references
parent
c1d585b1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
30 deletions
+36
-30
public/app/core/components/SharedPreferences/SharedPreferences.tsx
+17
-2
public/app/core/services/backend_srv.ts
+2
-23
public/app/core/services/search_srv.ts
+3
-2
public/app/types/search.ts
+14
-3
No files found.
public/app/core/components/SharedPreferences/SharedPreferences.tsx
View file @
d845aacb
...
...
@@ -3,7 +3,7 @@ import React, { PureComponent } from 'react';
import
{
FormLabel
,
Select
}
from
'@grafana/ui'
;
import
{
getBackendSrv
,
BackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
DashboardSearchHit
}
from
'app/types'
;
import
{
DashboardSearchHit
,
DashboardSearchHitType
}
from
'app/types'
;
export
interface
Props
{
resourceUri
:
string
;
...
...
@@ -41,6 +41,21 @@ export class SharedPreferences extends PureComponent<Props, State> {
async
componentDidMount
()
{
const
prefs
=
await
this
.
backendSrv
.
get
(
`/api/
${
this
.
props
.
resourceUri
}
/preferences`
);
const
dashboards
=
await
this
.
backendSrv
.
search
({
starred
:
true
});
const
defaultDashboardHit
:
DashboardSearchHit
=
{
id
:
0
,
title
:
'Default'
,
tags
:
[],
type
:
''
as
DashboardSearchHitType
,
uid
:
''
,
uri
:
''
,
url
:
''
,
folderId
:
0
,
folderTitle
:
''
,
folderUid
:
''
,
folderUrl
:
''
,
isStarred
:
false
,
slug
:
''
,
};
if
(
prefs
.
homeDashboardId
>
0
&&
!
dashboards
.
find
(
d
=>
d
.
id
===
prefs
.
homeDashboardId
))
{
const
missing
=
await
this
.
backendSrv
.
search
({
dashboardIds
:
[
prefs
.
homeDashboardId
]
});
...
...
@@ -53,7 +68,7 @@ export class SharedPreferences extends PureComponent<Props, State> {
homeDashboardId
:
prefs
.
homeDashboardId
,
theme
:
prefs
.
theme
,
timezone
:
prefs
.
timezone
,
dashboards
:
[
{
id
:
0
,
title
:
'Default'
,
tags
:
[],
type
:
''
,
uid
:
''
,
uri
:
''
,
url
:
''
}
,
...
dashboards
],
dashboards
:
[
defaultDashboardHit
,
...
dashboards
],
});
}
...
...
public/app/core/services/backend_srv.ts
View file @
d845aacb
...
...
@@ -3,28 +3,7 @@ import coreModule from 'app/core/core_module';
import
appEvents
from
'app/core/app_events'
;
import
config
from
'app/core/config'
;
import
{
DashboardModel
}
from
'app/features/dashboard/state/DashboardModel'
;
export
enum
HitType
{
DashHitDB
=
'dash-db'
,
DashHitHome
=
'dash-home'
,
DashHitFolder
=
'dash-folder'
,
}
export
interface
Hit
{
id
:
number
;
uid
:
string
;
title
:
string
;
uri
:
string
;
url
:
string
;
slug
:
string
;
type
:
HitType
;
tags
:
string
[];
isStarred
:
boolean
;
folderId
:
number
;
folderUid
:
string
;
folderTitle
:
string
;
folderUrl
:
string
;
}
import
{
DashboardSearchHit
}
from
'app/types/search'
;
export
class
BackendSrv
{
private
inFlightRequests
=
{};
...
...
@@ -259,7 +238,7 @@ export class BackendSrv {
return
this
.
request
({
url
:
'/api/login/ping'
,
method
:
'GET'
,
retry
:
1
});
}
search
(
query
):
Promise
<
Hit
[]
>
{
search
(
query
):
Promise
<
DashboardSearch
Hit
[]
>
{
return
this
.
get
(
'/api/search'
,
query
);
}
...
...
public/app/core/services/search_srv.ts
View file @
d845aacb
...
...
@@ -7,8 +7,9 @@ import coreModule from 'app/core/core_module';
import
impressionSrv
from
'app/core/services/impression_srv'
;
import
store
from
'app/core/store'
;
import
{
contextSrv
}
from
'app/core/services/context_srv'
;
import
{
BackendSrv
,
Hit
}
from
'./backend_srv'
;
import
{
BackendSrv
}
from
'./backend_srv'
;
import
{
Section
}
from
'../components/manage_dashboards/manage_dashboards'
;
import
{
DashboardSearchHit
}
from
'app/types/search'
;
interface
Sections
{
[
key
:
string
]:
Partial
<
Section
>
;
...
...
@@ -128,7 +129,7 @@ export class SearchSrv {
});
}
private
handleSearchResult
(
sections
:
Sections
,
results
:
Hit
[]):
any
{
private
handleSearchResult
(
sections
:
Sections
,
results
:
DashboardSearch
Hit
[]):
any
{
if
(
results
.
length
===
0
)
{
return
sections
;
}
...
...
public/app/types/search.ts
View file @
d845aacb
export
enum
DashboardSearchHitType
{
DashHitDB
=
'dash-db'
,
DashHitHome
=
'dash-home'
,
DashHitFolder
=
'dash-folder'
,
}
export
interface
DashboardSearchHit
{
id
:
number
;
tags
:
string
[];
title
:
string
;
type
:
string
;
uid
:
string
;
title
:
string
;
uri
:
string
;
url
:
string
;
slug
:
string
;
type
:
DashboardSearchHitType
;
tags
:
string
[];
isStarred
:
boolean
;
folderId
:
number
;
folderUid
:
string
;
folderTitle
:
string
;
folderUrl
:
string
;
}
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