diff --git a/src/app/UnlockService/unlock.service.spec.ts b/src/app/UnlockService/unlock.service.spec.ts new file mode 100644 index 0000000..220a688 --- /dev/null +++ b/src/app/UnlockService/unlock.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { UnlockService } from './unlock.service'; + +describe('UnlockService', () => { + let service: UnlockService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(UnlockService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/UnlockService/unlock.service.ts b/src/app/UnlockService/unlock.service.ts new file mode 100644 index 0000000..68ca718 --- /dev/null +++ b/src/app/UnlockService/unlock.service.ts @@ -0,0 +1,15 @@ +import { Injectable } from '@angular/core'; +import { Subject } from 'rxjs'; +@Injectable({ + providedIn: 'root' +}) +export class UnlockService { + + private unlockRequest = new Subject(); + + unlockRequest$ = this.unlockRequest.asObservable(); + + requestUnlock() { + this.unlockRequest.next(); + } +} diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index 3287300..83f5987 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -1,4 +1,4 @@ - + diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index e97e350..a4fd699 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -26,7 +26,7 @@ export class HomeComponent implements OnInit { words: number = 0; // Initialize the word count characters: number = 0; // Initialize the character count password: string = ''; - isPasswordIncorrect : boolean = false; + isPasswordIncorrect: boolean = false; constructor(private route: ActivatedRoute, private dialog: MatDialog) { this.routeId = this.route.snapshot.paramMap.get('id'); @@ -62,10 +62,13 @@ export class HomeComponent implements OnInit { // Listen for changes in a specific child ('text' in this case) onChildChanged(docRef, (snapshot) => { // console.log('Child changed:', snapshot.val()); - this.text = snapshot.val() || null; + if (snapshot.key === 'text') { + this.text = snapshot.val() || null; - // Update word and character counts - this.updateWordAndCharacterCount(); + // Update word and character counts + this.updateWordAndCharacterCount(); + } + }); } else { console.error('Route ID is null or undefined'); diff --git a/src/app/navigation/navigation.component.html b/src/app/navigation/navigation.component.html index 9fd9149..6793c16 100644 --- a/src/app/navigation/navigation.component.html +++ b/src/app/navigation/navigation.component.html @@ -2,7 +2,7 @@ NotePage
- - + diff --git a/src/app/password-input-dialog/password-input-dialog.component.ts b/src/app/password-input-dialog/password-input-dialog.component.ts index c2c5c51..0c27d44 100644 --- a/src/app/password-input-dialog/password-input-dialog.component.ts +++ b/src/app/password-input-dialog/password-input-dialog.component.ts @@ -1,12 +1,30 @@ -import { Component } from '@angular/core'; -import { MatDialogRef } from '@angular/material/dialog'; +import { Component, Input , Inject} from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { ActivatedRoute } from '@angular/router'; +import { UnlockService } from '../UnlockService/unlock.service'; @Component({ selector: 'app-password-input-dialog', templateUrl: './password-input-dialog.component.html', styleUrls: ['./password-input-dialog.component.css'] }) export class PasswordInputDialogComponent { + // @Input() password: string = ''; + passwordFieldType: string = 'password'; + showPasswordIcon: string = 'visibility'; + // @Input() + locked : boolean = false; + constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data : {locked : boolean,password : string},private passwordService: UnlockService) { + this.locked = data.locked; + this.password = data.password; + } - constructor(public dialogRef: MatDialogRef) {} + togglePasswordVisibility() { + this.passwordFieldType = this.passwordFieldType === 'password' ? 'text' : 'password'; + this.showPasswordIcon = this.showPasswordIcon === 'visibility' ? 'visibility_off' : 'visibility'; + } + unlock() { + // Call the unlock request when the "unlock" icon is clicked + this.passwordService.requestUnlock(); + } } diff --git a/src/app/redirection/redirection.component.html b/src/app/redirection/redirection.component.html index 7bbadf3..8e286a3 100644 --- a/src/app/redirection/redirection.component.html +++ b/src/app/redirection/redirection.component.html @@ -1,3 +1,3 @@ - +

redirection works!