2020-10-12 05:50:10 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2020-02-16 16:15:07 +01:00
|
|
|
import { WebsocketService } from '../../services/websocket.service';
|
2020-03-23 18:52:08 +01:00
|
|
|
import { SeoService } from 'src/app/services/seo.service';
|
2020-07-18 07:59:12 +02:00
|
|
|
import { StateService } from 'src/app/services/state.service';
|
2020-08-10 09:59:29 +02:00
|
|
|
import { Observable } from 'rxjs';
|
2020-10-26 17:23:08 +01:00
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
2020-10-07 15:15:42 +02:00
|
|
|
import { ApiService } from 'src/app/services/api.service';
|
2020-10-07 18:30:45 +02:00
|
|
|
import { env } from '../../app.constants';
|
2020-10-09 08:56:43 +02:00
|
|
|
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
2020-10-11 13:17:36 +02:00
|
|
|
import { map } from 'rxjs/operators';
|
2019-07-21 16:59:47 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-about',
|
|
|
|
templateUrl: './about.component.html',
|
2020-08-10 09:59:29 +02:00
|
|
|
styleUrls: ['./about.component.scss'],
|
2019-07-21 16:59:47 +02:00
|
|
|
})
|
|
|
|
export class AboutComponent implements OnInit {
|
2020-08-12 08:33:58 +02:00
|
|
|
gitCommit$: Observable<string>;
|
2020-10-07 15:15:42 +02:00
|
|
|
donationForm: FormGroup;
|
2020-10-26 12:29:25 +01:00
|
|
|
paymentForm: FormGroup;
|
2020-10-07 15:15:42 +02:00
|
|
|
donationStatus = 1;
|
|
|
|
sponsors$: Observable<any>;
|
|
|
|
donationObj: any;
|
2020-10-07 18:30:45 +02:00
|
|
|
sponsorsEnabled = env.SPONSORS_ENABLED;
|
2020-10-08 12:51:10 +02:00
|
|
|
sponsors = null;
|
2019-07-21 16:59:47 +02:00
|
|
|
|
2019-07-26 11:48:32 +02:00
|
|
|
constructor(
|
2020-02-16 16:15:07 +01:00
|
|
|
private websocketService: WebsocketService,
|
2020-03-23 18:52:08 +01:00
|
|
|
private seoService: SeoService,
|
2020-07-18 07:59:12 +02:00
|
|
|
private stateService: StateService,
|
2020-10-07 15:15:42 +02:00
|
|
|
private formBuilder: FormBuilder,
|
|
|
|
private apiService: ApiService,
|
2020-10-09 08:56:43 +02:00
|
|
|
private sanitizer: DomSanitizer,
|
2019-07-26 11:48:32 +02:00
|
|
|
) { }
|
2019-07-21 16:59:47 +02:00
|
|
|
|
|
|
|
ngOnInit() {
|
2020-10-11 13:17:36 +02:00
|
|
|
this.gitCommit$ = this.stateService.gitCommit$.pipe(map((str) => str.substr(0, 8)));
|
2020-09-28 11:32:48 +02:00
|
|
|
this.seoService.setTitle('About');
|
2020-02-17 14:39:20 +01:00
|
|
|
this.websocketService.want(['blocks']);
|
2020-10-07 15:15:42 +02:00
|
|
|
|
|
|
|
this.donationForm = this.formBuilder.group({
|
2020-10-26 17:23:08 +01:00
|
|
|
amount: [0.01, [Validators.min(0.001), Validators.required]],
|
2020-10-07 15:15:42 +02:00
|
|
|
handle: [''],
|
|
|
|
});
|
|
|
|
|
2020-10-26 12:29:25 +01:00
|
|
|
this.paymentForm = this.formBuilder.group({
|
|
|
|
'method': 'chain'
|
|
|
|
});
|
|
|
|
|
2020-10-12 05:50:10 +02:00
|
|
|
this.apiService.getDonation$()
|
2020-10-08 12:51:10 +02:00
|
|
|
.subscribe((sponsors) => {
|
|
|
|
this.sponsors = sponsors;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.apiService.getDonation$()
|
2020-10-07 15:15:42 +02:00
|
|
|
this.stateService.donationConfirmed$.subscribe(() => this.donationStatus = 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
submitDonation() {
|
|
|
|
if (this.donationForm.invalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.apiService.requestDonation$(
|
|
|
|
this.donationForm.get('amount').value,
|
|
|
|
this.donationForm.get('handle').value
|
|
|
|
)
|
|
|
|
.subscribe((response) => {
|
|
|
|
this.websocketService.trackDonation(response.id);
|
|
|
|
this.donationObj = response;
|
|
|
|
this.donationStatus = 3;
|
|
|
|
});
|
|
|
|
}
|
2020-10-16 11:29:54 +02:00
|
|
|
|
|
|
|
bypassSecurityTrustUrl(text: string): SafeUrl {
|
|
|
|
return this.sanitizer.bypassSecurityTrustUrl(text);
|
|
|
|
}
|
2019-07-21 16:59:47 +02:00
|
|
|
}
|