Blame view
resources/js/ban/BansOverviewController.js
1.63 KB
e77200db5 Initial commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
angular.module('footyroom') .controller('BansOverviewController', ['$http', '$uibModal', function ($http, $uibModal) { const ctrl = this; var offset = 0; ctrl.sortBy = 'latestBan'; ctrl.setSort = setSort; ctrl.loadMore = loadMore; ctrl.getBans = getBans; ctrl.searchUser = searchUser; ctrl.getSummaries = getSummaries; getSummaries(); function getSummaries() { $http.get('/bans/summaries.json', { params: { sortBy: ctrl.sortBy, offset: offset, username: ctrl.username, }, }) .success(function (response) { if (offset > 0) { ctrl.summaries = ctrl.summaries.concat(response.data); } else { ctrl.summaries = response.data; } }); } function setSort(newSortBy) { if (ctrl.sortBy === newSortBy) { return; } offset = 0; ctrl.sortBy = newSortBy; getSummaries(); } function loadMore() { offset += 20; getSummaries(); } function getBans(userId) { $uibModal.open({ templateUrl: '/views/ng/modal/userBanList.html', controllerAs: 'ctrl', bindToController: true, controller: function () { $http.get('/bans.json', { params: { userId } }) .success((response) => { this.bans = response.data; }); }, }); } function searchUser() { offset = 0; getSummaries(); } }]); |