-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd61215
commit a6b8c0a
Showing
249 changed files
with
811 additions
and
620 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/app/features/admin/settings/settings-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { SettingsComponent } from './settings.component'; | ||
import { UiComponent } from './ui/ui.component'; | ||
|
||
const routes: Routes = [ | ||
{ path: '', redirectTo: 'ui', pathMatch: 'full' }, | ||
{ | ||
path: '', | ||
component: SettingsComponent, | ||
children: [ | ||
{ | ||
path: 'ui', | ||
component: UiComponent, | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class SettingsRoutingModule {} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { activate } from '@angular/fire/remote-config'; | ||
|
||
interface TabItem { | ||
icon: string; | ||
link: string; | ||
label: string; | ||
} | ||
|
||
@Component({ | ||
selector: 'll-admin-settings', | ||
templateUrl: './settings.component.html', | ||
styleUrls: ['./settings.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class SettingsComponent { | ||
activeTab = 'ui'; | ||
tabItems: TabItem[] = [{ icon: 'palette', label: 'UI', link: 'ui' }]; | ||
|
||
constructor( | ||
private readonly route: ActivatedRoute, | ||
private readonly router: Router, | ||
private readonly cd: ChangeDetectorRef, | ||
) { | ||
const idx = router.url.lastIndexOf('/'); | ||
this.activeTab = router.url.substring(idx + 1); | ||
} | ||
|
||
protected readonly activate = activate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { SharedModule } from '@shared/shared.module'; | ||
import { SettingsComponent } from './settings.component'; | ||
import { SettingsRoutingModule } from './settings-routing.module'; | ||
import { UiComponent } from './ui/ui.component'; | ||
import { SettingsService } from '@shared/services/settings.service'; | ||
|
||
@NgModule({ | ||
declarations: [SettingsComponent, UiComponent], | ||
imports: [SharedModule, SettingsRoutingModule], | ||
providers: [SettingsService], | ||
}) | ||
export class SettingsModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<mat-toolbar class="border-b !bg-transparent"> | ||
<mat-toolbar-row> | ||
User Interface | ||
<span class="spacer"></span> | ||
<button mat-stroked-button color="primary" [disabled]="!form.valid" (click)="save()"> | ||
<mat-icon>save</mat-icon> | ||
Save | ||
</button> | ||
</mat-toolbar-row> | ||
</mat-toolbar> | ||
|
||
@if (isLoading()) { | ||
<mat-progress-bar mode="query" /> | ||
} | ||
|
||
<div class="my-3"> | ||
<form [formGroup]="form"> | ||
<mat-form-field> | ||
<mat-label>Color</mat-label> | ||
<mat-select formControlName="color"> | ||
<mat-option value="primary">Primary</mat-option> | ||
<mat-option value="secondary">Secondary</mat-option> | ||
<mat-option value="tertiary">Tertiary</mat-option> | ||
<mat-option value="error">Error</mat-option> | ||
</mat-select> | ||
@if (form.controls['color'].errors; as errors) { | ||
<mat-error>{{ fe.errors(errors) }}</mat-error> | ||
} | ||
</mat-form-field> | ||
<br /> | ||
<mat-form-field> | ||
<mat-label>Text</mat-label> | ||
<input matInput type="text" formControlName="text" maxlength="10" autocomplete="off" /> | ||
<mat-hint align="end">{{ form.controls['text'].value?.length || 0 }}/10</mat-hint> | ||
@if (form.controls['text'].errors; as errors) { | ||
<mat-error>{{ fe.errors(errors) }}</mat-error> | ||
} | ||
</mat-form-field> | ||
</form> | ||
</div> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, signal } from '@angular/core'; | ||
import { NotificationService } from '@shared/services/notification.service'; | ||
import { FormBuilder, FormGroup } from '@angular/forms'; | ||
import { FormErrorHandlerService } from '@core/error-handler/form-error-handler.service'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
import { AppUiColor } from '@shared/models/settings.model'; | ||
import { SettingsValidator } from '@shared/validators/settings.validator'; | ||
import { SettingsService } from '@shared/services/settings.service'; | ||
|
||
@Component({ | ||
selector: 'll-admin-settings-ui', | ||
templateUrl: './ui.component.html', | ||
styleUrls: ['./ui.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class UiComponent { | ||
private destroyRef = inject(DestroyRef); | ||
|
||
isLoading = signal(true); | ||
|
||
// Form | ||
form: FormGroup = this.fb.group({ | ||
text: this.fb.control<string | undefined>(undefined, SettingsValidator.UI_TEXT), | ||
color: this.fb.control<AppUiColor | undefined>(undefined, SettingsValidator.UI_COLOR), | ||
}); | ||
|
||
constructor( | ||
private readonly fb: FormBuilder, | ||
readonly fe: FormErrorHandlerService, | ||
private readonly settingService: SettingsService, | ||
private readonly cd: ChangeDetectorRef, | ||
private readonly notificationService: NotificationService, | ||
) { | ||
this.settingService | ||
.find() | ||
.pipe(takeUntilDestroyed(this.destroyRef)) | ||
.subscribe({ | ||
next: settings => { | ||
console.log(settings); | ||
if (settings?.ui) { | ||
this.form.patchValue(settings.ui); | ||
} | ||
this.isLoading.set(false); | ||
this.cd.markForCheck(); | ||
}, | ||
}); | ||
} | ||
|
||
save(): void { | ||
this.settingService.updateUi(this.form.value).subscribe({ | ||
next: () => { | ||
this.notificationService.success('Settings UI has been updated.'); | ||
}, | ||
error: (err: unknown) => { | ||
console.error(err); | ||
this.notificationService.error('Settings UI can not be updated.'); | ||
}, | ||
}); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.