5 Commits

34 changed files with 1119 additions and 49 deletions

20
package-lock.json generated
View File

@@ -16,7 +16,7 @@
"@angular/platform-browser": "^21.2.0",
"@angular/router": "^21.2.0",
"@angular/service-worker": "^21.2.0",
"@chatenium/chatenium-sdk": "^1.2.0",
"@chatenium/chatenium-sdk": "^1.2.2",
"@fortawesome/angular-fontawesome": "^4.0.0",
"@fortawesome/free-brands-svg-icons": "^7.1.0",
"@fortawesome/free-solid-svg-icons": "^7.1.0",
@@ -27,9 +27,11 @@
"@taiga-ui/addon-table": "^5.1.0",
"@taiga-ui/cdk": "^5.1.0",
"@taiga-ui/core": "^5.1.0",
"@taiga-ui/i18n": "^5.2.0",
"@taiga-ui/icons": "^5.1.0",
"@taiga-ui/kit": "^5.1.0",
"@taiga-ui/layout": "^5.1.0",
"libphonenumber-js": "^1.12.41",
"ngx-cookie-service": "^21.3.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
@@ -1011,9 +1013,9 @@
}
},
"node_modules/@chatenium/chatenium-sdk": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@chatenium/chatenium-sdk/-/chatenium-sdk-1.2.0.tgz",
"integrity": "sha512-myNvjsMbxRji6MEHufhgEbCmltLL+Azb2UUA+ovUDuf5+LcdYiLYcIF4A4/NAxRVYx3IcPB4uOVF2f5SqW2sLA==",
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@chatenium/chatenium-sdk/-/chatenium-sdk-1.2.2.tgz",
"integrity": "sha512-LVaw46XAf3gUXRtTjvUPA15SG+iqmOT9XFdeyc77X24vqv0f2IkvepnFqb/o3SVJ+7JRpibUx4QwnOmLy1enEg==",
"dependencies": {
"@faker-js/faker": "^10.4.0",
"axios": "^1.14.0",
@@ -4384,11 +4386,10 @@
"peer": true
},
"node_modules/@taiga-ui/i18n": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@taiga-ui/i18n/-/i18n-5.1.0.tgz",
"integrity": "sha512-NqCo1fK95w6aXHkvIZ3aqZOA2z+CnvD/eEEXZjbCs/Ik6QfWmGP8GbS5uwb7SzqNZz9QiVaJi5RNZtoInHf/tQ==",
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@taiga-ui/i18n/-/i18n-5.2.0.tgz",
"integrity": "sha512-dyjp5hqDR272EPX+aQVtCXKiFKEUggdf1Y/Gcdt4JGZ0WqYR5n5CjP1EoKRG3GQcgd1mCSXnAt2BQJpujGcaHw==",
"license": "Apache-2.0",
"peer": true,
"dependencies": {
"tslib": ">=2.8.1"
},
@@ -7061,8 +7062,7 @@
"version": "1.12.41",
"resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.12.41.tgz",
"integrity": "sha512-lsmMmGXBxXIK/VMLEj0kL6MtUs1kBGj1nTCzi6zgQoG1DEwqwt2DQyHxcLykceIxAnfE3hya7NuIh6PpC6S3fA==",
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/listr2": {
"version": "9.0.5",

View File

@@ -19,7 +19,7 @@
"@angular/platform-browser": "^21.2.0",
"@angular/router": "^21.2.0",
"@angular/service-worker": "^21.2.0",
"@chatenium/chatenium-sdk": "^1.2.0",
"@chatenium/chatenium-sdk": "^1.2.2",
"@fortawesome/angular-fontawesome": "^4.0.0",
"@fortawesome/free-brands-svg-icons": "^7.1.0",
"@fortawesome/free-solid-svg-icons": "^7.1.0",
@@ -30,9 +30,11 @@
"@taiga-ui/addon-table": "^5.1.0",
"@taiga-ui/cdk": "^5.1.0",
"@taiga-ui/core": "^5.1.0",
"@taiga-ui/i18n": "^5.2.0",
"@taiga-ui/icons": "^5.1.0",
"@taiga-ui/kit": "^5.1.0",
"@taiga-ui/layout": "^5.1.0",
"libphonenumber-js": "^1.12.41",
"ngx-cookie-service": "^21.3.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",

View File

@@ -1,5 +1,5 @@
{
"version": "Chatenium Nexum 3.0 Beta 8 (April 17, 2026)",
"version": "Chatenium Nexum 3.0 Beta 10 (April 27, 2026)",
"ok": "Ok",
"back": "Back",
"aChatProgram": "A messaging platform that you can trust.",
@@ -97,6 +97,62 @@
}
},
"chat": {
"userSettingsDialog": {
"label": "Settings",
"options": {
"security": "Privacy & Security",
"profile": "Profile",
"themes": "Themes",
"sessions": "Sessions",
"storage": "Data and Storage"
},
"security": {
"changePasswordDialog": {
"label": "Change password",
"labelSet": "Set password",
"labelRemove": "Remove password",
"warn": "After you change your password, you will be logged out of all your sessions.",
"currentPassword": "Current password",
"newPassword": "New password",
"newPasswordRepeat": "Repeat new password"
},
"changeEmailDialog": {
"label": "Change e-mail address",
"labelSet": "Set e-mail address",
"labelRemove": "Remove e-mail address",
"warn": "After you change your e-mail address, you will be logged out of all your sessions.",
"newMail": "New e-mail address",
"currentPassword": "Current password",
"oldCode": "Code sent to the old e-mail address",
"newCode": "Code sent to the new e-mail address"
},
"changePhoneDialog": {
"label": "Change phone number",
"labelSet": "Set phone number",
"labelRemove": "Remove phone number",
"warn": "After you change your phone number, you will be logged out of all your sessions.",
"newPhone": "New phone number",
"currentPassword": "Current password",
"oldCode": "Code sent to the old phone number",
"newCode": "Code sent to the new phone number"
},
"label": "Keep your account safe by using as much sign in methods as possible. Also check your credentials regularly to keep them up to date.",
"password": "Password",
"set": "Set",
"notSet": "Not set",
"changePassword": "Change password",
"phoneNumber": "Phone number",
"email": "E-mail address",
"removePassword": "Remove password",
"changePhone": "Change phone number",
"changeMail": "Change e-mail address",
"removePhone": "Remove phone number",
"removeMail": "Remove e-mail address",
"setPassword": "Set password",
"setPhone": "Set phone number",
"setMail": "Set e-mail address"
}
},
"tabBar": {
"tab1": "Chats",
"tab2": "Networks",
@@ -162,12 +218,7 @@
"changeLogDialog": {
"label": "Chatenium has been updated",
"changeLog": {
"1": "Optimized the loading of chats and networks",
"2": "Added skeleton loaders for messages inside DMs and channels",
"3": "Added tabs in networks",
"4": "Added option to edit network name",
"5": "Added option to change network visibility",
"6": "Fixed overflow issues in the mobile UI"
"1": "Fixed scrolling issues when sending or receiving new messages."
}
},
"chatnav": {

View File

@@ -6,6 +6,8 @@ import {routes} from './app.routes';
import {provideTranslateService} from '@ngx-translate/core';
import {provideTranslateHttpLoader} from '@ngx-translate/http-loader';
import {provideServiceWorker} from '@angular/service-worker';
import {tuiInputPhoneInternationalOptionsProvider} from '@taiga-ui/kit';
import {defer} from 'rxjs';
export const appConfig: ApplicationConfig = {
providers: [
@@ -25,6 +27,11 @@ export const appConfig: ApplicationConfig = {
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000'
})
}),
tuiInputPhoneInternationalOptionsProvider({
metadata: defer(async () =>
import('libphonenumber-js/max/metadata').then((m) => m.default),
),
}),
],
};

