Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core'
- import { ProjectService } from '../../../service/project.service';
- import { Project } from '../../../shared/project.pojo'
- import { KeyValuePipe } from '../../../service/keyPipe'
- import {LoggedInCallback, UserLoginService, UserParametersService, Callback} from "../../../service/cognito.service";
- import {Router} from "@angular/router";
- declare var AWS: any;
- export class Parameters {
- name: string;
- value: string;
- Username:string;
- }
- @Component({
- selector: 'demo',
- templateUrl: 'addProject.html'
- })
- export class AddProjectComponent implements LoggedInCallback {
- public projects: Project[];
- public brands:any;
- public bookdatails:any;
- public name:any;
- public owner:any;
- public parameters: Array<Parameters> = [];
- public cognitoId: String;
- constructor(private ProjectService: ProjectService, public router: Router, public userService: UserLoginService, public userParams: UserParametersService) {
- this.userService.isAuthenticated(this);
- console.log("In MyProfileComponent");
- }
- addProject(name: any){
- if(!name){return;}
- this.ProjectService.addProject(
- this.name,
- this.owner // tutaj chcę aby przekazać "Username": "p0pasxdd@gmail.com"
- )
- .subscribe(brands => this.brands = brands)};
- isLoggedIn(message: string, isLoggedIn: boolean) {
- if (!isLoggedIn) {
- this.router.navigate(['/home/login']);
- } else {
- this.userParams.getParameters(new GetParametersCallback(this));
- }
- }
- }
- export class GetParametersCallback implements Callback {
- constructor(public me: AddProjectComponent) {
- }
- callback() {
- }
- callbackWithParam(result: any) {
- for (let i = 0; i < result.length; i++) {
- let parameter = new Parameters();
- parameter.name = result[i].getName();
- parameter.value = result[i].getValue();
- this.me.parameters.push(parameter);
- }
- let param = new Parameters()
- param.name = "cognito ID";
- param.value = AWS.config.credentials.params.IdentityId;
- param.Username = result.Username;
- this.me.parameters.push(param);
- }
- }
- result to jest:
- {
- "UserAttributes": [{
- "Name": "sub",
- "Value": "a8a9f2e7-a39a-4c65-9dd7-292d21993153"
- }, {
- "Name": "email_verified",
- "Value": "true"
- }, {
- "Name": "nickname",
- "Value": "p0pas"
- }, {
- "Name": "email",
- "Value": "p0pasxdd@gmail.com"
- }],
- "Username": "p0pasxdd@gmail.com"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement