feat(torrents): show torrent global sale status if it is enabled

This commit is contained in:
OldHawk
2018-05-15 15:37:04 +08:00
parent 7caf321f95
commit bf78262ce4
13 changed files with 177 additions and 57 deletions

View File

@@ -1158,13 +1158,15 @@ exports.announce = function (req, res) {
var udr = {};
var sale = req.torrent.torrent_sale_status;
var start = moment(globalSalesConfig.global.startAt, globalSalesConfig.global.timeFormats).utc().valueOf();
var start = moment(globalSalesConfig.global.startAt, globalSalesConfig.global.timeFormats).valueOf();
var end = start + globalSalesConfig.global.expires;
var now = Date.now();
isGlobalSaleValid = (now > start && now < end && globalSalesConfig.global.value) ? true : false;
if (isGlobalSaleValid && globalSalesConfig.global.value) {
sale = globalSalesConfig.global.value;
mtDebug.debugRed('isGlobalSaleValid = ' + isGlobalSaleValid, 'ANNOUNCE', true, req.passkeyuser);
mtDebug.debugRed('global sale value = ' + sale, 'ANNOUNCE', true, req.passkeyuser);
}
switch (sale) {

View File

@@ -6,9 +6,9 @@
function torrentListItem() {
var TorrentsItemController = ['$scope', '$state', 'TorrentGetInfoServices', 'ResourcesTagsServices', '$timeout', 'DownloadService', 'MeanTorrentConfig',
'TorrentsService', 'Authentication', 'NotifycationService', 'ModalConfirmService', '$translate',
'TorrentsService', 'Authentication', 'NotifycationService', 'ModalConfirmService', '$translate', 'moment',
function ($scope, $state, TorrentGetInfoServices, ResourcesTagsServices, $timeout, DownloadService, MeanTorrentConfig, TorrentsService, Authentication,
NotifycationService, ModalConfirmService, $translate) {
NotifycationService, ModalConfirmService, $translate, moment) {
var vm = this;
vm.user = Authentication.user;
@@ -18,6 +18,7 @@
vm.DLS = DownloadService;
vm.torrentSalesType = MeanTorrentConfig.meanTorrentConfig.torrentSalesType;
vm.torrentRLevels = MeanTorrentConfig.meanTorrentConfig.torrentRecommendLevel;
vm.salesGlobalConfig = MeanTorrentConfig.meanTorrentConfig.torrentGlobalSales;
/**
* buildPager
@@ -311,6 +312,22 @@
}
};
/**
* isGlobalSaleNow
* @returns {boolean}
*/
vm.isGlobalSaleNow = function () {
var start = moment(vm.salesGlobalConfig.global.startAt, vm.salesGlobalConfig.global.timeFormats).valueOf();
var end = start + vm.salesGlobalConfig.global.expires;
var now = Date.now();
if (now > start && now < end && vm.salesGlobalConfig.global.value) {
return true;
} else {
return false;
}
};
}];
return {

View File

@@ -7,12 +7,12 @@
TorrentsAdminController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'Notification', 'TorrentsService',
'MeanTorrentConfig', 'DownloadService', '$window', 'ModalConfirmService', 'NotifycationService', 'DebugConsoleService', 'TorrentGetInfoServices',
'ResourcesTagsServices', 'localStorageService'
'ResourcesTagsServices', 'localStorageService', 'moment'
];
function TorrentsAdminController($scope, $state, $translate, $timeout, Authentication, Notification, TorrentsService, MeanTorrentConfig,
DownloadService, $window, ModalConfirmService, NotifycationService, mtDebug, TorrentGetInfoServices,
ResourcesTagsServices, localStorageService) {
ResourcesTagsServices, localStorageService, moment) {
var vm = this;
vm.DLS = DownloadService;
vm.TGI = TorrentGetInfoServices;
@@ -23,6 +23,7 @@
vm.torrentSalesType = MeanTorrentConfig.meanTorrentConfig.torrentSalesType;
vm.torrentRLevels = MeanTorrentConfig.meanTorrentConfig.torrentRecommendLevel;
vm.torrentTypeConfig = MeanTorrentConfig.meanTorrentConfig.torrentType;
vm.salesGlobalConfig = MeanTorrentConfig.meanTorrentConfig.torrentGlobalSales;
vm.selectedType = localStorageService.get('admin_last_selected_type') || 'movie';
vm.filterVIP = isSelectedVipType(vm.selectedType);
@@ -362,5 +363,21 @@
i.removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
}
};
/**
* isGlobalSaleNow
* @returns {boolean}
*/
vm.isGlobalSaleNow = function () {
var start = moment(vm.salesGlobalConfig.global.startAt, vm.salesGlobalConfig.global.timeFormats).valueOf();
var end = start + vm.salesGlobalConfig.global.expires;
var now = Date.now();
if (now > start && now < end && vm.salesGlobalConfig.global.value) {
return true;
} else {
return false;
}
};
}
}());

