Browse Source

refactoring

feature/ssr-migration-schematic
erdemcaygor 1 year ago
parent
commit
cf09eba39d
  1. 9
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts
  2. 11
      npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/current-user.component.ts

9
npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts

@ -66,22 +66,15 @@ export class RolesComponent implements OnInit {
private readonly injector = inject(Injector); private readonly injector = inject(Injector);
protected readonly service = inject(IdentityRoleService); protected readonly service = inject(IdentityRoleService);
protected readonly ssrService = inject(SSRService); protected readonly ssrService = inject(SSRService);
ROLES_KEY = makeStateKey<any>('roles');
ROLES_KEY = makeStateKey<any>('roles');
data: PagedResultDto<IdentityRoleDto> = { items: [], totalCount: 0 }; data: PagedResultDto<IdentityRoleDto> = { items: [], totalCount: 0 };
form!: UntypedFormGroup; form!: UntypedFormGroup;
selected?: IdentityRoleDto; selected?: IdentityRoleDto;
isModalVisible!: boolean; isModalVisible!: boolean;
visiblePermissions = false; visiblePermissions = false;
providerKey?: string; providerKey?: string;
modalBusy = false; modalBusy = false;
permissionManagementKey = ePermissionManagementComponents.PermissionManagement; permissionManagementKey = ePermissionManagementComponents.PermissionManagement;
constructor(private transferState: TransferState) {} constructor(private transferState: TransferState) {}

11
npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/current-user.component.ts

@ -6,10 +6,11 @@ import {
NAVIGATE_TO_MANAGE_PROFILE, NAVIGATE_TO_MANAGE_PROFILE,
PermissionDirective, PermissionDirective,
SessionStateService, SessionStateService,
SSRService,
ToInjectorPipe, ToInjectorPipe,
} from '@abp/ng.core'; } from '@abp/ng.core';
import { AbpVisibleDirective, UserMenu, UserMenuService } from '@abp/ng.theme.shared'; import { AbpVisibleDirective, UserMenu, UserMenuService } from '@abp/ng.theme.shared';
import { Component, Inject, TrackByFunction } from '@angular/core'; import { Component, inject, Inject, TrackByFunction } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
@ -29,11 +30,15 @@ import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
export class CurrentUserComponent { export class CurrentUserComponent {
currentUser$: Observable<CurrentUserDto> = this.configState.getOne$('currentUser'); currentUser$: Observable<CurrentUserDto> = this.configState.getOne$('currentUser');
selectedTenant$ = this.sessionState.getTenant$(); selectedTenant$ = this.sessionState.getTenant$();
trackByFn: TrackByFunction<UserMenu> = (_, element) => element.id; trackByFn: TrackByFunction<UserMenu> = (_, element) => element.id;
private ssrService = inject(SSRService);
get smallScreen(): boolean { get smallScreen(): boolean {
return window.innerWidth < 992; if (this.ssrService.isSsr) {
return false;
} else {
return window.innerWidth < 992;
}
} }
constructor( constructor(

Loading…
Cancel
Save