Made it load email on feedback form load

This commit is contained in:
piratefinn 2017-09-01 17:33:23 +01:00
parent 68cef62bde
commit 0aa6340454
5 changed files with 30 additions and 9 deletions

View file

@ -34,6 +34,7 @@ export class LoginComponent implements OnInit {
.subscribe(
result => {
console.log('Logged out!');
localStorage.clear();
}
);

View file

@ -11,8 +11,8 @@
<div class="form-group row">
<label class="col-md-3 form-control-label" for="text-input"><strong>Email</strong></label>
<div class="col-md-9">
<input type="text" class="form-control" formControlName="email" [(ngModel)]="loggedInEmail" [disabled]="noEmail">
<span class="help-block">Your email will load here.</span>
<input type="text" class="form-control" name="email" formControlName="email" placeholder="Enter Account Email Here" [(ngModel)]="loggedInEmail" [disabled]="noEmail">
<span class="help-block">Enter your email here if it doesn't show.</span>
</div>
</div>
<div class="form-group row">

View file

@ -10,7 +10,7 @@ import 'rxjs/add/operator/map';
})
export class FeedbackComponent {
feedbackForm: FormGroup;
loggedInEmail: any;
loggedInEmail: string;
noEmail: boolean = false;
username: any;
feedbackFormStatus: any;
@ -21,17 +21,36 @@ export class FeedbackComponent {
private formBuilder: FormBuilder,
private api: ApiService,
) {
this.loggedInEmail = localStorage.getItem('email');
if (this.loggedInEmail == null) {
this.noEmail = true;
}
this.feedbackForm = this.formBuilder.group({
email: ['', [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() {
this.api
.feedback(this.feedbackForm.value)

View file

@ -40,6 +40,7 @@ export class FullLayoutComponent implements OnInit {
.subscribe(
result => {
console.log('Logged out!');
localStorage.clear();
this.router.navigate(['/login']);
}
);