Skip to content

Commit

Permalink
Refactor names
Browse files Browse the repository at this point in the history
  • Loading branch information
mczachurski committed Jan 7, 2025
1 parent 681fa30 commit 21790b5
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 91 deletions.
10 changes: 5 additions & 5 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { HammerModule } from "@angular/platform-browser";

import { RouteReuseStrategy } from '@angular/router';
import { AppComponent } from './app.component';
import { PersistanceBrowserService, PersistanceServerService, PersistanceService } from './services/persistance/persistance.service';
import { PersistenceBrowserService, PersistenceServerService, PersistenceService } from './services/persistance/persistance.service';
import { AuthorizationService } from './services/authorization/authorization.service';
import { PagesModule } from './pages/pages.module';
import { APIInterceptor } from './interceptors/api.interceptor';
Expand Down Expand Up @@ -58,19 +58,19 @@ const httpInterceptor = (platformId: object, authorizationService: Authorization
multi: true
},
{
provide: PersistanceService,
provide: PersistenceService,
useFactory: (platformId: object) => {
if (isPlatformBrowser(platformId)) {
return new PersistanceBrowserService();
return new PersistenceBrowserService();
}
else {
return new PersistanceServerService();
return new PersistenceServerService();
}
},
deps: [PLATFORM_ID]
},
{
provide: ErrorHandler, useClass: GlobalErrorHandler, deps: [PLATFORM_ID, Injector, NgZone, AuthorizationService, PersistanceService, LoadingService, ErrorItemsService, RandomGeneratorService]
provide: ErrorHandler, useClass: GlobalErrorHandler, deps: [PLATFORM_ID, Injector, NgZone, AuthorizationService, PersistenceService, LoadingService, ErrorItemsService, RandomGeneratorService]
},
provideHttpClient(withFetch(), withInterceptorsFromDi()),
provideClientHydration(withEventReplay())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ResponsiveComponent } from 'src/app/common/responsive';
import { ConfirmationDialog } from 'src/app/dialogs/confirmation-dialog/confirmation.dialog';
import { InstanceBlockedDomainDialog } from 'src/app/dialogs/instance-blocked-domain-dialog/instance-blocked-domain.dialog';
import { InstanceBlockedDomain } from 'src/app/models/instance-blocked-domain';
import { PaginableResult } from 'src/app/models/paginable-result';
import { PagedResult } from 'src/app/models/paged-result';
import { MessagesService } from 'src/app/services/common/messages.service';
import { InstanceBlockedDomainsService } from 'src/app/services/http/instance-blocked-domains.service';

Expand All @@ -18,13 +18,13 @@ import { InstanceBlockedDomainsService } from 'src/app/services/http/instance-bl
standalone: false
})
export class DomainBlocksComponent extends ResponsiveComponent implements OnInit {
protected domains = signal<PaginableResult<InstanceBlockedDomain> | undefined>(undefined);
protected domains = signal<PagedResult<InstanceBlockedDomain> | undefined>(undefined);
protected displayedColumns = signal<string[]>([]);
protected pageIndex = signal(0);

private pageSize = 10;
private readonly displayedColumnsHandsetPortrait: string[] = ['domain', 'actions'];
private readonly displayedColumnsHandserLandscape: string[] = ['domain', 'actions'];
private readonly displayedColumnsHandsetLandscape: string[] = ['domain', 'actions'];
private readonly displayedColumnsTablet: string[] = ['domain', 'actions'];
private readonly displayedColumnsBrowser: string[] = ['domain', 'actions'];

Expand Down Expand Up @@ -93,7 +93,7 @@ export class DomainBlocksComponent extends ResponsiveComponent implements OnInit
}

protected override onHandsetLandscape(): void {
this.displayedColumns?.set(this.displayedColumnsHandserLandscape);
this.displayedColumns?.set(this.displayedColumnsHandsetLandscape);
}