View File

@@ -3,11 +3,6 @@
<h3>{{ "version"|translate }}</h3>
<ul>
<li>{{ "chat.changeLogDialog.changeLog.1"|translate }}</li>
<li>{{ "chat.changeLogDialog.changeLog.2"|translate }}</li>
<li>{{ "chat.changeLogDialog.changeLog.3"|translate }}</li>
<li>{{ "chat.changeLogDialog.changeLog.4"|translate }}</li>
<li>{{ "chat.changeLogDialog.changeLog.5"|translate }}</li>
<li>{{ "chat.changeLogDialog.changeLog.6"|translate }}</li>
</ul>
<button tuiButton iconStart="@tui.check"
@@ -15,6 +10,10 @@
</button>
</ng-template>
<ng-template [(tuiDialog)]="userSettingsOpen" [tuiDialogOptions]="{closable: false, appearance: 'taiga big'}" class="user-settings">
<user-settings (close)="userSettingsOpen.set(false)"/>
</ng-template>
@if (serviceManager.currentSession() == null) {
<main style="width: 100%; height: 100svh; display: flex; justify-content: center; align-items: center;">
<tui-loader size="xl"/>
@@ -36,7 +35,7 @@
</button>
</tui-segmented>
<button id="bottom_btn" tuiButton appearance="flat" disabled>
<button id="bottom_btn" tuiButton [appearance]="userSettingsOpen() ? 'primary' : 'flat'" (click)="userSettingsOpen.set(true)">
<tui-icon icon="@tui.cog"/>
</button>
</aside>
@@ -90,6 +89,13 @@
<network-list [token]="serviceManager.currentSession()!.token"
[userid]="serviceManager.currentSession()!.userData.userid"></network-list>
}
@case (2) {
<app-picture-list [token]="serviceManager.currentSession()!.token"
[userid]="serviceManager.currentSession()!.userData.userid"></app-picture-list>
}
@case (3) {
<user-settings/>
}
}
</div>
@@ -110,10 +116,10 @@
</div>
}
@if (router.url.startsWith("/chat/dm")) {
@if (router.url.startsWith("/chat/dm") || router.url.startsWith("/chat/picture")) {
<!-- To ensure data is loaded -->
@defer (when serviceManager.chatsStatus() != LoadStatus.loading) {
<router-outlet (activate)="routerOutletActive.set(true)" (deactivate)="routerOutletActive.set(false)"/>
<router-outlet (activate)="routerOutletActive.set(true)" (deactivate)="routerOutletActive.set(false)"/>
}
} @else if (router.url.startsWith("/chat/network")) {
@defer (when serviceManager.networksStatus() != LoadStatus.loading) {

View File

@@ -85,3 +85,8 @@
}
}
}
::ng-deep tui-dialog[data-appearance~=big] {
height: 90svh;
width: 90svw !important;
}

View File

