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

@@ -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 {*}