2021-10-28 20:34:48 +00:00
|
|
|
import { Inject, Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
|
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
|
|
import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms';
|
|
|
|
import {User} from '../user.model';
|
|
|
|
import {Owner} from '../owner.model';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-settings',
|
|
|
|
templateUrl: './settings.component.html',
|
|
|
|
styleUrls: ['/settings.component.css']
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SettingsComponent implements OnInit {
|
|
|
|
|
|
|
|
settingsForm: FormGroup;
|
|
|
|
owner: Owner;
|
2021-11-22 20:37:45 +00:00
|
|
|
coins = [
|
|
|
|
{
|
|
|
|
label: 'US Dollar',
|
|
|
|
symbol: 'usd'
|
|
|
|
},{
|
|
|
|
label: 'Euro',
|
|
|
|
symbol: 'eur'
|
|
|
|
},{
|
|
|
|
label: 'British Pound',
|
|
|
|
symbol: 'gbp'
|
|
|
|
},{
|
|
|
|
label: 'Canadian Dollar',
|
|
|
|
symbol: 'cad'
|
|
|
|
},{
|
|
|
|
label: 'Australian Dollar',
|
|
|
|
symbol: 'aud'
|
|
|
|
}
|
|
|
|
];
|
2021-10-28 20:34:48 +00:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private fb: FormBuilder,
|
|
|
|
private dialogRef: MatDialogRef<SettingsComponent>,
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data: Owner
|
|
|
|
) {
|
|
|
|
this.settingsForm = fb.group({
|
2021-11-22 20:37:45 +00:00
|
|
|
name: [data.name, Validators.required],
|
|
|
|
currency: [data.currency, Validators.required]
|
2021-10-28 20:34:48 +00:00
|
|
|
});
|
|
|
|
this.owner = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
}
|
|
|
|
|
|
|
|
close() {
|
|
|
|
this.dialogRef.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
save() {
|
|
|
|
this.owner.name = this.settingsForm.value.name;
|
2021-11-22 20:37:45 +00:00
|
|
|
this.owner.currency = this.settingsForm.value.currency;
|
2021-10-28 20:34:48 +00:00
|
|
|
this.dialogRef.close(this.owner);
|
|
|
|
}
|
|
|
|
}
|