@@ -13,6 +13,9 @@ import {environment} from '../../environments/environment';
import {TuiTabBarComponent, TuiTabBarItem} from '@taiga-ui/addon-mobile';
import {NetworkList} from './network-list/network-list';
import {PictureList} from './picture-list/picture-list';
import {UserSettings} from './user-settings/user-settings';
import {AuthService} from '@chatenium/chatenium-sdk/services/authService';
import {UserService} from '@chatenium/chatenium-sdk/services/userService';
@Component({
selector: 'app-chat',
@@ -31,7 +34,8 @@ import {PictureList} from './picture-list/picture-list';
TuiTabBarComponent,
TuiTabBarItem,
NetworkList,
PictureList
PictureList,
UserSettings
],
templateUrl: './chat.html',
styleUrl: './chat.scss',
@@ -43,6 +47,7 @@ export class Chat implements OnInit {
router = inject(Router)
routerOutletActive = signal(false)
userSettingsOpen = signal(false)
navigationActiveIndex = 0
// Mobile navigation //
@@ -60,12 +65,12 @@ export class Chat implements OnInit {
{
text: "chat.tabBar.tab3",
icon: '@tui.image',
implemented: false,
implemented: true,
},
{
text: "chat.tabBar.tab4",
icon: '@tui.cog',
implemented: false,
implemented: true,
}
];
@@ -81,7 +86,19 @@ export class Chat implements OnInit {
this.indexedDb.openDatabase().then(async () => {
const session = await this.serviceManager.sessionManager.loadPreferredSession()
this.serviceManager.currentSession.set(session)
this.serviceManager.currentSessionHandler = new UserService(session.userData.userid, session.token, this.indexedDb.getApi())
await WebSocketHandler.getInstance().connect(session.userData.userid, session.token)
try {
console.log("Updating sessions...")
const sessions = await this.serviceManager.sessionManager.loadSessions()
console.log("Updating sessions: saved sessions loaded...")
await this.serviceManager.sessionManager.updateSessions(sessions)
const session = await this.serviceManager.sessionManager.loadPreferredSession()
console.log("Updating sessions succeeded: updating sessions...")
this.serviceManager.currentSession.set(session)
} catch (e) {
console.warn("Session update failed, skipping...", e)
}
})
setTimeout(() => {

View File

@@ -43,7 +43,6 @@ export class Dm implements OnInit {
async sendMessage(message: string, files: FileDataWithPreview[] | null) {
if (!files && message.trim() == "") return
this.scrollToBottom("smooth")
const session = this.serviceManager.currentSession();
if (session != null) {
@@ -102,14 +101,13 @@ export class Dm implements OnInit {
forwardedFromName: ""
}])
this.scrollToBottom("smooth")
const respMessage = await this.store.service.sendMessage(tempMsgId, message, null, null, files, <FileUploadProgressListener>{
fileProgressUpdate: (tempMsgId, fileId, allChunks, chunksDone) => {
this.uploadProgressUpdate(tempMsgId, fileId, allChunks, chunksDone)
}
})
this.updateTempMessage(tempMsgId, respMessage)
this.scrollToBottom("smooth")
}
}
@@ -126,13 +124,13 @@ export class Dm implements OnInit {
}
}
scrollToBottom(anim: 'instant' | 'smooth'): void {
restoreScrollState(): void {
setTimeout(() => {
const scrollContainer = <HTMLDivElement>document.querySelector("#scrollContainer")
scrollContainer.scroll({
top: this.store.messagesVm.scrollBarStatus() == -1 ? scrollContainer.scrollHeight : this.store.messagesVm.scrollBarStatus(),
left: 0,
behavior: anim
behavior: "instant"
});
if (this.store.messagesVm.scrollBarStatus() == -1) {
@@ -141,6 +139,17 @@ export class Dm implements OnInit {
}, 0)
}
scrollToBottom(anim: 'instant' | 'smooth'): void {
setTimeout(() => {
const scrollContainer = <HTMLDivElement>document.querySelector("#scrollContainer")
scrollContainer.scroll({
top: scrollContainer.scrollHeight,
left: 0,
behavior: anim
});
}, 0)
}
handleMessagesScroll(e: any) {
this.store.messagesVm.scrollBarStatus.set(e.target.scrollTop)
}
@@ -241,18 +250,18 @@ export class Dm implements OnInit {
const messagesCache = await currentStore.service.getQuick();
currentStore.messages.set(messagesCache);
this.store.messagesStatus.set(LoadStatus.updating)
this.scrollToBottom("instant")
this.restoreScrollState()
} catch (e) {
console.warn(`Cache load failed: ${e}. Skipping cache load...`)
}
const messages = await currentStore.service.get();
currentStore.messages.set(messages);
this.store.messagesStatus.set(LoadStatus.loaded)
this.scrollToBottom("instant")
this.restoreScrollState()
await currentStore.service.joinWebSocketRoom();
} else {
this.scrollToBottom("instant")
this.restoreScrollState()
}
});
}

View File

@@ -116,14 +116,13 @@ export class Text {
forwardedFromName: ""
}])
this.scrollToBottom("smooth")
const respMessage = await this.store.service.sendMessage(tempMsgId, message, null, null, files, <FileUploadProgressListener>{
fileProgressUpdate: (tempMsgId, fileId, allChunks, chunksDone) => {
this.uploadProgressUpdate(tempMsgId, fileId, allChunks, chunksDone)
}
})
this.updateTempMessage(tempMsgId, respMessage)
this.scrollToBottom("smooth")
}
}
@@ -141,7 +140,7 @@ export class Text {
}
}
scrollToBottom(anim: 'instant' | 'smooth'): void {
restoreScrollState() {
setTimeout(() => {
if (!this.store) {
return
@@ -150,7 +149,7 @@ export class Text {
scrollContainer.scroll({
top: this.store.messagesVm.scrollBarStatus() == -1 ? scrollContainer.scrollHeight : this.store.messagesVm.scrollBarStatus(),
left: 0,
behavior: anim
behavior: "instant"
});
if (this.store.messagesVm.scrollBarStatus() == -1) {
@@ -159,6 +158,17 @@ export class Text {
}, 0)
}
scrollToBottom(anim: 'instant' | 'smooth'): void {
setTimeout(() => {
const scrollContainer = <HTMLDivElement>document.querySelector("#scrollContainer")
scrollContainer.scroll({
top: scrollContainer.scrollHeight,
left: 0,
behavior: anim
});
}, 0)
}
handleMessagesScroll(e: any) {
if (!this.store) return
this.store.messagesVm.scrollBarStatus.set(e.target.scrollTop)
@@ -282,7 +292,7 @@ export class Text {
try {
const messagesCache = await currentStore.service.getQuick();
currentStore.messages.set(messagesCache);
this.scrollToBottom("instant")
this.restoreScrollState()
currentStore.messagesStatus.set(LoadStatus.updating)
} catch (e) {
console.warn(`Cache load failed: ${e}. Skipping cache load...`)
@@ -290,11 +300,11 @@ export class Text {
const messages = await currentStore.service.get();
currentStore.messages.set(messages);
currentStore.messagesStatus.set(LoadStatus.loaded)
this.scrollToBottom("instant")
this.restoreScrollState()
await currentStore.service.joinWebSocketRoom();
} else {
this.scrollToBottom("instant")
this.restoreScrollState()
}
});
}

View File

@@ -43,7 +43,7 @@ export class Network implements OnInit {
breakpoint = inject(TUI_BREAKPOINT)
router = inject(Router)
tabActiveIndex = 2
tabActiveIndex = 0
routerOutletActive = signal(false)

View File

@@ -0,0 +1,100 @@
<div class="option" [class.mobile]="breakpoint() == 'mobile'">
<ng-template [(tuiDialog)]="changeEmailDialogOpen"
[tuiDialogOptions]="{label: ('chat.userSettingsDialog.security.changeEmailDialog.'+ (changeEmailRemoveMode() ? 'labelRemove' : serviceManager.currentSession()!.userData.emailSet ? 'label' : 'labelSet'))|translate}">
<p>{{ "chat.userSettingsDialog.security.changeEmailDialog.warn"|translate }}</p>
@if (step() == 0) {
<form [formGroup]="changeEmailForm" style="display: flex; flex-direction: column; gap: 10px">
@if (!changeEmailRemoveMode()) {
<tui-textfield iconStart="@tui.mail">
<label
tuiLabel>{{ "chat.userSettingsDialog.security.changeEmailDialog.newMail"|translate }}</label>
<input formControlName="newAddress" tuiInput type="email">
</tui-textfield>
}
<tui-textfield iconStart="@tui.key">
<label tuiLabel>{{ "chat.userSettingsDialog.security.changeEmailDialog.currentPassword"|translate }}</label>
<input formControlName="currentPassword" tuiInput type="password">
</tui-textfield>
@if (changeEmailForm.controls['currentPassword'].dirty) {
@if (changeEmailForm.controls['currentPassword'].hasError("required")) {
<tui-error
[error]="'chat.userSettingsDialog.security.changeEmailDialog.errors.currentPasswordRequired'|translate"></tui-error>
}
@if (changeEmailForm.controls['currentPassword'].hasError("incorrect")) {
<tui-error
[error]="'chat.userSettingsDialog.security.changeEmailDialog.errors.incorrectPassword'|translate"></tui-error>
}
}
</form>
<footer>
<button tuiButton iconStart="@tui.check" [loading]="changeEmailPending()"
[disabled]="changeEmailPending()"
(click)="changeEmail(changeEmailForm.controls['currentPassword'].value, changeEmailForm.controls['newAddress'].value)">
{{ ('chat.userSettingsDialog.security.changeEmailDialog.' + (changeEmailRemoveMode() ? 'labelRemove' : serviceManager.currentSession()!.userData.passwordSet ? 'label' : 'labelSet'))|translate }}
</button>
</footer>
} @else {
<form style="display: flex; flex-direction: column; gap: 10px" [formGroup]="verifyEmailForm">
@if (serviceManager.currentSession()!.userData.emailSet) {
<tui-textfield iconStart="@tui.mail">
<label tuiLabel>{{ "chat.userSettingsDialog.security.changeEmailDialog.oldCode"|translate }}</label>
<input tuiInput type="number" [step]="1" formControlName="oldCode">
</tui-textfield>
}
@if (!changeEmailRemoveMode()) {
<tui-textfield iconStart="@tui.badge-plus">
<label tuiLabel>{{ "chat.userSettingsDialog.security.changeEmailDialog.newCode"|translate }}</label>
<input tuiInput type="number" [step]="1" formControlName="newCode">
</tui-textfield>
}
</form>
<footer>
<button tuiButton iconStart="@tui.check" [loading]="verifyEmailPending()"
[disabled]="verifyEmailForm.invalid || verifyEmailPending()"
(click)="verifyEmail(verifyEmailForm.controls['newCode'].value, verifyEmailForm.controls['oldCode'].value)">
{{ ('chat.userSettingsDialog.security.changeEmailDialog.' + (changeEmailRemoveMode() ? 'labelRemove' : serviceManager.currentSession()!.userData.passwordSet ? 'label' : 'labelSet'))|translate }}
</button>
</footer>
}
</ng-template>
<header>
<tui-icon icon="@tui.mail"/>
<span>{{ "chat.userSettingsDialog.security.email"|translate }}</span>
@if (serviceManager.currentSession()!.userData.emailSet) {
<div tuiBadge appearance="positive"
iconStart="@tui.check">{{ 'chat.userSettingsDialog.security.set'|translate }}
</div>
} @else {
<div tuiBadge appearance="negative"
iconStart="@tui.x">{{ 'chat.userSettingsDialog.security.notSet'|translate }}
</div>
}
</header>
<main>
<button tuiButton appearance="outline" (click)="openChangeEmailDialog(false)"
[iconStart]="serviceManager.currentSession()!.userData.emailSet ? '@tui.pencil' : '@tui.plus'">
@if (serviceManager.currentSession()!.userData.phoneSet) {
{{ "chat.userSettingsDialog.security.changeMail"|translate }}
} @else {
{{ "chat.userSettingsDialog.security.setMail"|translate }}
}
</button>
@if (serviceManager.currentSession()!.userData.emailSet) {
<button tuiButton appearance="outline" tuiAppearanceMode="invalid" iconStart="@tui.x" [disabled]="!serviceManager.currentSession()!.userData.phoneSet && !serviceManager.currentSession()!.userData.passwordSet"
(click)="openChangeEmailDialog(true)"
style="color: var(--tui-text-negative)">
{{ "chat.userSettingsDialog.security.removeMail"|translate }}
</button>
}
</main>
</div>

View File

@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Email } from './email';
describe('Email', () => {
let component: Email;
let fixture: ComponentFixture<Email>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Email],
}).compileComponents();
fixture = TestBed.createComponent(Email);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,112 @@
import {Component, inject, signal} from '@angular/core';
import {TranslatePipe} from '@ngx-translate/core';
import {TuiBadge, TuiButtonLoading, TuiInputNumber} from '@taiga-ui/kit';
import {
TUI_BREAKPOINT,
TuiButton,
TuiDialog,
TuiErrorComponent,
TuiIcon,
TuiInputDirective,
TuiLabel,
TuiTextfieldComponent
} from '@taiga-ui/core';
import {ServiceManager} from '../../../../service-manager';
import {
AbstractControl,
FormControl,
FormGroup,
ReactiveFormsModule,
ValidationErrors,
Validators
} from '@angular/forms';
@Component({
selector: 'user-settings-security-email',
imports: [
TranslatePipe,
TuiBadge,
TuiButton,
TuiIcon,
ReactiveFormsModule,
TuiButtonLoading,
TuiDialog,
TuiErrorComponent,
TuiInputDirective,
TuiLabel,
TuiTextfieldComponent,
TuiInputNumber,
],
templateUrl: './email.html',
styleUrl: './email.scss',
})
export class Email {
serviceManager = inject(ServiceManager)
breakpoint = inject(TUI_BREAKPOINT)
step = signal(0)
changeEmailDialogOpen = signal(false)
changeEmailRemoveMode = signal(false)
changeEmailPending = signal(false)
verifyEmailPending = signal(false)
newAddress = ""
changeEmailForm = new FormGroup({
newAddress: new FormControl(""),
currentPassword: new FormControl(""),
})
verifyEmailForm = new FormGroup({
oldCode: new FormControl(0),
newCode: new FormControl(0, {validators: [Validators.required]})
})
openChangeEmailDialog(modeRemove: boolean) {
this.changeEmailDialogOpen.set(true)
this.changeEmailRemoveMode.set(modeRemove)
this.changeEmailForm.controls["currentPassword"].clearValidators()
this.changeEmailForm.controls["newAddress"].clearValidators()
if (!modeRemove) {
this.changeEmailForm.controls["newAddress"].setValidators([Validators.required])
this.changeEmailForm.controls["newAddress"].updateValueAndValidity()
}
this.changeEmailForm.controls["currentPassword"].setValidators([Validators.required])
this.changeEmailForm.controls["currentPassword"].updateValueAndValidity()
}
async changeEmail(currentPassword: string | null, newMail: string | null) {
if (this.changeEmailRemoveMode()) {
newMail = "remove"
}
this.changeEmailPending.set(true)
const service = this.serviceManager.currentSessionHandler
if (service) {
try {
await service.changeEmail(newMail ?? "", currentPassword ?? "")
this.step.set(1)
this.newAddress = newMail ?? ""
if (!this.changeEmailRemoveMode()) {
this.verifyEmailForm.controls["oldCode"].setValidators([Validators.required])
}
} catch (e) {
this.changeEmailForm.controls["currentPassword"].setErrors({incorrect: true})
this.changeEmailPending.set(false)
}
}
}
async verifyEmail(newCode: number | null, oldCode: number | null) {
this.verifyEmailPending.set(true)
const service = this.serviceManager.currentSessionHandler
if (service) {
try {
await service.verifyEmailChange(oldCode ?? 0, newCode ?? 0, this.newAddress)
this.changeEmailDialogOpen.set(false)
} catch (e) {
this.verifyEmailForm.controls["newCode"].setErrors({incorrect: true})
this.verifyEmailPending.set(false)
}
}
}
}

View File

@@ -0,0 +1,81 @@
<div class="option" [class.mobile]="breakpoint() == 'mobile'">
<ng-template [(tuiDialog)]="changePasswordDialogOpen"
[tuiDialogOptions]="{label: ('chat.userSettingsDialog.security.changePasswordDialog.'+ (changePasswordRemoveMode() ? 'labelRemove' : serviceManager.currentSession()!.userData.passwordSet ? 'label' : 'labelSet'))|translate}">
<p>{{"chat.userSettingsDialog.security.changePasswordDialog.warn"|translate}}</p>
<form [formGroup]="changeEmailForm" style="display: flex; flex-direction: column; gap: 10px">
@if (serviceManager.currentSession()!.userData.passwordSet) {
<tui-textfield iconStart="@tui.key">
<label
tuiLabel>{{ "chat.userSettingsDialog.security.changePasswordDialog.currentPassword"|translate }}</label>
<input formControlName="currentPassword" tuiInput type="password">
</tui-textfield>
@if (changeEmailForm.controls['currentPassword'].dirty) {
@if (changeEmailForm.controls['currentPassword'].hasError("required")) {
<tui-error
[error]="'chat.userSettingsDialog.security.changePasswordDialog.errors.currentPasswordRequired'|translate"></tui-error>
}
@if (changeEmailForm.controls['currentPassword'].hasError("incorrect")) {
<tui-error
[error]="'chat.userSettingsDialog.security.changePasswordDialog.errors.incorrectPassword'|translate"></tui-error>
}
}
}
@if (!changePasswordRemoveMode()) {
<tui-textfield iconStart="@tui.badge-plus">
<label tuiLabel>{{ "chat.userSettingsDialog.security.changePasswordDialog.newPassword"|translate }}</label>
<input formControlName="newPassword" tuiInput type="password">
</tui-textfield>
<tui-textfield iconStart="@tui.badge-plus">
<label
tuiLabel>{{ "chat.userSettingsDialog.security.changePasswordDialog.newPasswordRepeat"|translate }}</label>
<input formControlName="newPasswordRepeat" tuiInput type="password">
</tui-textfield>
}
</form>
<footer>
<button tuiButton iconStart="@tui.check" [loading]="changePasswordPending()"
[disabled]="changeEmailForm.invalid || changePasswordPending()"
(click)="changePassword(changeEmailForm.controls['currentPassword'].value, changeEmailForm.controls['newPassword'].value)">
{{ ('chat.userSettingsDialog.security.changePasswordDialog.' + (changePasswordRemoveMode() ? 'labelRemove' : serviceManager.currentSession()!.userData.passwordSet ? 'label' : 'labelSet'))|translate }}
</button>
</footer>
</ng-template>
<header>
<tui-icon icon="@tui.key"/>
<span>{{ "chat.userSettingsDialog.security.password"|translate }}</span>
@if (serviceManager.currentSession()!.userData.passwordSet) {
<div tuiBadge appearance="positive"
iconStart="@tui.check">{{ 'chat.userSettingsDialog.security.set'|translate }}
</div>
} @else {
<div tuiBadge appearance="negative"
iconStart="@tui.x">{{ 'chat.userSettingsDialog.security.notSet'|translate }}
</div>
}
</header>
<main>
<button tuiButton appearance="outline" (click)="openChangePasswordDialog(false)"
[iconStart]="serviceManager.currentSession()!.userData.passwordSet ? '@tui.pencil' : '@tui.plus'">
@if (serviceManager.currentSession()!.userData.passwordSet) {
{{ "chat.userSettingsDialog.security.changePassword"|translate }}
} @else {
{{ "chat.userSettingsDialog.security.setPassword"|translate }}
}
</button>
@if (serviceManager.currentSession()!.userData.passwordSet) {
<button tuiButton appearance="outline" tuiAppearanceMode="invalid" iconStart="@tui.x" [disabled]="!serviceManager.currentSession()!.userData.phoneSet && !serviceManager.currentSession()!.userData.emailSet"
style="color: var(--tui-text-negative)" (click)="openChangePasswordDialog(true)">
{{ "chat.userSettingsDialog.security.removePassword"|translate }}
</button>
}
</main>
</div>

View File

@@ -0,0 +1,3 @@
:host {
width: 100%;
}

View File

@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Password } from './password';
describe('Password', () => {
let component: Password;
let fixture: ComponentFixture<Password>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Password],
}).compileComponents();
fixture = TestBed.createComponent(Password);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,93 @@
import {Component, inject, signal} from '@angular/core';
import {ServiceManager} from '../../../../service-manager';
import {
AbstractControl,
FormControl,
FormGroup,
FormsModule,
ReactiveFormsModule,
ValidationErrors,
Validators
} from '@angular/forms';
import {TranslatePipe} from '@ngx-translate/core';
import {TuiBadge, TuiButtonLoading} from '@taiga-ui/kit';
import {
TUI_BREAKPOINT,
TuiButton,
TuiDialog,
TuiErrorComponent,
TuiIcon,
TuiInputDirective,
TuiLabel,
TuiTextfieldComponent
} from '@taiga-ui/core';
@Component({
selector: 'user-settings-security-password',
imports: [
FormsModule,
ReactiveFormsModule,
TranslatePipe,
TuiBadge,
TuiButton,
TuiButtonLoading,
TuiDialog,
TuiErrorComponent,
TuiIcon,
TuiInputDirective,
TuiLabel,
TuiTextfieldComponent
],
templateUrl: './password.html',
styleUrl: './password.scss',
})
export class Password {
serviceManager = inject(ServiceManager)
breakpoint = inject(TUI_BREAKPOINT)
changePasswordDialogOpen = signal(false)
changePasswordRemoveMode = signal(false)
changePasswordPending = signal(false)
changeEmailForm = new FormGroup({
currentPassword: new FormControl(""),
newPassword: new FormControl(""),
newPasswordRepeat: new FormControl("")
}, {
validators: [(group) => this.chkPassMatch(group)]
})
openChangePasswordDialog(modeRemove: boolean) {
this.changePasswordDialogOpen.set(true)
this.changePasswordRemoveMode.set(modeRemove)
this.changeEmailForm.controls["currentPassword"].clearValidators()
this.changeEmailForm.controls["newPassword"].clearValidators()
this.changeEmailForm.controls["newPasswordRepeat"].clearValidators()
if (!modeRemove) {
this.changeEmailForm.controls["newPassword"].setValidators([Validators.required])
this.changeEmailForm.controls["newPasswordRepeat"].setValidators([Validators.required])
this.changeEmailForm.controls["newPassword"].updateValueAndValidity()
this.changeEmailForm.controls["newPasswordRepeat"].updateValueAndValidity()
}
this.changeEmailForm.controls["currentPassword"].setValidators([Validators.required])
this.changeEmailForm.controls["currentPassword"].updateValueAndValidity()
}
async changePassword(currentPassword: string | null, newPassword: string | null) {
this.changePasswordPending.set(true)
const service = this.serviceManager.currentSessionHandler
if (service) {
try {
await service.changePassword(newPassword ?? "", currentPassword ?? "")
} catch (e) {
this.changeEmailForm.controls["currentPassword"].setErrors({incorrect: true})
}
}
}
chkPassMatch(group: AbstractControl): ValidationErrors | null {
return this.changePasswordRemoveMode() ? null : group.value.newPassword == group.value.newPasswordRepeat
? null : {passMatchError: true};
}
}

View File

@@ -0,0 +1,99 @@
<div class="option" [class.mobile]="breakpoint() == 'mobile'">
<ng-template [(tuiDialog)]="changePhoneDialogOpen"
[tuiDialogOptions]="{label: ('chat.userSettingsDialog.security.changePhoneDialog.'+ (changePhoneRemoveMode() ? 'labelRemove' : serviceManager.currentSession()!.userData.phoneSet ? 'label' : 'labelSet'))|translate}">
<p>{{ "chat.userSettingsDialog.security.changePhoneDialog.warn"|translate }}</p>
@if (step() == 0) {
<form [formGroup]="changePhoneForm" style="display: flex; flex-direction: column; gap: 10px">
@if (!changePhoneRemoveMode()) {
<tui-textfield>
<label
tuiLabel>{{ "chat.userSettingsDialog.security.changePhoneDialog.newPhone"|translate }}</label>
<input formControlName="newNumber" tuiInputPhoneInternational [countrySearch]="true" [countries]="countries | tuiSortCountries" [(countryIsoCode)]="countryIsoCode">
</tui-textfield>
}
<tui-textfield iconStart="@tui.key">
<label tuiLabel>{{ "chat.userSettingsDialog.security.changePhoneDialog.currentPassword"|translate }}</label>
<input formControlName="currentPassword" tuiInput type="password">
</tui-textfield>
@if (changePhoneForm.controls['currentPassword'].dirty) {
@if (changePhoneForm.controls['currentPassword'].hasError("required")) {
<tui-error
[error]="'chat.userSettingsDialog.security.changePhoneDialog.errors.currentPasswordRequired'|translate"></tui-error>
}
@if (changePhoneForm.controls['currentPassword'].hasError("incorrect")) {
<tui-error
[error]="'chat.userSettingsDialog.security.changePhoneDialog.errors.incorrectPassword'|translate"></tui-error>
}
}
</form>
<footer>
<button tuiButton iconStart="@tui.check" [loading]="changePhonePending()"
[disabled]="changePhonePending()"
(click)="changePhone(changePhoneForm.controls['currentPassword'].value, changePhoneForm.controls['newNumber'].value)">
{{ ('chat.userSettingsDialog.security.changePhoneDialog.' + (changePhoneRemoveMode() ? 'labelRemove' : serviceManager.currentSession()!.userData.passwordSet ? 'label' : 'labelSet'))|translate }}
</button>
</footer>
} @else {
<form style="display: flex; flex-direction: column; gap: 10px" [formGroup]="verifyPhoneForm">
@if (serviceManager.currentSession()!.userData.phoneSet) {
<tui-textfield iconStart="@tui.phone">
<label tuiLabel>{{ "chat.userSettingsDialog.security.changePhoneDialog.oldCode"|translate }}</label>
<input tuiInput type="number" [step]="1" formControlName="oldCode">
</tui-textfield>
}
@if (!changePhoneRemoveMode()) {
<tui-textfield iconStart="@tui.badge-plus">
<label tuiLabel>{{ "chat.userSettingsDialog.security.changePhoneDialog.newCode"|translate }}</label>
<input tuiInput type="number" [step]="1" formControlName="newCode">
</tui-textfield>
}
</form>
<footer>
<button tuiButton iconStart="@tui.check" [loading]="verifyPhonePending()"
[disabled]="verifyPhoneForm.invalid || verifyPhonePending()"
(click)="verifyPhone(verifyPhoneForm.controls['newCode'].value, verifyPhoneForm.controls['oldCode'].value)">
{{ ('chat.userSettingsDialog.security.changePhoneDialog.' + (changePhoneRemoveMode() ? 'labelRemove' : serviceManager.currentSession()!.userData.passwordSet ? 'label' : 'labelSet'))|translate }}
</button>
</footer>
}
</ng-template>
<header>
<tui-icon icon="@tui.phone"/>
<span>{{ "chat.userSettingsDialog.security.phoneNumber"|translate }}</span>
@if (serviceManager.currentSession()!.userData.phoneSet) {
<div tuiBadge appearance="positive"
iconStart="@tui.check">{{ 'chat.userSettingsDialog.security.set'|translate }}
</div>
} @else {
<div tuiBadge appearance="negative"
iconStart="@tui.x">{{ 'chat.userSettingsDialog.security.notSet'|translate }}
</div>
}
</header>
<main>
<button tuiButton appearance="outline" (click)="openChangePhoneDialog(false)"
[iconStart]="serviceManager.currentSession()!.userData.phoneSet ? '@tui.pencil' : '@tui.plus'">
@if (serviceManager.currentSession()!.userData.phoneSet) {
{{ "chat.userSettingsDialog.security.changePhone"|translate }}
} @else {
{{ "chat.userSettingsDialog.security.setPhone"|translate }}
}
</button>
@if (serviceManager.currentSession()!.userData.phoneSet) {
<button [disabled]="!serviceManager.currentSession()!.userData.passwordSet && !serviceManager.currentSession()!.userData.emailSet" tuiButton appearance="outline" tuiAppearanceMode="invalid" iconStart="@tui.x" (click)="openChangePhoneDialog(true)"
style="color: var(--tui-text-negative)">
{{ "chat.userSettingsDialog.security.removePhone"|translate }}
</button>
}
</main>
</div>

View File

@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Phone } from './phone';
describe('Phone', () => {
let component: Phone;
let fixture: ComponentFixture<Phone>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Phone],
}).compileComponents();
fixture = TestBed.createComponent(Phone);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,111 @@
import {Component, inject, signal} from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
import {TranslatePipe} from '@ngx-translate/core';
import {TuiBadge, TuiButtonLoading, TuiInputPhoneInternationalComponent, TuiSortCountriesPipe} from '@taiga-ui/kit';
import {
TUI_BREAKPOINT,
TuiButton,
TuiDialog,
TuiErrorComponent,
TuiIcon,
TuiInputDirective,
TuiLabel,
TuiTextfieldComponent
} from '@taiga-ui/core';
import {ServiceManager} from '../../../../service-manager';
import {getCountries} from 'libphonenumber-js';
import {TuiCountryIsoCode} from '@taiga-ui/i18n';
@Component({
selector: 'user-settings-security-phone',
imports: [
ReactiveFormsModule,
TranslatePipe,
TuiBadge,
TuiButton,
TuiButtonLoading,
TuiDialog,
TuiErrorComponent,
TuiIcon,
TuiInputDirective,
TuiLabel,
TuiTextfieldComponent,
TuiInputPhoneInternationalComponent,
TuiSortCountriesPipe
],
templateUrl: './phone.html',
styleUrl: './phone.scss',
})
export class Phone {
protected readonly countries = getCountries();
protected countryIsoCode: TuiCountryIsoCode = 'HU';
breakpoint = inject(TUI_BREAKPOINT)
serviceManager = inject(ServiceManager)
step = signal(0)
changePhoneDialogOpen = signal(false)
changePhoneRemoveMode = signal(false)
changePhonePending = signal(false)
verifyPhonePending = signal(false)
newNumber = ""
changePhoneForm = new FormGroup({
newNumber: new FormControl(""),
currentPassword: new FormControl(""),
})
verifyPhoneForm = new FormGroup({
oldCode: new FormControl(0),
newCode: new FormControl(0, {validators: [Validators.required]})
})
openChangePhoneDialog(modeRemove: boolean) {
this.changePhoneDialogOpen.set(true)
this.changePhoneRemoveMode.set(modeRemove)
this.changePhoneForm.controls["currentPassword"].clearValidators()
this.changePhoneForm.controls["newNumber"].clearValidators()
if (!modeRemove) {
this.changePhoneForm.controls["newNumber"].setValidators([Validators.required])
this.changePhoneForm.controls["newNumber"].updateValueAndValidity()
}
this.changePhoneForm.controls["currentPassword"].setValidators([Validators.required])
this.changePhoneForm.controls["currentPassword"].updateValueAndValidity()
}
async changePhone(currentPassword: string | null, newNumber: string | null) {
if (this.changePhoneRemoveMode()) {
newNumber = "remove"
}
this.changePhonePending.set(true)
const service = this.serviceManager.currentSessionHandler
if (service) {
try {
await service.changePhoneNumber(currentPassword ?? "", newNumber ?? "")
this.step.set(1)
this.newNumber = newNumber ?? ""
if (!this.changePhoneRemoveMode()) {
this.verifyPhoneForm.controls["oldCode"].setValidators([Validators.required])
}
} catch (e) {
this.changePhoneForm.controls["currentPassword"].setErrors({incorrect: true})
this.changePhonePending.set(false)
}
}
}
async verifyPhone(newCode: number | null, oldCode: number | null) {
this.verifyPhonePending.set(true)
const service = this.serviceManager.currentSessionHandler
if (service) {
try {
await service.verifyPhoneNumberChange(this.newNumber, oldCode ?? 0, newCode ?? 0)
this.changePhoneDialogOpen.set(false)
} catch (e) {
this.verifyPhoneForm.controls["newCode"].setErrors({incorrect: true})
this.verifyPhonePending.set(false)
}
}
}
}

