Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add:黑名单的删除实现 #22

Merged
merged 1 commit into from
Aug 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ table a{color: #30bfa1;}
.xg{float: right; margin-top: 10px;font-size: 16px;color: #30bfa1;}
.xg span{cursor: pointer;}
.nb-more{display: none;}
.del-popWrap{width: 100%; height: 100%; background: rgba(0,0,0,0.5); position: fixed; left: 0; top: 0; display: none; z-index: 999;}
.del-popWrap{width: 100%; height: 100%; background: rgba(0,0,0,0.5); position: fixed; left: 0; top: 0; z-index: 999;}
.del-pop{width: 550px; height: 220px; background: #fff; border-radius: 5px; border: 1px solid #ddd; position: absolute; left: 50%; top: 25%; margin-left: -275px;}
.deltit{width: 100%; height:40px;text-align: center;line-height: 40px; border-bottom: 1px solid #ddd;}
.del-pop h5{font-size: 16px; text-align: center;margin: 20px 0; font-weight: normal;}
Expand Down
53 changes: 39 additions & 14 deletions public/src/js/controllers/blacklists.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ angular.module('insight.blacklists').controller('BlacklistsController',
// click dialog's add btn
$scope.doAdd = function () {
if (!$scope.newblacklist || !$scope.newblacklist.addr) {
// TODO 还需要验证地址的有效性
$scope.newblacklist = {addr:'please input address'}
} else if ($scope.newblacklist.addr.length !== 34) {
// TODO 还需要验证地址的有效性
Expand Down Expand Up @@ -82,7 +81,7 @@ angular.module('insight.blacklists').controller('BlacklistsController',

$scope.checked = [];
$scope.selectAll = function () {
if ($scope.select_all) {
if (!$scope.select_all) {
$scope.checked = [];
angular.forEach($scope.blacklists, function (i) {
i.checked = true;
Expand All @@ -94,25 +93,50 @@ angular.module('insight.blacklists').controller('BlacklistsController',
$scope.checked = [];
})
}
console.log($scope.checked);
// console.log('Achecked:',$scope.checked);
};
$scope.selectOne = function () {
angular.forEach($scope.blacklists, function (i) {
var index = $scope.checked.indexOf(i.addr);
if (i.checked && index === -1) {
$scope.checked.push(i.addr);
} else if (!i.checked && index !== -1) {
$scope.checked.splice(index, 1);
}
;
})
$scope.selectOne = function (addr) {
var index = $scope.checked.indexOf(addr);
if (index === -1) {
$scope.checked.push(addr);
} else if (index !== -1) {
$scope.checked.splice(index, 1);
}

if ($scope.blacklists.length === $scope.checked.length) {
$scope.select_all = true;
} else {
$scope.select_all = false;
}
console.log($scope.checked);
// console.log('1checked:',$scope.checked);
}

// click delete btn
$scope.delMode = function () {
// console.log('$scope.checked=',$scope.checked)
if (!$scope.checked || $scope.checked.length === 0) {
return;
}
$scope.isDel = true
}
// click dialog delete btn
$scope.doDel = function (ok) {

if (!ok) {
$scope.isDel = false
return;
}

$http.delete(Service.apiPrefix + '/blacklist/list/' + JSON.stringify($scope.checked))
.success(function(data, status, headers, config) {
if (data.code === 0) {
$scope.list();
}
})
.error(function(data, status, headers, config) {
});

$scope.isDel = false
}

$scope.saveBlacklist = function (blacklist) {
Expand Down Expand Up @@ -153,6 +177,7 @@ angular.module('insight.blacklists').controller('BlacklistsController',
$scope.bedit = true;
};

// form delete.(old)
$scope.delete = function (hash) {
// console.log('controller,delete hash=', hash)

Expand Down
3 changes: 2 additions & 1 deletion public/views/blacklists.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<button ng-click="doEdit()">更新</button>
</div>
</div>

<div class="del-popWrap" ng-show="isDel">
<div class="del-pop">
<div class="deltit">系统提示</div>
Expand Down Expand Up @@ -68,7 +69,7 @@ <h5>确定要将选中的地址从黑名单中移除吗?</h5>
</tr>
<tr class="fader" data-ng-repeat='b in blacklists | filter:name_filter'>
<td class="td1">
<input type="checkbox" ng-hide="bedit" ng-model="b.checked" ng-click="selectOne()">
<input type="checkbox" ng-hide="bedit" ng-model="b.checked" ng-click="selectOne(b.addr)">
</td>
<td class="td1" ng-click="openEdit(b.addr, b.comment)">{{b.no}}</td>
<td><a href="address/{{b.addr}}">{{b.addr}}</a></td>
Expand Down