diff --git a/ClientApp/src/app/app.component.scss b/ClientApp/src/app/app.component.scss index a4add75..bade6fd 100644 --- a/ClientApp/src/app/app.component.scss +++ b/ClientApp/src/app/app.component.scss @@ -20,24 +20,11 @@ } } -// RTL & Font setup +// Application font * { - font-family: Vazir, system-ui, -apple-system, BlinkMacSystemFont, sans-serif; + font-family: Roboto, system-ui, -apple-system, BlinkMacSystemFont, sans-serif; } -// Material theme setup .mat-typography { - font-family: Vazir, system-ui, -apple-system, BlinkMacSystemFont, sans-serif; + font-family: Roboto, system-ui, -apple-system, BlinkMacSystemFont, sans-serif; } - -// Material Components RTL setup -[dir='rtl'] { - .mat-form-field-appearance-outline { - .mat-form-field-outline-start { - border-radius: 0 4px 4px 0; - } - .mat-form-field-outline-end { - border-radius: 4px 0 0 4px; - } - } -} \ No newline at end of file diff --git a/ClientApp/src/app/app.component.spec.ts b/ClientApp/src/app/app.component.spec.ts index 520887f..93cbb8a 100644 --- a/ClientApp/src/app/app.component.spec.ts +++ b/ClientApp/src/app/app.component.spec.ts @@ -1,7 +1,44 @@ import { ApiBaseSettings } from './environmets/ApiSettings'; +import { AuthenticationModel } from './environmets/AuthenticationModel'; describe('API configuration', () => { it('uses a same-origin API URL', () => { expect(new ApiBaseSettings().baseUrl).toBe('/api'); }); }); + +describe('AuthenticationModel', () => { + const authentication = new AuthenticationModel(); + + afterEach(() => localStorage.clear()); + + it('accepts a token that has not expired', () => { + authentication.Set(createToken(Math.floor(Date.now() / 1000) + 60), 'test-user'); + + expect(authentication.IsUserLogin()).toBeTrue(); + expect(authentication.GetUserName()).toBe('test-user'); + }); + + it('clears an expired token instead of keeping the user in a login loop', () => { + authentication.Set(createToken(Math.floor(Date.now() / 1000) - 60), 'test-user'); + + expect(authentication.IsUserLogin()).toBeFalse(); + expect(authentication.GetToken()).toBeNull(); + expect(authentication.GetUserName()).toBeNull(); + }); + + it('clears malformed tokens', () => { + authentication.Set('not-a-jwt', 'test-user'); + + expect(authentication.IsUserLogin()).toBeFalse(); + expect(authentication.GetToken()).toBeNull(); + }); +}); + +function createToken(exp: number): string { + const payload = btoa(JSON.stringify({ exp })) + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=+$/, ''); + return `header.${payload}.signature`; +} diff --git a/ClientApp/src/app/authentication/login/login.component.html b/ClientApp/src/app/authentication/login/login.component.html index 370f475..59cc56f 100644 --- a/ClientApp/src/app/authentication/login/login.component.html +++ b/ClientApp/src/app/authentication/login/login.component.html @@ -1,23 +1,24 @@ -
+
-
\ No newline at end of file +
diff --git a/ClientApp/src/app/authentication/register/register.component.html b/ClientApp/src/app/authentication/register/register.component.html index 0f69e74..fe89b0a 100644 --- a/ClientApp/src/app/authentication/register/register.component.html +++ b/ClientApp/src/app/authentication/register/register.component.html @@ -1,31 +1,31 @@ -
+
- ثبت نام + Create an account
- نام کاربری + Username - ایمیل + Email - رمز عبور + Password - تکرار رمز عبور - + Confirm password +
-
\ No newline at end of file +
diff --git a/ClientApp/src/app/components/add-note/add-note.component.html b/ClientApp/src/app/components/add-note/add-note.component.html index cd2dc6d..97deca5 100644 --- a/ClientApp/src/app/components/add-note/add-note.component.html +++ b/ClientApp/src/app/components/add-note/add-note.component.html @@ -2,25 +2,25 @@
- افزودن جزوه جدید + Create a note
- +
- - -
@@ -28,13 +28,13 @@
- - -
@@ -42,10 +42,10 @@
- -
@@ -53,7 +53,7 @@
-
@@ -64,7 +64,6 @@ class="editor-content" contenteditable="true" (input)="onEditorInput($event)" - dir="rtl" >
@@ -72,13 +71,13 @@ - لینک مرتبط - + Related link + - کلمات کلیدی + Keywords @@ -98,7 +97,7 @@
- +
cloud_upload - برای آپلود فایل کلیک کنید یا فایل را اینجا رها کنید + Click to upload files or drop them here
@@ -124,8 +123,8 @@
-
\ No newline at end of file +
diff --git a/ClientApp/src/app/components/add-note/add-note.component.ts b/ClientApp/src/app/components/add-note/add-note.component.ts index 700ece6..f6fad0f 100644 --- a/ClientApp/src/app/components/add-note/add-note.component.ts +++ b/ClientApp/src/app/components/add-note/add-note.component.ts @@ -76,7 +76,7 @@ export class AddNoteComponent implements OnInit { formatDoc(command: string) { if (command === 'createLink') { - const url = prompt('لطفاً URL را وارد کنید:'); + const url = prompt('Enter a URL:'); if (url) { document.execCommand(command, false, url); } @@ -125,7 +125,7 @@ export class AddNoteComponent implements OnInit { if (this.noteForm.valid) { if(this.searchWords.length == 0) { - this.showErrorMessage('کلمات کلیدی نمیتواند خالی باشد'); + this.showErrorMessage('Add at least one keyword.'); return; } this.loading = true; @@ -142,7 +142,6 @@ export class AddNoteComponent implements OnInit { formData.append('files', file); }); - // contentType parameter رو حذف کنید this.apiService.post(this.baseUrls.createNoteSettingItem, formData) .subscribe({ next: () => { @@ -159,20 +158,18 @@ export class AddNoteComponent implements OnInit { } private showSuccessMessage(): void { - this.snackBar.open('نوت با موفقیت ذخیره شد', 'باشه', { + this.snackBar.open('Note saved successfully.', 'OK', { duration: 3000, horizontalPosition: 'start', - direction: 'rtl', panelClass: 'success-snackbar' }); this.router.navigate(['note-list']) } - private showErrorMessage(errMsg:string='خطا در ذخیره نوت'): void { - this.snackBar.open(errMsg, 'تلاش مجدد', { + private showErrorMessage(errMsg:string='Could not save the note.'): void { + this.snackBar.open(errMsg, 'Try again', { duration: 5000, horizontalPosition: 'start', - direction: 'rtl', panelClass: 'error-snackbar' }); } diff --git a/ClientApp/src/app/components/home/home.component.html b/ClientApp/src/app/components/home/home.component.html index 8525fcd..5335aa0 100644 --- a/ClientApp/src/app/components/home/home.component.html +++ b/ClientApp/src/app/components/home/home.component.html @@ -7,24 +7,23 @@
-

نوت هاتو بزار جا ما

-

با قابلیت جست و جو توی جزوت میتونی

-

دنیارو بدست بیاری

+

Keep every idea within reach

+

Organize your notes and find anything in seconds.

+

Your knowledge, always ready when you need it.

-

به نوت کیپر خوش اومدی

+

Welcome to NoteKeeper

- در اینجا میتونی نوت هاتو نگه داری و توشون جست و جو کنی، فقط کافیه - از منو نوت جدید رو انتخاب کنی + Create categories, save detailed notes, attach files, and search your content whenever you need it.

-
\ No newline at end of file + diff --git a/ClientApp/src/app/components/home/home.component.scss b/ClientApp/src/app/components/home/home.component.scss index 72dd2e4..44181f6 100644 --- a/ClientApp/src/app/components/home/home.component.scss +++ b/ClientApp/src/app/components/home/home.component.scss @@ -4,7 +4,6 @@ position: relative; overflow: hidden; background: #f8f9fa; - direction: rtl; } .background-pattern { @@ -140,12 +139,6 @@ } } - // Add Persian/Arabic font support - @font-face { - font-family: 'Vazir'; - src: url('../../../assets/Vazir.woff2') format('woff2'); - } - :host { - font-family: 'Vazir', system-ui, -apple-system, sans-serif; - } \ No newline at end of file + font-family: Roboto, system-ui, -apple-system, sans-serif; + } diff --git a/ClientApp/src/app/components/newnote/newnote.component.html b/ClientApp/src/app/components/newnote/newnote.component.html index bfe3199..a6e5e37 100644 --- a/ClientApp/src/app/components/newnote/newnote.component.html +++ b/ClientApp/src/app/components/newnote/newnote.component.html @@ -2,8 +2,8 @@
- افزودن موضوع نوت - لطفاً اطلاعات نوت خود را وارد کنید + Create a category + Enter a name and an optional description. @@ -13,23 +13,23 @@ autocomplete="off"> - موضوع + Category name + placeholder="Enter a category name"> - موضوع اجباری است + A category name is required - موضوع باید حداقل ۳ حرف باشد + The category name must contain at least 3 characters - توضیحات + Description