View File

@@ -8,12 +8,12 @@
TorrentsInfoController.$inject = ['$scope', '$state', '$stateParams', '$translate', 'Authentication', 'Notification', 'TorrentsService',
'MeanTorrentConfig', 'DownloadService', '$sce', '$filter', 'CommentsService', 'ModalConfirmService', 'marked', 'Upload', '$timeout',
'SubtitlesService', 'getStorageLangService', 'NotifycationService', 'DebugConsoleService', 'TorrentGetInfoServices',
'localStorageService', '$compile', 'SideOverlay', 'ResourcesTagsServices', 'CollectionsService'];
'localStorageService', '$compile', 'SideOverlay', 'ResourcesTagsServices', 'CollectionsService', 'moment'];
function TorrentsInfoController($scope, $state, $stateParams, $translate, Authentication, Notification, TorrentsService, MeanTorrentConfig,
DownloadService, $sce, $filter, CommentsService, ModalConfirmService, marked, Upload, $timeout, SubtitlesService,
getStorageLangService, NotifycationService, mtDebug, TorrentGetInfoServices,
localStorageService, $compile, SideOverlay, ResourcesTagsServices, CollectionsService) {
localStorageService, $compile, SideOverlay, ResourcesTagsServices, CollectionsService, moment) {
var vm = this;
vm.DLS = DownloadService;
vm.TGI = TorrentGetInfoServices;
@@ -30,6 +30,7 @@
vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage;
vm.scoreConfig = MeanTorrentConfig.meanTorrentConfig.score;
vm.inputLengthConfig = MeanTorrentConfig.meanTorrentConfig.inputLength;
vm.salesGlobalConfig = MeanTorrentConfig.meanTorrentConfig.torrentGlobalSales;
vm.torrentTabs = [];
vm.searchTags = [];
@@ -1396,5 +1397,21 @@
});
};
/**
* isGlobalSaleNow
* @returns {boolean}
*/
vm.isGlobalSaleNow = function () {
var start = moment(vm.salesGlobalConfig.global.startAt, vm.salesGlobalConfig.global.timeFormats).valueOf();
var end = start + vm.salesGlobalConfig.global.expires;
var now = Date.now();
if (now > start && now < end && vm.salesGlobalConfig.global.value) {
return true;
} else {
return false;
}
};
}
}());

View File

