You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.4 KiB

4 years ago
  1. app.controller('PersonalController', function($scope, $cookieStore, $http, $filter, $modal) {
  2. if(typeof($cookieStore.get('user')) != "undefined"){
  3. $scope.user = $cookieStore.get('user');
  4. }
  5. $http({
  6. method: 'GET',
  7. url: serverURL+"/personals/",
  8. headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  9. }).success(function(data, status, headers, config) {
  10. if(data.success == "true"){
  11. $scope.list = data.personals;
  12. }else{
  13. modal = modalCreate($modal,"danger", "Error", "It has successfully made the connection but something went wrong");
  14. }
  15. }).error(function(data, status, headers, config) {
  16. modal = modalCreate($modal,"danger", "Error", "Not connected with server.");
  17. });
  18. $scope.removePersonal = function(personal){
  19. var basket = $cookieStore.get('basket');
  20. $http({
  21. method: 'POST',
  22. url: serverURL+"/personals/delete",
  23. data: {
  24. personal: personal,
  25. user: $scope.user
  26. },
  27. headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  28. }).success(function(data, status, headers, config) {
  29. if(data.success == "true"){
  30. var index = $scope.list.indexOf(personal)
  31. $scope.list.splice(index, 1);
  32. }else{
  33. modal = modalCreate($modal,"danger", "Error", "It has successfully made the connection but something went wrong");
  34. }
  35. }).error(function(data, status, headers, config) {
  36. modal = modalCreate($modal,"danger", "Error", "Not connected with server.");
  37. });
  38. };
  39. });