View File

@@ -0,0 +1,9 @@
<p>
<tui-icon icon="@tui.info"/>
{{ "chat.userSettingsDialog.security.label"|translate }}
</p>
<div id="options" tuiGroup orientation="vertical">
<user-settings-security-password style="overflow: hidden"/>
<user-settings-security-email style="overflow: hidden"/>
<user-settings-security-phone style="overflow: hidden"/>
</div>

View File

@@ -0,0 +1,45 @@
#options {
display: flex;
flex-direction: column;
::ng-deep .option {
width: 100%;
height: 60px;
background: var(--tui-background-base-alt);
padding: 15px;
display: grid;
grid-template-columns: 1fr 1fr;
align-items: center;
gap: 10px;
&.mobile {
grid-template-rows: 50px 50px;
grid-template-columns: 1fr;
height: 150px;
main {
display: flex;
justify-content: start;
flex-direction: column;
}
}
::ng-deep header {
display: flex;
gap: 5px;
align-items: center;
}
::ng-deep main {
display: flex;
align-items: center;
justify-content: end;
display: flex;
gap: 5px;
button {
height: 35px;
}
}
}
}

View File

@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Security } from './security';
describe('Security', () => {
let component: Security;
let fixture: ComponentFixture<Security>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Security],
}).compileComponents();
fixture = TestBed.createComponent(Security);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,43 @@
import {Component, inject, signal} from '@angular/core';
import {TuiButton, TuiDialog, TuiErrorComponent, TuiGroup, TuiIcon, TuiInputDirective} from '@taiga-ui/core';
import {TranslatePipe} from '@ngx-translate/core';
import {ServiceManager} from '../../../service-manager';
import {JsonPipe} from '@angular/common';
import {TuiBadge, TuiButtonLoading, TuiInputColor} from '@taiga-ui/kit';
import {
AbstractControl,
FormControl,
FormGroup,
ReactiveFormsModule,
ValidationErrors,
Validators
} from '@angular/forms';
import {Password} from './password/password';
import {Email} from './email/email';
import {Phone} from './phone/phone';
@Component({
selector: 'user-settings-security',
imports: [
TuiGroup,
TranslatePipe,
TuiIcon,
JsonPipe,
TuiBadge,
TuiButton,
TuiDialog,
ReactiveFormsModule,
TuiInputColor,
TuiInputDirective,
TuiButtonLoading,
TuiErrorComponent,
Password,
Email,
Phone
],
templateUrl: './security.html',
styleUrl: './security.scss',
})
export class Security {
serviceManager = inject(ServiceManager)
}

