Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core'
  2. import { ProjectService } from '../../../service/project.service';
  3. import { Project } from '../../../shared/project.pojo'
  4. import { KeyValuePipe } from '../../../service/keyPipe'
  5. import {LoggedInCallback, UserLoginService, UserParametersService, Callback} from "../../../service/cognito.service";
  6. import {Router} from "@angular/router";
  7. declare var AWS: any;
  8. export class Parameters {
  9. name: string;
  10. value: string;
  11. Username:string;
  12. }
  13. @Component({
  14. selector: 'demo',
  15. templateUrl: 'addProject.html'
  16. })
  17. export class AddProjectComponent implements LoggedInCallback {
  18. public projects: Project[];
  19. public brands:any;
  20. public bookdatails:any;
  21. public name:any;
  22. public owner:any;
  23. public parameters: Array<Parameters> = [];
  24. public cognitoId: String;
  25. constructor(private ProjectService: ProjectService, public router: Router, public userService: UserLoginService, public userParams: UserParametersService) {
  26. this.userService.isAuthenticated(this);
  27. console.log("In MyProfileComponent");
  28. }
  29.  
  30.  
  31. addProject(name: any){
  32. if(!name){return;}
  33. this.ProjectService.addProject(
  34. this.name,
  35. this.owner // tutaj chcę aby przekazać "Username": "p0pasxdd@gmail.com"
  36. )
  37. .subscribe(brands => this.brands = brands)};
  38.  
  39.  
  40. isLoggedIn(message: string, isLoggedIn: boolean) {
  41. if (!isLoggedIn) {
  42. this.router.navigate(['/home/login']);
  43. } else {
  44. this.userParams.getParameters(new GetParametersCallback(this));
  45. }
  46. }
  47.  
  48. }
  49. export class GetParametersCallback implements Callback {
  50.  
  51. constructor(public me: AddProjectComponent) {
  52.  
  53. }
  54.  
  55. callback() {
  56.  
  57. }
  58.  
  59. callbackWithParam(result: any) {
  60.  
  61. for (let i = 0; i < result.length; i++) {
  62. let parameter = new Parameters();
  63. parameter.name = result[i].getName();
  64. parameter.value = result[i].getValue();
  65. this.me.parameters.push(parameter);
  66. }
  67.  
  68. let param = new Parameters()
  69. param.name = "cognito ID";
  70. param.value = AWS.config.credentials.params.IdentityId;
  71. param.Username = result.Username;
  72. this.me.parameters.push(param);
  73.  
  74. }
  75.  
  76. }
  77.  
  78. result to jest:
  79. {
  80. "UserAttributes": [{
  81. "Name": "sub",
  82. "Value": "a8a9f2e7-a39a-4c65-9dd7-292d21993153"
  83. }, {
  84. "Name": "email_verified",
  85. "Value": "true"
  86. }, {
  87. "Name": "nickname",
  88. "Value": "p0pas"
  89. }, {
  90. "Name": "email",
  91. "Value": "p0pasxdd@gmail.com"
  92. }],
  93. "Username": "p0pasxdd@gmail.com"
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement