mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-24 08:09:16 +01:00
feat(dataCenter): admin can view any users dataCenter
This commit is contained in:
@@ -984,6 +984,7 @@
|
||||
BTN_UNFOLLOW: 'Unfollow',
|
||||
BTN_MANAGE: 'Manage',
|
||||
BTN_SEND_MESSAGE: 'Send message',
|
||||
BTN_VIEW_USER_DATA_CENTER: 'Data Center',
|
||||
BTN_EDIT: 'Edit',
|
||||
BTN_REMOVE: 'Remove',
|
||||
PICTURE: 'Profile picture',
|
||||
|
||||
@@ -984,6 +984,7 @@
|
||||
BTN_UNFOLLOW: '取消關注',
|
||||
BTN_MANAGE: '管理',
|
||||
BTN_SEND_MESSAGE: '發消息',
|
||||
BTN_VIEW_USER_DATA_CENTER: '數據中心',
|
||||
BTN_EDIT: '編輯',
|
||||
BTN_REMOVE: '刪除',
|
||||
PICTURE: '頭像',
|
||||
|
||||
@@ -984,6 +984,7 @@
|
||||
BTN_UNFOLLOW: '取消关注',
|
||||
BTN_MANAGE: '管理',
|
||||
BTN_SEND_MESSAGE: '发消息',
|
||||
BTN_VIEW_USER_DATA_CENTER: '数据中心',
|
||||
BTN_EDIT: '编辑',
|
||||
BTN_REMOVE: '删除',
|
||||
PICTURE: '头像',
|
||||
|
||||
@@ -20,42 +20,42 @@
|
||||
}
|
||||
})
|
||||
.state('dataCenter.score', {
|
||||
url: '/score',
|
||||
url: '/score?:uid',
|
||||
templateUrl: '/modules/data-logs/client/views/data-score.client.view.html',
|
||||
data: {
|
||||
pageTitle: 'PAGETITLE.DATA_CENTER'
|
||||
}
|
||||
})
|
||||
.state('dataCenter.uploaded', {
|
||||
url: '/uploaded',
|
||||
url: '/uploaded?:uid',
|
||||
templateUrl: '/modules/data-logs/client/views/data-uploaded.client.view.html',
|
||||
data: {
|
||||
pageTitle: 'PAGETITLE.DATA_CENTER'
|
||||
}
|
||||
})
|
||||
.state('dataCenter.downloaded', {
|
||||
url: '/downloaded',
|
||||
url: '/downloaded?:uid',
|
||||
templateUrl: '/modules/data-logs/client/views/data-downloaded.client.view.html',
|
||||
data: {
|
||||
pageTitle: 'PAGETITLE.DATA_CENTER'
|
||||
}
|
||||
})
|
||||
.state('dataCenter.scoreHistory', {
|
||||
url: '/scoreHistory',
|
||||
url: '/scoreHistory?:uid',
|
||||
templateUrl: '/modules/data-logs/client/views/data-score-history.client.view.html',
|
||||
data: {
|
||||
pageTitle: 'PAGETITLE.DATA_CENTER'
|
||||
}
|
||||
})
|
||||
.state('dataCenter.uploadedHistory', {
|
||||
url: '/uploadedHistory',
|
||||
url: '/uploadedHistory?:uid',
|
||||
templateUrl: '/modules/data-logs/client/views/data-uploaded-history.client.view.html',
|
||||
data: {
|
||||
pageTitle: 'PAGETITLE.DATA_CENTER'
|
||||
}
|
||||
})
|
||||
.state('dataCenter.downloadedHistory', {
|
||||
url: '/downloadedHistory',
|
||||
url: '/downloadedHistory?:uid',
|
||||
templateUrl: '/modules/data-logs/client/views/data-downloaded-history.client.view.html',
|
||||
data: {
|
||||
pageTitle: 'PAGETITLE.DATA_CENTER'
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
function DataCenterController($scope, $state, $translate, $timeout, Authentication, $window, MeanTorrentConfig, NotifycationService,
|
||||
UserDaysLogsService, UserMonthsLogsService, $rootScope, moment, mtDebug, $filter, UserScoreLogsService, UserAnnounceLogsService) {
|
||||
$scope.$state = $state;
|
||||
|
||||
var vm = this;
|
||||
vm.user = Authentication.user;
|
||||
vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage;
|
||||
@@ -28,7 +30,7 @@
|
||||
*/
|
||||
vm.getUserDaysLogs = function () {
|
||||
UserDaysLogsService.query({
|
||||
userId: vm.user._id
|
||||
userId: $state.params.uid ? $state.params.uid : vm.user._id
|
||||
}, function (items) {
|
||||
vm.userDaysLogsData = getUserDaysLogsData(items);
|
||||
mtDebug.info(vm.userDaysLogsData);
|
||||
@@ -121,7 +123,7 @@
|
||||
*/
|
||||
vm.getUserMonthsLogs = function () {
|
||||
UserMonthsLogsService.query({
|
||||
userId: vm.user._id
|
||||
userId: $state.params.uid ? $state.params.uid : vm.user._id
|
||||
}, function (items) {
|
||||
vm.userMonthsLogsData = getUserMonthsLogsData(items);
|
||||
mtDebug.info(vm.userMonthsLogsData);
|
||||
@@ -214,7 +216,7 @@
|
||||
*/
|
||||
vm.getUserScoreHistory = function () {
|
||||
UserScoreLogsService.query({
|
||||
userId: vm.user._id
|
||||
userId: $state.params.uid ? $state.params.uid : vm.user._id
|
||||
}, function (items) {
|
||||
vm.userLogsData = items;
|
||||
vm.buildPager();
|
||||
@@ -228,7 +230,7 @@
|
||||
*/
|
||||
vm.getUserAnnounceHistory = function (status) {
|
||||
UserAnnounceLogsService.query({
|
||||
userId: vm.user._id
|
||||
userId: $state.params.uid ? $state.params.uid : vm.user._id
|
||||
}, function (items) {
|
||||
if (status === 'seeding') {
|
||||
vm.userLogsData = items.filter(function (it) {
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<section class="container padding-top-30">
|
||||
<section class="container padding-top-30" ng-controller="DataCenterController as vm">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="list-group panel-menu-list">
|
||||
<a ui-sref="dataCenter.score" class="list-group-item"
|
||||
<a ui-sref="dataCenter.score({uid: $state.params.uid})" class="list-group-item"
|
||||
ui-sref-active="active">{{'DATA_CENTER.ITEM_SCORE' | translate}}</a>
|
||||
<a ui-sref="dataCenter.uploaded" class="list-group-item"
|
||||
<a ui-sref="dataCenter.uploaded({uid: $state.params.uid})" class="list-group-item"
|
||||
ui-sref-active="active">{{'DATA_CENTER.ITEM_UPLOADED' | translate}}</a>
|
||||
<a ui-sref="dataCenter.downloaded" class="list-group-item"
|
||||
<a ui-sref="dataCenter.downloaded({uid: $state.params.uid})" class="list-group-item"
|
||||
ui-sref-active="active">{{'DATA_CENTER.ITEM_DOWNLOADED' | translate}}</a>
|
||||
</div>
|
||||
<div class="list-group panel-menu-list">
|
||||
<a ui-sref="dataCenter.scoreHistory" class="list-group-item"
|
||||
<a ui-sref="dataCenter.scoreHistory({uid: $state.params.uid})" class="list-group-item"
|
||||
ui-sref-active="active">{{'DATA_CENTER.ITEM_SCORE_HISTORY' | translate}}</a>
|
||||
<a ui-sref="dataCenter.uploadedHistory" class="list-group-item"
|
||||
<a ui-sref="dataCenter.uploadedHistory({uid: $state.params.uid})" class="list-group-item"
|
||||
ui-sref-active="active">{{'DATA_CENTER.ITEM_UPLOADED_HISTORY' | translate}}</a>
|
||||
<a ui-sref="dataCenter.downloadedHistory" class="list-group-item"
|
||||
<a ui-sref="dataCenter.downloadedHistory({uid: $state.params.uid})" class="list-group-item"
|
||||
ui-sref-active="active">{{'DATA_CENTER.ITEM_DOWNLOADED_HISTORY' | translate}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -21,34 +21,52 @@ var announceConfig = config.meanTorrentConfig.announce;
|
||||
* List of UserDaysLog
|
||||
*/
|
||||
exports.getUserDaysLogs = function (req, res) {
|
||||
UserDaysLog.find({
|
||||
user: objectId(req.params.userId)
|
||||
}).exec(function (err, logs) {
|
||||
res.json(logs);
|
||||
});
|
||||
if (objectId(req.params.userId).equals(req.user._id) || req.user.isOper) {
|
||||
UserDaysLog.find({
|
||||
user: objectId(req.params.userId)
|
||||
}).exec(function (err, logs) {
|
||||
res.json(logs);
|
||||
});
|
||||
} else {
|
||||
return res.status(403).json({
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* List of UserMonthsLog
|
||||
*/
|
||||
exports.getUserMonthsLogs = function (req, res) {
|
||||
UserMonthsLog.find({
|
||||
user: objectId(req.params.userId)
|
||||
}).exec(function (err, logs) {
|
||||
res.json(logs);
|
||||
});
|
||||
if (objectId(req.params.userId).equals(req.user._id) || req.user.isOper) {
|
||||
UserMonthsLog.find({
|
||||
user: objectId(req.params.userId)
|
||||
}).exec(function (err, logs) {
|
||||
res.json(logs);
|
||||
});
|
||||
} else {
|
||||
return res.status(403).json({
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* List of getUserScoreLogs
|
||||
*/
|
||||
exports.getUserScoreLogs = function (req, res) {
|
||||
ScoreLog.find({
|
||||
user: objectId(req.params.userId)
|
||||
}).sort('-createdAt')
|
||||
.exec(function (err, logs) {
|
||||
res.json(logs);
|
||||
if (objectId(req.params.userId).equals(req.user._id) || req.user.isOper) {
|
||||
ScoreLog.find({
|
||||
user: objectId(req.params.userId)
|
||||
}).sort('-createdAt')
|
||||
.exec(function (err, logs) {
|
||||
res.json(logs);
|
||||
});
|
||||
} else {
|
||||
return res.status(403).json({
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,10 +75,16 @@ exports.getUserScoreLogs = function (req, res) {
|
||||
* @param res
|
||||
*/
|
||||
exports.getUserAnnounceLogs = function (req, res) {
|
||||
AnnounceLog.find({
|
||||
user: objectId(req.params.userId)
|
||||
}).sort('-createdAt')
|
||||
.exec(function (err, logs) {
|
||||
res.json(logs);
|
||||
if (objectId(req.params.userId).equals(req.user._id) || req.user.isOper) {
|
||||
AnnounceLog.find({
|
||||
user: objectId(req.params.userId)
|
||||
}).sort('-createdAt')
|
||||
.exec(function (err, logs) {
|
||||
res.json(logs);
|
||||
});
|
||||
} else {
|
||||
return res.status(403).json({
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
<a class="btn btn-default btn-width-80" ng-click="vm.messageTo()" ng-if="!vm.isContextUserSelf()">
|
||||
{{ 'STATUS_FIELD.BTN_SEND_MESSAGE' | translate}}
|
||||
</a>
|
||||
<a class="btn btn-default btn-width-80" ui-sref="dataCenter.score({uid: vm.user._id})"
|
||||
ng-if="vm.authentication.user.isOper">
|
||||
{{ 'STATUS_FIELD.BTN_VIEW_USER_DATA_CENTER' | translate}}
|
||||
</a>
|
||||
<button class="btn btn-primary" ng-if="vm.authentication.user.isAdmin"
|
||||
uib-popover-template="vm.presentInvitationsPopover.templateUrl"
|
||||
popover-title="{{vm.presentInvitationsPopover.title | translate}}"
|
||||
|
||||
Reference in New Issue
Block a user