2017-05-04 17:49:33 +08:00
|
|
|
(function () {
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular
|
|
|
|
|
.module('forums')
|
|
|
|
|
.controller('ForumsController', ForumsController);
|
|
|
|
|
|
2017-07-05 17:01:59 +08:00
|
|
|
ForumsController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsService', 'SideOverlay', '$filter', 'NotifycationService',
|
2017-07-04 13:18:30 +08:00
|
|
|
'marked', 'ModalConfirmService'];
|
2017-05-04 17:49:33 +08:00
|
|
|
|
2017-07-05 17:01:59 +08:00
|
|
|
function ForumsController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsService, SideOverlay, $filter, NotifycationService,
|
2017-07-04 13:18:30 +08:00
|
|
|
marked, ModalConfirmService) {
|
2017-05-04 17:49:33 +08:00
|
|
|
var vm = this;
|
2017-07-03 18:15:11 +08:00
|
|
|
vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig;
|
2017-07-03 18:00:24 +08:00
|
|
|
vm.user = Authentication.user;
|
2017-05-04 17:49:33 +08:00
|
|
|
|
2017-07-08 10:17:20 +08:00
|
|
|
/**
|
|
|
|
|
* If user is not signed in then redirect back home
|
|
|
|
|
*/
|
|
|
|
|
if (!Authentication.user) {
|
|
|
|
|
$state.go('authentication.signin');
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-03 18:27:07 +08:00
|
|
|
/**
|
|
|
|
|
* init
|
|
|
|
|
*/
|
2017-05-04 17:49:33 +08:00
|
|
|
vm.init = function () {
|
2017-07-05 17:01:59 +08:00
|
|
|
ForumsService.query({}, function (items) {
|
2017-07-03 18:00:24 +08:00
|
|
|
vm.forums = items;
|
2017-07-04 11:42:47 +08:00
|
|
|
});
|
|
|
|
|
};
|
2017-07-04 11:51:02 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* getForumDesc
|
2017-07-05 10:02:50 +08:00
|
|
|
* @param f: forum
|
2017-07-04 11:51:02 +08:00
|
|
|
* @returns {*}
|
|
|
|
|
*/
|
|
|
|
|
vm.getForumDesc = function (f) {
|
|
|
|
|
if (f) {
|
|
|
|
|
return marked(f.desc, {sanitize: true});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-04 17:49:33 +08:00
|
|
|
}
|
|
|
|
|
}());
|