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.

77 lines
2.8 KiB

  1. 'use strict';
  2. angular.module('app.user', ['ngRoute'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/user/:userid', {
  5. templateUrl: 'views/user/user.html',
  6. controller: 'UserCtrl'
  7. });
  8. }])
  9. .controller('UserCtrl', function($scope, $http, $routeParams) {
  10. $scope.user = {};
  11. $scope.likes = {};
  12. $http.get(urlapi + 'users/id/' + $routeParams.userid)
  13. .then(function(data, status, headers, config) {
  14. console.log('data success');
  15. console.log(data);
  16. $scope.user = data.data;
  17. }, function(data, status, headers, config) {
  18. console.log('data error');
  19. });
  20. $http.get(urlapi + 'users/id/likes/' + $routeParams.userid)
  21. .then(function(data, status, headers, config) {
  22. console.log('data success');
  23. console.log(data);
  24. $scope.likes = data.data;
  25. $scope.$broadcast('scroll.refreshComplete'); //refresher stop
  26. }, function(data, status, headers, config) {
  27. console.log('data error');
  28. $scope.$broadcast('scroll.refreshComplete'); //refresher stop
  29. });
  30. //delete user
  31. $scope.deleteUser = function() {
  32. console.log("delete user: " + $routeParams.userid);
  33. $http({
  34. url: urlapi + 'admin/users/id/' + $routeParams.userid,
  35. method: "DELETE"
  36. })
  37. .then(function(data) {
  38. window.location = "#!/main/";
  39. },
  40. function(data) { // optional
  41. // failed
  42. });
  43. };
  44. $scope.validateUser = function() {
  45. $http({
  46. url: urlapi + 'admin/users/validate/id/' + $routeParams.userid,
  47. method: "POST",
  48. data: {}
  49. })
  50. .then(function(data) {
  51. /*window.location = "#!/main/";*/
  52. $scope.user = data.data;
  53. },
  54. function(data) { // optional
  55. // failed
  56. });
  57. };
  58. $scope.unvalidateUser = function() {
  59. $http({
  60. url: urlapi + 'admin/users/unvalidate/id/' + $routeParams.userid,
  61. method: "POST",
  62. data: {}
  63. })
  64. .then(function(data) {
  65. /*window.location = "#!/main/";*/
  66. $scope.user = data.data;
  67. },
  68. function(data) { // optional
  69. // failed
  70. });
  71. };
  72. });