Made it load email on feedback form load
This commit is contained in:
parent
68cef62bde
commit
0aa6340454
5 changed files with 30 additions and 9 deletions
|
@ -34,6 +34,7 @@ export class LoginComponent implements OnInit {
|
||||||
.subscribe(
|
.subscribe(
|
||||||
result => {
|
result => {
|
||||||
console.log('Logged out!');
|
console.log('Logged out!');
|
||||||
|
localStorage.clear();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-3 form-control-label" for="text-input"><strong>Email</strong></label>
|
<label class="col-md-3 form-control-label" for="text-input"><strong>Email</strong></label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" class="form-control" formControlName="email" [(ngModel)]="loggedInEmail" [disabled]="noEmail">
|
<input type="text" class="form-control" name="email" formControlName="email" placeholder="Enter Account Email Here" [(ngModel)]="loggedInEmail" [disabled]="noEmail">
|
||||||
<span class="help-block">Your email will load here.</span>
|
<span class="help-block">Enter your email here if it doesn't show.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|
|
@ -10,7 +10,7 @@ import 'rxjs/add/operator/map';
|
||||||
})
|
})
|
||||||
export class FeedbackComponent {
|
export class FeedbackComponent {
|
||||||
feedbackForm: FormGroup;
|
feedbackForm: FormGroup;
|
||||||
loggedInEmail: any;
|
loggedInEmail: string;
|
||||||
noEmail: boolean = false;
|
noEmail: boolean = false;
|
||||||
username: any;
|
username: any;
|
||||||
feedbackFormStatus: any;
|
feedbackFormStatus: any;
|
||||||
|
@ -21,17 +21,36 @@ export class FeedbackComponent {
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private api: ApiService,
|
private api: ApiService,
|
||||||
) {
|
) {
|
||||||
this.loggedInEmail = localStorage.getItem('email');
|
|
||||||
if (this.loggedInEmail == null) {
|
|
||||||
this.noEmail = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.feedbackForm = this.formBuilder.group({
|
this.feedbackForm = this.formBuilder.group({
|
||||||
email: ['', [Validators.required]],
|
email: ['', [Validators.required]],
|
||||||
feedbacktext: ['', [Validators.required]],
|
feedbacktext: ['', [Validators.required]],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
|
||||||
|
if(localStorage.getItem('email')) {
|
||||||
|
this.loggedInEmail = localStorage.getItem('email');
|
||||||
|
}
|
||||||
|
console.log('loggedInEmail: ' + this.loggedInEmail);
|
||||||
|
if (this.loggedInEmail) {
|
||||||
|
console.log('email not found in storage');
|
||||||
|
this.api.accountFullLoad().subscribe(
|
||||||
|
result => {
|
||||||
|
console.log(result);
|
||||||
|
this.feedbackForm.patchValue({
|
||||||
|
email: result.email,
|
||||||
|
});
|
||||||
|
this.api.setUserInfo( result.email, result.display_name );
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log( error._body );
|
||||||
|
this.noEmail = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.api
|
this.api
|
||||||
.feedback(this.feedbackForm.value)
|
.feedback(this.feedbackForm.value)
|
||||||
|
|
|
@ -40,6 +40,7 @@ export class FullLayoutComponent implements OnInit {
|
||||||
.subscribe(
|
.subscribe(
|
||||||
result => {
|
result => {
|
||||||
console.log('Logged out!');
|
console.log('Logged out!');
|
||||||
|
localStorage.clear();
|
||||||
this.router.navigate(['/login']);
|
this.router.navigate(['/login']);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -66,7 +66,7 @@ export class ApiService {
|
||||||
result.email,
|
result.email,
|
||||||
result.display_name
|
result.display_name
|
||||||
);
|
);
|
||||||
this.setUserType(result.user_type)
|
this.setUserType(result.user_type)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return login_event;
|
return login_event;
|
||||||
|
|
Reference in a new issue