feat(torrents): owner and oper can modify the main title and subtitle now

This commit is contained in:
OldHawk
2018-05-19 10:41:25 +08:00
parent 948b9e989f
commit 8a89b27d9a
5 changed files with 106 additions and 12 deletions

View File

@@ -27,9 +27,9 @@
$scope.input = jQuery($element).find('.editable-line-input');
$scope.originalDivBackground = $scope.div.css('background-color');
$scope.div.awesomeCursor('wrench', {
$scope.div.awesomeCursor('pencil', {
color: '#ff6000',
flip: 'horizontal',
flip: 'vertical',
outline: '#ff3e00'
});

View File

@@ -95,6 +95,11 @@
* $watch 'vm.torrentLocalInfo'
*/
$scope.$watch('vm.torrentLocalInfo', function (newValue, oldValue) {
if(vm.torrentLocalInfo) {
vm.torrentLocalInfo.resource_detail_info.custom_title = vm.TGI.getTorrentCustomTitle(vm.torrentLocalInfo);
vm.torrentLocalInfo.resource_detail_info.custom_subtitle = vm.TGI.getTorrentCustomSubTitle(vm.torrentLocalInfo);
}
if (vm.torrentLocalInfo && vm.torrentLocalInfo._replies) {
var hasme = false;
var meitem = null;
@@ -517,13 +522,13 @@
}
]
},
{
icon: 'fa-user-md',
title: $translate.instant('TAB_MY_PANEL'),
templateUrl: 'myPanel.html',
ng_show: vm.torrentLocalInfo.isCurrentUserOwner,
badges: []
},
// {
// icon: 'fa-user-md',
// title: $translate.instant('TAB_MY_PANEL'),
// templateUrl: 'myPanel.html',
// ng_show: vm.torrentLocalInfo.isCurrentUserOwner,
// badges: []
// },
{
icon: 'fa-cog',
title: $translate.instant('TAB_ADMIN_PANEL'),
@@ -1011,6 +1016,69 @@
});
};
/**
* isOwner
* @param o, topic or reply
* @returns {boolean}
*/
vm.isOwner = function (o) {
if (o) {
if (o.isCurrentUserOwner) {
return true;
} else {
return false;
}
} else {
return false;
}
};
/**
* canEdit
* @returns {boolean}
*/
vm.canEdit = function () {
if (vm.user.isOper) {
return true;
} else {
return false;
}
};
/**
* onTorrentTitleEdited
*/
$scope.onTorrentTitleEdited = function (modifyed) {
if (vm.torrentLocalInfo && modifyed) {
TorrentsService.update({
_id: vm.torrentLocalInfo._id,
custom_title: vm.torrentLocalInfo.resource_detail_info.custom_title
}, function (res) {
vm.torrentLocalInfo = res;
NotifycationService.showSuccessNotify('TORRENT_UPDATE_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'TORRENT_UPDATE_ERROR');
});
}
};
/**
* onTorrentSubTitleEdited
*/
$scope.onTorrentSubTitleEdited = function (modifyed) {
if (vm.torrentLocalInfo && modifyed) {
TorrentsService.update({
_id: vm.torrentLocalInfo._id,
custom_subtitle: vm.torrentLocalInfo.resource_detail_info.custom_subtitle
}, function (res) {
vm.torrentLocalInfo = res;
NotifycationService.showSuccessNotify('TORRENT_UPDATE_SUCCESSFULLY');
}, function (res) {
NotifycationService.showErrorNotify(res.data.message, 'TORRENT_UPDATE_ERROR');
});
}
};
/**
* doUpdateTorrentInfo
* @param minfo

View File

@@ -1,5 +1,9 @@
@import (reference) "../../../core/client/less/mt-var.less";
.text-bold {
font-weight: bold;
}
.filter-tags {
padding-bottom: 10px;
margin-bottom: 15px;

View File

@@ -579,13 +579,27 @@
</span>
<dl class="dl-horizontal" style="margin-bottom: 0;">
<dt class="h-line">{{ 'RESOURCE_TITLE' | translate}}</dt>
<dd class="h-line">
<span class="text-bold" editable-line readonly="!vm.canEdit() && !vm.isOwner(vm.torrentLocalInfo)"
ng-model="vm.torrentLocalInfo.resource_detail_info.custom_title"
callback="onTorrentTitleEdited"></span>
</dd>
<dt class="h-line">{{ 'RESOURCE_SUB_TITLE' | translate}}</dt>
<dd class="h-line">
<span class="text-bold" editable-line readonly="!vm.canEdit() && !vm.isOwner(vm.torrentLocalInfo)"
ng-model="vm.torrentLocalInfo.resource_detail_info.custom_subtitle"
callback="onTorrentSubTitleEdited"></span>
</dd>
<dt class="h-line">{{ 'TABLE_FIELDS.PUBLISHER' | translate}}</dt>
<dd class="h-line">
<span ng-if="!vm.torrentLocalInfo.isAnonymous" user-info="vm.torrentLocalInfo.user" info-name></span>
<span ng-if="vm.torrentLocalInfo.isAnonymous">{{ 'ANONYMOUS' | translate }}</span>
<span maker-info="vm.torrentLocalInfo.maker"></span>
<!--<span message-to="vm.torrentLocalInfo.user" to-class="message-to-icon"></span>-->
<span>&emsp;&emsp;{{'MESSAGES_FIELD.INFO_SEND_AT' | translate}}: {{vm.torrentLocalInfo.createdat | date: 'yyyy-MM-dd HH:mm:ss'}}</span>
<span>&nbsp;{{'MESSAGES_FIELD.INFO_SEND_AT' | translate}}: {{vm.torrentLocalInfo.createdat | date: 'yyyy-MM-dd HH:mm:ss'}}</span>
</dd>
<dt class="h-line">{{ 'TORRENT_FILENAME' | translate}}</dt>
@@ -596,8 +610,8 @@
<dt class="h-line">{{ 'TABLE_FIELDS.ABBR_SEEDS_LEECHERS_FINISHED' | translate}}</dt>
<dd class="h-line">
<span><span class="glyphicon glyphicon-arrow-up torrent-up"></span> {{vm.torrentLocalInfo.torrent_seeds}}</span>&emsp;&emsp;
<span><span class="glyphicon glyphicon-arrow-down torrent-down"></span> {{vm.torrentLocalInfo.torrent_leechers}}</span>&emsp;&emsp;
<span><span class="glyphicon glyphicon-arrow-up torrent-up"></span> {{vm.torrentLocalInfo.torrent_seeds}}</span>&emsp;
<span><span class="glyphicon glyphicon-arrow-down torrent-down"></span> {{vm.torrentLocalInfo.torrent_leechers}}</span>&emsp;
<span><span class="glyphicon glyphicon-ok torrent-finished"></span> {{vm.torrentLocalInfo.torrent_finished}}</span>
</dd>

View File

@@ -849,6 +849,14 @@ exports.update = function (req, res) {
torrent.torrent_nfo = req.body.torrent_nfo;
torrent.torrent_media_info = mediaInfo.getMediaInfo(req.body.torrent_nfo);
}
if (req.body.hasOwnProperty('custom_title')) {
torrent.resource_detail_info.custom_title = req.body.custom_title;
torrent.markModified('resource_detail_info');
}
if (req.body.hasOwnProperty('custom_subtitle')) {
torrent.resource_detail_info.custom_subtitle = req.body.custom_subtitle;
torrent.markModified('resource_detail_info');
}
torrent.save(function (err) {
if (err) {