change-key.component.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { OnInit } from '@angular/core';
  2. import { Component } from '@angular/core';
  3. import { Router } from '@angular/router';
  4. import { IonHeader, IonToolbar, IonTitle, IonContent, IonCard, IonCardContent, IonButton, IonCardHeader, IonCardTitle, IonCardSubtitle, ModalController, IonInput, IonItem, IonSegment, IonSegmentButton, IonLabel } from '@ionic/angular/standalone';
  5. import { CloudUser } from 'src/lib/ncloud';
  6. @Component({
  7. selector: 'app-change-key-edit',
  8. templateUrl: './change-key.component.html',
  9. styleUrls: ['./change-key.component.scss'],
  10. standalone: true,
  11. imports: [IonHeader, IonToolbar, IonTitle, IonContent,
  12. IonCard,IonCardContent,IonButton,IonCardHeader,IonCardTitle,IonCardSubtitle,
  13. IonInput,IonItem,
  14. IonSegment,IonSegmentButton,IonLabel
  15. ],
  16. })
  17. export class ChangeKeyComponent implements OnInit {
  18. currentUser:CloudUser|undefined
  19. userData:any = {}
  20. userDataChange(key:string,ev:any){
  21. let value = ev?.detail?.value
  22. if(value){
  23. this.userData[key] = value
  24. }
  25. }
  26. constructor(
  27. private router: Router,
  28. private modalCtrl:ModalController) {
  29. this.currentUser = new CloudUser();
  30. this.userData = this.currentUser.data;
  31. }
  32. ngOnInit() {}
  33. async save(){
  34. this.currentUser?.set(this.userData)
  35. await this.currentUser?.save()
  36. this.modalCtrl.dismiss(this.currentUser,"confirm")
  37. this.router.navigate(['/tabs/tab4'])
  38. }
  39. cancel(){
  40. this.modalCtrl.dismiss(null,"cancel")
  41. this.router.navigate(['/tabs/tab4'])
  42. }
  43. }