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
6ad06364
Unverified
Commit
6ad06364
authored
Dec 19, 2017
by
Daniel Lee
Committed by
GitHub
Dec 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search: closes dash search when selecting current dashboard (#10285)
Fixes #10231.
parent
0bc6f4e2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
15 deletions
+66
-15
public/app/core/components/navbar/navbar.ts
+3
-3
public/app/core/components/search/search.ts
+5
-3
public/app/core/components/search/search_results.html
+1
-1
public/app/core/components/search/search_results.ts
+7
-0
public/app/core/services/keybindingSrv.ts
+3
-3
public/app/core/specs/search.jest.ts
+1
-1
public/app/core/specs/search_results.jest.ts
+43
-0
public/app/features/dashboard/dashnav/dashnav.ts
+1
-2
public/app/features/org/teams_ctrl.ts
+2
-2
No files found.
public/app/core/components/navbar/navbar.ts
View file @
6ad06364
import
coreModule
from
'../../core_module'
;
import
coreModule
from
'../../core_module'
;
import
{
NavModel
}
from
'../../nav_model_srv'
;
import
{
NavModel
}
from
'../../nav_model_srv'
;
import
appEvents
from
'app/core/app_events'
;
export
class
NavbarCtrl
{
export
class
NavbarCtrl
{
model
:
NavModel
;
model
:
NavModel
;
/** @ngInject */
/** @ngInject */
constructor
(
private
$rootScope
)
{
constructor
()
{}
}
showSearch
()
{
showSearch
()
{
this
.
$rootScope
.
appEven
t
(
'show-dash-search'
);
appEvents
.
emi
t
(
'show-dash-search'
);
}
}
navItemClicked
(
navItem
,
evt
)
{
navItemClicked
(
navItem
,
evt
)
{
...
...
public/app/core/components/search/search.ts
View file @
6ad06364
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
coreModule
from
'../../core_module'
;
import
coreModule
from
'../../core_module'
;
import
{
SearchSrv
}
from
'app/core/services/search_srv'
;
import
{
SearchSrv
}
from
'app/core/services/search_srv'
;
import
appEvents
from
'app/core/app_events'
;
export
class
SearchCtrl
{
export
class
SearchCtrl
{
isOpen
:
boolean
;
isOpen
:
boolean
;
...
@@ -16,9 +17,9 @@ export class SearchCtrl {
...
@@ -16,9 +17,9 @@ export class SearchCtrl {
initialFolderFilterTitle
:
string
;
initialFolderFilterTitle
:
string
;
/** @ngInject */
/** @ngInject */
constructor
(
$scope
,
private
$location
,
private
$timeout
,
private
searchSrv
:
SearchSrv
,
$rootScope
)
{
constructor
(
$scope
,
private
$location
,
private
$timeout
,
private
searchSrv
:
SearchSrv
)
{
$rootScope
.
onAppEvent
(
'show-dash-search'
,
this
.
openSearch
.
bind
(
this
),
$scope
);
appEvents
.
on
(
'show-dash-search'
,
this
.
openSearch
.
bind
(
this
),
$scope
);
$rootScope
.
onAppEvent
(
'hide-dash-search'
,
this
.
closeSearch
.
bind
(
this
),
$scope
);
appEvents
.
on
(
'hide-dash-search'
,
this
.
closeSearch
.
bind
(
this
),
$scope
);
this
.
initialFolderFilterTitle
=
"All"
;
this
.
initialFolderFilterTitle
=
"All"
;
}
}
...
@@ -74,6 +75,7 @@ export class SearchCtrl {
...
@@ -74,6 +75,7 @@ export class SearchCtrl {
if
(
selectedDash
)
{
if
(
selectedDash
)
{
this
.
$location
.
search
({});
this
.
$location
.
search
({});
this
.
$location
.
path
(
selectedDash
.
url
);
this
.
$location
.
path
(
selectedDash
.
url
);
this
.
closeSearch
();
}
}
}
else
{
}
else
{
const
selectedFolder
=
this
.
results
[
currentItem
.
folderIndex
];
const
selectedFolder
=
this
.
results
[
currentItem
.
folderIndex
];
...
...
public/app/core/components/search/search_results.html
View file @
6ad06364
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
<span
class=
"search-item__icon"
>
<span
class=
"search-item__icon"
>
<i
class=
"gicon mini gicon-dashboard-list"
></i>
<i
class=
"gicon mini gicon-dashboard-list"
></i>
</span>
</span>
<span
class=
"search-item__body"
>
<span
class=
"search-item__body"
ng-click=
"ctrl.onItemClick(item)"
>
<div
class=
"search-item__body-title"
>
{{::item.title}}
</div>
<div
class=
"search-item__body-title"
>
{{::item.title}}
</div>
</span>
</span>
<span
class=
"search-item__tags"
>
<span
class=
"search-item__tags"
>
...
...
public/app/core/components/search/search_results.ts
View file @
6ad06364
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
coreModule
from
'../../core_module'
;
import
coreModule
from
'../../core_module'
;
import
appEvents
from
'app/core/app_events'
;
export
class
SearchResultsCtrl
{
export
class
SearchResultsCtrl
{
results
:
any
;
results
:
any
;
...
@@ -61,6 +62,12 @@ export class SearchResultsCtrl {
...
@@ -61,6 +62,12 @@ export class SearchResultsCtrl {
}
}
}
}
onItemClick
(
item
)
{
if
(
this
.
$location
.
path
().
indexOf
(
item
.
url
)
>
-
1
)
{
appEvents
.
emit
(
'hide-dash-search'
);
}
}
selectTag
(
tag
,
evt
)
{
selectTag
(
tag
,
evt
)
{
if
(
this
.
onTagSelected
)
{
if
(
this
.
onTagSelected
)
{
this
.
onTagSelected
({
$tag
:
tag
});
this
.
onTagSelected
({
$tag
:
tag
});
...
...
public/app/core/services/keybindingSrv.ts
View file @
6ad06364
...
@@ -36,15 +36,15 @@ export class KeybindingSrv {
...
@@ -36,15 +36,15 @@ export class KeybindingSrv {
}
}
openSearchStarred
()
{
openSearchStarred
()
{
this
.
$rootScope
.
appEven
t
(
'show-dash-search'
,
{
starred
:
true
});
appEvents
.
emi
t
(
'show-dash-search'
,
{
starred
:
true
});
}
}
openSearchTags
()
{
openSearchTags
()
{
this
.
$rootScope
.
appEven
t
(
'show-dash-search'
,
{
tagsMode
:
true
});
appEvents
.
emi
t
(
'show-dash-search'
,
{
tagsMode
:
true
});
}
}
openSearch
()
{
openSearch
()
{
this
.
$rootScope
.
appEven
t
(
'show-dash-search'
);
appEvents
.
emi
t
(
'show-dash-search'
);
}
}
openAlerting
()
{
openAlerting
()
{
...
...
public/app/core/specs/search.jest.ts
View file @
6ad06364
...
@@ -6,7 +6,7 @@ describe('SearchCtrl', () => {
...
@@ -6,7 +6,7 @@ describe('SearchCtrl', () => {
search
:
(
options
:
any
)
=>
{},
search
:
(
options
:
any
)
=>
{},
getDashboardTags
:
()
=>
{}
getDashboardTags
:
()
=>
{}
};
};
let
ctrl
=
new
SearchCtrl
({
},
{},
{},
<
SearchSrv
>
searchSrvStub
,
{
onAppEvent
:
()
=>
{
}
}
);
let
ctrl
=
new
SearchCtrl
({
$on
:
()
=>
{}},
{},
{},
<
SearchSrv
>
searchSrvStub
);
describe
(
'Given an empty result'
,
()
=>
{
describe
(
'Given an empty result'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
...
public/app/core/specs/search_results.jest.ts
View file @
6ad06364
import
{
SearchResultsCtrl
}
from
'../components/search/search_results'
;
import
{
SearchResultsCtrl
}
from
'../components/search/search_results'
;
import
{
beforeEach
,
afterEach
}
from
'test/lib/common'
;
import
appEvents
from
'app/core/app_events'
;
jest
.
mock
(
'app/core/app_events'
,
()
=>
{
return
{
emit
:
jest
.
fn
<
any
>
()
};
});
describe
(
'SearchResultsCtrl'
,
()
=>
{
describe
(
'SearchResultsCtrl'
,
()
=>
{
let
ctrl
;
let
ctrl
;
...
@@ -94,4 +102,39 @@ describe('SearchResultsCtrl', () => {
...
@@ -94,4 +102,39 @@ describe('SearchResultsCtrl', () => {
expect
(
folderExpanded
).
toBeFalsy
();
expect
(
folderExpanded
).
toBeFalsy
();
});
});
});
});
describe
(
'when clicking on a link in search result'
,
()
=>
{
const
dashPath
=
'dashboard/path'
;
const
$location
=
{
path
:
()
=>
dashPath
};
const
appEventsMock
=
appEvents
as
any
;
describe
(
'with the same url as current path'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
=
new
SearchResultsCtrl
(
$location
);
const
item
=
{
url
:
dashPath
};
ctrl
.
onItemClick
(
item
);
});
it
(
'should close the search'
,
()
=>
{
expect
(
appEventsMock
.
emit
.
mock
.
calls
.
length
).
toBe
(
1
);
expect
(
appEventsMock
.
emit
.
mock
.
calls
[
0
][
0
]).
toBe
(
'hide-dash-search'
);
});
});
describe
(
'with a different url than current path'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
=
new
SearchResultsCtrl
(
$location
);
const
item
=
{
url
:
'another/path'
};
ctrl
.
onItemClick
(
item
);
});
it
(
'should do nothing'
,
()
=>
{
expect
(
appEventsMock
.
emit
.
mock
.
calls
.
length
).
toBe
(
0
);
});
});
afterEach
(()
=>
{
appEventsMock
.
emit
.
mockClear
();
});
});
});
});
public/app/features/dashboard/dashnav/dashnav.ts
View file @
6ad06364
...
@@ -11,7 +11,6 @@ export class DashNavCtrl {
...
@@ -11,7 +11,6 @@ export class DashNavCtrl {
/** @ngInject */
/** @ngInject */
constructor
(
constructor
(
private
$scope
,
private
$scope
,
private
$rootScope
,
private
dashboardSrv
,
private
dashboardSrv
,
private
$location
,
private
$location
,
public
playlistSrv
)
{
public
playlistSrv
)
{
...
@@ -75,7 +74,7 @@ export class DashNavCtrl {
...
@@ -75,7 +74,7 @@ export class DashNavCtrl {
}
}
showSearch
()
{
showSearch
()
{
this
.
$rootScope
.
appEven
t
(
'show-dash-search'
);
appEvents
.
emi
t
(
'show-dash-search'
);
}
}
addPanel
()
{
addPanel
()
{
...
...
public/app/features/org/teams_ctrl.ts
View file @
6ad06364
///<reference path="../../headers/common.d.ts" />
///<reference path="../../headers/common.d.ts" />
import
coreModule
from
"app/core/core_module"
;
import
coreModule
from
'app/core/core_module'
;
import
{
appEvents
}
from
"app/core/core"
;
import
appEvents
from
'app/core/app_events'
;
export
class
TeamsCtrl
{
export
class
TeamsCtrl
{
teams
:
any
;
teams
:
any
;
...
...
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