mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-07 00:45:31 +02:00
feat(history): show user account history on manage page
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
.controller('UserController', UserController);
|
||||
|
||||
UserController.$inject = ['$scope', '$state', '$window', 'Authentication', 'userResolve', 'Notification', 'NotifycationService', 'MeanTorrentConfig',
|
||||
'AdminService', 'ScoreLevelService', 'DebugConsoleService', 'TorrentGetInfoServices', 'SideOverlay', 'MakerGroupService'];
|
||||
'AdminService', 'ScoreLevelService', 'DebugConsoleService', 'TorrentGetInfoServices', 'SideOverlay', 'MakerGroupService', '$filter', '$translate',
|
||||
'marked'];
|
||||
|
||||
function UserController($scope, $state, $window, Authentication, user, Notification, NotifycationService, MeanTorrentConfig,
|
||||
AdminService, ScoreLevelService, mtDebug, TorrentGetInfoServices, SideOverlay, MakerGroupService) {
|
||||
AdminService, ScoreLevelService, mtDebug, TorrentGetInfoServices, SideOverlay, MakerGroupService, $filter, $translate,
|
||||
marked) {
|
||||
var vm = this;
|
||||
vm.TGI = TorrentGetInfoServices;
|
||||
vm.authentication = Authentication;
|
||||
@@ -62,6 +64,15 @@
|
||||
|
||||
mtDebug.info(vm.user);
|
||||
|
||||
/**
|
||||
* $watch 'vm.user'
|
||||
*/
|
||||
$scope.$watch('vm.user', function (newValue, oldValue) {
|
||||
if (vm.user) {
|
||||
vm.getUserHistory();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* remove
|
||||
* @param user
|
||||
@@ -466,5 +477,29 @@
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* getUserHistory
|
||||
*/
|
||||
vm.getUserHistory = function () {
|
||||
AdminService.userHistory({
|
||||
userId: user._id
|
||||
}).then(function (res) {
|
||||
vm.historyList = res;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* getHistoryContent
|
||||
* @param h
|
||||
* @returns {string}
|
||||
*/
|
||||
vm.getHistoryContent = function (h) {
|
||||
var time = $filter('date')(h.createdAt, 'yyyy-MM-dd HH:mm');
|
||||
var con = $translate.instant('HISTORY.' + h.event_str, h.params);
|
||||
|
||||
var res = time + ' - ' + con;
|
||||
return marked(res, {sanitize: false});
|
||||
};
|
||||
}
|
||||
}());
|
||||
|
||||
@@ -31,4 +31,17 @@
|
||||
display: table-row !important;
|
||||
float: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.user-remarks {
|
||||
textarea {
|
||||
min-height: 150px;
|
||||
line-height: 0.8;
|
||||
resize: vertical;
|
||||
}
|
||||
}
|
||||
.user-history {
|
||||
height: 150px;
|
||||
line-height: 0.8;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
@@ -325,6 +325,14 @@
|
||||
params: {
|
||||
userId: '@userId'
|
||||
}
|
||||
},
|
||||
getUserHistory: {
|
||||
method: 'GET',
|
||||
isArray: true,
|
||||
url: '/api/users/:userId/history',
|
||||
params: {
|
||||
userId: '@userId'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -361,6 +369,9 @@
|
||||
},
|
||||
presentUserInvitations: function (params) {
|
||||
return this.presentInvitations(params).$promise;
|
||||
},
|
||||
userHistory: function (params) {
|
||||
return this.getUserHistory(params).$promise;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
{{'BTN_PRESENT_INVITATIONS' | translate}}
|
||||
</button>
|
||||
<!--<a class="btn btn-primary btn-width-80" ui-sref="admin.user-edit({userId: vm.user._id})"-->
|
||||
<!--ng-if="vm.authentication.user.isAdmin">-->
|
||||
<!--{{ 'STATUS_FIELD.BTN_EDIT' | translate}}-->
|
||||
<!--ng-if="vm.authentication.user.isAdmin">-->
|
||||
<!--{{ 'STATUS_FIELD.BTN_EDIT' | translate}}-->
|
||||
<!--</a>-->
|
||||
<a class="btn btn-primary btn-width-80" ng-click="vm.remove()" ng-if="!vm.isContextUserSelf() && !vm.user.isOper">
|
||||
{{ 'STATUS_FIELD.BTN_REMOVE' | translate}}
|
||||
@@ -285,10 +285,17 @@
|
||||
|
||||
<li class="status-divider"></li>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.ADMIN_HISTORY' | translate}}:</dt>
|
||||
<dd class="h-line" ng-init="vm.getUserHistory()">
|
||||
<div class="form-control user-history padding-top-15 padding-bottom-15 margin-top-10 margin-bottom-10">
|
||||
<p ng-repeat="h in vm.historyList | orderBy: '-createdAt'" ng-bind-html="vm.getHistoryContent(h)"></p>
|
||||
</div>
|
||||
</dd>
|
||||
|
||||
<dt class="h-line">{{ 'STATUS_FIELD.ADMIN_REMARKS' | translate}}:</dt>
|
||||
<dd class="h-line">
|
||||
<div class="padding-top-10 padding-bottom-10">
|
||||
<textarea class="form-control" rows="8" ng-model="vm.user.remarks"></textarea>
|
||||
<div class="user-remarks padding-top-10 padding-bottom-10">
|
||||
<textarea class="form-control" ng-model="vm.user.remarks"></textarea>
|
||||
<button class="btn btn-default btn-width-100 margin-top-10"
|
||||
ng-click="vm.saveRemarks()">
|
||||
{{'STATUS_FIELD.BTN_SAVE_REMARKS' | translate}}
|
||||
|
||||
Reference in New Issue
Block a user