feat(request): list all requests

This commit is contained in:
OldHawk
2018-01-10 18:15:11 +08:00
parent 9a3d096bb1
commit b6bbd91dfb
5 changed files with 51 additions and 26 deletions

View File

@@ -714,8 +714,8 @@
FORM_REWARDS_MAX_MIN: 'Rewards score numbers must more than {{min}} and less than {{max}}',
BTN_SUBMIT_REQUEST: 'Submit Request',
NO_MY_REQUESTS: 'You arent post any request.',
STATUS_GETTING: 'Getting your requests, please waiting ...',
STATUS_GETTING_ERROR: 'Getting your requests ERROR!',
STATUS_GETTING: 'Getting requests, please waiting ...',
STATUS_GETTING_ERROR: 'Getting requests ERROR!',
POST_REQUEST_SUCCESSFULLY: 'Create request successfully',
POST_REQUEST_FAILED: 'Create request failed',
FIELD_TITLE: 'Title',

View File

@@ -714,8 +714,8 @@
FORM_REWARDS_MAX_MIN: '悬赏积分必须大于 {{min}} 且小于 {{max}}',
BTN_SUBMIT_REQUEST: '提交请求',
NO_MY_REQUESTS: '您没有提交过任何求种请求.',
STATUS_GETTING: '正在获取您的求种请求, 请稍候 ...',
STATUS_GETTING_ERROR: '获取您的求种请求失败!',
STATUS_GETTING: '正在获取求种请求, 请稍候 ...',
STATUS_GETTING_ERROR: '获取求种请求失败!',
POST_REQUEST_SUCCESSFULLY: '创建求种请求成功!',
POST_REQUEST_FAILED: '创建求种请求失败!',
FIELD_TITLE: '求种标题',

View File

@@ -5,10 +5,10 @@
.module('requests')
.controller('RequestsListController', RequestsListController);
RequestsListController.$inject = ['$scope', '$rootScope', '$state', '$timeout', '$translate', 'Authentication', 'UsersService', 'ScoreLevelService', 'MeanTorrentConfig', 'DebugConsoleService',
RequestsListController.$inject = ['$scope', '$rootScope', '$state', '$timeout', '$translate', 'Authentication', 'RequestsService', 'ScoreLevelService', 'MeanTorrentConfig', 'DebugConsoleService',
'NotifycationService', 'uibButtonConfig', 'marked'];
function RequestsListController($scope, $rootScope, $state, $timeout, $translate, Authentication, UsersService, ScoreLevelService, MeanTorrentConfig, mtDebug,
function RequestsListController($scope, $rootScope, $state, $timeout, $translate, Authentication, RequestsService, ScoreLevelService, MeanTorrentConfig, mtDebug,
NotifycationService, uibButtonConfig, marked) {
var vm = this;
vm.user = Authentication.user;
@@ -44,7 +44,7 @@
vm.figureOutItemsToDisplay = function (callback) {
vm.getRequests(vm.currentPage, function (items) {
vm.filterLength = items.total;
vm.pagedItems = items;
vm.pagedItems = items.rows;
if (callback) callback();
});
@@ -54,24 +54,18 @@
* getRequests
*/
vm.getRequests = function (p, callback) {
vm.statusMsg = 'FOLLOW.STATUS_GETTING';
vm.statusMsg = 'REQUESTS.STATUS_GETTING';
UsersService.getMyFollowers({
RequestsService.get({
skip: (p - 1) * vm.itemsPerPage,
limit: vm.itemsPerPage
})
.then(onSuccess)
.catch(onError);
function onSuccess(data) {
}, function (data) {
vm.statusMsg = undefined;
mtDebug.info(data);
callback(data);
}
function onError(data) {
vm.statusMsg = 'FOLLOW.STATUS_GETTING_ERROR';
}
}, function (res) {
vm.statusMsg = 'REQUESTS.STATUS_GETTING_ERROR';
});
};
/**

View File

@@ -1,4 +1,4 @@
<div ng-controller="RequestsListController as vm">
<div ng-controller="RequestsListController as vm" ng-init="vm.buildPager();">
<div class="pagetop">
<div class="container">
<div class="padding-top-30 padding-bottom-30 text-center">
@@ -27,8 +27,7 @@
</div>
<div class="container">
<h3>LIST</h3>
<div class="margin-bottom-30 margin-top-30">
<div class="margin-bottom-10 margin-top-10">
<div class="jumbotron text-center" ng-if="vm.statusMsg || vm.pagedItems.length<=0">
<div ng-if="vm.statusMsg">
<h3 class="text-muted">{{vm.statusMsg | translate}}</h3>
@@ -49,6 +48,38 @@
</ul>
</div>
<div class="request-list">
<div class="table-responsive">
<table class="table table-hover tb-v-middle">
<thead>
<tr>
<th>{{ 'REQUESTS.FIELD_TITLE' | translate}}</th>
<th class="text-center">{{ 'REQUESTS.FIELD_TYPE' | translate}}</th>
<th class="text-center">{{ 'REQUESTS.FIELD_CREATEDAT' | translate}}</th>
<th class="text-center">{{ 'REQUESTS.FIELD_REWARDS' | translate}}</th>
<th class="text-center">{{ 'REQUESTS.FIELD_USER' | translate}}</th>
</tr>
</thead>
<tbody>
<tr class="request-item" ng-repeat="item in vm.pagedItems">
<td class="col-md-7 td-text-overflow">
<h4>
<a ui-sref="requests.view({requestId: item._id})">{{item.title}}</a>
</h4>
<div class="item-desc text-long">{{item.desc}}</div>
</td>
<td class="col-md-1 td-v-middle text-center width-80">{{'MENU_TORRENTS_SUB.'+item.type.toUpperCase() | translate}}</td>
<td class="col-md-2 td-v-middle text-center width-160">{{item.createdAt | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
<td class="col-md-1 td-v-middle text-center width-80">{{item.rewards}}</td>
<td class="col-md-1 td-v-middle text-center width-80">
<span user-info="item.user" info-name></span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="pagination-border-top">
<ul uib-pagination boundary-links="true" max-size="8" items-per-page="vm.itemsPerPage" total-items="vm.filterLength"
ng-model="vm.currentPage"

View File

@@ -27,7 +27,7 @@
</div>
<div class="container">
<div class="margin-bottom-30 margin-top-30">
<div class="margin-bottom-10 margin-top-10">
<div class="jumbotron text-center" ng-if="vm.statusMsg || vm.pagedItems.length<=0">
<div ng-if="vm.statusMsg">
<h3 class="text-muted">{{vm.statusMsg | translate}}</h3>
@@ -68,10 +68,10 @@
</h4>
<div class="item-desc text-long">{{item.desc}}</div>
</td>
<td class="col-md-1 td-v-middle text-center">{{'MENU_TORRENTS_SUB.'+item.type.toUpperCase() | translate}}</td>
<td class="col-md-1 td-v-middle text-center width-80">{{'MENU_TORRENTS_SUB.'+item.type.toUpperCase() | translate}}</td>
<td class="col-md-2 td-v-middle text-center width-160">{{item.createdAt | date: 'yyyy-MM-dd HH:mm:ss'}}</td>
<td class="col-md-1 td-v-middle text-center width-140">{{item.rewards}}</td>
<td class="col-md-1 td-v-middle text-center">
<td class="col-md-1 td-v-middle text-center width-80">{{item.rewards}}</td>
<td class="col-md-1 td-v-middle text-center width-80">
<span user-info="item.user" info-name></span>
</td>
</tr>