protected override onTablet(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PageEvent } from '@angular/material/paginator';
import { ResponsiveComponent } from 'src/app/common/responsive';
import { ConfirmationDialog } from 'src/app/dialogs/confirmation-dialog/confirmation.dialog';
import { InstanceRuleDialog } from 'src/app/dialogs/instance-rule-dialog/instance-rule.dialog';
import { PaginableResult } from 'src/app/models/paginable-result';
import { PagedResult } from 'src/app/models/paged-result';
import { Rule } from 'src/app/models/rule';
import { MessagesService } from 'src/app/services/common/messages.service';
import { RulesService } from 'src/app/services/http/rules.service';
Expand All @@ -18,13 +18,13 @@ import { RulesService } from 'src/app/services/http/rules.service';
standalone: false
})
export class InstanceRulesComponent extends ResponsiveComponent implements OnInit {
protected rules = signal<PaginableResult<Rule> | undefined>(undefined);
protected rules = signal<PagedResult<Rule> | undefined>(undefined);
protected displayedColumns = signal<string[]>([]);
protected pageIndex = signal(0);

private pageSize = 10;
private readonly displayedColumnsHandsetPortrait: string[] = ['text', 'actions'];
private readonly displayedColumnsHandserLandscape: string[] = ['text', 'actions'];
private readonly displayedColumnsHandsetLandscape: string[] = ['text', 'actions'];
private readonly displayedColumnsTablet: string[] = ['order', 'text', 'actions'];
private readonly displayedColumnsBrowser: string[] = ['order', 'text', 'actions'];

Expand Down Expand Up @@ -93,7 +93,7 @@ export class InstanceRulesComponent extends ResponsiveComponent implements OnIni
}

protected override onHandsetLandscape(): void {
this.displayedColumns?.set(this.displayedColumnsHandserLandscape);
this.displayedColumns?.set(this.displayedColumnsHandsetLandscape);
}

protected override onTablet(): void {
Expand Down
6 changes: 3 additions & 3 deletions src/app/handlers/global-error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ErrorItemsService } from '../services/http/error-items.service';
import { RandomGeneratorService } from '../services/common/random-generator.service';
import { ErrorItem } from '../models/error-item';
import { isPlatformBrowser } from '@angular/common';
import { PersistanceService } from '../services/persistance/persistance.service';
import { PersistenceService } from '../services/persistance/persistance.service';
import { CustomError } from '../errors/custom-error';
import { environment } from 'src/environments/environment';

