Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
fix: Update more constants names to UPPER_CASE, change config in auth…
Browse files Browse the repository at this point in the history
… module
  • Loading branch information
EndyKaufman committed Feb 5, 2019
1 parent 4a98023 commit 084dce9
Show file tree
Hide file tree
Showing 76 changed files with 382 additions and 339 deletions.
7 changes: 3 additions & 4 deletions apps/demo/src/app/app.browser.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { REQUEST } from '@nguniversal/express-engine/tokens';
import { BrowserStorage, LangService, STORAGE_CONFIG_TOKEN, TokenService } from '@rucken/core';
import { ThemesService } from '@rucken/web';
import { AppComponent } from './app.component';
import { AppId } from './app.config';
import { AppModule } from './app.module';
import { config } from './config/config';
import { initializeBrowserApp } from './shared/utils/initialize-browser-app';

@NgModule({
bootstrap: [AppComponent],
imports: [BrowserModule.withServerTransition({ appId: AppId }), FontAwesomeModule, AppModule],
imports: [BrowserModule.withServerTransition({ appId: config.app.id }), FontAwesomeModule, AppModule],
providers: [
{
provide: REQUEST,
Expand All @@ -29,4 +28,4 @@ import { initializeBrowserApp } from './shared/utils/initialize-browser-app';
}
]
})
export class AppBrowserModule {}
export class AppBrowserModule { }
23 changes: 7 additions & 16 deletions apps/demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@ import { isPlatformBrowser } from '@angular/common';
import { ChangeDetectionStrategy, Component, Inject, OnDestroy, OnInit, PLATFORM_ID, ViewChild } from '@angular/core';
import { MetaService } from '@ngx-meta/core';
import { TranslateService } from '@ngx-translate/core';
import {
AuthModalComponent,
AuthModalService,
AuthService,
LangService,
RedirectUrlDto,
TokenService,
User,
UserTokenDto
} from '@rucken/core';
import { AuthModalComponent, AuthModalService, AuthService, LangService, RedirectUrlDto, TokenService, User, UserTokenDto } from '@rucken/core';
import { NavbarComponent } from '@rucken/web';
import { BindIoInner } from 'ngx-bind-io';
import { BsLocaleService } from 'ngx-bootstrap/datepicker';
import { Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { AuthModalSignInInfoMessage, AuthModalSignUpInfoMessage } from './app.config';
import { AppRoutes } from './app.routes';
import { BindIoInner } from 'ngx-bind-io';
import { APP_ROUTES } from './app.routes';
import { config } from './config/config';

@BindIoInner()
@Component({
Expand All @@ -43,8 +34,8 @@ export class AppComponent implements OnDestroy, OnInit {
private _authModalService: AuthModalService,
@Inject(PLATFORM_ID) private _platformId: Object
) {
this._authModalService.signInInfoMessage = AuthModalSignInInfoMessage;
this._authModalService.signUpInfoMessage = AuthModalSignUpInfoMessage;
this._authModalService.signInInfoMessage = config.authModal.signInInfoMessage;
this._authModalService.signUpInfoMessage = config.authModal.signUpInfoMessage;
this.currentUser$ = this._authService.current$;
this._langService.current$.pipe(takeUntil(this._destroyed$)).subscribe(lang => {
this._bsLocaleService.use(lang);
Expand All @@ -63,7 +54,7 @@ export class AppComponent implements OnDestroy, OnInit {
if (isPlatformBrowser(this._platformId)) {
this.onInfo();
}
this.navbar.setRoutes(AppRoutes);
this.navbar.setRoutes(APP_ROUTES);
}
ngOnDestroy() {
this._destroyed$.next(true);
Expand Down
101 changes: 0 additions & 101 deletions apps/demo/src/app/app.config.ts

This file was deleted.

25 changes: 15 additions & 10 deletions apps/demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,55 @@ import { BrowserModule } from '@angular/platform-browser';
import { PreloadAllModules, RouterModule } from '@angular/router';
import { MetaLoader, MetaModule } from '@ngx-meta/core';
import { TranslateService } from '@ngx-translate/core';
import { AccountModule, AuthModalModule, AuthModule, entitiesProviders, ErrorsExtractor, LangModule, PermissionsGuard, TransferHttpCacheModule } from '@rucken/core';
import { AccountModule, AuthModalModule, AuthModule, ENTITIES_PROVIDERS, ErrorsExtractor, LangModule, PermissionsGuard, TransferHttpCacheModule } from '@rucken/core';
import { NavbarModule, ThemesModule, WebAuthModalModule, WebModalsModule } from '@rucken/web';
import { environment } from 'apps/demo/src/environments/environment';
import { NgxBindIOModule } from 'ngx-bind-io';
import { BsDatepickerModule, BsLocaleService } from 'ngx-bootstrap/datepicker';
import { CookieService } from 'ngx-cookie-service';
import { NgxPermissionsModule } from 'ngx-permissions';
import { environment } from '../environments/environment';
import { AppComponent } from './app.component';
import { AllRoutes, AppId, AppLangs, appMetaFactory, OauthModalProviders, OauthProviders } from './app.config';
import { APP_ROUTES } from './app.routes';
import { config } from './config/config';
import { SharedModule } from './shared/shared.module';
import { metaFactory } from './shared/utils/meta-factory';

@NgModule({
declarations: [AppComponent],
imports: [
RouterModule,
SharedModule,
HttpClientModule,
BrowserModule.withServerTransition({ appId: AppId }),
BrowserModule.withServerTransition({
appId: config.app.id
}),
TransferHttpCacheModule.forRoot(),
NgxPermissionsModule.forRoot(),
AuthModule.forRoot({
apiUrl: environment.apiUrl,
oauth: {
providers: OauthProviders
providers: config.oauth
}
}),
AccountModule.forRoot({
apiUrl: environment.apiUrl
}),
LangModule.forRoot({
languages: AppLangs
languages: config.app.languages
}),
ThemesModule.forRoot(),
RouterModule.forRoot(AllRoutes, {
RouterModule.forRoot(APP_ROUTES, {
preloadingStrategy: PreloadAllModules,
initialNavigation: 'enabled'
}),
MetaModule.forRoot({
provide: MetaLoader,
useFactory: appMetaFactory,
useFactory: metaFactory,
deps: [TranslateService]
}),
AuthModalModule.forRoot({
oauth: {
providers: OauthModalProviders
providers: config.oauth
}
}),
WebAuthModalModule,
Expand All @@ -56,7 +61,7 @@ import { SharedModule } from './shared/shared.module';
WebModalsModule,
NgxBindIOModule.forRoot()
],
providers: [...entitiesProviders, CookieService, ErrorsExtractor, BsLocaleService, PermissionsGuard],
providers: [...ENTITIES_PROVIDERS, CookieService, ErrorsExtractor, BsLocaleService, PermissionsGuard],
bootstrap: [AppComponent]
})
export class AppModule { }
57 changes: 44 additions & 13 deletions apps/demo/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
import { Routes, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AccountPageRoutes } from './pages/account-page/account-page.routes';
import { AdminPageRoutes } from './pages/admin-page/admin-page.routes';
import { EntitiesPageRoutes } from './pages/entities-page/entities-page.routes';
import { HomePageRoutes } from './pages/home-page/home-page.routes';
import { ThemesPageRoutes } from './pages/themes-page/themes-page.routes';
import { OauthGuard } from '@rucken/core';
import { Routes } from '@angular/router';
import { AuthEmptyPageComponent, OauthGuard } from '@rucken/core';
import { ACCOUNT_PAGE_ROUTES } from './pages/account-page/account-page.routes';
import { ADMIN_PAGE_ROUTES } from './pages/admin-page/admin-page.routes';
import { ENTITIES_PAGE_ROUTES } from './pages/entities-page/entities-page.routes';
import { HOME_PAGE_ROUTES } from './pages/home-page/home-page.routes';
import { THEMES_PAGE_ROUTES } from './pages/themes-page/themes-page.routes';

export const AppRoutes: Routes = [
export const OAUTH_ROUTES = [
{
path: 'auth/facebook',
component: AuthEmptyPageComponent,
canActivate: [OauthGuard],
data: {
oauth: {
provider: 'facebook',
redirectTo: {
ifSuccess: '/home',
ifFail: '/home'
}
}
}
},
{
path: 'auth/google-plus',
component: AuthEmptyPageComponent,
canActivate: [OauthGuard],
data: {
oauth: {
provider: 'google-plus',
redirectTo: {
ifSuccess: '/home',
ifFail: '/home'
}
}
}
}
];
export const APP_ROUTES: Routes = [
...OAUTH_ROUTES,
{
path: '',
redirectTo: '/home',
Expand All @@ -15,27 +46,27 @@ export const AppRoutes: Routes = [
{
path: 'home',
loadChildren: './pages/home-page/home-page.module#HomePageModule',
data: HomePageRoutes[0].data
data: HOME_PAGE_ROUTES[0].data
},
{
path: 'entities',
loadChildren: './pages/entities-page/entities-page.module#EntitiesPageModule',
data: EntitiesPageRoutes[0].data
data: ENTITIES_PAGE_ROUTES[0].data
},
{
path: 'themes',
loadChildren: './pages/themes-page/themes-page.module#ThemesPageModule',
data: ThemesPageRoutes[0].data
data: THEMES_PAGE_ROUTES[0].data
},
{
path: 'account',
loadChildren: './pages/account-page/account-page.module#AccountPageModule',
data: AccountPageRoutes[0].data
data: ACCOUNT_PAGE_ROUTES[0].data
},
{
path: 'admin',
loadChildren: './pages/admin-page/admin-page.module#AdminPageModule',
data: AdminPageRoutes[0].data
data: ADMIN_PAGE_ROUTES[0].data
},
{
path: '**',
Expand Down
15 changes: 15 additions & 0 deletions apps/demo/src/app/config/config.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { IAuthModalOauthProvider, ILanguagesItem } from '@rucken/core';

export interface ICoreConfig {
app: {
id: string;
title: string;
description: string;
languages: ILanguagesItem[]
};
authModal: {
signInInfoMessage: string;
signUpInfoMessage: string;
};
oauth: IAuthModalOauthProvider[];
}
Loading

0 comments on commit 084dce9

Please sign in to comment.