mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-20 22:01:50 +02:00
9
config/env/torrents.js
vendored
9
config/env/torrents.js
vendored
@@ -259,10 +259,11 @@ module.exports = {
|
||||
type: {
|
||||
name: 'TYPE',
|
||||
value: [
|
||||
{name: 'USER', value: 'user'},
|
||||
{name: 'SYSTEM', value: 'system'},
|
||||
{name: 'ADVERT', value: 'advert'},
|
||||
{name: 'NOTICE', value: 'notice'}
|
||||
{name: 'USER', value: 'user', role: 'user'},
|
||||
{name: 'SERVER', value: 'server', role: 'server'},
|
||||
{name: 'SYSTEM', value: 'system', role: 'admin'},
|
||||
{name: 'ADVERT', value: 'advert', role: 'admin'},
|
||||
{name: 'NOTICE', value: 'notice', role: 'admin'}
|
||||
]
|
||||
},
|
||||
checkUnreadInterval: 60 * 1000 * 2
|
||||
|
||||
@@ -854,6 +854,7 @@
|
||||
MESSAGE_TYPE_SYSTEM: 'System message',
|
||||
MESSAGE_TYPE_ADVERT: 'Advert message',
|
||||
MESSAGE_TYPE_NOTICE: 'Notice message',
|
||||
MESSAGE_TYPE_SERVER: 'Server message',
|
||||
MESSAGE_SEND_SUCCESSFULLY: 'Message send successfully',
|
||||
MESSAGE_SEND_FAILED: 'Message send failed',
|
||||
MESSAGE_DELETED_SUCCESSFULLY: 'Message deleted successfully',
|
||||
|
||||
@@ -854,6 +854,7 @@
|
||||
MESSAGE_TYPE_SYSTEM: '系统消息',
|
||||
MESSAGE_TYPE_ADVERT: '广告推送',
|
||||
MESSAGE_TYPE_NOTICE: '系统通知',
|
||||
MESSAGE_TYPE_SERVER: '服务器通知',
|
||||
MESSAGE_SEND_SUCCESSFULLY: '消息发送成功',
|
||||
MESSAGE_SEND_FAILED: '消息发送失败',
|
||||
MESSAGE_DELETED_SUCCESSFULLY: '消息删除成功',
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
vm.getCountUnread = function () {
|
||||
if (Authentication.user) {
|
||||
MessagesService.countUnread(function (data) {
|
||||
vm.unreadCount = data.countFrom + data.countTo + data.countAdmin;
|
||||
vm.unreadCount = data.countAll;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,16 +6,21 @@
|
||||
.controller('MessageController', MessageController);
|
||||
|
||||
MessageController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', '$filter', 'NotifycationService', '$stateParams', 'MessagesService',
|
||||
'MeanTorrentConfig', 'ModalConfirmService', 'marked', '$rootScope', 'AdminMessagesService', 'SideOverlay', '$interval'];
|
||||
'MeanTorrentConfig', 'ModalConfirmService', 'marked', '$rootScope', 'AdminMessagesService', 'SideOverlay', '$interval', 'uibButtonConfig',
|
||||
'DebugConsoleService'];
|
||||
|
||||
function MessageController($scope, $state, $translate, $timeout, Authentication, $filter, NotifycationService, $stateParams, MessagesService,
|
||||
MeanTorrentConfig, ModalConfirmService, marked, $rootScope, AdminMessagesService, SideOverlay, $interval) {
|
||||
MeanTorrentConfig, ModalConfirmService, marked, $rootScope, AdminMessagesService, SideOverlay, $interval, uibButtonConfig,
|
||||
mtDebug) {
|
||||
var vm = this;
|
||||
vm.messageConfig = MeanTorrentConfig.meanTorrentConfig.messages;
|
||||
vm.inputLengthConfig = MeanTorrentConfig.meanTorrentConfig.inputLength;
|
||||
vm.user = Authentication.user;
|
||||
vm.messageFields = {};
|
||||
vm.deleteList = [];
|
||||
vm.messageType = 'user';
|
||||
|
||||
uibButtonConfig.activeClass = 'btn-success';
|
||||
|
||||
/**
|
||||
* user-unread-count-changed
|
||||
@@ -105,6 +110,7 @@
|
||||
*/
|
||||
vm.figureOutItemsToDisplay = function () {
|
||||
vm.filteredItems = $filter('filter')(vm.messages, {
|
||||
type: vm.messageType,
|
||||
$: vm.search
|
||||
});
|
||||
vm.filteredItems = $filter('orderBy')(vm.filteredItems, ['-updatedat']);
|
||||
@@ -278,11 +284,38 @@
|
||||
vm.getCountUnread = function () {
|
||||
if (Authentication.user) {
|
||||
MessagesService.countUnread(function (data) {
|
||||
vm.unreadCount = data.countFrom + data.countTo + data.countAdmin;
|
||||
mtDebug.info(data);
|
||||
vm.unreadCountData = data;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* hasNewMessage
|
||||
* @param t
|
||||
*/
|
||||
vm.getNewMessageCount = function (t) {
|
||||
if (vm.unreadCountData) {
|
||||
switch (t) {
|
||||
case 'user':
|
||||
return (vm.unreadCountData.countFrom + vm.unreadCountData.countTo);
|
||||
break;
|
||||
case 'server':
|
||||
return vm.unreadCountData.countServer;
|
||||
break;
|
||||
case 'system':
|
||||
return vm.unreadCountData.countSystem;
|
||||
break;
|
||||
case 'advert':
|
||||
return vm.unreadCountData.countAdvert;
|
||||
break;
|
||||
case 'notice':
|
||||
return vm.unreadCountData.countNotice;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* isUnread
|
||||
* @param m
|
||||
|
||||
@@ -7,6 +7,26 @@
|
||||
.pagination-div-top {
|
||||
border-bottom: 2px solid lighten(@gray-base, 85%)
|
||||
}
|
||||
.message-type-group {
|
||||
position: relative;
|
||||
.btn {
|
||||
text-shadow: none !important;
|
||||
}
|
||||
.message-dot {
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
font-family: serif;
|
||||
padding: 0 5px;
|
||||
border: solid 1px #fff;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.btn-default .message-dot {
|
||||
background-color: #5bc0de;
|
||||
}
|
||||
.btn-success .message-dot {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.message-textarea {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<dt class="h-line">{{ 'MESSAGES_FIELD.TYPE' | translate}}</dt>
|
||||
<dd class="h-line">
|
||||
<select class="form-control" ng-model="vm.messageType">
|
||||
<option ng-repeat="t in vm.messageConfig.type.value" ng-if="t.value!='user'"
|
||||
<option ng-repeat="t in vm.messageConfig.type.value | filter:{role: 'admin'}"
|
||||
value="{{t.value}}">{{'MESSAGE_TYPE_'+t.name | translate}}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
@@ -5,14 +5,26 @@
|
||||
<div class="row margin-bottom-20">
|
||||
<div class="col-xs-12 col-md-9">
|
||||
<h4>{{'MESSAGES_BOX' | translate}}
|
||||
<small ng-show="vm.unreadCount>0"> - (<span
|
||||
class="badge badge_info">{{vm.unreadCount}}</span> {{'MESSAGES_FIELD.NEW_MSG' | translate}})
|
||||
<small ng-show="vm.unreadCountData.countAll>0"> - (<span
|
||||
class="badge badge_info">{{vm.unreadCountData.countAll}}</span> {{'MESSAGES_FIELD.NEW_MSG' | translate}})
|
||||
</small>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-3">
|
||||
<input class="form-control" type="text" ng-model="vm.search" placeholder="Search"
|
||||
ng-change="vm.figureOutItemsToDisplay()"/>
|
||||
ng-change="vm.buildPager()"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="margin-bottom-20">
|
||||
<div class="btn-group message-type-group">
|
||||
<label class="btn btn-default"
|
||||
ng-repeat="t in vm.messageConfig.type.value"
|
||||
ng-model="vm.messageType" uib-btn-radio="'{{t.value}}'"
|
||||
ng-click="vm.onMessageTypeBtnClick(); vm.buildPager();">
|
||||
{{'MESSAGE_TYPE_'+t.name | translate}}
|
||||
<span class="message-dot" ng-if="vm.getNewMessageCount(t.value)>0">{{vm.getNewMessageCount(t.value)}}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -76,7 +88,7 @@
|
||||
</td>
|
||||
<td class="td-v-middle text-center" ng-click="$event.stopPropagation();">
|
||||
<input type="checkbox" class="tcheckbox" ng-model="vm.selected[m._id]"
|
||||
id="checkbox_{{m._id}}" ng-show="m.type=='user'">
|
||||
id="checkbox_{{m._id}}" ng-if="m.type=='user'">
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -217,6 +217,7 @@ exports.countUnread = function (req, res) {
|
||||
|
||||
var countFrom = function (callback) {
|
||||
Message.count({
|
||||
type: 'user',
|
||||
from_user: req.user._id,
|
||||
from_status: 0
|
||||
}, function (err, count) {
|
||||
@@ -229,6 +230,7 @@ exports.countUnread = function (req, res) {
|
||||
};
|
||||
var countTo = function (callback) {
|
||||
Message.count({
|
||||
type: 'user',
|
||||
to_user: req.user._id,
|
||||
to_status: 0
|
||||
}, function (err, count) {
|
||||
@@ -239,8 +241,50 @@ exports.countUnread = function (req, res) {
|
||||
}
|
||||
});
|
||||
};
|
||||
var countAdminMessage = function (callback) {
|
||||
var countServer = function (callback) {
|
||||
Message.count({
|
||||
type: 'server',
|
||||
to_user: req.user._id,
|
||||
to_status: 0
|
||||
}, function (err, count) {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
} else {
|
||||
callback(null, count);
|
||||
}
|
||||
});
|
||||
};
|
||||
var countAdminSystemMessage = function (callback) {
|
||||
AdminMessage.count({
|
||||
type: 'system',
|
||||
createdat: {$gt: req.user.created},
|
||||
_readers: {$not: {$in: [req.user._id]}}
|
||||
|
||||
}, function (err, count) {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
} else {
|
||||
callback(null, count);
|
||||
}
|
||||
});
|
||||
};
|
||||
var countAdminAdvertMessage = function (callback) {
|
||||
AdminMessage.count({
|
||||
type: 'advert',
|
||||
createdat: {$gt: req.user.created},
|
||||
_readers: {$not: {$in: [req.user._id]}}
|
||||
|
||||
}, function (err, count) {
|
||||
if (err) {
|
||||
callback(err, null);
|
||||
} else {
|
||||
callback(null, count);
|
||||
}
|
||||
});
|
||||
};
|
||||
var countAdminNoticeMessage = function (callback) {
|
||||
AdminMessage.count({
|
||||
type: 'notice',
|
||||
createdat: {$gt: req.user.created},
|
||||
_readers: {$not: {$in: [req.user._id]}}
|
||||
|
||||
@@ -253,14 +297,18 @@ exports.countUnread = function (req, res) {
|
||||
});
|
||||
};
|
||||
|
||||
async.parallel([countFrom, countTo, countAdminMessage], function (err, results) {
|
||||
async.parallel([countFrom, countTo, countServer, countAdminSystemMessage, countAdminAdvertMessage, countAdminNoticeMessage], function (err, results) {
|
||||
if (err) {
|
||||
return res.status(422).send(err);
|
||||
} else {
|
||||
res.json({
|
||||
countAll: results[0] + results[1] + results[2] + results[3] + results[4] + results[5],
|
||||
countFrom: results[0],
|
||||
countTo: results[1],
|
||||
countAdmin: results[2]
|
||||
countServer: results[2],
|
||||
countSystem: results[3],
|
||||
countAdvert: results[4],
|
||||
countNotice: results[5]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ var AdminMessageSchema = new Schema({
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: 'user'
|
||||
default: 'system'
|
||||
},
|
||||
_readers: [{
|
||||
type: Schema.Types.ObjectId,
|
||||
|
||||
Reference in New Issue
Block a user