Browse Source

ssr and client app config updated

feature/ssr-migration-schematic
erdemcaygor 1 year ago
parent
commit
b079f5e40f
  1. 61
      npm/ng-packs/apps/dev-app/src/app/app.config.ts
  2. 4
      npm/ng-packs/apps/dev-app/src/main.server.ts
  3. 4
      npm/ng-packs/apps/dev-app/src/main.ts
  4. 8
      npm/ng-packs/packages/core/src/lib/providers/cookie-language.provider.ts
  5. 7
      npm/ng-packs/packages/identity/src/lib/components/roles/roles.component.ts
  6. 1
      npm/ng-packs/packages/oauth/src/lib/services/server-token-storage.service.ts

61
npm/ng-packs/apps/dev-app/src/app/app.config.ts

@ -1,6 +1,10 @@
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideClientHydration, withEventReplay } from '@angular/platform-browser';
import {
provideClientHydration,
withEventReplay,
withHttpTransferCacheOptions,
} from '@angular/platform-browser';
import { appRoutes } from './app.routes';
import { APP_ROUTE_PROVIDER } from './route.provider';
@ -16,30 +20,33 @@ import { provideTenantManagementConfig } from '@abp/ng.tenant-management/config'
import { provideFeatureManagementConfig } from '@abp/ng.feature-management';
import { provideThemeBasicConfig } from '@abp/ng.theme.basic';
import { provideAnimations } from '@angular/platform-browser/animations';
import { provideServerRendering } from '@angular/platform-server';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(appRoutes),
APP_ROUTE_PROVIDER,
provideAbpCore(
withOptions({
environment,
registerLocaleFn: registerLocale(),
sendNullsAsQueryParam: false,
skipGetAppConfiguration: false,
}),
),
provideAbpOAuth({ ssr: false }),
provideAbpThemeShared(),
provideSettingManagementConfig(),
provideAccountConfig(),
provideIdentityConfig(),
provideTenantManagementConfig(),
provideFeatureManagementConfig(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideThemeBasicConfig(),
provideAnimations(),
provideRouter(appRoutes),
provideClientHydration(withEventReplay()),
],
};
export function createAppConfig(ssr: boolean): ApplicationConfig {
return {
providers: [
APP_ROUTE_PROVIDER,
provideAbpCore(
withOptions({
environment,
registerLocaleFn: registerLocale(),
sendNullsAsQueryParam: false,
skipGetAppConfiguration: false,
}),
),
provideAbpOAuth({ ssr }),
provideAbpThemeShared(),
provideSettingManagementConfig(),
provideAccountConfig(),
provideIdentityConfig(),
provideTenantManagementConfig(),
provideFeatureManagementConfig(),
provideZoneChangeDetection({ eventCoalescing: true }),
provideThemeBasicConfig(),
provideAnimations(),
provideRouter(appRoutes),
provideClientHydration(withEventReplay(), withHttpTransferCacheOptions({})),
...(ssr ? [provideServerRendering()] : []),
],
};
}

4
npm/ng-packs/apps/dev-app/src/main.server.ts

@ -1,7 +1,7 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { config } from './app/app.config.server';
import { createAppConfig } from './app/app.config';
const bootstrap = () => bootstrapApplication(AppComponent, config);
const bootstrap = () => bootstrapApplication(AppComponent, createAppConfig(true));
export default bootstrap;

4
npm/ng-packs/apps/dev-app/src/main.ts

@ -1,5 +1,5 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { createAppConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, appConfig).catch(err => console.error(err));
bootstrapApplication(AppComponent, createAppConfig(false)).catch(err => console.error(err));

8
npm/ng-packs/packages/core/src/lib/providers/cookie-language.provider.ts

@ -1,10 +1,14 @@
import { Injector, inject, provideAppInitializer } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { Injector, inject, provideAppInitializer, PLATFORM_ID } from '@angular/core';
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
import { SessionStateService } from '../services/session-state.service';
import { COOKIE_LANGUAGE_KEY } from '../tokens/cookie-language-key.token';
export function setLanguageToCookie() {
const injector = inject(Injector);
const platformId = injector.get(PLATFORM_ID);
if (!isPlatformBrowser(platformId)) return;
const sessionState = injector.get(SessionStateService);
const document = injector.get(DOCUMENT);
const cookieLanguageKey = injector.get(COOKIE_LANGUAGE_KEY);

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

@ -131,7 +131,12 @@ export class RolesComponent implements OnInit {
}
private hookToQuery() {
this.list.hookToQuery(query => this.service.getList(query)).subscribe(res => (this.data = res));
this.list
.hookToQuery(query => this.service.getList(query))
.subscribe(res => {
console.log(res);
this.data = res;
});
}
openPermissionsModal(providerKey: string) {

1
npm/ng-packs/packages/oauth/src/lib/services/server-token-storage.service.ts

@ -7,7 +7,6 @@ import { OAuthStorage } from 'angular-oauth2-oidc';
export class ServerTokenStorageService implements OAuthStorage {
private cookies: Map<string, string>;
constructor(@Inject('cookies') c: any) {
console.log('cookies ---->>>>>>>', c);
const cookies = JSON.parse(c);
this.cookies = new Map<string, string>();

Loading…
Cancel
Save