@@ -6,10 +6,10 @@
.controller('TorrentsController', TorrentsController);
TorrentsController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'Notification', 'TorrentsService', 'getStorageLangService',
'MeanTorrentConfig', 'DownloadService', '$window', 'DebugConsoleService', 'TorrentGetInfoServices', 'ResourcesTagsServices'];
'MeanTorrentConfig', 'DownloadService', '$window', 'DebugConsoleService', 'TorrentGetInfoServices', 'ResourcesTagsServices', 'moment'];
function TorrentsController($scope, $state, $translate, $timeout, Authentication, Notification, TorrentsService, getStorageLangService, MeanTorrentConfig,
DownloadService, $window, mtDebug, TorrentGetInfoServices, ResourcesTagsServices) {
DownloadService, $window, mtDebug, TorrentGetInfoServices, ResourcesTagsServices, moment) {
var vm = this;
vm.DLS = DownloadService;
vm.TGI = TorrentGetInfoServices;
@@ -22,6 +22,7 @@
vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage;
vm.appConfig = MeanTorrentConfig.meanTorrentConfig.app;
vm.torrentTypeConfig = MeanTorrentConfig.meanTorrentConfig.torrentType;
vm.salesGlobalConfig = MeanTorrentConfig.meanTorrentConfig.torrentGlobalSales;
vm.searchTags = [];
vm.searchKey = $state.params.keys || '';
@@ -479,6 +480,22 @@
}
};
/**
* isGlobalSaleNow
* @returns {boolean}
*/
vm.isGlobalSaleNow = function () {
var start = moment(vm.salesGlobalConfig.global.startAt, vm.salesGlobalConfig.global.timeFormats).valueOf();
var end = start + vm.salesGlobalConfig.global.expires;
var now = Date.now();
if (now > start && now < end && vm.salesGlobalConfig.global.value) {
return true;
} else {
return false;
}
};
/**
* onTorrentTypeChanged
*/

View File

@@ -31,7 +31,8 @@
getTorrentOverview: getTorrentOverview,
openTorrentDetailInfo: openTorrentDetailInfo,
getTorrentSaleTypeDesc: getTorrentSaleTypeDesc
getTorrentSaleTypeDesc: getTorrentSaleTypeDesc,
getTorrentSaleTypeDescByValue: getTorrentSaleTypeDescByValue
};
return service;
@@ -327,5 +328,19 @@
return desc;
}
/**
* getTorrentSaleTypeDescByValue
*/
function getTorrentSaleTypeDescByValue(v) {
var desc = '';
angular.forEach(torrentSalesType.value, function (st) {
if (st.name === v) {
desc = st.desc;
}
});
return desc;
}
}
}());

View File

@@ -60,12 +60,17 @@
{{ 'TORRENT_RECOMMEND_LEVEL_ITEM.' + item.torrent_recommended.toUpperCase() | translate}}
</span>
<span class="label label-sale" ng-if="item.isSaling"
<span class="label label-sale" ng-if="!vm.isGlobalSaleNow() && item.isSaling"
title="{{vm.TGI.getTorrentSaleTypeDesc(item);}} | {{ 'SALE_EXPIRES_TIME' | translate}}: {{item.torrent_sale_expires | date: 'MM-dd HH:mm'}}"
ng-click="vm.onSaleClicked(); $event.stopPropagation();"
ng-class="{'label-default': !item.isSaling, 'label-success': item.isSaling, 'used': parent.filterSale}">
{{item.torrent_sale_status}} {{item.torrent_sale_expires | unlife}}
</span>
<span class="label label-sale label-success" ng-if="vm.isGlobalSaleNow()"
title="{{vm.TGI.getTorrentSaleTypeDescByValue(vm.salesGlobalConfig.global.value);}}"
ng-click="$event.stopPropagation();">
G: {{vm.salesGlobalConfig.global.value}}
</span>
<span class="label label-se-info" ng-if="vm.torrentType == 'tvserial'"
ng-click="$event.stopPropagation();">S{{item.torrent_seasons}}E{{item.torrent_episodes}}</span>

View File

