update admin torrents manager function delete/setSaleType

This commit is contained in:
OldHawk
2017-05-07 23:17:35 +08:00
parent dde3a6d6bc
commit 431ebc8a9f
8 changed files with 120 additions and 27 deletions

View File

@@ -78,6 +78,7 @@
SIZE: 'Size',
SEEDS_LEECHERS_FINISHED: 'S/L/F',
PUBLISHER: 'Publisher',
ADMIN_TOOLS: 'Admin Tools',
LIFETIME: 'Life',
VOTES: 'Votes',
@@ -175,6 +176,7 @@
ADMIN_BASIC_COMMAND: 'Basic Command',
ADMIN_BASIC_DELETE: 'Delete torrent',
ADMIN_BASIC_TYPE_SET: 'Sale Type',
ADMIN_SALE_TYPE_SET: 'Sale Type Set',
TORRENT_DELETE_CONFIRM_OK: 'Delete',

View File

@@ -78,6 +78,7 @@
SIZE: '大小',
SEEDS_LEECHERS_FINISHED: '上/下/完',
PUBLISHER: '发布者',
ADMIN_TOOLS: '管理工具',
LIFETIME: '存活时间',
VOTES: '评分',
@@ -175,6 +176,7 @@
ADMIN_BASIC_COMMAND: '操作命令',
ADMIN_BASIC_DELETE: '删除种子',
ADMIN_BASIC_TYPE_SET: '设置促销',
ADMIN_SALE_TYPE_SET: '种子促销类型',
TORRENT_DELETE_CONFIRM_OK: '删除',

View File

@@ -561,3 +561,6 @@
.button-variant(@btn-mt-color; @btn-mt-bg; @btn-mt-border);
}
.admin-tools-btn-list {
width: 100%;
}

View File

@@ -6,10 +6,10 @@
.controller('TorrentsAdminController', TorrentsAdminController);
TorrentsAdminController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'Notification', 'TorrentsService',
'MeanTorrentConfig', 'DownloadService', '$window'];
'MeanTorrentConfig', 'DownloadService', '$window', 'ModalConfirmService'];
function TorrentsAdminController($scope, $state, $translate, $timeout, Authentication, Notification, TorrentsService, MeanTorrentConfig,
DownloadService, $window) {
DownloadService, $window, ModalConfirmService) {
var vm = this;
vm.user = Authentication.user;
vm.announce = MeanTorrentConfig.meanTorrentConfig.announce;
@@ -275,5 +275,64 @@
var url = $state.href('torrents.view', {torrentId: id});
$window.open(url, '_blank');
};
/**
* deleteTorrent
*/
vm.deleteTorrent = function (item) {
var modalOptions = {
closeButtonText: $translate.instant('TORRENT_DELETE_CONFIRM_CANCEL'),
actionButtonText: $translate.instant('TORRENT_DELETE_CONFIRM_OK'),
headerText: $translate.instant('TORRENT_DELETE_CONFIRM_HEADER_TEXT'),
bodyText: $translate.instant('TORRENT_DELETE_CONFIRM_BODY_TEXT'),
bodyParams: item.torrent_filename
};
ModalConfirmService.showModal({}, modalOptions)
.then(function (result) {
item.$remove(function (response) {
successCallback(response);
}, function (errorResponse) {
errorCallback(errorResponse);
});
function successCallback(res) {
vm.torrentPagedItems.splice(vm.torrentPagedItems.indexOf(item), 1);
Notification.success({
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TORRENT_DELETE_SUCCESSFULLY')
});
}
function errorCallback(res) {
vm.error_msg = res.data.message;
Notification.error({
message: res.data.message,
title: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TORRENT_DELETE_ERROR')
});
}
});
};
/**
* setSaleType
*/
vm.setSaleType = function (item, st) {
TorrentsService.setSaleType({
_torrentId: item._id,
_saleType: st.name
}, function (res) {
Notification.success({
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TORRENT_SETSALETYPE_SUCCESSFULLY')
});
vm.torrentPagedItems[vm.torrentPagedItems.indexOf(item)] = res;
}, function (res) {
Notification.error({
message: res.data.message,
title: '<i class="glyphicon glyphicon-remove"></i> ' + $translate.instant('TORRENT_SETSALETYPE_ERROR')
});
});
};
}
}());

