Guest User

Untitled

a guest
Apr 5th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. <div>
  2. <div class="row">
  3. <div class="input-field col s12">
  4. <i class="material-icons prefix">account_circle</i>
  5. <input type="text" #UserName ngModel name="UserName" placeholder="Username" required>
  6. </div>
  7. </div>
  8. <div class="row">
  9. <div class="input-field col s12">
  10. <i class="material-icons prefix">key</i>
  11. <input type="password" #Password ngModel name="Password" placeholder="Password" required>
  12. </div>
  13. </div>
  14. <div class="row">
  15. <div class="input-field col s12">
  16. <i class="material-icons prefix">account_circle</i>
  17. <input type="text" #Email ngModel name="Email" placeholder="Email" required>
  18. </div>
  19. </div>
  20. <div class="row">
  21. <div class="col s4">
  22. <p>
  23. <input #Blocked ngModel name="blocked" type="checkbox" id="blocked_check_create" >
  24. <label for="blocked_check_create">Blocked</label>
  25. </p>
  26. <p>
  27. <input #Activate ngModel name="activate" type="checkbox" id="activate_check_create">
  28. <label for="activate_check_create">Activate</label>
  29. </p>
  30. </div>
  31. <div class="col s8">
  32. <div class="input-field">
  33. <div class="input-field col s12">
  34. <select multiple #Authorities ngModel name="authorities" id="authorities">
  35. <option value="" disabled selected>Choose your option</option>
  36. <option *ngFor="let authority of athorities" value="{{ authority.id }}">{{ authority.name }}</option>
  37. </select>
  38. <label>Materialize Multiple Select</label>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43.  
  44. </div>
  45.  
  46. </div>
  47. <div class="modal-footer">
  48. <button class="modal-action modal-close waves-effect waves-green btn-flat" (click)="onCreate(UserName.value , Password.value ,Email.value, Blocked.checked, Activate.checked, Authorities.value)">
  49. Create
  50. </button>
  51. </div>
  52. </div>
  53.  
  54. onCreate(username : string , password : string , email : string, blocked : boolean , activate : boolean, authorities : any[]){
  55. this.userAdd.username = username;
  56. this.userAdd.password = password;
  57. this.userAdd.email = email;
  58. this.userAdd.blocked = blocked;
  59. this.userAdd.activate = activate;
  60.  
  61. authorities.forEach(obj => {
  62. this.authorityTemp.id = obj.id;
  63. this.authorityTemp.name = obj.name;
  64. this.authoritiesToAdd.push();
  65. })
  66.  
  67. this.userAdd.authorities = this.authoritiesToAdd;
  68. this.authorityTemp = null;
  69. this.authoritiesToAdd = null;
  70.  
  71. this.userService.addUser(this.userAdd);
  72. this.userAdd = null;
  73. }
  74.  
  75. addUser(user: User): Observable<User> {
  76. let headers = new HttpHeaders().set('Content-Type', 'application/json');
  77.  
  78. this.http.post(this.userAdd, user).subscribe((result) => {
  79. this.globalResponse = result;
  80. }, error => {
  81. //This is the part of the error
  82. console.log(error);
  83. }, () => {
  84. //This is the part of the success
  85. location.reload();
  86. });
  87. return;
  88. }
Add Comment
Please, Sign In to add comment