@@ -101,15 +101,17 @@
</div>
</dd>
<dt class="h-line">{{ 'CA_TORRENT_SALE_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-hnr">
<label>
<input type="checkbox" ng-model="vm.filterSale"
ng-change="vm.onSaleChanged();"> {{ 'CA_TORRENT_SALE_NOW' | translate}}
</label>
</div>
</dd>
<div ng-if="!vm.isGlobalSaleNow()">
<dt class="h-line">{{ 'CA_TORRENT_SALE_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-hnr">
<label>
<input type="checkbox" ng-model="vm.filterSale"
ng-change="vm.onSaleChanged();"> {{ 'CA_TORRENT_SALE_NOW' | translate}}
</label>
</div>
</dd>
</div>
<dt class="h-line">{{ 'CA_TORRENT_VIP' | translate}}:</dt>
<dd class="h-line">
@@ -124,7 +126,8 @@
<dd class="h-line">
<div class="checkbox checkbox-vip">
<label>
<input type="checkbox" ng-model="vm.filterTop" ng-change="vm.onTopChanged();"> {{ 'TORRENT_STATUS_TOP_TITLE' | translate}}
<input type="checkbox" ng-model="vm.filterTop"
ng-change="vm.onTopChanged();"> {{ 'TORRENT_STATUS_TOP_TITLE' | translate}}
</label>
</div>
</dd>

View File

@@ -148,21 +148,24 @@
</div>
</dd>
<dt class="h-line">{{ 'CA_TORRENT_SALE_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-hnr">
<label>
<input type="checkbox" ng-model="vm.filterSale"
ng-change="vm.onSaleChanged();"> {{ 'CA_TORRENT_SALE_NOW' | translate}}
</label>
</div>
</dd>
<div ng-if="!vm.isGlobalSaleNow()">
<dt class="h-line">{{ 'CA_TORRENT_SALE_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-hnr">
<label>
<input type="checkbox" ng-model="vm.filterSale"
ng-change="vm.onSaleChanged();"> {{ 'CA_TORRENT_SALE_NOW' | translate}}
</label>
</div>
</dd>
</div>
<dt class="h-line">{{ 'CA_TORRENT_TOP' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-vip">
<label>
<input type="checkbox" ng-model="vm.filterTop" ng-change="vm.onTopChanged();"> {{ 'TORRENT_STATUS_TOP_TITLE' | translate}}
<input type="checkbox" ng-model="vm.filterTop"
ng-change="vm.onTopChanged();"> {{ 'TORRENT_STATUS_TOP_TITLE' | translate}}
</label>
</div>
</dd>

View File

@@ -96,15 +96,17 @@
</div>
</dd>
<dt class="h-line">{{ 'CA_TORRENT_SALE_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-hnr">
<label>
<input type="checkbox" ng-model="vm.filterSale"
ng-change="vm.onSaleChanged();"> {{ 'CA_TORRENT_SALE_NOW' | translate}}
</label>
</div>
</dd>
<div ng-if="vm.isGlobalSaleNow()">
<dt class="h-line">{{ 'CA_TORRENT_SALE_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-hnr">
<label>
<input type="checkbox" ng-model="vm.filterSale"
ng-change="vm.onSaleChanged();"> {{ 'CA_TORRENT_SALE_NOW' | translate}}
</label>
</div>
</dd>
</div>
<div class="more-tags panel-collapsed" style="display: none; margin-bottom: 20px;">
<div ng-repeat="item in vm.resourcesTags.radio | filter:vm.torrentType">

View File

@@ -634,14 +634,16 @@
<dt class="h-line">{{ 'VIDEO_SALE_INFO' | translate}}</dt>
<dd class="h-line">
<span class="label label-sale"
<span class="label label-sale" ng-if="!vm.isGlobalSaleNow()"
title="{{vm.TGI.getTorrentSaleTypeDesc(vm.torrentLocalInfo);}} | {{ 'SALE_EXPIRES_TIME' | translate}}: {{vm.torrentLocalInfo.isSaling ? (vm.torrentLocalInfo.torrent_sale_expires | date: 'MM-dd HH:mm') : 'NO'}}"
ng-class="{'label-default': !vm.torrentLocalInfo.isSaling, 'label-success': vm.torrentLocalInfo.isSaling}">
{{vm.torrentLocalInfo.torrent_sale_status}} {{vm.torrentLocalInfo.isSaling ? (vm.torrentLocalInfo.torrent_sale_expires | unlife) : ''}}
</span>
<!--<span ng-if="vm.torrentLocalInfo.isSaling">-->
<!--[{{ 'SALE_EXPIRES_TIME' | translate}}: {{vm.torrentLocalInfo.torrent_sale_expires | unlife}}]-->
<!--</span>-->
<span class="label label-sale label-success" ng-if="vm.isGlobalSaleNow()"
title="{{vm.TGI.getTorrentSaleTypeDescByValue(vm.salesGlobalConfig.global.value);}}"
ng-click="$event.stopPropagation();">
G: {{vm.salesGlobalConfig.global.value}}
</span>
</dd>
<div ng-if="vm.torrentLocalInfo.torrent_recommended != 'level0' || vm.torrentLocalInfo.isTop">

View File

@@ -7,11 +7,11 @@
VipController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'getStorageLangService', 'MeanTorrentConfig', 'TorrentsService',
'DebugConsoleService', '$timeout', 'uibButtonConfig', 'TorrentGetInfoServices', 'DownloadService', 'ResourcesTagsServices', '$window',
'localStorageService', 'marked', '$templateRequest', '$filter'];
'localStorageService', 'marked', '$templateRequest', '$filter', 'moment'];
function VipController($scope, $state, $translate, Authentication, getStorageLangService, MeanTorrentConfig, TorrentsService,
mtDebug, $timeout, uibButtonConfig, TorrentGetInfoServices, DownloadService, ResourcesTagsServices, $window,
localStorageService, marked, $templateRequest, $filter) {
localStorageService, marked, $templateRequest, $filter, moment) {
var vm = this;
vm.DLS = DownloadService;
vm.TGI = TorrentGetInfoServices;
@@ -488,5 +488,21 @@
return marked(ts, {sanitize: true});
};
/**
* isGlobalSaleNow
* @returns {boolean}
*/
vm.isGlobalSaleNow = function () {
var start = moment(vm.salesGlobalConfig.global.startAt, vm.salesGlobalConfig.global.timeFormats).valueOf();
var end = start + vm.salesGlobalConfig.global.expires;
var now = Date.now();
if (now > start && now < end && vm.salesGlobalConfig.global.value) {
return true;
} else {
return false;
}
};
}
}());

View File

@@ -124,21 +124,24 @@
</div>
</dd>
<dt class="h-line">{{ 'CA_TORRENT_SALE_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-hnr">
<label>
<input type="checkbox" ng-model="vm.filterSale"
ng-change="vm.onSaleChanged();"> {{ 'CA_TORRENT_SALE_NOW' | translate}}
</label>
</div>
</dd>
<div ng-if="!vm.isGlobalSaleNow()">
<dt class="h-line">{{ 'CA_TORRENT_SALE_STATUS' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-hnr">
<label>
<input type="checkbox" ng-model="vm.filterSale"
ng-change="vm.onSaleChanged();"> {{ 'CA_TORRENT_SALE_NOW' | translate}}
</label>
</div>
</dd>
</div>
<dt class="h-line">{{ 'CA_TORRENT_TOP' | translate}}:</dt>
<dd class="h-line">
<div class="checkbox checkbox-vip">
<label>
<input type="checkbox" ng-model="vm.filterTop" ng-change="vm.onTopChanged();"> {{ 'TORRENT_STATUS_TOP_TITLE' | translate}}
<input type="checkbox" ng-model="vm.filterTop"
ng-change="vm.onTopChanged();"> {{ 'TORRENT_STATUS_TOP_TITLE' | translate}}
</label>
</div>
</dd>
@@ -251,7 +254,8 @@
</td>
</tr>
</tbody>
<tbody ng-if="!vm.tooltipMsg" torrent-list-item parent="vm" item="item" list="vm.pagedItems" ng-repeat="item in vm.pagedItems"></tbody>
<tbody ng-if="!vm.tooltipMsg" torrent-list-item parent="vm" item="item" list="vm.pagedItems"
ng-repeat="item in vm.pagedItems"></tbody>
</table>
</div>