View File

@@ -0,0 +1,38 @@
<div id="layout" [class.mobile]="breakpoint() != 'desktopLarge'">
@if (breakpoint() == "desktopLarge" || selectedOption == "") {
<aside>
<header>
<tui-icon icon="@tui.cog"/>
<h2>{{ "chat.userSettingsDialog.label"|translate }}</h2>
@if (breakpoint() != "mobile") {
<button tuiButtonX (click)="close.emit()"></button>
}
</header>
<div id="options">
@for (option of options; track option) {
<button [disabled]="!option.implemented" tuiButton [iconStart]="'@tui.'+option.icon" [appearance]="selectedOption == option.name ? 'primary' : 'flat'" (click)="selectedOption = option.name">
{{"chat.userSettingsDialog.options."+option.name|translate}}
</button>
}
</div>
</aside>
}
@if (breakpoint() == "desktopLarge" || selectedOption != "") {
<main>
@if (breakpoint() != "desktopLarge") {
<div style="display: flex; align-items: center; gap: 1rem;">
<button tuiButton appearance="flat" iconStart="@tui.arrow-left" (click)="selectedOption = ''"></button>
<h3>{{"chat.userSettingsDialog.options."+selectedOption|translate}}</h3>
</div>
}
@switch (selectedOption) {
@case ("security") {
<user-settings-security/>
}
}
</main>
}
</div>

