Skip to content

Commit 7f075f7

Browse files
committed
Fixes alibaba#13: Fix search filter in Sentinel Dashboard sidebar
Signed-off-by: Eric Zhao <[email protected]>
1 parent 19fdd45 commit 7f075f7

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html

+2-11
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@
22
<div class="sidebar-nav navbar-collapse">
33
<ul class="nav in" id="side-menu">
44
<li class="sidebar-search">
5-
<!-- <div class="input-group custom-search-form">
6-
<input type="text" class="form-control" ng-model="searchApp"
7-
placeholder="搜索应用"> <span class="input-group-btn">
8-
<button class="btn btn-default" type="button"
9-
>
10-
<i class="glyphicon glyphicon-search"></i>
11-
</button>
12-
</span>
13-
</div> -->
145
<div class="input-group" style="">
156
<input type="text" class="form-control highlight-border" placeholder="应用名" ng-model="searchApp">
167
<span class="input-group-btn">
17-
<button class="btn btn-secondary btn-default-inverse" type="button" ng-click="addSearchApp()">搜索</button>
8+
<button class="btn btn-secondary btn-default-inverse" type="button">搜索</button>
189
</span>
1910
</div>
2011
</li>
@@ -28,7 +19,7 @@
2819
&nbsp;&nbsp;首页</a>
2920
</li>
3021

31-
<li ng-class="{active: true}" ng-repeat="entry in apps | filter:searchApp">{{dropDown}}
22+
<li ng-class="{active: true}" ng-repeat="entry in apps | filter: { app: searchApp}">{{dropDown}}
3223
<a href="" ng-click="click($event)" collapse="{{collpaseall == 1}}" style="font-size: 16px;">
3324
<!--<i class="glyphicon glyphicon-chevron-right"></i>-->
3425
<!--<span class="fa arrow"></span>-->

sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ angular.module('sentinelDashboardApp')
1919
// app
2020
AppService.getApps().success(
2121
function (data) {
22-
if (data.code == 0) {
23-
var initHashApp = $location.path().split('/')[3];
22+
if (data.code === 0) {
23+
let initHashApp = $location.path().split('/')[3];
2424
$scope.apps = data.data;
2525
$scope.apps.forEach(function (item) {
26-
if (item.app == initHashApp) {
26+
if (item.app === initHashApp) {
2727
item.active = true;
2828
}
2929
});
@@ -33,30 +33,33 @@ angular.module('sentinelDashboardApp')
3333

3434
// toggle side bar
3535
$scope.click = function ($event) {
36-
var element = angular.element($event.target);
37-
var entry = angular.element($event.target).scope().entry;
36+
let element = angular.element($event.target);
37+
let entry = angular.element($event.target).scope().entry;
3838
entry.active = !entry.active;
3939

40-
if (entry.active == false) {
40+
if (entry.active === false) {
4141
element.parent().children('ul').hide();
4242
} else {
4343
element.parent().parent().children('li').children('ul').hide();
4444
element.parent().children('ul').show();
4545
}
46-
}
46+
};
4747

48+
/**
49+
* @deprecated
50+
*/
4851
$scope.addSearchApp = function () {
49-
var findApp = false;
50-
for (var i = 0; i < $scope.apps.length; i++) {
51-
if ($scope.apps[i].app == $scope.searchApp) {
52+
let findApp = false;
53+
for (let i = 0; i < $scope.apps.length; i++) {
54+
if ($scope.apps[i].app === $scope.searchApp) {
5255
findApp = true;
5356
break;
5457
}
5558
}
5659
if (!findApp) {
5760
$scope.apps.push({ app: $scope.searchApp });
5861
}
59-
}
62+
};
6063
}
61-
}
64+
};
6265
}]);

0 commit comments

Comments
 (0)