feat(history): show user account history on manage page

This commit is contained in:
OldHawk
2018-05-29 18:05:10 +08:00
parent 330f0c5406
commit 37cd2887fe
14 changed files with 151 additions and 44 deletions

View File

@@ -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});
};
}
}());