View File

@@ -20,7 +20,8 @@
closeButtonText: 'Close',
actionButtonText: 'Yes',
headerText: 'Confirm?',
bodyText: 'Confirm this action?'
bodyText: 'Confirm this action?',
bodyParams: undefined
};
var showModal = function (customModalDefaults, customModalOptions) {

View File

@@ -3,6 +3,7 @@
</div>
<div class="modal-body">
<p>{{modalOptions.bodyText}}</p>
<p ng-show="modalOptions.bodyParams">{{modalOptions.bodyParams}}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"

View File

@@ -77,11 +77,11 @@
<thead>
<tr>
<th>{{ 'TABLE_FIELDS.INFO' | translate}}</th>
<th>{{ 'TABLE_FIELDS.VOTES' | translate}}</th>
<th>{{ 'TABLE_FIELDS.LIFETIME' | translate}}</th>
<th>{{ 'TABLE_FIELDS.SIZE' | translate}}</th>
<th>{{ 'TABLE_FIELDS.SEEDS_LEECHERS_FINISHED' | translate}}</th>
<th>{{ 'TABLE_FIELDS.PUBLISHER' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.VOTES' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.LIFETIME' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.SIZE' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.SEEDS_LEECHERS_FINISHED' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.ADMIN_TOOLS' | translate}}</th>
</tr>
</thead>
<tbody>
@@ -109,7 +109,8 @@
<div class="list-all-tags">
<!--<span class="label label-success text-uppercase">{{ item.torrent_type}}</span>-->
<span class="label label-release label-warning" ng-click="vm.onReleaseClicked(item.torrent_release); $event.stopPropagation();">
<span class="label label-release label-warning"
ng-click="vm.onReleaseClicked(item.torrent_release); $event.stopPropagation();">
{{ item.torrent_release}}
</span>
<span class="label label-sale" ng-if="item.isSaling"
@@ -128,12 +129,12 @@
</div>
</td>
<td class="col-md-1 td-v-middle text-center">
<span title="{{ 'TITLE_ALT.IMDB_VOTES' | translate}}"
class="pull-right torrent-votes"><kbd>IMDB</kbd> {{item.torrent_imdb_votes | number : 1}}</span>
<span title="{{ 'TITLE_ALT.IMDB_VOTES' | translate}}"
class="pull-right torrent-votes"><kbd>IMDB</kbd> {{item.torrent_imdb_votes | number : 1}}</span>
</td>
<td class="col-md-1 td-v-middle">{{item.createdat | life}}</td>
<td class="col-md-1 td-v-middle">{{item.torrent_size | bytes:2}}</td>
<td class="col-md-1 td-v-middle list-user-info">
<td class="col-md-1 td-v-middle text-center">{{item.createdat | life}}</td>
<td class="col-md-1 td-v-middle text-center">{{item.torrent_size | bytes:2}}</td>
<td class="col-md-1 td-v-middle text-center list-user-info">
<p class="no-margin-p" title="{{ 'TITLE_ALT.SEEDS' | translate}}">
<span class="glyphicon glyphicon-arrow-up torrent-up"></span>
{{item.torrent_seeds}}
@@ -149,7 +150,30 @@
{{item.torrent_finished}}
</p>
</td>
<td class="col-md-1 td-v-middle">{{item.user.displayName}}</td>
<td class="col-md-1 td-v-middle text-center">
<div>
<button class="btn btn-md btn-default btn-block" ng-click="vm.deleteTorrent(item); $event.stopPropagation();">
{{ 'ADMIN_BASIC_DELETE' | translate}}
</button>
</div>
<div class="margin-top-10">
<div class="admin-tools-btn-list btn-group" uib-dropdown dropdown-append-to-body>
<button id="btn-append-to-body" type="button"
class="btn btn-md btn-default btn-block"
ng-click="$event.stopPropagation();"
uib-dropdown-toggle>
{{'ADMIN_BASIC_TYPE_SET' | translate }} <span class="caret"></span>
</button>
<ul class="dropdown-menu-right" uib-dropdown-menu role="menu"
aria-labelledby="btn-append-to-body">
<li role="menuitem" ng-repeat="st in vm.torrentSalesType.value"
ng-class="{'active': item.torrent_sale_status == st.name}">
<a href="#" ng-click="vm.setSaleType(item, st);">{{st.name}}</a>
</li>
</ul>
</div>
</div>
</td>
</tr>
</tbody>
</table>

View File

@@ -112,11 +112,11 @@
<thead>
<tr>
<th>{{ 'TABLE_FIELDS.INFO' | translate}}</th>
<th>{{ 'TABLE_FIELDS.VOTES' | translate}}</th>
<th>{{ 'TABLE_FIELDS.LIFETIME' | translate}}</th>
<th>{{ 'TABLE_FIELDS.SIZE' | translate}}</th>
<th>{{ 'TABLE_FIELDS.SEEDS_LEECHERS_FINISHED' | translate}}</th>
<th>{{ 'TABLE_FIELDS.PUBLISHER' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.VOTES' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.LIFETIME' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.SIZE' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.SEEDS_LEECHERS_FINISHED' | translate}}</th>
<th class="text-center">{{ 'TABLE_FIELDS.PUBLISHER' | translate}}</th>
</tr>
</thead>
<tbody>
@@ -144,7 +144,8 @@
<div class="list-all-tags">
<!--<span class="label label-success text-uppercase">{{ item.torrent_type}}</span>-->
<span class="label label-release label-warning" ng-click="vm.onReleaseClicked(item.torrent_release); $event.stopPropagation();">
<span class="label label-release label-warning"
ng-click="vm.onReleaseClicked(item.torrent_release); $event.stopPropagation();">
{{ item.torrent_release}}
</span>
<span class="label label-sale" ng-if="item.isSaling"
@@ -163,12 +164,12 @@
</div>
</td>
<td class="col-md-1 td-v-middle text-center">
<span title="{{ 'TITLE_ALT.IMDB_VOTES' | translate}}"
class="pull-right torrent-votes"><kbd>IMDB</kbd> {{item.torrent_imdb_votes | number : 1}}</span>
<span title="{{ 'TITLE_ALT.IMDB_VOTES' | translate}}"
class="pull-right torrent-votes"><kbd>IMDB</kbd> {{item.torrent_imdb_votes | number : 1}}</span>
</td>
<td class="col-md-1 td-v-middle">{{item.createdat | life}}</td>
<td class="col-md-1 td-v-middle">{{item.torrent_size | bytes:2}}</td>
<td class="col-md-1 td-v-middle list-user-info">
<td class="col-md-1 td-v-middle text-center">{{item.createdat | life}}</td>
<td class="col-md-1 td-v-middle text-center">{{item.torrent_size | bytes:2}}</td>
<td class="col-md-1 td-v-middle text-center list-user-info">
<p class="no-margin-p" title="{{ 'TITLE_ALT.SEEDS' | translate}}">
<span class="glyphicon glyphicon-arrow-up torrent-up"></span>
{{item.torrent_seeds}}
@@ -184,7 +185,7 @@
{{item.torrent_finished}}
</p>
</td>
<td class="col-md-1 td-v-middle">{{item.user.displayName}}</td>
<td class="col-md-1 td-v-middle text-center">{{item.user.displayName}}</td>
</tr>
</tbody>
</table>