diff --git a/userManagment/static/userManagment/userManagment.js b/userManagment/static/userManagment/userManagment.js index b25c5a400..39cbf5d6d 100755 --- a/userManagment/static/userManagment/userManagment.js +++ b/userManagment/static/userManagment/userManagment.js @@ -1686,8 +1686,59 @@ app.controller('listTableUsers', function ($scope, $http) { }; - $scope.controlUserState = function (state) { - alert(state); + $scope.controlUserState = function (userName, state) { + $scope.cyberpanelLoading = false; + + var url = "/users/controlUserState"; + + var data = { + accountUsername: userName, + state : state + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + $scope.cyberpanelLoading = true; + if (response.data.status === 1) { + $scope.populateCurrentRecords(); + new PNotify({ + title: 'Success!', + text: 'Action successfully started.', + type: 'success' + }); + + } else { + + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.cyberpanelLoading = false; + new PNotify({ + title: 'Error!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + + + } } }); diff --git a/userManagment/templates/userManagment/listUsers.html b/userManagment/templates/userManagment/listUsers.html index 470d78207..05271bf79 100755 --- a/userManagment/templates/userManagment/listUsers.html +++ b/userManagment/templates/userManagment/listUsers.html @@ -49,10 +49,10 @@ {% trans 'Suspend' %} + ng-click="controlUserState(record.name, 'SUSPEND')" title="">{% trans 'Suspend' %} {% trans 'Activate' %} + ng-click="controlUserState(record.name, 'ACTIVATE')" title="">{% trans 'Activate' %}