Chore: Updated resolvers from Class to ResolveFn
This commit is contained in:
1 parent
6f433ef203
commit
6e3c429db3
255 files changed
+1737
-2155
No files matched your search
@@ -1,16 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { LockInfo } from './lock-info';
|
||||
import { SettingsService } from './settings.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class LockInformationResolver {
|
||||
constructor(private ser: SettingsService) {}
|
||||
|
||||
resolve(): Observable<[LockInfo]> {
|
||||
return this.ser.getLockInformation();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { LockInfo } from './lock-info';
|
||||
import { SettingsService } from './settings.service';
|
||||
|
||||
export const lockInformationResolver: ResolveFn<[LockInfo]> = () => {
|
||||
return inject(SettingsService).getLockInformation();
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { SettingsService } from './settings.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MaintenanceResolver {
|
||||
constructor(private ser: SettingsService) {}
|
||||
|
||||
resolve(): Observable<{ enabled: boolean; user: string }> {
|
||||
return this.ser.getMaintenance();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { SettingsService } from './settings.service';
|
||||
|
||||
export const maintenanceResolver: ResolveFn<{ enabled: boolean; user: string }> = () => {
|
||||
return inject(SettingsService).getMaintenance();
|
||||
};
|
||||
@@ -2,13 +2,13 @@ import { CommonModule } from '@angular/common';
|
||||
import { NgModule, inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, RouterModule, RouterStateSnapshot, Routes } from '@angular/router';
|
||||
|
||||
import { AccountTypeResolver } from '../account/account-type-resolver.service';
|
||||
import { accountTypeResolver } from '../account/account-type.resolver';
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { LockInformationResolver } from './lock-information-resolver.service';
|
||||
import { MaintenanceResolver } from './maintenance-resolver.service';
|
||||
import { lockInformationResolver } from './lock-information.resolver';
|
||||
import { maintenanceResolver } from './maintenance.resolver';
|
||||
import { SettingsComponent } from './settings.component';
|
||||
import { VoucherTypeResolver } from './voucher-type-resolver.service';
|
||||
import { voucherTypeResolver } from './voucher-type.resolver';
|
||||
|
||||
const settingsRoutes: Routes = [
|
||||
{
|
||||
@@ -21,10 +21,10 @@ const settingsRoutes: Routes = [
|
||||
permission: 'Maintenance', // 'Lock Date'
|
||||
},
|
||||
resolve: {
|
||||
maintenance: () => inject(MaintenanceResolver).resolve(),
|
||||
lockInformation: () => inject(LockInformationResolver).resolve(),
|
||||
accountTypes: () => inject(AccountTypeResolver).resolve(),
|
||||
voucherTypes: () => inject(VoucherTypeResolver).resolve(),
|
||||
maintenance: maintenanceResolver,
|
||||
lockInformation: lockInformationResolver,
|
||||
accountTypes: accountTypeResolver,
|
||||
voucherTypes: voucherTypeResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { AccountType } from '../core/account-type';
|
||||
|
||||
import { VoucherTypeService } from './voucher-type.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class VoucherTypeResolver {
|
||||
constructor(private ser: VoucherTypeService) {}
|
||||
|
||||
resolve(): Observable<AccountType[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { AccountType } from '../core/account-type';
|
||||
|
||||
import { VoucherTypeService } from './voucher-type.service';
|
||||
|
||||
export const voucherTypeResolver: ResolveFn<AccountType[]> = () => {
|
||||
return inject(VoucherTypeService).list();
|
||||
};
|
||||
Reference in new issue
Block a user