Sfoglia il codice sorgente

Fixes #13: Fix search filter in Sentinel Dashboard sidebar

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 6 anni fa
parent
commit
f1b52a66b2
2 ha cambiato i file con 17 aggiunte e 23 eliminazioni
  1. +2
    -11
      sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html
  2. +15
    -12
      sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js

+ 2
- 11
sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html Vedi File

@@ -2,19 +2,10 @@
<div class="sidebar-nav navbar-collapse">
<ul class="nav in" id="side-menu">
<li class="sidebar-search">
<!-- <div class="input-group custom-search-form">
<input type="text" class="form-control" ng-model="searchApp"
placeholder="搜索应用"> <span class="input-group-btn">
<button class="btn btn-default" type="button"
>
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div> -->
<div class="input-group" style="">
<input type="text" class="form-control highlight-border" placeholder="应用名" ng-model="searchApp">
<span class="input-group-btn">
<button class="btn btn-secondary btn-default-inverse" type="button" ng-click="addSearchApp()">搜索</button>
<button class="btn btn-secondary btn-default-inverse" type="button">搜索</button>
</span>
</div>
</li>
@@ -28,7 +19,7 @@
&nbsp;&nbsp;首页</a>
</li>

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


+ 15
- 12
sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js Vedi File

@@ -19,11 +19,11 @@ angular.module('sentinelDashboardApp')
// app
AppService.getApps().success(
function (data) {
if (data.code == 0) {
var initHashApp = $location.path().split('/')[3];
if (data.code === 0) {
let initHashApp = $location.path().split('/')[3];
$scope.apps = data.data;
$scope.apps.forEach(function (item) {
if (item.app == initHashApp) {
if (item.app === initHashApp) {
item.active = true;
}
});
@@ -33,22 +33,25 @@ angular.module('sentinelDashboardApp')

// toggle side bar
$scope.click = function ($event) {
var element = angular.element($event.target);
var entry = angular.element($event.target).scope().entry;
let element = angular.element($event.target);
let entry = angular.element($event.target).scope().entry;
entry.active = !entry.active;

if (entry.active == false) {
if (entry.active === false) {
element.parent().children('ul').hide();
} else {
element.parent().parent().children('li').children('ul').hide();
element.parent().children('ul').show();
}
}
};

/**
* @deprecated
*/
$scope.addSearchApp = function () {
var findApp = false;
for (var i = 0; i < $scope.apps.length; i++) {
if ($scope.apps[i].app == $scope.searchApp) {
let findApp = false;
for (let i = 0; i < $scope.apps.length; i++) {
if ($scope.apps[i].app === $scope.searchApp) {
findApp = true;
break;
}
@@ -56,7 +59,7 @@ angular.module('sentinelDashboardApp')
if (!findApp) {
$scope.apps.push({ app: $scope.searchApp });
}
}
};
}
}
};
}]);

Loading…
Annulla
Salva