View File

@@ -0,0 +1,59 @@
#layout {
height: 100%;
width: 100%;
display: grid;
grid-template-columns: 300px 1fr;
&.mobile {
grid-template-columns: 1fr;
aside, main {
border-radius: 1.5rem;
background: transparent;
}
}
aside {
background-color: var(--tui-background-base-alt);
height: 100%;
width: 100%;
border-radius: 1.5rem 0 0 1.5rem;
header {
display: flex;
justify-content: center;
align-items: center;
gap: 5px;
position: relative;
tui-icon {
font-size: 35px;
}
button {
position: absolute;
right: 25px;
}
}
#options {
display: flex;
flex-direction: column;
gap: 1px;
padding: 15px;
button {
width: 100%;
display: flex;
justify-content: start;
}
}
}
main {
background: var(--tui-background-neutral-2);
width: 100%;
border-radius: 0 1.5rem 1.5rem 0;
padding: 15px;
}
}

View File

@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UserSettings } from './user-settings';
describe('UserSettings', () => {
let component: UserSettings;
let fixture: ComponentFixture<UserSettings>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [UserSettings],
}).compileComponents();
fixture = TestBed.createComponent(UserSettings);
component = fixture.componentInstance;
await fixture.whenStable();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,57 @@
import {Component, EventEmitter, inject, OnInit, Output} from '@angular/core';
import {TranslatePipe} from '@ngx-translate/core';
import {TUI_BREAKPOINT, TuiButton, TuiButtonX, TuiIcon} from '@taiga-ui/core';
import {Security} from './security/security';
@Component({
selector: 'user-settings',
imports: [
TranslatePipe,
TuiIcon,
TuiButtonX,
TuiButton,
Security
],
templateUrl: './user-settings.html',
styleUrl: './user-settings.scss',
})
export class UserSettings implements OnInit {
breakpoint = inject(TUI_BREAKPOINT)
@Output() close = new EventEmitter<void>()
selectedOption = "security"
options = [
{
icon: "shield",
name: "security",
implemented: true,
},
{
icon: "users",
name: "profile",
implemented: false,
},
{
icon: "paint-roller",
name: "themes",
implemented: false,
},
{
icon: "computer",
name: "sessions",
implemented: false,
},
{
icon: "hard-drive",
name: "storage",
implemented: false,
}
]
ngOnInit() {
if (this.breakpoint() != "desktopLarge") {
this.selectedOption = ""
}
}
}

