Guest User

Untitled

a guest
Aug 30th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <tr *ngFor="let detail of userDetails" style="text-align:center">
  2. <td><input type="checkbox"></td>
  3. <td>{{detail.username}}</td>
  4. <td>{{detail.uemail}}</td>
  5. <td>Inactive</td>
  6. <td>{{detail.added_on}}</td>
  7. <td>
  8. <a routerLink="/dashboard-info/basic-settings">
  9. <i class="fas fa-edit" (click)="editIssue(i,detail._id)"></i>
  10. </a>
  11.  
  12. import { Component, OnInit } from '@angular/core';
  13. import { FormBuilder, FormGroup , Validators } from '@angular/forms';
  14. import { DataService } from '../../../services/data.service';
  15. import { AccountService } from '../../../services/account.service';
  16. import { Router } from '@angular/router';
  17.  
  18. @Component({
  19. selector: 'app-manage-users',
  20. templateUrl: './manage-users.component.html',
  21. styleUrls: ['./manage-users.component.css'],
  22. })
  23. export class ManageUsersComponent implements OnInit {
  24.  
  25. userDetails:any = [];
  26.  
  27. detail:Detail={
  28. added_on:'',
  29. username:'',
  30. uemail:'',
  31. upassword:'',
  32. };
  33. constructor(private router: Router,private fb:FormBuilder,private dataService: DataService, private accountService: AccountService) {}
  34.  
  35. editIssue(id,detail){
  36. alert(detail);
  37. let data = {
  38. _id:detail,
  39. };
  40. this.accountService.editDetail(data).subscribe(
  41. response => {
  42. console.log(response);
  43. this.userDetails = JSON.parse(response);
  44. //this.router.navigate(['/dashboard-info/basic-settings', this.userDetails]);
  45. },
  46. err => {
  47. console.error('User Not found');
  48. })
  49. }
  50.  
  51. ngOnInit() {}
  52. }
  53.  
  54. interface Detail{
  55. added_on:string
  56. username:string,
  57. upassword:string,
  58. uemail:string,
  59. }
  60.  
  61. editDetail(data) {//Getting User with userId
  62. return this.http.post(this.apiPath + 'user/editDetail', data,{responseType: 'text'});
  63. }
  64.  
  65. userRouter.post('/editDetail', function (req, res) {
  66. console.log(req.body._id);
  67.  
  68. Collections.user.findOne({_id: req.body._id}, function (err, result) {
  69. if (err) return res.status(500).send("There was a problem finding the user");
  70. if (result) {
  71. console.log(result);
  72. res.status(200).send(result);
  73. } else {
  74. return res.status(500).send("User Not Found with Details: " + JSON.stringify(user));
  75. }
  76. });
  77. });
Add Comment
Please, Sign In to add comment