diff --git a/README.md b/README.md index 47403e0f..e36086af 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ and [AngularJS](http://angularjs.org/) based applications. 68. Tracker PIV6 support, and show uses IP type(v4.v6) in users list of torrent detail page. 69. Add a reason when administrator to banned a user. 70. Add a configure item to setting whether ban the users inviter when the user was banned. and you can setting whether ban the inviter when the inviter is a vip user. +71. Check the un-reviewed new torrents and opened tickets status and show in top menu item. #### Chat room feature: 1. Users name list diff --git a/config/env/torrents.js b/config/env/torrents.js index 9cc1a19f..4a14136d 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -47,6 +47,8 @@ module.exports = { * @supportMailAddress: support group mail address * @mailTicketSupportService: settings mailTicketSupportService status, true is enable, false is disable * @messageTicketSupportService: settings messageTicketSupportService status, true is enable, false is disable + * @checkOpenedTicketsInterval: set check opened tickets interval, default 2 minutes + * @checkOpenedTicketsInterval_str: string desc of @checkOpenedTicketsInterval * * NOTE: * ===== @@ -57,7 +59,9 @@ module.exports = { supportGroupNameDesc: 'SUPPORT_GROUP_NAME_DESC', supportMailAddress: 'support@mean.im', mailTicketSupportService: false, - messageTicketSupportService: true + messageTicketSupportService: true, + checkOpenedTicketsInterval: 60 * 1000 * 2, + checkOpenedTicketsInterval_str: '2m' }, /** @@ -1028,11 +1032,12 @@ module.exports = { * the torrent status settings * NOTE: don`t change these value if you can not understand it * - * @name: do not change it - * @value: value of status - * - * @name: name of status level, used by $translate at TORRENT_RECOMMEND_LEVEL_ITEM, will show translate result in torrent admin list - * @value: value of status level, will write this value into mongodb and query(search) torrents by this value + * @name: do not change it + * @value: value of status + * @name: name of status level, used by $translate at TORRENT_RECOMMEND_LEVEL_ITEM, will show translate result in torrent admin list + * @value: value of status level, will write this value into mongodb and query(search) torrents by this value + * @checkNewTorrentsInterval: set check new torrents interval, default 2 minutes + * @checkNewTorrentsInterval_str: string desc of @checkNewTorrentsInterval */ torrentStatus: { name: 'STATUS', @@ -1040,7 +1045,9 @@ module.exports = { {name: 'NEW', value: 'new'}, {name: 'REVIEWED', value: 'reviewed'}, {name: 'DELETED', value: 'deleted'} - ] + ], + checkNewTorrentsInterval: 60 * 1000 * 2, + checkNewTorrentsInterval_str: '2m' }, /** diff --git a/modules/core/client/config/core-admin.client.menus.js b/modules/core/client/config/core-admin.client.menus.js index 9b09e0df..b59632cd 100644 --- a/modules/core/client/config/core-admin.client.menus.js +++ b/modules/core/client/config/core-admin.client.menus.js @@ -13,7 +13,8 @@ state: 'admin', type: 'dropdown', roles: ['oper', 'admin'], - position: 10 + position: 10, + shouldDotClass: 'header-dot-class-admin' }); } }()); diff --git a/modules/core/client/controllers/header.client.controller.js b/modules/core/client/controllers/header.client.controller.js index b59f3fa1..4cd15674 100644 --- a/modules/core/client/controllers/header.client.controller.js +++ b/modules/core/client/controllers/header.client.controller.js @@ -7,11 +7,11 @@ HeaderController.$inject = ['$scope', '$rootScope', '$state', '$timeout', '$translate', 'Authentication', 'menuService', 'MeanTorrentConfig', 'localStorageService', 'ScoreLevelService', 'InvitationsService', '$interval', 'MessagesService', 'marked', 'UsersService', 'DebugConsoleService', 'getStorageLangService', - 'AdminMessagesService']; + 'AdminMessagesService', 'TorrentsService', 'MailTicketsService']; - function HeaderController($scope, $rootScope, $state, $timeout, $translate, Authentication, menuService, MeanTorrentConfig, localStorageService, ScoreLevelService, - InvitationsService, $interval, MessagesService, marked, UsersService, mtDebug, getStorageLangService, - AdminMessagesService) { + function HeaderController($scope, $rootScope, $state, $timeout, $translate, Authentication, menuService, MeanTorrentConfig, localStorageService, + ScoreLevelService, InvitationsService, $interval, MessagesService, marked, UsersService, mtDebug, getStorageLangService, + AdminMessagesService, TorrentsService, MailTicketsService) { $scope.$state = $state; var vm = this; vm.user = Authentication.user; @@ -21,6 +21,8 @@ vm.messageConfig = MeanTorrentConfig.meanTorrentConfig.messages; vm.hnrConfig = MeanTorrentConfig.meanTorrentConfig.hitAndRun; vm.supportConfig = MeanTorrentConfig.meanTorrentConfig.support; + vm.torrentStatusConfig = MeanTorrentConfig.meanTorrentConfig.torrentStatus; + vm.supportConfig = MeanTorrentConfig.meanTorrentConfig.support; vm.appConfig = MeanTorrentConfig.meanTorrentConfig.app; vm.signConfig = MeanTorrentConfig.meanTorrentConfig.sign; vm.accountMenu = menuService.getMenu('account').items[0]; @@ -35,6 +37,9 @@ vm.menu = menuService.getMenu('topbar'); vm.scoreLevelData = vm.user ? ScoreLevelService.getScoreLevelJson(vm.user.score) : undefined; + vm.newTorrentCount = 0; + vm.ticketsCount = 0; + $scope.$on('$stateChangeSuccess', stateChangeSuccess); /** @@ -229,6 +234,81 @@ } }; + /** + * checkNewTorrents + */ + vm.checkNewTorrents = function () { + vm.getNewTorrentsCount(); + $interval(vm.getNewTorrentsCount, vm.torrentStatusConfig.checkNewTorrentsInterval); + }; + + vm.getNewTorrentsCount = function () { + if (Authentication.user) { + TorrentsService.countNewTorrents(function (data) { + vm.newTorrentCount = data.newCount; + + var ele = $('.header-dot-class-admin'); + if (ele) { + if (vm.newTorrentCount <= 0 && vm.ticketsCount <= 0) { + ele.css('display', 'none'); + } else { + ele.css('display', 'block'); + if (vm.newTorrentCount > 0) { + ele.addClass('new-torrent'); + } + } + } + + var badgeEle = $('.badge-class-admin-torrents'); + if (badgeEle) { + if (vm.newTorrentCount > 0) { + badgeEle.css('display', 'block'); + badgeEle.addClass('badge_info'); + badgeEle.html(vm.newTorrentCount); + } + } + }); + } + }; + + /** + * checkTicketsOpened + */ + vm.checkTicketsOpened = function () { + vm.getTicketsOpenedCount(); + $interval(vm.getTicketsOpenedCount, vm.supportConfig.checkOpenedTicketsInterval); + }; + + vm.getTicketsOpenedCount = function () { + if (Authentication.user) { + MailTicketsService.getOpenedAllCount(function (data) { + vm.ticketsCount = data.ticketsOpenedCount; + + console.log(data); + var ele = $('.header-dot-class-admin'); + if (ele) { + if (vm.newTorrentCount <= 0 && vm.ticketsCount <= 0) { + ele.css('display', 'none'); + } else { + ele.css('display', 'block'); + if (vm.ticketsCount > 0) { + ele.addClass('opened-tickets'); + } + } + } + + var badgeEle = $('.badge-class-admin-tickets'); + if (badgeEle) { + if (vm.ticketsCount > 0) { + badgeEle.css('display', 'block'); + badgeEle.addClass('badge_danger'); + badgeEle.html(vm.ticketsCount); + } + } + }); + } + }; + /** * getMustReadMessageContentMarked * @param m diff --git a/modules/core/client/less/home.less b/modules/core/client/less/home.less index ee978f96..113250ba 100644 --- a/modules/core/client/less/home.less +++ b/modules/core/client/less/home.less @@ -1,6 +1,9 @@ @import (reference) "../../../core/client/less/mt-var.less"; .navbar-nav { + .dropdown-toggle { + position: relative; + } .fa-class-revers { .fa-fw { color: #fafbfc; @@ -12,6 +15,32 @@ } } +.header-dot-class-admin { + display: none; + position: absolute; + width: 10px; + height: 10px; + top: 12px; + right: 25px; + border-radius: 50%; + border: solid 1px #fff; + &.new-torrent { + background-color: @brand-info; + } + &.opened-tickets { + background-color: @brand-danger !important; + } +} + +.badge-class-admin-torrents { + display: none; +} + +.badge-class-admin-tickets { + display: none; + top: 12px !important; +} + .home_notice { padding-top: 20px; .alert { diff --git a/modules/core/client/less/mt.less b/modules/core/client/less/mt.less index ddbf6761..c58bb2de 100644 --- a/modules/core/client/less/mt.less +++ b/modules/core/client/less/mt.less @@ -1471,7 +1471,7 @@ body { > li { > a { padding-left: 10px; - padding-right: 15px; + padding-right: 50px; } } } diff --git a/modules/core/client/services/menu.client.service.js b/modules/core/client/services/menu.client.service.js index f0419915..34436d58 100644 --- a/modules/core/client/services/menu.client.service.js +++ b/modules/core/client/services/menu.client.service.js @@ -62,7 +62,8 @@ divider: options.divider || false, faClass: options.faClass || null, faIcon: options.faIcon || null, - linkState: options.linkState || undefined + linkState: options.linkState || undefined, + shouldDotClass: options.shouldDotClass || undefined }); // Add submenu items @@ -98,7 +99,8 @@ divider: options.divider || false, faClass: options.faClass || null, faIcon: options.faIcon || null, - linkState: options.linkState || undefined + linkState: options.linkState || undefined, + shouldBadgeClass: options.shouldBadgeClass || undefined }); }); diff --git a/modules/core/client/views/header.client.view.html b/modules/core/client/views/header.client.view.html index f7625c77..6452ad99 100644 --- a/modules/core/client/views/header.client.view.html +++ b/modules/core/client/views/header.client.view.html @@ -1,5 +1,5 @@