From 6a44634ecefcd320c40dd799c14e507270e2d6dc Mon Sep 17 00:00:00 2001 From: Milad Raeisi Date: Fri, 20 Sep 2024 09:51:49 +0400 Subject: [PATCH] Load all contact --- src/app/components/chat/chat.service.ts | 61 ++++++- src/app/components/chat/chat.types.ts | 31 +--- .../chat/chats/chats.component.html | 12 +- .../contact-info/contact-info.component.html | 69 +------ .../conversation/conversation.component.html | 9 +- .../chat/new-chat/new-chat.component.html | 9 +- .../chat/profile/profile.component.html | 5 +- .../settings/account/account.component.html | 168 ----------------- .../settings/account/account.component.ts | 71 -------- .../notifications.component.html | 156 ---------------- .../notifications/notifications.component.ts | 56 ------ .../plan-billing/plan-billing.component.html | 171 ------------------ .../plan-billing/plan-billing.component.ts | 108 ----------- .../settings/security/security.component.html | 123 ------------- .../settings/security/security.component.ts | 59 ------ .../error/settings/settings.component.html | 126 ------------- .../error/settings/settings.component.ts | 165 ----------------- .../pages/error/settings/settings.routes.ts | 9 - .../error/settings/team/team.component.html | 99 ---------- .../error/settings/team/team.component.ts | 130 ------------- 20 files changed, 91 insertions(+), 1546 deletions(-) delete mode 100644 src/app/components/pages/error/settings/account/account.component.html delete mode 100644 src/app/components/pages/error/settings/account/account.component.ts delete mode 100644 src/app/components/pages/error/settings/notifications/notifications.component.html delete mode 100644 src/app/components/pages/error/settings/notifications/notifications.component.ts delete mode 100644 src/app/components/pages/error/settings/plan-billing/plan-billing.component.html delete mode 100644 src/app/components/pages/error/settings/plan-billing/plan-billing.component.ts delete mode 100644 src/app/components/pages/error/settings/security/security.component.html delete mode 100644 src/app/components/pages/error/settings/security/security.component.ts delete mode 100644 src/app/components/pages/error/settings/settings.component.html delete mode 100644 src/app/components/pages/error/settings/settings.component.ts delete mode 100644 src/app/components/pages/error/settings/settings.routes.ts delete mode 100644 src/app/components/pages/error/settings/team/team.component.html delete mode 100644 src/app/components/pages/error/settings/team/team.component.ts diff --git a/src/app/components/chat/chat.service.ts b/src/app/components/chat/chat.service.ts index 814f034..8fa8443 100644 --- a/src/app/components/chat/chat.service.ts +++ b/src/app/components/chat/chat.service.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { Injectable, OnDestroy } from '@angular/core'; -import { BehaviorSubject, Observable, Subject, throwError, of } from 'rxjs'; +import { BehaviorSubject, Observable, Subject, throwError, of, Subscriber } from 'rxjs'; import { filter, map, switchMap, take, takeUntil, tap } from 'rxjs/operators'; import { DomSanitizer } from '@angular/platform-browser'; import { Chat, Contact, Profile } from 'app/components/chat/chat.types'; @@ -78,13 +78,62 @@ export class ChatService implements OnDestroy { * Fetch all contacts from the server */ getContacts(): Observable { - return this._httpClient.get('api/apps/chat/contacts').pipe( - tap((contacts: Contact[]) => { - this._contacts.next(contacts); - }) - ); + return new Observable((observer) => { + this._indexedDBService.getAllUsers() + .then((cachedContacts: Contact[]) => { + if (cachedContacts.length > 0) { + this._contacts.next(cachedContacts); + observer.next(cachedContacts); + } + + const pubkeys = cachedContacts.map(contact => contact.pubKey); + + if (pubkeys.length > 0) { + this.subscribeToRealTimeContacts(pubkeys, observer); + } + }) + .catch((error) => { + console.error('Error loading cached contacts:', error); + observer.error(error); + }); + + return () => { + // Cleanup logic if needed (for example, closing subscriptions) + }; + }); } + private subscribeToRealTimeContacts(pubkeys: string[], observer: Subscriber): void { + this._metadataService.fetchMetadataForMultipleKeys(pubkeys) + .then((metadataList: any[]) => { + metadataList.forEach((metadata) => { + const contact = this._contacts.value?.find(c => c.pubKey === metadata.pubkey); + if (contact) { + contact.displayName = metadata.name; + contact.picture = metadata.picture; + contact.about = metadata.about; + } else { + const updatedContacts = [...(this._contacts.value || []), { + pubKey: metadata.pubkey, + displayName: metadata.name, + picture: metadata.picture, + about: metadata.about + }]; + this._contacts.next(updatedContacts); + observer.next(updatedContacts); + } + }); + + observer.next(this._contacts.value || []); + }) + .catch((error) => { + console.error('Error fetching metadata for contacts:', error); + observer.error(error); + }); + } + + + /** * Fetch the profile metadata using the public key and subscribe to real-time updates */ diff --git a/src/app/components/chat/chat.types.ts b/src/app/components/chat/chat.types.ts index 285f9d7..c3cc0be 100644 --- a/src/app/components/chat/chat.types.ts +++ b/src/app/components/chat/chat.types.ts @@ -13,30 +13,17 @@ export interface Profile { } export interface Contact { - id?: string; - avatar?: string; + pubKey?: string; name?: string; + username?: string; + picture?: string; about?: string; - details?: { - emails?: { - email?: string; - label?: string; - }[]; - phoneNumbers?: { - country?: string; - phoneNumber?: string; - label?: string; - }[]; - title?: string; - company?: string; - birthday?: string; - address?: string; - }; - attachments?: { - media?: any[]; - docs?: any[]; - links?: any[]; - }; + displayName?: string; + website?: string; + banner?: string; + lud06?: string; + lud16?: string; + nip05?: string; } export interface Chat { diff --git a/src/app/components/chat/chats/chats.component.html b/src/app/components/chat/chats/chats.component.html index 14b9d30..12586e8 100644 --- a/src/app/components/chat/chats/chats.component.html +++ b/src/app/components/chat/chats/chats.component.html @@ -38,7 +38,8 @@ @if (profile.picture) { Profile picture } @@ -181,14 +182,15 @@ " > } - @if (chat.contact.avatar) { + @if (chat.contact.picture) { Contact avatar } - @if (!chat.contact.avatar) { + @if (!chat.contact.picture) {
diff --git a/src/app/components/chat/contact-info/contact-info.component.html b/src/app/components/chat/contact-info/contact-info.component.html index 8a5f2e1..03438d3 100644 --- a/src/app/components/chat/contact-info/contact-info.component.html +++ b/src/app/components/chat/contact-info/contact-info.component.html @@ -10,17 +10,18 @@
- +
- @if (chat.contact.avatar) { + @if (chat.contact.picture) { } - @if (!chat.contact.avatar) { + @if (!chat.contact.picture) {
@@ -34,62 +35,6 @@
-
- -
Media
-
- @for (media of chat.contact.attachments.media; track media) { - - } -
- -
-
Details
- @if (chat.contact.details.emails.length) { -
-
Email
-
- {{ chat.contact.details.emails[0].email }} -
-
- } - @if (chat.contact.details.phoneNumbers.length) { -
-
- Phone number -
-
- {{ - chat.contact.details.phoneNumbers[0].phoneNumber - }} -
-
- } - @if (chat.contact.details.title) { -
-
Title
-
{{ chat.contact.details.title }}
-
- } - @if (chat.contact.details.company) { -
-
Company
-
{{ chat.contact.details.company }}
-
- } - @if (chat.contact.details.birthday) { -
-
Birthday
-
{{ chat.contact.details.birthday }}
-
- } - @if (chat.contact.details.address) { -
-
Address
-
{{ chat.contact.details.address }}
-
- } -
-
+
diff --git a/src/app/components/chat/conversation/conversation.component.html b/src/app/components/chat/conversation/conversation.component.html index 16c5311..da59a66 100644 --- a/src/app/components/chat/conversation/conversation.component.html +++ b/src/app/components/chat/conversation/conversation.component.html @@ -45,14 +45,15 @@
- @if (chat.contact.avatar) { + @if (chat.contact.picture) { Contact avatar } - @if (!chat.contact.avatar) { + @if (!chat.contact.picture) {
diff --git a/src/app/components/chat/new-chat/new-chat.component.html b/src/app/components/chat/new-chat/new-chat.component.html index 0cac936..3ada97c 100644 --- a/src/app/components/chat/new-chat/new-chat.component.html +++ b/src/app/components/chat/new-chat/new-chat.component.html @@ -38,14 +38,15 @@
- @if (contact.avatar) { + @if (contact.picture) { Contact avatar } - @if (!contact.avatar) { + @if (!contact.picture) {
diff --git a/src/app/components/chat/profile/profile.component.html b/src/app/components/chat/profile/profile.component.html index fb50e46..e63fe09 100644 --- a/src/app/components/chat/profile/profile.component.html +++ b/src/app/components/chat/profile/profile.component.html @@ -30,8 +30,9 @@ @if (profile.picture) { } @if (!profile.picture) { diff --git a/src/app/components/pages/error/settings/account/account.component.html b/src/app/components/pages/error/settings/account/account.component.html deleted file mode 100644 index 55cba56..0000000 --- a/src/app/components/pages/error/settings/account/account.component.html +++ /dev/null @@ -1,168 +0,0 @@ -
- -
- -
-
Profile
-
- Following information is publicly displayed, be careful! -
-
-
- -
- - Name - - - -
- -
- - Username -
angortheme.com/
- -
-
- -
- - Title - - - -
- -
- - Company - - - -
- -
- - About - - -
- Brief description for your profile. Basic HTML and Emoji are - allowed. -
-
-
- - -
- - -
-
Personal Information
-
- Communication details in case we want to connect with you. These - will be kept private. -
-
-
- -
- - Email - - - -
- -
- - Phone - - - -
- -
- - Country - - - United States - Canada - Mexico - France - Germany - Italy - - -
- -
- - Language - - - English - French - Spanish - German - Italian - - -
-
- - -
- - -
- - -
-
-
diff --git a/src/app/components/pages/error/settings/account/account.component.ts b/src/app/components/pages/error/settings/account/account.component.ts deleted file mode 100644 index 6ba8b01..0000000 --- a/src/app/components/pages/error/settings/account/account.component.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { TextFieldModule } from '@angular/cdk/text-field'; -import { - ChangeDetectionStrategy, - Component, - OnInit, - ViewEncapsulation, -} from '@angular/core'; -import { - FormsModule, - ReactiveFormsModule, - UntypedFormBuilder, - UntypedFormGroup, - Validators, -} from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatOptionModule } from '@angular/material/core'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatIconModule } from '@angular/material/icon'; -import { MatInputModule } from '@angular/material/input'; -import { MatSelectModule } from '@angular/material/select'; - -@Component({ - selector: 'settings-account', - templateUrl: './account.component.html', - encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [ - FormsModule, - ReactiveFormsModule, - MatFormFieldModule, - MatIconModule, - MatInputModule, - TextFieldModule, - MatSelectModule, - MatOptionModule, - MatButtonModule, - ], -}) -export class SettingsAccountComponent implements OnInit { - accountForm: UntypedFormGroup; - - /** - * Constructor - */ - constructor(private _formBuilder: UntypedFormBuilder) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Lifecycle hooks - // ----------------------------------------------------------------------------------------------------- - - /** - * On init - */ - ngOnInit(): void { - // Create the form - this.accountForm = this._formBuilder.group({ - name: ['Display Name'], - username: ['brianh'], - title: ['Senior Frontend Developer'], - company: ['YXZ Software'], - about: [ - "Hey! This is Brian; husband, father and gamer. I'm mostly passionate about bleeding edge tech and chocolate! 🍫", - ], - email: ['hughes.brian@mail.com', Validators.email], - phone: ['121-490-33-12'], - country: ['usa'], - language: ['english'], - }); - } -} diff --git a/src/app/components/pages/error/settings/notifications/notifications.component.html b/src/app/components/pages/error/settings/notifications/notifications.component.html deleted file mode 100644 index 190dc4c..0000000 --- a/src/app/components/pages/error/settings/notifications/notifications.component.html +++ /dev/null @@ -1,156 +0,0 @@ -
- -
- -
Alerts
-
- -
-
-
Communication
-
- Get news, announcements, and product updates. -
-
- - -
- -
-
-
Security
-
- Get important notifications about your account security. -
-
- - -
- -
-
-
Meetups
-
- Get an email when a Meetup is posted close to my - location. -
-
- - -
-
- - -
- - -
Account Activity
-
Email me when:
-
- -
-
- someone comments on one of my items -
- - -
- -
-
- someone mentions me -
- - -
- -
-
- someone follows me -
- - -
- -
-
- someone replies to my job posting -
- - -
-
- - -
- - -
- - -
-
-
diff --git a/src/app/components/pages/error/settings/notifications/notifications.component.ts b/src/app/components/pages/error/settings/notifications/notifications.component.ts deleted file mode 100644 index 7d75b0f..0000000 --- a/src/app/components/pages/error/settings/notifications/notifications.component.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - ChangeDetectionStrategy, - Component, - OnInit, - ViewEncapsulation, -} from '@angular/core'; -import { - FormsModule, - ReactiveFormsModule, - UntypedFormBuilder, - UntypedFormGroup, -} from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatSlideToggleModule } from '@angular/material/slide-toggle'; - -@Component({ - selector: 'settings-notifications', - templateUrl: './notifications.component.html', - encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [ - FormsModule, - ReactiveFormsModule, - MatSlideToggleModule, - MatButtonModule, - ], -}) -export class SettingsNotificationsComponent implements OnInit { - notificationsForm: UntypedFormGroup; - - /** - * Constructor - */ - constructor(private _formBuilder: UntypedFormBuilder) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Lifecycle hooks - // ----------------------------------------------------------------------------------------------------- - - /** - * On init - */ - ngOnInit(): void { - // Create the form - this.notificationsForm = this._formBuilder.group({ - communication: [true], - security: [true], - meetups: [false], - comments: [false], - mention: [true], - follow: [true], - inquiry: [true], - }); - } -} diff --git a/src/app/components/pages/error/settings/plan-billing/plan-billing.component.html b/src/app/components/pages/error/settings/plan-billing/plan-billing.component.html deleted file mode 100644 index efe7a3c..0000000 --- a/src/app/components/pages/error/settings/plan-billing/plan-billing.component.html +++ /dev/null @@ -1,171 +0,0 @@ -
- -
- -
-
Change your plan
-
- Upgrade or downgrade your current plan. -
-
-
- -
- - Changing the plan will take effect immediately. You will be - charged for the rest of the current month. - -
- - @for (plan of plans; track trackByFn($index, plan)) { -
- @if (planRadioGroup.value === plan.value) { - - } -
{{ plan.label }}
-
- {{ plan.details }} -
-
-
- {{ - plan.price | currency: 'USD' : 'symbol' : '1.0' - }} - / month -
-
- } -
- - -
- - -
-
Payment Details
-
- Update your billing information. Make sure to set your location - correctly as it could affect your tax rates. -
-
-
- -
- - Card holder - - - -
- -
- - Card number - - - -
- -
- - Expiration date - - - -
- -
- - CVC / CVC2 - - - -
- -
- - Country - - - United States - Canada - Mexico - France - Germany - Italy - - -
- -
- - ZIP / Postal code - - - -
-
- - -
- - -
- - -
-
-
diff --git a/src/app/components/pages/error/settings/plan-billing/plan-billing.component.ts b/src/app/components/pages/error/settings/plan-billing/plan-billing.component.ts deleted file mode 100644 index 1495891..0000000 --- a/src/app/components/pages/error/settings/plan-billing/plan-billing.component.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { CurrencyPipe, NgClass } from '@angular/common'; -import { - ChangeDetectionStrategy, - Component, - OnInit, - ViewEncapsulation, -} from '@angular/core'; -import { - FormsModule, - ReactiveFormsModule, - UntypedFormBuilder, - UntypedFormGroup, -} from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatOptionModule } from '@angular/material/core'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatIconModule } from '@angular/material/icon'; -import { MatInputModule } from '@angular/material/input'; -import { MatRadioModule } from '@angular/material/radio'; -import { MatSelectModule } from '@angular/material/select'; -import { AngorAlertComponent } from '@angor/components/alert'; - -@Component({ - selector: 'settings-plan-billing', - templateUrl: './plan-billing.component.html', - encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [ - FormsModule, - ReactiveFormsModule, - AngorAlertComponent, - MatRadioModule, - NgClass, - MatIconModule, - MatFormFieldModule, - MatInputModule, - MatSelectModule, - MatOptionModule, - MatButtonModule, - CurrencyPipe, - ], -}) -export class SettingsPlanBillingComponent implements OnInit { - planBillingForm: UntypedFormGroup; - plans: any[]; - - /** - * Constructor - */ - constructor(private _formBuilder: UntypedFormBuilder) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Lifecycle hooks - // ----------------------------------------------------------------------------------------------------- - - /** - * On init - */ - ngOnInit(): void { - // Create the form - this.planBillingForm = this._formBuilder.group({ - plan: ['team'], - cardHolder: ['Display Name'], - cardNumber: [''], - cardExpiration: [''], - cardCVC: [''], - country: ['usa'], - zip: [''], - }); - - // Setup the plans - this.plans = [ - { - value: 'basic', - label: 'BASIC', - details: 'Starter plan for individuals.', - price: '10', - }, - { - value: 'team', - label: 'TEAM', - details: 'Collaborate up to 10 people.', - price: '20', - }, - { - value: 'enterprise', - label: 'ENTERPRISE', - details: 'For bigger businesses.', - price: '40', - }, - ]; - } - - // ----------------------------------------------------------------------------------------------------- - // @ Public methods - // ----------------------------------------------------------------------------------------------------- - - /** - * Track by function for ngFor loops - * - * @param index - * @param item - */ - trackByFn(index: number, item: any): any { - return item.id || index; - } -} diff --git a/src/app/components/pages/error/settings/security/security.component.html b/src/app/components/pages/error/settings/security/security.component.html deleted file mode 100644 index 7cca822..0000000 --- a/src/app/components/pages/error/settings/security/security.component.html +++ /dev/null @@ -1,123 +0,0 @@ -
- -
- -
-
Change your password
-
- You can only change your password twice within 24 hours! -
-
-
- -
- - Current password - - - -
- -
- - New password - - - -
- Minimum 8 characters. Must include numbers, letters and - special characters. -
-
-
- - -
- - -
-
Security preferences
-
- Keep your account more secure with following preferences. -
-
-
- -
-
-
- Enable 2-step authentication -
-
- Protects you against password theft by requesting an - authentication code via SMS on every login. -
-
- - -
- -
-
-
- Ask to change password on every 6 months -
-
- A simple but an effective way to be protected against - data leaks and password theft. -
-
- - -
-
- - -
- - -
- - -
-
-
diff --git a/src/app/components/pages/error/settings/security/security.component.ts b/src/app/components/pages/error/settings/security/security.component.ts deleted file mode 100644 index 175f67b..0000000 --- a/src/app/components/pages/error/settings/security/security.component.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { - ChangeDetectionStrategy, - Component, - OnInit, - ViewEncapsulation, -} from '@angular/core'; -import { - FormsModule, - ReactiveFormsModule, - UntypedFormBuilder, - UntypedFormGroup, -} from '@angular/forms'; -import { MatButtonModule } from '@angular/material/button'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatIconModule } from '@angular/material/icon'; -import { MatInputModule } from '@angular/material/input'; -import { MatSlideToggleModule } from '@angular/material/slide-toggle'; - -@Component({ - selector: 'settings-security', - templateUrl: './security.component.html', - encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [ - FormsModule, - ReactiveFormsModule, - MatFormFieldModule, - MatIconModule, - MatInputModule, - MatSlideToggleModule, - MatButtonModule, - ], -}) -export class SettingsSecurityComponent implements OnInit { - securityForm: UntypedFormGroup; - - /** - * Constructor - */ - constructor(private _formBuilder: UntypedFormBuilder) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Lifecycle hooks - // ----------------------------------------------------------------------------------------------------- - - /** - * On init - */ - ngOnInit(): void { - // Create the form - this.securityForm = this._formBuilder.group({ - currentPassword: [''], - newPassword: [''], - twoStep: [true], - askPasswordChange: [false], - }); - } -} diff --git a/src/app/components/pages/error/settings/settings.component.html b/src/app/components/pages/error/settings/settings.component.html deleted file mode 100644 index 963e198..0000000 --- a/src/app/components/pages/error/settings/settings.component.html +++ /dev/null @@ -1,126 +0,0 @@ -
- - - - -
- -
- Settings -
- -
- -
-
- -
- @for (panel of panels; track trackByFn($index, panel)) { -
- -
-
- {{ panel.title }} -
-
- {{ panel.description }} -
-
-
- } -
-
- - - - -
- -
- - - - -
- {{ getPanelInfo(selectedPanel).title }} -
-
- - -
- @switch (selectedPanel) { - - @case ('account') { - - } - - @case ('security') { - - } - - @case ('plan-billing') { - - } - - @case ('notifications') { - - } - - @case ('team') { - - } - } -
-
-
-
-
diff --git a/src/app/components/pages/error/settings/settings.component.ts b/src/app/components/pages/error/settings/settings.component.ts deleted file mode 100644 index 6bce8d9..0000000 --- a/src/app/components/pages/error/settings/settings.component.ts +++ /dev/null @@ -1,165 +0,0 @@ -import { NgClass } from '@angular/common'; -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - OnDestroy, - OnInit, - ViewChild, - ViewEncapsulation, -} from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; -import { MatIconModule } from '@angular/material/icon'; -import { MatDrawer, MatSidenavModule } from '@angular/material/sidenav'; -import { AngorMediaWatcherService } from '@angor/services/media-watcher'; -import { Subject, takeUntil } from 'rxjs'; -import { SettingsAccountComponent } from './account/account.component'; -import { SettingsNotificationsComponent } from './notifications/notifications.component'; -import { SettingsPlanBillingComponent } from './plan-billing/plan-billing.component'; -import { SettingsSecurityComponent } from './security/security.component'; -import { SettingsTeamComponent } from './team/team.component'; - -@Component({ - selector: 'settings', - templateUrl: './settings.component.html', - encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [ - MatSidenavModule, - MatButtonModule, - MatIconModule, - NgClass, - SettingsAccountComponent, - SettingsSecurityComponent, - SettingsPlanBillingComponent, - SettingsNotificationsComponent, - SettingsTeamComponent, - ], -}) -export class SettingsComponent implements OnInit, OnDestroy { - @ViewChild('drawer') drawer: MatDrawer; - drawerMode: 'over' | 'side' = 'side'; - drawerOpened: boolean = true; - panels: any[] = []; - selectedPanel: string = 'account'; - private _unsubscribeAll: Subject = new Subject(); - - /** - * Constructor - */ - constructor( - private _changeDetectorRef: ChangeDetectorRef, - private _angorMediaWatcherService: AngorMediaWatcherService - ) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Lifecycle hooks - // ----------------------------------------------------------------------------------------------------- - - /** - * On init - */ - ngOnInit(): void { - // Setup available panels - this.panels = [ - { - id: 'account', - icon: 'heroicons_outline:user-circle', - title: 'Account', - description: - 'Manage your public profile and private information', - }, - { - id: 'security', - icon: 'heroicons_outline:lock-closed', - title: 'Security', - description: - 'Manage your password and 2-step verification preferences', - }, - { - id: 'plan-billing', - icon: 'heroicons_outline:credit-card', - title: 'Plan & Billing', - description: - 'Manage your subscription plan, payment method and billing information', - }, - { - id: 'notifications', - icon: 'heroicons_outline:bell', - title: 'Notifications', - description: "Manage when you'll be notified on which channels", - }, - { - id: 'team', - icon: 'heroicons_outline:user-group', - title: 'Team', - description: - 'Manage your existing team and change roles/permissions', - }, - ]; - - // Subscribe to media changes - this._angorMediaWatcherService.onMediaChange$ - .pipe(takeUntil(this._unsubscribeAll)) - .subscribe(({ matchingAliases }) => { - // Set the drawerMode and drawerOpened - if (matchingAliases.includes('lg')) { - this.drawerMode = 'side'; - this.drawerOpened = true; - } else { - this.drawerMode = 'over'; - this.drawerOpened = false; - } - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); - } - - /** - * On destroy - */ - ngOnDestroy(): void { - // Unsubscribe from all subscriptions - this._unsubscribeAll.next(null); - this._unsubscribeAll.complete(); - } - - // ----------------------------------------------------------------------------------------------------- - // @ Public methods - // ----------------------------------------------------------------------------------------------------- - - /** - * Navigate to the panel - * - * @param panel - */ - goToPanel(panel: string): void { - this.selectedPanel = panel; - - // Close the drawer on 'over' mode - if (this.drawerMode === 'over') { - this.drawer.close(); - } - } - - /** - * Get the details of the panel - * - * @param id - */ - getPanelInfo(id: string): any { - return this.panels.find((panel) => panel.id === id); - } - - /** - * Track by function for ngFor loops - * - * @param index - * @param item - */ - trackByFn(index: number, item: any): any { - return item.id || index; - } -} diff --git a/src/app/components/pages/error/settings/settings.routes.ts b/src/app/components/pages/error/settings/settings.routes.ts deleted file mode 100644 index 0704a7c..0000000 --- a/src/app/components/pages/error/settings/settings.routes.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Routes } from '@angular/router'; -import { SettingsComponent } from 'app/components/settings/settings.component'; - -export default [ - { - path: '', - component: SettingsComponent, - }, -] as Routes; diff --git a/src/app/components/pages/error/settings/team/team.component.html b/src/app/components/pages/error/settings/team/team.component.html deleted file mode 100644 index da86c5a..0000000 --- a/src/app/components/pages/error/settings/team/team.component.html +++ /dev/null @@ -1,99 +0,0 @@ -
- -
- - Add team members - - - - -
- - -
- @for (member of members; track trackByFn($index, member)) { -
-
-
- @if (member.avatar) { - Contact avatar - } - @if (!member.avatar) { -
- {{ member.name.charAt(0) }} -
- } -
-
-
{{ member.name }}
-
{{ member.email }}
-
-
-
-
- - - - Role: - {{ - roleSelect.value | titlecase - }} - - @for (role of roles; track role) { - -
- {{ role.label }} -
-
- {{ role.description }} -
-
- } -
-
-
-
- -
-
-
- } -
-
diff --git a/src/app/components/pages/error/settings/team/team.component.ts b/src/app/components/pages/error/settings/team/team.component.ts deleted file mode 100644 index 6ddeae5..0000000 --- a/src/app/components/pages/error/settings/team/team.component.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { TitleCasePipe } from '@angular/common'; -import { - ChangeDetectionStrategy, - Component, - OnInit, - ViewEncapsulation, -} from '@angular/core'; -import { MatButtonModule } from '@angular/material/button'; -import { MatOptionModule } from '@angular/material/core'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatIconModule } from '@angular/material/icon'; -import { MatInputModule } from '@angular/material/input'; -import { MatSelectModule } from '@angular/material/select'; - -@Component({ - selector: 'settings-team', - templateUrl: './team.component.html', - encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [ - MatFormFieldModule, - MatIconModule, - MatInputModule, - MatButtonModule, - MatSelectModule, - MatOptionModule, - TitleCasePipe, - ], -}) -export class SettingsTeamComponent implements OnInit { - members: any[]; - roles: any[]; - - /** - * Constructor - */ - constructor() {} - - // ----------------------------------------------------------------------------------------------------- - // @ Lifecycle hooks - // ----------------------------------------------------------------------------------------------------- - - /** - * On init - */ - ngOnInit(): void { - // Setup the team members - this.members = [ - { - avatar: 'images/avatars/avatar-placeholder.png', - name: 'Dejesus Michael', - email: 'dejesusmichael@mail.org', - role: 'admin', - }, - { - avatar: 'images/avatars/avatar-placeholder.png', - name: 'Mclaughlin Steele', - email: 'mclaughlinsteele@mail.me', - role: 'admin', - }, - { - avatar: 'images/avatars/avatar-placeholder.png', - name: 'Laverne Dodson', - email: 'lavernedodson@mail.ca', - role: 'write', - }, - { - avatar: 'images/avatars/avatar-placeholder.png', - name: 'Trudy Berg', - email: 'trudyberg@mail.us', - role: 'read', - }, - { - avatar: 'images/avatars/avatar-placeholder.png', - name: 'Lamb Underwood', - email: 'lambunderwood@mail.me', - role: 'read', - }, - { - avatar: 'images/avatars/avatar-placeholder.png', - name: 'Mcleod Wagner', - email: 'mcleodwagner@mail.biz', - role: 'read', - }, - { - avatar: 'images/avatars/avatar-placeholder.png', - name: 'Shannon Kennedy', - email: 'shannonkennedy@mail.ca', - role: 'read', - }, - ]; - - // Setup the roles - this.roles = [ - { - label: 'Read', - value: 'read', - description: - 'Can read and clone this repository. Can also open and comment on issues and pull requests.', - }, - { - label: 'Write', - value: 'write', - description: - 'Can read, clone, and push to this repository. Can also manage issues and pull requests.', - }, - { - label: 'Admin', - value: 'admin', - description: - 'Can read, clone, and push to this repository. Can also manage issues, pull requests, and repository settings, including adding collaborators.', - }, - ]; - } - - // ----------------------------------------------------------------------------------------------------- - // @ Public methods - // ----------------------------------------------------------------------------------------------------- - - /** - * Track by function for ngFor loops - * - * @param index - * @param item - */ - trackByFn(index: number, item: any): any { - return item.id || index; - } -}