View File

@@ -17,6 +17,8 @@ import {PictureService} from '@chatenium/chatenium-sdk/services/pictureService';
import {Album} from '@chatenium/chatenium-sdk/domain/pictureService.schema';
import {PublicUserData} from '@chatenium/chatenium-sdk/domain/common.schema';
import {MessagesViewModel} from './chat/elements/messages/messages-viewmodel';
import {AuthService} from '@chatenium/chatenium-sdk/services/authService';
import {UserService} from '@chatenium/chatenium-sdk/services/userService';
@Injectable({
providedIn: 'root',
@@ -28,6 +30,7 @@ export class ServiceManager {
sessionManager = new SessionManager(this.database.getApi(), this.keyring.getApi(), this.keyValue.getApi())
currentSession = signal<Session | null>(null)
currentSessionHandler: UserService | null = null
chatService: ChatService | null = null // Initialized in picture-list.ts
chatsStatus = signal<LoadStatus>(LoadStatus.loading)

View File

@@ -147,7 +147,7 @@ export class IndexedDB {
delete(storeName: string, key: string): Promise<void> {
return new Promise((resolve, reject) => {
if (this.db) {
const transaction = this.db.transaction([storeName], "readonly");
const transaction = this.db.transaction([storeName], "readwrite");
const store = transaction.objectStore(storeName);
const request = store.delete(key);

View File

@@ -1,5 +1,5 @@
export const environment = {
version: "3.0-beta8",
version: "3.0-beta10",
api_url: "http://localhost:3000",
cdn_url: "http://localhost:4000",
ws_url: "ws://localhost:3000",

View File

@@ -1,5 +1,5 @@
export const environment = {
version: "3.0-beta8",
version: "3.0-beta10",
api_url: "https://api.chatenium.hu",
cdn_url: "https://cdn.chatenium.hu",
ws_url: "wss://api.chatenium.hu",