fix(core): fixed many issue of $resource method

This commit is contained in:
OldHawk
2018-05-05 14:56:26 +08:00
parent ccfc005397
commit 00cfe341db
7 changed files with 59 additions and 57 deletions

View File

@@ -311,11 +311,11 @@
vm.getMaker = function () {
MakerGroupService.get({
makerId: $state.params.makerId
}, function (data) {
vm.maker = data;
}, function (res) {
vm.maker = new MakerGroupService(res);
vm.rating_vote = vm.maker.vote_average;
mtDebug.info(data);
mtDebug.info(res);
vm.buildPager();
});
@@ -374,7 +374,7 @@
_id: vm.maker._id,
_username: vm.addMemberPopover.username
}, function (res) {
vm.maker = res;
vm.maker = new MakerGroupService(res);
NotifycationService.showSuccessNotify('ABOUT.ADD_MEMBER_SUCCESSFULLY');
vm.addMemberPopover.isOpen = false;
}, function (res) {
@@ -402,7 +402,7 @@
_id: m._id,
_username: u.username
}, function (res) {
vm.maker = res;
vm.maker = new MakerGroupService(res);
NotifycationService.showSuccessNotify('ABOUT.REMOVE_MEMBER_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'ABOUT.REMOVE_MEMBER_FAILED');
@@ -429,7 +429,7 @@
if (e.isDirty()) {
vm.maker.desc = e.getContent();
vm.maker.$update(function (res) {
vm.maker = res;
vm.maker = new MakerGroupService(res);
NotifycationService.showSuccessNotify('ABOUT.EDIT_DESC_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'ABOUT.EDIT_DESC_FAILED');
@@ -533,7 +533,7 @@
vm.setMakerUploadAccess = function (acc) {
vm.maker.upload_access = acc;
vm.maker.$update(function (res) {
vm.maker = res;
vm.maker = new MakerGroupService(res);
NotifycationService.showSuccessNotify('UPLOADER.ACCESS_CHANGED_SUCCESSFULLY');
});
@@ -547,7 +547,7 @@
item.$rating({
vote: vm.rating_vote
}, function (res) {
vm.maker = res;
vm.maker = new MakerGroupService(res);
vm.rating_vote = vm.maker.vote_average;
NotifycationService.showSuccessNotify('ABOUT.RATING_SUCCESSFULLY');

View File

@@ -31,7 +31,7 @@
CollectionsService.get({
collectionId: $state.params.collectionId
}, function (data) {
vm.collection = data;
vm.collection = new CollectionsService(data);
$('.backdrop').css('backgroundImage', 'url("' + vm.tmdbConfig.backdropImgBaseUrl + vm.collection.backdrop_path + '")');
@@ -119,7 +119,7 @@
if (e.isDirty()) {
vm.collection.overview = e.getContent();
vm.collection.$update(function (res) {
vm.collection = res;
vm.collection = new CollectionsService(res);
NotifycationService.showSuccessNotify('COLLECTIONS.EDIT_OVERVIEW_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'COLLECTIONS.EDIT_OVERVIEW_FAILED');
@@ -201,7 +201,7 @@
_id: item._id,
rlevel: rl.value
}, function (res) {
vm.collection = res;
vm.collection = new CollectionsService(res);
NotifycationService.showSuccessNotify('COLLECTIONS.SETRLEVEL_SUCCESSFULLY');
}, function (res) {
NotifycationService.showSuccessNotify('COLLECTIONS.SETRLEVEL_ERROR');
@@ -227,7 +227,7 @@
torrentId: item._id
}, function (res) {
mtDebug.info(res);
vm.collection = res;
vm.collection = new CollectionsService(res);
NotifycationService.showSuccessNotify('COLLECTIONS.REMOVE_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'COLLECTIONS.REMOVE_FAILED');

View File

@@ -98,7 +98,7 @@
topicId: $stateParams.topicId
}, function (topic) {
mtDebug.info(topic);
vm.topic = topic;
vm.topic = new TopicsService(topic);
vm.buildPager();
vm.forumPath.push({name: topic.title, state: undefined});
@@ -196,7 +196,7 @@
$scope.onTopicTitleEdited = function (modifyed) {
if (vm.topic && modifyed) {
vm.topic.$update(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
NotifycationService.showSuccessNotify('FORUMS.TOPIC_EDIT_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'FORUMS.TOPIC_EDIT_FAILED');
@@ -224,7 +224,7 @@
//save content
t.content = e.getContent();
t.$update(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
vm.figureOutItemsToDisplay();
NotifycationService.showSuccessNotify('FORUMS.TOPIC_EDIT_SUCCESSFULLY');
}, function (res) {
@@ -322,7 +322,7 @@
});
rep.$update(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
vm.figureOutItemsToDisplay();
NotifycationService.showSuccessNotify('FORUMS.REPLY_EDIT_SUCCESSFULLY');
}, function (res) {
@@ -428,7 +428,7 @@
});
topic.$toggleTopicTopStatus(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
NotifycationService.showSuccessNotify('FORUMS.TOPIC_TOGGLE_TOP_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'FORUMS.TOPIC_TOGGLE_TOP_FAILED');
@@ -446,7 +446,7 @@
});
topic.$toggleTopicGlobalStatus(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
NotifycationService.showSuccessNotify('FORUMS.TOPIC_TOGGLE_GLOBAL_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'FORUMS.TOPIC_TOGGLE_GLOBAL_FAILED');
@@ -464,7 +464,7 @@
});
topic.$toggleTopicHomeHelpStatus(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
NotifycationService.showSuccessNotify('FORUMS.TOPIC_TOGGLE_HOME_HELP_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'FORUMS.TOPIC_TOGGLE_HOME_HELP_FAILED');
@@ -482,7 +482,7 @@
});
topic.$toggleTopicHomeNoticeStatus(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
NotifycationService.showSuccessNotify('FORUMS.TOPIC_TOGGLE_HOME_NOTICE_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'FORUMS.TOPIC_TOGGLE_HOME_NOTICE_FAILED');
@@ -508,7 +508,7 @@
topicId: vm.topic._id,
replyId: reply._id
}, function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
vm.figureOutItemsToDisplay();
NotifycationService.showSuccessNotify('FORUMS.DELETE_REPLY_SUCCESSFULLY');
}, function (res) {
@@ -538,7 +538,7 @@
});
topic.$toggleTopicReadonly(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
NotifycationService.showSuccessNotify('FORUMS.TOPIC_TOGGLE_READONLY_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'FORUMS.TOPIC_TOGGLE_READONLY_FAILED');
@@ -588,7 +588,7 @@
function successCallback(res) {
vm.postReplyFields = {};
vm.currentPage = Math.ceil(res._replies.length / vm.itemsPerPage);
vm.topic = res;
vm.topic = new TopicsService(res);
vm.pageChanged();
$scope.$broadcast('show-errors-reset', 'vm.replyForm');
@@ -636,7 +636,7 @@
});
topic.$thumbsUp(function (res) {
vm.topic = res;
vm.topic = new TopicsService(res);
vm.figureOutItemsToDisplay();
$timeout(function () {

View File

@@ -92,7 +92,7 @@
RequestsService.get({
requestId: $stateParams.requestId
}, function (res) {
vm.request = res;
vm.request = new RequestsService(res);
mtDebug.info(vm.request);
vm.commentBuildPager();
});
@@ -191,7 +191,7 @@
if (e.isDirty()) {
vm.request.desc = e.getContent();
vm.request.$update(function (res) {
vm.request = res;
vm.request = new RequestsService(res);
NotifycationService.showSuccessNotify('REQUESTS.EDIT_DESC_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'REQUESTS.EDIT_DESC_FAILED');
@@ -293,7 +293,7 @@
$scope.onRequestTitleEdited = function (modifyed) {
if (vm.request && modifyed) {
vm.request.$update(function (res) {
vm.request = res;
vm.request = new RequestsService(res);
NotifycationService.showSuccessNotify('REQUESTS.EDIT_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'REQUESTS.EDIT_FAILED');
@@ -317,7 +317,7 @@
vm.request.$accept({
torrentId: t._id
}, function (res) {
vm.request = res;
vm.request = new RequestsService(res);
NotifycationService.showSuccessNotify('REQUESTS.ACCEPT_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'REQUESTS.ACCEPT_FAILED');
@@ -404,7 +404,7 @@
function successCallback(res) {
vm.scrollToId = vm.comment.to_id;
vm.submitInit();
vm.request = res;
vm.request = new RequestsService(res);
NotifycationService.showSuccessNotify('REQUESTS.COMMENT_CREATE_SUCCESS');
}
@@ -434,7 +434,7 @@
function successCallback(res) {
vm.scrollToId = vm.comment.to_id;
vm.submitInit();
vm.request = res;
vm.request = new RequestsService(res);
NotifycationService.showSuccessNotify('REQUESTS.COMMENT_EDIT_SUCCESS');
}
@@ -559,7 +559,7 @@
function successCallback(res) {
vm.submitInit();
vm.scrollToId = undefined;
vm.request = res;
vm.request = new RequestsService(res);
NotifycationService.showSuccessNotify('REQUESTS.COMMENT_REMOVE_SUCCESS');
}
@@ -599,7 +599,7 @@
function successCallback(res) {
vm.submitInit();
vm.scrollToId = undefined;
vm.request = res;
vm.request = new RequestsService(res);
NotifycationService.showSuccessNotify('REQUESTS.COMMENT_REMOVE_SUCCESS');
}

View File

@@ -101,7 +101,7 @@
messageTicketId: t._id
}, function (res) {
// vm.ticket = res;
vm.pagedItems[vm.pagedItems.indexOf(t)] = res;
vm.pagedItems[vm.pagedItems.indexOf(t)] = new MessageTicketsService(res);
NotifycationService.showSuccessNotify('SUPPORT.HANDLE_TICKET_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'SUPPORT.HANDLE_TICKET_FAILED');

View File

@@ -24,7 +24,7 @@
messageTicketId: $stateParams.messageTicketId
}, function (ticket) {
mtDebug.info(ticket);
vm.ticket = ticket;
vm.ticket = new MessageTicketsService(ticket);
vm.buildPager();
});
};
@@ -112,7 +112,7 @@
$scope.onTopicTitleEdited = function (modifyed) {
if (vm.ticket && modifyed) {
vm.ticket.$update(function (res) {
vm.ticket = res;
vm.ticket = new MessageTicketsService(res);
NotifycationService.showSuccessNotify('SUPPORT.TICKET_EDIT_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'SUPPORT.TICKET_EDIT_FAILED');
@@ -153,7 +153,7 @@
function successCallback(res) {
vm.postReplyFields = {};
vm.currentPage = Math.ceil(res._replies.length / vm.itemsPerPage);
vm.ticket = res;
vm.ticket = new MessageTicketsService(res);
vm.pageChanged();
$scope.$broadcast('show-errors-reset', 'vm.replyForm');
@@ -240,7 +240,7 @@
messageTicketId: vm.ticket._id,
replyId: reply._id
}, function (res) {
vm.ticket = res;
vm.ticket = new MessageTicketsService(res);
vm.figureOutItemsToDisplay();
NotifycationService.showSuccessNotify('FORUMS.DELETE_REPLY_SUCCESSFULLY');
}, function (res) {
@@ -269,7 +269,7 @@
//save content
t.content = e.getContent();
t.$update(function (res) {
vm.ticket = res;
vm.ticket = new MessageTicketsService(res);
vm.figureOutItemsToDisplay();
NotifycationService.showSuccessNotify('SUPPORT.TICKET_EDIT_SUCCESSFULLY');
}, function (res) {
@@ -366,7 +366,7 @@
});
rep.$update(function (res) {
vm.ticket = res;
vm.ticket = new MessageTicketsService(res);
vm.figureOutItemsToDisplay();
NotifycationService.showSuccessNotify('FORUMS.REPLY_EDIT_SUCCESSFULLY');
}, function (res) {
@@ -454,7 +454,7 @@
MessageTicketsService.handle({
messageTicketId: t._id
}, function (res) {
vm.ticket = res;
vm.ticket = new MessageTicketsService(res);
NotifycationService.showSuccessNotify('SUPPORT.HANDLE_TICKET_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'SUPPORT.HANDLE_TICKET_FAILED');
@@ -478,7 +478,7 @@
MessageTicketsService.solved({
messageTicketId: t._id
}, function (res) {
vm.ticket = res;
vm.ticket = new MessageTicketsService(res);
NotifycationService.showSuccessNotify('SUPPORT.SOLVED_TICKET_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'SUPPORT.SOLVED_TICKET_FAILED');

View File

@@ -134,7 +134,7 @@
TorrentsService.get({
torrentId: $stateParams.torrentId
}, function (res) {
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
mtDebug.info(vm.torrentLocalInfo);
$('.backdrop').css('backgroundImage', 'url("' + vm.TGI.getTorrentBackdropImage(vm.torrentLocalInfo) + '")');
@@ -152,7 +152,7 @@
vm.toggleHnR = function () {
vm.torrentLocalInfo.$toggleHnRStatus(function (res) {
mtDebug.info(res);
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
NotifycationService.showSuccessNotify('TORRENT_TOGGLE_HNR_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'TORRENT_TOGGLE_HNR_FAILED');
@@ -163,9 +163,11 @@
* toggleVIP
*/
vm.toggleVIP = function () {
console.log(vm.torrentLocalInfo);
vm.torrentLocalInfo.$toggleVIPStatus(function (res) {
mtDebug.info(res);
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
console.log(vm.torrentLocalInfo);
NotifycationService.showSuccessNotify('TORRENT_TOGGLE_VIP_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'TORRENT_TOGGLE_VIP_FAILED');
@@ -178,7 +180,7 @@
vm.toggleTop = function (item) {
vm.torrentLocalInfo.$toggleTopStatus(function (res) {
mtDebug.info(res);
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
NotifycationService.showSuccessNotify('TORRENT_TOGGLE_TOP_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'TORRENT_TOGGLE_TOP_FAILED');
@@ -242,7 +244,7 @@
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TORRENT_SETTAGS_SUCCESSFULLY')
});
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
mtDebug.info(res);
}, function (res) {
Notification.error({
@@ -587,7 +589,7 @@
vm.scrollToId = vm.comment_to_id;
vm.submitInit();
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
}
function errorCallback(res) {
@@ -623,7 +625,7 @@
vm.scrollToId = vm.comment_to_id;
vm.submitInit();
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
}
function errorCallback(res) {
@@ -765,7 +767,7 @@
vm.submitInit();
vm.scrollToId = undefined;
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
}
function errorCallback(res) {
@@ -811,7 +813,7 @@
vm.submitInit();
vm.scrollToId = undefined;
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
}
function errorCallback(res) {
@@ -862,7 +864,7 @@
vm.sFile = undefined;
mtDebug.info(res);
vm.torrentLocalInfo = res.data;
vm.torrentLocalInfo = new TorrentsService(res.data);
}
/**
@@ -909,7 +911,7 @@
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('SUBTITLE_DELETE_SUCCESSFULLY')
});
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
}
function errorCallback(res) {
@@ -1007,7 +1009,7 @@
});
function successCallback(res) {
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
Notification.success({
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TORRENT_UPDATE_SUCCESSFULLY')
});
@@ -1036,7 +1038,7 @@
});
mtDebug.info(res);
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
}, function (res) {
Notification.error({
message: res.data.message,
@@ -1059,7 +1061,7 @@
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TORRENT_SETRLEVEL_SUCCESSFULLY')
});
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
}, function (res) {
Notification.error({
message: res.data.message,
@@ -1075,7 +1077,7 @@
*/
vm.beginThumbsUp = function (t) {
t.$thumbsUp(function (res) {
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
vm.torrentTabs[3].badges[0].value += 1;
Notification.success({
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TORRENT_THUMBS_SUCCESSFULLY')
@@ -1163,7 +1165,7 @@
item.$rating({
vote: vm.rating_vote
}, function (res) {
vm.torrentLocalInfo = res;
vm.torrentLocalInfo = new TorrentsService(res);
vm.rating_vote = res.resource_detail_info.vote_average;
Notification.success({