Expand All @@ -22,7 +22,7 @@ export class GlobalErrorHandler implements ErrorHandler {
private injector: Injector,
private zone: NgZone,
private authorizationService: AuthorizationService,
private persistanceService: PersistanceService,
private persistenceService: PersistenceService,
private loadingService: LoadingService,
private errorItemsService: ErrorItemsService,
private randomGeneratorService: RandomGeneratorService
Expand All @@ -38,7 +38,7 @@ export class GlobalErrorHandler implements ErrorHandler {
await this.zone.run(async () => {
console.error(error);
const stringified = this.getStringFromError(error);
this.persistanceService.set('exception', stringified.trim());
this.persistenceService.set('exception', stringified.trim());

this.loadingService.hideLoader();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class PaginableResult<T> {
export class PagedResult<T> {
public page = 0;
public size = 0;
public total = 0;
Expand Down
51 changes: 24 additions & 27 deletions src/app/pages/account/account.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,34 @@ <h3>Fields</h3>
<div></div>
</div>

<div *ngFor="let field of user().fields; let i = index">

<div class="flex-row flex-responsive flex-stretch gap-16 margin-bottom-20">
<mat-form-field appearance="outline">
<mat-label>Key</mat-label>
<input matInput [name]="'key-' + i" #key="ngModel" [(ngModel)]="field.key" placeholder="Key" aria-label="Key" appMaxLength="500" />
<mat-error *ngIf="key.invalid && key.errors?.appMaxLength">
Too long key.
</mat-error>
</mat-form-field>
<div></div>
</div>
@for (field of user().fields; track field.id; let i = $index) {
<div>
<div class="flex-row flex-responsive flex-stretch gap-16 margin-bottom-20">
<mat-form-field appearance="outline">
<mat-label>Key</mat-label>
<input matInput [name]="'key-' + i" #key="ngModel" [(ngModel)]="field.key" placeholder="Key" aria-label="Key" appMaxLength="500" />
<mat-error *ngIf="key.invalid && key.errors?.appMaxLength">Too long key.</mat-error>
</mat-form-field>
<div></div>
</div>

<div class="flex-row flex-responsive flex-stretch gap-16">
<mat-form-field appearance="outline">
<mat-label>Value</mat-label>
<input matInput [name]="'value-' + i" #value="ngModel" [(ngModel)]="field.value" placeholder="Value" aria-label="Value" appMaxLength="500" />
<mat-error *ngIf="value.invalid && value.errors?.appMaxLength">
Too long value.
</mat-error>
</mat-form-field>
<div></div>
</div>
<div class="flex-row flex-responsive flex-stretch gap-16">
<mat-form-field appearance="outline">
<mat-label>Value</mat-label>
<input matInput [name]="'value-' + i" #value="ngModel" [(ngModel)]="field.value" placeholder="Value" aria-label="Value" appMaxLength="500" />
<mat-error *ngIf="value.invalid && value.errors?.appMaxLength">Too long value.</mat-error>
</mat-form-field>
<div></div>
</div>

<div class="flex-row flex-responsive flex-stretch gap-16 margin-bottom-20">
<div class="text-right">
<button mat-stroked-button color="primary" type="button" (click)="onDeleteField(field)">Delete</button>
<div class="flex-row flex-responsive flex-stretch gap-16 margin-bottom-20">
<div class="text-right">
<button mat-stroked-button color="primary" type="button" (click)="onDeleteField(field)">Delete</button>
</div>
<div></div>
</div>
<div></div>
</div>
</div>
}

<div class="flex-row flex-responsive flex-stretch gap-16 margin-bottom-20 padding-top-20">
<div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/error-items/error-items.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ResponsiveComponent } from 'src/app/common/responsive';
import { BreakpointObserver } from '@angular/cdk/layout';
import { AuthorizationService } from 'src/app/services/authorization/authorization.service';
import { Role } from 'src/app/models/role';
import { PaginableResult } from 'src/app/models/paginable-result';
import { PagedResult } from 'src/app/models/paged-result';
import { PageEvent } from '@angular/material/paginator';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { Subscription } from 'rxjs';
Expand All @@ -31,7 +31,7 @@ export class ErrorItemsPage extends ResponsiveComponent implements OnInit, OnDes
protected search = model('');
protected isReady = signal(false);
protected pageIndex = signal(0);
protected errorItems = signal<PaginableResult<ErrorItem> | undefined>(undefined);
protected errorItems = signal<PagedResult<ErrorItem> | undefined>(undefined);
protected displayedColumns = signal<string[]>([]);

private routeParamsSubscription?: Subscription;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit, signal } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { fadeInAnimation } from 'src/app/animations/fade-in.animation';
import { PersistanceService } from 'src/app/services/persistance/persistance.service';
import { PersistenceService } from 'src/app/services/persistance/persistance.service';

@Component({
selector: 'app-unexpected-error',
Expand All @@ -20,7 +20,7 @@ export class UnexpectedErrorPage implements OnInit, OnDestroy {
private interval: NodeJS.Timeout | undefined;

constructor(
private persistanceService: PersistanceService,
private persistenceService: PersistenceService,
private router: Router,
private activatedRoute: ActivatedRoute) {
}
Expand Down Expand Up @@ -50,10 +50,10 @@ export class UnexpectedErrorPage implements OnInit, OnDestroy {
});
}, 200);

const errorObject = this.persistanceService.get('exception');
const errorObject = this.persistenceService.get('exception');
if (errorObject) {
this.errorMessage.set(errorObject.toString());
this.persistanceService.remove('exception');
this.persistenceService.remove('exception');
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/invitations/invitations.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class InvitationsPage extends ResponsiveComponent implements OnInit {
protected canGenerateNewInvitations = computed(() => (this.invitations?.length ?? 0) < (this.publicSettings()?.maximumNumberOfInvitations ?? 0));

private readonly displayedColumnsHandsetPortrait: string[] = ['code', 'actions'];
private readonly displayedColumnsHandserLandscape: string[] = ['code', 'actions'];
private readonly displayedColumnsHandsetLandscape: string[] = ['code', 'actions'];
private readonly displayedColumnsTablet: string[] = ['code', 'invited', 'actions'];
private readonly displayedColumnsBrowser: string[] = ['code', 'createdAt', 'invited', 'actions'];

Expand Down Expand Up @@ -70,7 +70,7 @@ export class InvitationsPage extends ResponsiveComponent implements OnInit {
}

protected override onHandsetLandscape(): void {
this.displayedColumns?.set(this.displayedColumnsHandserLandscape);
this.displayedColumns?.set(this.displayedColumnsHandsetLandscape);
}

protected override onTablet(): void {
Expand Down
5 changes: 1 addition & 4 deletions src/app/pages/login/login.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
<mat-form-field appearance="outline">
<mat-label>Token</mat-label>
<input matInput [errorStateMatcher]="alwaysErrorStateMatcher" inputmode="numeric" name="token" [(ngModel)]="twoFactorToken" #twoFactorTokenInput="ngModel" type="text" placeholder="Two factor token" aria-label="Two factor token" required />

@if (tokenMessage(); as tokenMessageString) {
<mat-error>{{ tokenMessageString }}</mat-error>
}
<mat-error *ngIf="tokenMessage()">{{ tokenMessage() }}</mat-error>
</mat-form-field>
<mat-checkbox class="margin-bottom-20" name="trustMachine" [disableRipple]="true" [(ngModel)]="trustMachine">
Trust this machine for the next 30 days.
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/profile/profile.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<div class="margin-auto fields-container padding-top-10">
<mat-card *ngIf="(userInternal.fields?.length ?? 0) > 0" appearance="outlined">
<mat-card-content>
<ng-container *ngFor="let item of userInternal.fields; let i = index">
@for (item of userInternal.fields; track item.id; let i = $index) {
<div class="flex-row flex-align-center flex-space-between margin-bottom-10">
<div>
<div class="field-key text-muted">{{ item.key }}</div>
Expand All @@ -58,7 +58,7 @@
</div>
</div>
<mat-divider *ngIf="(i + 1) < (userInternal.fields?.length ?? 0)" class="padding-bottom-5"></mat-divider>
</ng-container>
}
</mat-card-content>
</mat-card>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/app/pages/reports/reports.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BreakpointObserver } from '@angular/cdk/layout';
import { AuthorizationService } from 'src/app/services/authorization/authorization.service';
import { ReportsService } from 'src/app/services/http/reports.service';
import { Role } from 'src/app/models/role';
import { PaginableResult } from 'src/app/models/paginable-result';
import { PagedResult } from 'src/app/models/paged-result';
import { PageEvent } from '@angular/material/paginator';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { Subscription } from 'rxjs';
Expand All @@ -32,12 +32,12 @@ export class ReportsPage extends ResponsiveComponent implements OnInit, OnDestro
protected readonly avatarSize = AvatarSize;
protected isReady = signal(false);
protected pageIndex = signal(0);
protected reports = signal<PaginableResult<Report> | undefined>(undefined);
protected reports = signal<PagedResult<Report> | undefined>(undefined);
protected displayedColumns = signal<string[]>([]);

private routeParamsSubscription?: Subscription;
private readonly displayedColumnsHandsetPortrait: string[] = ['reportedUser', 'status'];
private readonly displayedColumnsHandserLandscape: string[] = ['reportedUser', 'status', 'actions'];
private readonly displayedColumnsHandsetLandscape: string[] = ['reportedUser', 'status', 'actions'];
private readonly displayedColumnsTablet: string[] = ['user', 'reportedUser', 'category', 'status', 'actions'];
private readonly displayedColumnsBrowser: string[] = ['user', 'reportedUser', 'status', 'category', 'considerationUser', 'considerationDate', 'actions'];

Expand Down Expand Up @@ -101,7 +101,7 @@ export class ReportsPage extends ResponsiveComponent implements OnInit, OnDestro
}

protected override onHandsetLandscape(): void {
this.displayedColumns?.set(this.displayedColumnsHandserLandscape);
this.displayedColumns?.set(this.displayedColumnsHandsetLandscape);
}

protected override onTablet(): void {
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/users/users.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ResponsiveComponent } from 'src/app/common/responsive';
import { BreakpointObserver } from '@angular/cdk/layout';
import { AuthorizationService } from 'src/app/services/authorization/authorization.service';
import { Role } from 'src/app/models/role';
import { PaginableResult } from 'src/app/models/paginable-result';
import { PagedResult } from 'src/app/models/paged-result';
import { PageEvent } from '@angular/material/paginator';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { Subscription } from 'rxjs';
Expand All @@ -34,7 +34,7 @@ export class UsersPage extends ResponsiveComponent implements OnInit, OnDestroy
protected search = model('');
protected onlyLocal = model(false);
protected isReady = signal(false);
protected users = signal<PaginableResult<User> | undefined>(undefined);
protected users = signal<PagedResult<User> | undefined>(undefined);
protected pageIndex = signal(0);
protected displayedColumns = signal<string[]>([]);

Expand Down
Loading

0 comments on commit 21790b5

Please sign in to comment.