feat(forums): global search from forum at home

This commit is contained in:
OldHawk
2018-01-26 10:51:29 +08:00
parent 48d1c18cfa
commit a51142dc4d
6 changed files with 55 additions and 4 deletions

View File

@@ -1172,6 +1172,8 @@
READ_ONLY_POST: '*** Readonly forum, cannot to post topic!',
READ_ONLY_REPLY: '*** Readonly topic, cannot to post reply!',
TITLE_READONLY: 'readonly',
TITLE_VIPONLY: 'vip only',
TITLE_OPERONLY: 'oper only',
TODAY_NEW_COUNT_ALL: '(Today: <mark class="text-danger">{{topic}}</mark> topics, <mark class="text-danger">{{reply}}</mark> replies)',
TODAY_NEW_COUNT_TOPIC: '(Today: <mark class="text-danger">{{topic}}</mark> topics)',
TODAY_NEW_COUNT_REPLY: '(Today: <mark class="text-danger">{{reply}}</mark> replies)',

View File

@@ -1172,6 +1172,8 @@
READ_ONLY_POST: '*** 只读版块,不能发表话题!',
READ_ONLY_REPLY: '*** 只读话题,不能发表回复!',
TITLE_READONLY: '只读',
TITLE_VIPONLY: 'vip 专区',
TITLE_OPERONLY: 'oper 专区',
TODAY_NEW_COUNT_ALL: '(今日: <mark class="text-danger">{{topic}}</mark> 话题, <mark class="text-danger">{{reply}}</mark> 回复)',
TODAY_NEW_COUNT_TOPIC: '(今日: <mark class="text-danger">{{topic}}</mark> 话题)',
TODAY_NEW_COUNT_REPLY: '(今日: <mark class="text-danger">{{reply}}</mark> 回复)',

View File

@@ -6,11 +6,11 @@
.controller('HomeController', HomeController);
HomeController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'TorrentsService', 'Notification', 'MeanTorrentConfig',
'getStorageLangService', 'DownloadService', '$timeout', 'localStorageService', 'TopicsService', 'TorrentGetInfoServices', 'DebugConsoleService',
'getStorageLangService', 'ForumsService', '$timeout', 'localStorageService', 'TopicsService', 'TorrentGetInfoServices', 'DebugConsoleService',
'marked'];
function HomeController($scope, $state, $translate, Authentication, TorrentsService, Notification, MeanTorrentConfig, getStorageLangService,
DownloadService, $timeout, localStorageService, TopicsService, TorrentGetInfoServices, mtDebug,
ForumsService, $timeout, localStorageService, TopicsService, TorrentGetInfoServices, mtDebug,
marked) {
var vm = this;
vm.appConfig = MeanTorrentConfig.meanTorrentConfig.app;
@@ -21,6 +21,45 @@
vm.searchType = 'torrents';
/**
* getForumList
*/
vm.getForumList = function () {
ForumsService.get({}, function (items) {
vm.forums = items.forumsList;
console.log(items);
});
};
/**
* doGlobalSearch
*/
vm.doGlobalSearch = function () {
if (vm.searchKeys) {
if (vm.searchType === 'forum') { //search from forum
var fid = [];
angular.forEach(vm.forums, function (f) {
fid.push(f._id);
});
$state.go('forums.search', {forumId: fid, keys: vm.searchKeys});
} else { //search from torrents
}
}
};
/**
* onSearchKeyDown
* @param evt
*/
vm.onSearchKeyDown = function (evt) {
if (evt.keyCode === 13 && vm.searchKeys) {
vm.doGlobalSearch();
}
};
/**
* getSaleNoticeMessage
* @returns {*}

View File

@@ -132,6 +132,11 @@
}
.vip-more {
text-shadow: 0 0 0.1em #3a3a3a,-0 -0 0.1em #3a3a3a;
&:hover {
a {
color: @brand-success;
}
}
}
@media (min-width: @screen-sm-min) {
display: table-cell;

View File

@@ -9,7 +9,7 @@
</div>
</div>
<div class="home_global_search">
<div class="home_global_search" ng-init="vm.getForumList()">
<div class="search-panel pagetop">
<div class="container">
<div class="col-sm-7">
@@ -25,7 +25,8 @@
<div class="input-group-btn">
<button class="btn btn-width-100 btn-search" id="search-button" aria-label="Search"
mouse-enter-toggle-class="btn-success" base-class="btn-default">
mouse-enter-toggle-class="btn-success" base-class="btn-default"
ng-click="vm.doGlobalSearch()">
{{'BTN_SEARCH' | translate}}
</button>
</div>

View File

@@ -28,6 +28,8 @@
<div class="forum-info">
<h4><a ui-sref="forums.view({ forumId: f._id})">{{f.name}}</a>
<small class="badge badge_default readonly" title="{{'FORUMS.TITLE_READONLY' | translate}}" ng-show="f.readOnly">R</small>
<small class="badge badge_default readonly" title="{{'FORUMS.TITLE_VIPONLY' | translate}}" ng-show="f.vipOnly">V</small>
<small class="badge badge_default readonly" title="{{'FORUMS.TITLE_OPERONLY' | translate}}" ng-show="f.operOnly">O</small>
<span class="today-new-count" ng-if="vm.getTodayNewCount(f);" ng-bind-html="vm.getTodayNewCount(f);"></span>
</h4>