angular.module('footyroom').component('banWizard', { template: /* html */`
`, bindings: { userId: '<', dismiss: '&', }, /** * @param {ng.IHttpService} $http * @param {ng.ISCEService} $sce */ controller: ['$http', '$sce', function ($http, $sce) { const vm = this; vm.ban = ban; vm.permaban = permaban; vm.duration = '600'; vm.isLoading = true; $http.get('/bans/active-pagelet', { params: { userId: vm.userId, type: 'comment' } }) .then((response) => { vm.warning = $sce.trustAsHtml(response.data); }) .finally(() => { vm.isLoading = false; }); function ban() { confirm('/bans', { entity: 'user_id', value: vm.userId, type: 'comment', duration: vm.duration, }); } function permaban() { confirm('/bans/request-permaban', { userId: vm.userId, explanation: vm.explanation, }); } function confirm(action, data) { vm.isSaving = true; return $http.post(action, data) .then(() => vm.dismiss()) .catch((response) => { alert(response.data.errors); }) .finally(() => { vm.isSaving = false; }); } }], });