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.

92 lines
2.9 KiB

  1. 'use strict';
  2. angular.module('app.main', ['ngRoute'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/main', {
  5. templateUrl: 'views/main/main.html',
  6. controller: 'MainCtrl'
  7. });
  8. }])
  9. .controller('MainCtrl', function($scope, $rootScope, $http, toastr) {
  10. $rootScope.server = JSON.parse(localStorage.getItem("old_darkID_server"));
  11. $scope.generatingID = false;
  12. $scope.ids = [];
  13. $http.get(clientapi + 'ids')
  14. .then(function(data) {
  15. console.log('data success');
  16. console.log(data);
  17. $scope.ids = data.data;
  18. }, function(data) {
  19. console.log('data error');
  20. });
  21. $scope.newID = function() {
  22. $scope.generatingID = true;
  23. $http.get(clientapi + 'newid')
  24. .then(function(data) {
  25. console.log('data success');
  26. console.log(data);
  27. $scope.ids = data.data;
  28. $scope.generatingID = false;
  29. }, function(data) {
  30. console.log('data error');
  31. });
  32. };
  33. $scope.blindAndSendToSign = function(id) {
  34. $http.get(clientapi + 'blindandsendtosign/' + id)
  35. .then(function(data) {
  36. console.log('data success');
  37. console.log(data);
  38. $scope.ids = data.data;
  39. }, function(data) {
  40. console.log('data error');
  41. });
  42. };
  43. $scope.verify = function(id) {
  44. $http.get(clientapi + 'verify/' + id)
  45. .then(function(data) {
  46. console.log('data success');
  47. console.log(data);
  48. $scope.ids = data.data;
  49. }, function(data) {
  50. console.log('data error');
  51. });
  52. };
  53. $scope.clientApp = function(route, param) {
  54. $http.get(clientapi + route + '/' + param)
  55. .then(function(data) {
  56. console.log('data success');
  57. console.log(data);
  58. $scope.ids = data.data;
  59. }, function(data) {
  60. console.log('data error');
  61. });
  62. };
  63. $scope.addToBlockchain = function(id) {
  64. $http({
  65. url: 'http://127.0.0.1:3002/register',
  66. method: "POST",
  67. headers: {
  68. "Content-Type": undefined
  69. },
  70. data: {address: id}
  71. })
  72. .then(function(data) {
  73. //$scope.ids = data.data;
  74. toastr.success("added to blockchain");
  75. },
  76. function(data) {
  77. console.log(data);
  78. });
  79. };
  80. });