diff --git a/apps/demo/src/app/app.browser.module.ts b/apps/demo/src/app/app.browser.module.ts index cf095aad..ccfa2bc0 100644 --- a/apps/demo/src/app/app.browser.module.ts +++ b/apps/demo/src/app/app.browser.module.ts @@ -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, @@ -29,4 +28,4 @@ import { initializeBrowserApp } from './shared/utils/initialize-browser-app'; } ] }) -export class AppBrowserModule {} +export class AppBrowserModule { } diff --git a/apps/demo/src/app/app.component.ts b/apps/demo/src/app/app.component.ts index 3d5b9043..54c775f3 100644 --- a/apps/demo/src/app/app.component.ts +++ b/apps/demo/src/app/app.component.ts @@ -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({ @@ -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); @@ -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); diff --git a/apps/demo/src/app/app.config.ts b/apps/demo/src/app/app.config.ts deleted file mode 100644 index 200843e8..00000000 --- a/apps/demo/src/app/app.config.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { library } from '@fortawesome/fontawesome-svg-core'; -import { fab } from '@fortawesome/free-brands-svg-icons'; -import { fas } from '@fortawesome/free-solid-svg-icons'; -import { MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'; -import { TranslateService } from '@ngx-translate/core'; -import { AuthEmptyPageComponent, OauthGuard, RuI18n as CoreRuI18n, translate } from '@rucken/core'; -import { RuI18n as WebRuI18n } from '@rucken/web'; -import { defineLocale } from 'ngx-bootstrap/chronos'; -import { enGbLocale, ruLocale } from 'ngx-bootstrap/locale'; -import { AppRoutes } from './app.routes'; -import { RuI18n } from './i18n/ru.i18n'; - -library.add(fas, fab); - -defineLocale('ru', ruLocale); -defineLocale('en', enGbLocale); - -export const AppLangs = [ - { - title: translate('Russian'), - code: 'ru', - translations: [WebRuI18n, CoreRuI18n, RuI18n] - }, - { - title: translate('English'), - code: 'en', - translations: [] - } -]; -export const AppId = 'demo'; -export const ApplicationName = translate('Rucken: Demo'); -export const ApplicationDescription = translate('Core with Admin UI for web and native application maked on Angular7+'); -export const AuthModalSignInInfoMessage = translate(`

Demo users:

`); -export const AuthModalSignUpInfoMessage = ''; - -export function appMetaFactory(translateService: TranslateService): MetaLoader { - return new MetaStaticLoader({ - callback: (key: string) => { - return translateService.get(key); - }, - pageTitlePositioning: PageTitlePositioning.PrependPageTitle, - pageTitleSeparator: ' - ', - applicationName: ApplicationName, - defaults: { - title: ApplicationName, - description: ApplicationDescription, - 'og:type': 'website', - 'og:locale': 'en_US', - 'og:locale:alternate': 'en_US,ru_RU' - } - }); -} - -export const OauthProviders = ['facebook', 'google-plus']; -export const OauthModalProviders = [ - { - name: 'facebook', - icon: ['fab', 'facebook-square'], - signInTitle: translate('Sign in with Facebook') - }, - { - name: 'google-plus', - icon: ['fab', 'google-plus'], - signInTitle: translate('Sign in with Google+') - } -]; -export const OauthRoutes = [ - { - 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 AllRoutes = [...OauthRoutes, ...AppRoutes]; diff --git a/apps/demo/src/app/app.module.ts b/apps/demo/src/app/app.module.ts index 0a798ebd..66306322 100644 --- a/apps/demo/src/app/app.module.ts +++ b/apps/demo/src/app/app.module.ts @@ -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, @@ -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 { } diff --git a/apps/demo/src/app/app.routes.ts b/apps/demo/src/app/app.routes.ts index e4e59fe2..b59ab2a1 100644 --- a/apps/demo/src/app/app.routes.ts +++ b/apps/demo/src/app/app.routes.ts @@ -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', @@ -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: '**', diff --git a/apps/demo/src/app/config/config.interface.ts b/apps/demo/src/app/config/config.interface.ts new file mode 100644 index 00000000..bdf3d243 --- /dev/null +++ b/apps/demo/src/app/config/config.interface.ts @@ -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[]; +} diff --git a/apps/demo/src/app/config/config.ts b/apps/demo/src/app/config/config.ts new file mode 100644 index 00000000..dab9fa90 --- /dev/null +++ b/apps/demo/src/app/config/config.ts @@ -0,0 +1,54 @@ +import { library } from '@fortawesome/fontawesome-svg-core'; +import { fab } from '@fortawesome/free-brands-svg-icons'; +import { fas } from '@fortawesome/free-solid-svg-icons'; +import { RuI18n as CoreRuI18n, translate } from '@rucken/core'; +import { RuI18n as WebRuI18n } from '@rucken/web'; +import { defineLocale } from 'ngx-bootstrap/chronos'; +import { enGbLocale, ruLocale } from 'ngx-bootstrap/locale'; +import { RuI18n } from '../i18n/ru.i18n'; +import { ICoreConfig } from './config.interface'; + +library.add(fas, fab); + +defineLocale('ru', ruLocale); +defineLocale('en', enGbLocale); + +export const config: ICoreConfig = { + app: { + id: 'demo', + title: translate('Rucken: Demo'), + description: translate('Core with Admin UI for web and native application maked on Angular7+'), + languages: [ + { + title: translate('Russian'), + code: 'ru', + translations: [WebRuI18n, CoreRuI18n, RuI18n] + }, + { + title: translate('English'), + code: 'en', + translations: [] + } + ] + }, + authModal: { + signInInfoMessage: translate(`

Demo users:

`), + signUpInfoMessage: '', + }, + oauth: [ + { + name: 'facebook', + icon: ['fab', 'facebook-square'], + signInTitle: translate('Sign in with Facebook') + }, + { + name: 'google-plus', + icon: ['fab', 'google-plus'], + signInTitle: translate('Sign in with Google+') + } + ] +}; diff --git a/apps/demo/src/app/i18n/template.pot b/apps/demo/src/app/i18n/template.pot index a88e9e6d..7e361290 100644 --- a/apps/demo/src/app/i18n/template.pot +++ b/apps/demo/src/app/i18n/template.pot @@ -4,16 +4,16 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -msgid "Russian" +msgid "Rucken: Demo" msgstr "" -msgid "English" +msgid "Core with Admin UI for web and native application maked on Angular7+" msgstr "" -msgid "Rucken: Demo" +msgid "Russian" msgstr "" -msgid "Core with Admin UI for web and native application maked on Angular7+" +msgid "English" msgstr "" msgid "" diff --git a/apps/demo/src/app/index.ts b/apps/demo/src/app/index.ts index 85c939ff..5a32d0ff 100644 --- a/apps/demo/src/app/index.ts +++ b/apps/demo/src/app/index.ts @@ -1,9 +1,10 @@ export * from './app.browser.module'; export * from './app.component.spec'; export * from './app.component'; -export * from './app.config'; export * from './app.module'; export * from './app.routes'; +export * from './config/config.interface'; +export * from './config/config'; export * from './i18n/af.i18n'; export * from './i18n/ru.i18n'; export * from './i18n/tr.i18n'; @@ -45,3 +46,4 @@ export * from './pages/themes-page/themes-page.routes'; export * from './shared/shared.module'; export * from './shared/exceptions/error.handler'; export * from './shared/utils/initialize-browser-app'; +export * from './shared/utils/meta-factory'; diff --git a/apps/demo/src/app/pages/account-page/account-page.children-routes.ts b/apps/demo/src/app/pages/account-page/account-page.children-routes.ts index 11223799..4de15c5a 100644 --- a/apps/demo/src/app/pages/account-page/account-page.children-routes.ts +++ b/apps/demo/src/app/pages/account-page/account-page.children-routes.ts @@ -1,10 +1,10 @@ -import { ProfileFrameRoutes } from './profile-frame/profile-frame.routes'; +import { PROFILE_FRAME_ROUTES } from './profile-frame/profile-frame.routes'; -export const AccountPageChildrenRoutes = [ +export const ACCOUNT_PAGE_CHILDREN_ROUTES = [ { path: '', redirectTo: '/account/profile', pathMatch: 'full' }, { path: 'profile', loadChildren: './profile-frame/profile-frame.module#ProfileFrameModule', - data: ProfileFrameRoutes[0].data + data: PROFILE_FRAME_ROUTES[0].data } ]; diff --git a/apps/demo/src/app/pages/account-page/account-page.component.ts b/apps/demo/src/app/pages/account-page/account-page.component.ts index 956aa644..7fa27797 100644 --- a/apps/demo/src/app/pages/account-page/account-page.component.ts +++ b/apps/demo/src/app/pages/account-page/account-page.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { NavSidebarComponent } from '@rucken/web'; -import { AccountPageChildrenRoutes } from './account-page.children-routes'; +import { ACCOUNT_PAGE_CHILDREN_ROUTES } from './account-page.children-routes'; import { BindIoInner } from 'ngx-bind-io'; @BindIoInner() @@ -13,8 +13,8 @@ import { BindIoInner } from 'ngx-bind-io'; export class AccountPageComponent implements OnInit { @ViewChild('sidebar') sidebar: NavSidebarComponent; - constructor(private _activatedRoute: ActivatedRoute) {} + constructor(private _activatedRoute: ActivatedRoute) { } ngOnInit() { - this.sidebar.setRoutes(AccountPageChildrenRoutes); + this.sidebar.setRoutes(ACCOUNT_PAGE_CHILDREN_ROUTES); } } diff --git a/apps/demo/src/app/pages/account-page/account-page.module.ts b/apps/demo/src/app/pages/account-page/account-page.module.ts index abeea936..f2428cdd 100644 --- a/apps/demo/src/app/pages/account-page/account-page.module.ts +++ b/apps/demo/src/app/pages/account-page/account-page.module.ts @@ -4,10 +4,10 @@ import { NavSidebarModule } from '@rucken/web'; import { NgxPermissionsModule } from 'ngx-permissions'; import { SharedModule } from '../../shared/shared.module'; import { AccountPageComponent } from './account-page.component'; -import { AccountPageRoutes } from './account-page.routes'; +import { ACCOUNT_PAGE_ROUTES } from './account-page.routes'; @NgModule({ - imports: [SharedModule, NgxPermissionsModule.forChild(), NavSidebarModule, RouterModule.forChild(AccountPageRoutes)], + imports: [SharedModule, NgxPermissionsModule.forChild(), NavSidebarModule, RouterModule.forChild(ACCOUNT_PAGE_ROUTES)], declarations: [AccountPageComponent] }) -export class AccountPageModule {} +export class AccountPageModule { } diff --git a/apps/demo/src/app/pages/account-page/account-page.routes.ts b/apps/demo/src/app/pages/account-page/account-page.routes.ts index ed90742a..1f2651c6 100644 --- a/apps/demo/src/app/pages/account-page/account-page.routes.ts +++ b/apps/demo/src/app/pages/account-page/account-page.routes.ts @@ -1,9 +1,9 @@ import { MetaGuard } from '@ngx-meta/core'; import { PermissionsGuard, translate } from '@rucken/core'; -import { AccountPageChildrenRoutes } from './account-page.children-routes'; +import { ACCOUNT_PAGE_CHILDREN_ROUTES } from './account-page.children-routes'; import { AccountPageComponent } from './account-page.component'; -export const AccountPageRoutes = [ +export const ACCOUNT_PAGE_ROUTES = [ { path: '', component: AccountPageComponent, @@ -19,6 +19,6 @@ export const AccountPageRoutes = [ description: translate('Account page') } }, - children: AccountPageChildrenRoutes + children: ACCOUNT_PAGE_CHILDREN_ROUTES } ]; diff --git a/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.component.ts b/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.component.ts index b2479d2b..c5e530e7 100644 --- a/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.component.ts +++ b/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { environment } from '../../../../environments/environment'; +import { environment } from 'apps/demo/src/environments/environment'; import { BindIoInner } from 'ngx-bind-io'; @BindIoInner() diff --git a/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.module.ts b/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.module.ts index caf6c9d1..b2050183 100644 --- a/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.module.ts +++ b/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.module.ts @@ -4,14 +4,14 @@ import { ProfilePanelModule } from '@rucken/web'; import { NgxPermissionsModule } from 'ngx-permissions'; import { SharedModule } from '../../../shared/shared.module'; import { ProfileFrameComponent } from './profile-frame.component'; -import { ProfileFrameRoutes } from './profile-frame.routes'; +import { PROFILE_FRAME_ROUTES } from './profile-frame.routes'; @NgModule({ imports: [ SharedModule, NgxPermissionsModule.forChild(), ProfilePanelModule, - RouterModule.forChild(ProfileFrameRoutes) + RouterModule.forChild(PROFILE_FRAME_ROUTES) ], declarations: [ProfileFrameComponent] }) diff --git a/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.routes.ts b/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.routes.ts index 225e9284..a9dc321a 100644 --- a/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.routes.ts +++ b/apps/demo/src/app/pages/account-page/profile-frame/profile-frame.routes.ts @@ -2,7 +2,7 @@ import { translate, PermissionsGuard } from '@rucken/core'; import { ProfileFrameComponent } from './profile-frame.component'; import { MetaGuard } from '@ngx-meta/core'; -export const ProfileFrameRoutes = [ +export const PROFILE_FRAME_ROUTES = [ { path: '', component: ProfileFrameComponent, diff --git a/apps/demo/src/app/pages/admin-page/admin-page.children-routes.ts b/apps/demo/src/app/pages/admin-page/admin-page.children-routes.ts index 9390eb65..ce3244f6 100644 --- a/apps/demo/src/app/pages/admin-page/admin-page.children-routes.ts +++ b/apps/demo/src/app/pages/admin-page/admin-page.children-routes.ts @@ -1,16 +1,16 @@ -import { GroupsFrameRoutes } from '../entities-page/groups-frame/groups-frame.routes'; -import { UsersFrameRoutes } from '../entities-page/users-frame/users-frame.routes'; +import { GROUPS_FRAME_ROUTES } from '../entities-page/groups-frame/groups-frame.routes'; +import { USERS_FRAME_ROUTES } from '../entities-page/users-frame/users-frame.routes'; -export const AdminPageChildrenRoutes = [ +export const ADMIN_PAGE_CHILDREN_ROUTES = [ { path: '', redirectTo: '/admin/users', pathMatch: 'full' }, { path: 'users', loadChildren: '../entities-page/users-frame/users-frame.module#UsersFrameModule', - data: UsersFrameRoutes[0].data + data: USERS_FRAME_ROUTES[0].data }, { path: 'groups', loadChildren: '../entities-page/groups-frame/groups-frame.module#GroupsFrameModule', - data: GroupsFrameRoutes[0].data + data: GROUPS_FRAME_ROUTES[0].data } ]; diff --git a/apps/demo/src/app/pages/admin-page/admin-page.component.ts b/apps/demo/src/app/pages/admin-page/admin-page.component.ts index 50c833de..3ea71f9c 100644 --- a/apps/demo/src/app/pages/admin-page/admin-page.component.ts +++ b/apps/demo/src/app/pages/admin-page/admin-page.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; import { NavSidebarComponent } from '@rucken/web'; -import { AdminPageChildrenRoutes } from './admin-page.children-routes'; +import { ADMIN_PAGE_CHILDREN_ROUTES } from './admin-page.children-routes'; import { BindIoInner } from 'ngx-bind-io'; @BindIoInner() @@ -13,6 +13,6 @@ export class AdminPageComponent implements OnInit { @ViewChild('sidebar') sidebar: NavSidebarComponent; ngOnInit() { - this.sidebar.setRoutes(AdminPageChildrenRoutes); + this.sidebar.setRoutes(ADMIN_PAGE_CHILDREN_ROUTES); } } diff --git a/apps/demo/src/app/pages/admin-page/admin-page.module.ts b/apps/demo/src/app/pages/admin-page/admin-page.module.ts index b261e992..9b25bf2d 100644 --- a/apps/demo/src/app/pages/admin-page/admin-page.module.ts +++ b/apps/demo/src/app/pages/admin-page/admin-page.module.ts @@ -4,10 +4,10 @@ import { NavSidebarModule } from '@rucken/web'; import { NgxPermissionsModule } from 'ngx-permissions'; import { SharedModule } from '../../shared/shared.module'; import { AdminPageComponent } from './admin-page.component'; -import { AdminPageRoutes } from './admin-page.routes'; +import { ADMIN_PAGE_ROUTES } from './admin-page.routes'; @NgModule({ - imports: [SharedModule, NgxPermissionsModule.forChild(), NavSidebarModule, RouterModule.forChild(AdminPageRoutes)], + imports: [SharedModule, NgxPermissionsModule.forChild(), NavSidebarModule, RouterModule.forChild(ADMIN_PAGE_ROUTES)], declarations: [AdminPageComponent] }) -export class AdminPageModule {} +export class AdminPageModule { } diff --git a/apps/demo/src/app/pages/admin-page/admin-page.routes.ts b/apps/demo/src/app/pages/admin-page/admin-page.routes.ts index cb6084e4..0a9ed0e8 100644 --- a/apps/demo/src/app/pages/admin-page/admin-page.routes.ts +++ b/apps/demo/src/app/pages/admin-page/admin-page.routes.ts @@ -1,9 +1,9 @@ import { MetaGuard } from '@ngx-meta/core'; import { PermissionsGuard, translate } from '@rucken/core'; -import { AdminPageChildrenRoutes } from './admin-page.children-routes'; +import { ADMIN_PAGE_CHILDREN_ROUTES } from './admin-page.children-routes'; import { AdminPageComponent } from './admin-page.component'; -export const AdminPageRoutes = [ +export const ADMIN_PAGE_ROUTES = [ { path: '', component: AdminPageComponent, @@ -19,6 +19,6 @@ export const AdminPageRoutes = [ description: translate('Administration page') } }, - children: AdminPageChildrenRoutes + children: ADMIN_PAGE_CHILDREN_ROUTES } ]; diff --git a/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.component.ts b/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.component.ts index 30a58c21..1628eb1b 100644 --- a/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.component.ts +++ b/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { environment } from '../../../../environments/environment'; +import { environment } from 'apps/demo/src/environments/environment'; import { BindIoInner } from 'ngx-bind-io'; @BindIoInner() diff --git a/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.module.ts b/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.module.ts index c9993f44..618aca80 100644 --- a/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.module.ts +++ b/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.module.ts @@ -5,16 +5,16 @@ import { ContentTypesGridModule } from '@rucken/web'; import { NgxPermissionsModule } from 'ngx-permissions'; import { SharedModule } from '../../../shared/shared.module'; import { ContentTypesFrameComponent } from './content-types-frame.component'; -import { ContentTypesFrameRoutes } from './content-types-frame.routes'; +import { CONTENT_TYPES_FRAME_ROUTES } from './content-types-frame.routes'; @NgModule({ imports: [ SharedModule, NgxPermissionsModule.forChild(), - RouterModule.forChild(ContentTypesFrameRoutes), + RouterModule.forChild(CONTENT_TYPES_FRAME_ROUTES), ContentTypesGridModule, FormsModule ], declarations: [ContentTypesFrameComponent] }) -export class ContentTypesFrameModule {} +export class ContentTypesFrameModule { } diff --git a/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.routes.ts b/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.routes.ts index 1dd60de2..7dfe3a46 100644 --- a/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.routes.ts +++ b/apps/demo/src/app/pages/entities-page/content-types-frame/content-types-frame.routes.ts @@ -2,7 +2,7 @@ import { translate } from '@rucken/core'; import { ContentTypesFrameComponent } from './content-types-frame.component'; import { MetaGuard } from '@ngx-meta/core'; -export const ContentTypesFrameRoutes = [ +export const CONTENT_TYPES_FRAME_ROUTES = [ { path: '', component: ContentTypesFrameComponent, diff --git a/apps/demo/src/app/pages/entities-page/entities-page.children-routes.ts b/apps/demo/src/app/pages/entities-page/entities-page.children-routes.ts index 3dbe6007..77c208f1 100644 --- a/apps/demo/src/app/pages/entities-page/entities-page.children-routes.ts +++ b/apps/demo/src/app/pages/entities-page/entities-page.children-routes.ts @@ -1,28 +1,28 @@ -import { ContentTypesFrameRoutes } from './content-types-frame/content-types-frame.routes'; -import { GroupsFrameRoutes } from './groups-frame/groups-frame.routes'; -import { PermissionsFrameRoutes } from './permissions-frame/permissions-frame.routes'; -import { UsersFrameRoutes } from './users-frame/users-frame.routes'; +import { CONTENT_TYPES_FRAME_ROUTES } from './content-types-frame/content-types-frame.routes'; +import { GROUPS_FRAME_ROUTES } from './groups-frame/groups-frame.routes'; +import { PERMISSIONS_FRAME_ROUTES } from './permissions-frame/permissions-frame.routes'; +import { USERS_FRAME_ROUTES } from './users-frame/users-frame.routes'; -export const EntitiesPageChildrenRoutes = [ +export const ENTITIES_PAGE_CHILDREN_ROUTES = [ { path: '', redirectTo: '/entities/content-types', pathMatch: 'full' }, { path: 'content-types', loadChildren: './content-types-frame/content-types-frame.module#ContentTypesFrameModule', - data: ContentTypesFrameRoutes[0].data + data: CONTENT_TYPES_FRAME_ROUTES[0].data }, { path: 'groups', loadChildren: './groups-frame/groups-frame.module#GroupsFrameModule', - data: GroupsFrameRoutes[0].data + data: GROUPS_FRAME_ROUTES[0].data }, { path: 'permissions', loadChildren: './permissions-frame/permissions-frame.module#PermissionsFrameModule', - data: PermissionsFrameRoutes[0].data + data: PERMISSIONS_FRAME_ROUTES[0].data }, { path: 'users', loadChildren: './users-frame/users-frame.module#UsersFrameModule', - data: UsersFrameRoutes[0].data + data: USERS_FRAME_ROUTES[0].data } ]; diff --git a/apps/demo/src/app/pages/entities-page/entities-page.component.ts b/apps/demo/src/app/pages/entities-page/entities-page.component.ts index f970b18b..f3d145dd 100644 --- a/apps/demo/src/app/pages/entities-page/entities-page.component.ts +++ b/apps/demo/src/app/pages/entities-page/entities-page.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { NavSidebarComponent } from '@rucken/web'; -import { EntitiesPageChildrenRoutes } from './entities-page.children-routes'; +import { ENTITIES_PAGE_CHILDREN_ROUTES } from './entities-page.children-routes'; import { BindIoInner } from 'ngx-bind-io'; @BindIoInner() @@ -13,8 +13,8 @@ import { BindIoInner } from 'ngx-bind-io'; export class EntitiesPageComponent implements OnInit { @ViewChild('sidebar') sidebar: NavSidebarComponent; - constructor(private _activatedRoute: ActivatedRoute) {} + constructor(private _activatedRoute: ActivatedRoute) { } ngOnInit() { - this.sidebar.setRoutes(EntitiesPageChildrenRoutes); + this.sidebar.setRoutes(ENTITIES_PAGE_CHILDREN_ROUTES); } } diff --git a/apps/demo/src/app/pages/entities-page/entities-page.module.ts b/apps/demo/src/app/pages/entities-page/entities-page.module.ts index 1682ec90..1ceba6b4 100644 --- a/apps/demo/src/app/pages/entities-page/entities-page.module.ts +++ b/apps/demo/src/app/pages/entities-page/entities-page.module.ts @@ -4,10 +4,10 @@ import { NavSidebarModule } from '@rucken/web'; import { NgxPermissionsModule } from 'ngx-permissions'; import { SharedModule } from '../../shared/shared.module'; import { EntitiesPageComponent } from './entities-page.component'; -import { EntitiesPageRoutes } from './entities-page.routes'; +import { ENTITIES_PAGE_ROUTES } from './entities-page.routes'; @NgModule({ - imports: [SharedModule, NgxPermissionsModule.forChild(), NavSidebarModule, RouterModule.forChild(EntitiesPageRoutes)], + imports: [SharedModule, NgxPermissionsModule.forChild(), NavSidebarModule, RouterModule.forChild(ENTITIES_PAGE_ROUTES)], declarations: [EntitiesPageComponent] }) -export class EntitiesPageModule {} +export class EntitiesPageModule { } diff --git a/apps/demo/src/app/pages/entities-page/entities-page.routes.ts b/apps/demo/src/app/pages/entities-page/entities-page.routes.ts index 50a846b1..57a5f222 100644 --- a/apps/demo/src/app/pages/entities-page/entities-page.routes.ts +++ b/apps/demo/src/app/pages/entities-page/entities-page.routes.ts @@ -1,9 +1,9 @@ import { translate } from '@rucken/core'; -import { EntitiesPageChildrenRoutes } from './entities-page.children-routes'; +import { ENTITIES_PAGE_CHILDREN_ROUTES } from './entities-page.children-routes'; import { EntitiesPageComponent } from './entities-page.component'; import { MetaGuard } from '@ngx-meta/core'; -export const EntitiesPageRoutes = [ +export const ENTITIES_PAGE_ROUTES = [ { path: '', component: EntitiesPageComponent, @@ -15,6 +15,6 @@ export const EntitiesPageRoutes = [ description: translate('Entities page') } }, - children: EntitiesPageChildrenRoutes + children: ENTITIES_PAGE_CHILDREN_ROUTES } ]; diff --git a/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.component.ts b/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.component.ts index 65bbf44a..e4e8622c 100644 --- a/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.component.ts +++ b/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { environment } from '../../../../environments/environment'; +import { environment } from 'apps/demo/src/environments/environment'; import { BindIoInner } from 'ngx-bind-io'; @BindIoInner() diff --git a/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.module.ts b/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.module.ts index 4148f5ea..482d9191 100644 --- a/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.module.ts +++ b/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.module.ts @@ -5,16 +5,16 @@ import { GroupsGridModule } from '@rucken/web'; import { NgxPermissionsModule } from 'ngx-permissions'; import { SharedModule } from '../../../shared/shared.module'; import { GroupsFrameComponent } from './groups-frame.component'; -import { GroupsFrameRoutes } from './groups-frame.routes'; +import { GROUPS_FRAME_ROUTES } from './groups-frame.routes'; @NgModule({ imports: [ SharedModule, NgxPermissionsModule.forChild(), - RouterModule.forChild(GroupsFrameRoutes), + RouterModule.forChild(GROUPS_FRAME_ROUTES), GroupsGridModule, FormsModule ], declarations: [GroupsFrameComponent] }) -export class GroupsFrameModule {} +export class GroupsFrameModule { } diff --git a/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.routes.ts b/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.routes.ts index 18979a17..07d75f41 100644 --- a/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.routes.ts +++ b/apps/demo/src/app/pages/entities-page/groups-frame/groups-frame.routes.ts @@ -2,7 +2,7 @@ import { translate } from '@rucken/core'; import { GroupsFrameComponent } from './groups-frame.component'; import { MetaGuard } from '@ngx-meta/core'; -export const GroupsFrameRoutes = [ +export const GROUPS_FRAME_ROUTES = [ { path: '', component: GroupsFrameComponent, diff --git a/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.component.ts b/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.component.ts index ea87d3a3..7c5c207e 100644 --- a/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.component.ts +++ b/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { environment } from '../../../../environments/environment'; +import { environment } from 'apps/demo/src/environments/environment'; import { BindIoInner } from 'ngx-bind-io'; @BindIoInner() diff --git a/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.module.ts b/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.module.ts index f6d242a8..0c87eeba 100644 --- a/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.module.ts +++ b/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.module.ts @@ -5,16 +5,16 @@ import { PermissionsGridModule } from '@rucken/web'; import { NgxPermissionsModule } from 'ngx-permissions'; import { SharedModule } from '../../../shared/shared.module'; import { PermissionsFrameComponent } from './permissions-frame.component'; -import { PermissionsFrameRoutes } from './permissions-frame.routes'; +import { PERMISSIONS_FRAME_ROUTES } from './permissions-frame.routes'; @NgModule({ imports: [ SharedModule, NgxPermissionsModule.forChild(), - RouterModule.forChild(PermissionsFrameRoutes), + RouterModule.forChild(PERMISSIONS_FRAME_ROUTES), PermissionsGridModule, FormsModule ], declarations: [PermissionsFrameComponent] }) -export class PermissionsFrameModule {} +export class PermissionsFrameModule { } diff --git a/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.routes.ts b/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.routes.ts index cbf8a1d1..a975362a 100644 --- a/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.routes.ts +++ b/apps/demo/src/app/pages/entities-page/permissions-frame/permissions-frame.routes.ts @@ -2,17 +2,18 @@ import { translate } from '@rucken/core'; import { PermissionsFrameComponent } from './permissions-frame.component'; import { MetaGuard } from '@ngx-meta/core'; -export const PermissionsFrameRoutes = [ - { - path: '', - component: PermissionsFrameComponent, - canActivate: [MetaGuard], - data: { - name: 'permissions', - meta: { - title: translate('Permissions'), - description: translate('Permissions frame') +export const PERMISSIONS_FRAME_ROUTES + = [ + { + path: '', + component: PermissionsFrameComponent, + canActivate: [MetaGuard], + data: { + name: 'permissions', + meta: { + title: translate('Permissions'), + description: translate('Permissions frame') + } } } - } -]; + ]; diff --git a/apps/demo/src/app/pages/entities-page/users-frame/users-frame.component.ts b/apps/demo/src/app/pages/entities-page/users-frame/users-frame.component.ts index 6afa0955..95667c9e 100644 --- a/apps/demo/src/app/pages/entities-page/users-frame/users-frame.component.ts +++ b/apps/demo/src/app/pages/entities-page/users-frame/users-frame.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { environment } from '../../../../environments/environment'; +import { environment } from 'apps/demo/src/environments/environment'; import { BindIoInner } from 'ngx-bind-io'; @BindIoInner() diff --git a/apps/demo/src/app/pages/entities-page/users-frame/users-frame.module.ts b/apps/demo/src/app/pages/entities-page/users-frame/users-frame.module.ts index 379ee977..be93f277 100644 --- a/apps/demo/src/app/pages/entities-page/users-frame/users-frame.module.ts +++ b/apps/demo/src/app/pages/entities-page/users-frame/users-frame.module.ts @@ -5,16 +5,16 @@ import { UsersGridModule } from '@rucken/web'; import { NgxPermissionsModule } from 'ngx-permissions'; import { SharedModule } from '../../../shared/shared.module'; import { UsersFrameComponent } from './users-frame.component'; -import { UsersFrameRoutes } from './users-frame.routes'; +import { USERS_FRAME_ROUTES } from './users-frame.routes'; @NgModule({ imports: [ SharedModule, NgxPermissionsModule.forChild(), - RouterModule.forChild(UsersFrameRoutes), + RouterModule.forChild(USERS_FRAME_ROUTES), UsersGridModule, FormsModule ], declarations: [UsersFrameComponent] }) -export class UsersFrameModule {} +export class UsersFrameModule { } diff --git a/apps/demo/src/app/pages/entities-page/users-frame/users-frame.routes.ts b/apps/demo/src/app/pages/entities-page/users-frame/users-frame.routes.ts index b837a4f3..e3e74933 100644 --- a/apps/demo/src/app/pages/entities-page/users-frame/users-frame.routes.ts +++ b/apps/demo/src/app/pages/entities-page/users-frame/users-frame.routes.ts @@ -2,7 +2,7 @@ import { translate } from '@rucken/core'; import { UsersFrameComponent } from './users-frame.component'; import { MetaGuard } from '@ngx-meta/core'; -export const UsersFrameRoutes = [ +export const USERS_FRAME_ROUTES = [ { path: '', component: UsersFrameComponent, diff --git a/apps/demo/src/app/pages/home-page/home-page.module.ts b/apps/demo/src/app/pages/home-page/home-page.module.ts index c59f7b1e..381825f3 100644 --- a/apps/demo/src/app/pages/home-page/home-page.module.ts +++ b/apps/demo/src/app/pages/home-page/home-page.module.ts @@ -2,10 +2,10 @@ import { ModuleWithProviders, NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { SharedModule } from '../../shared/shared.module'; import { HomePageComponent } from './home-page.component'; -import { HomePageRoutes } from './home-page.routes'; +import { HOME_PAGE_ROUTES } from './home-page.routes'; @NgModule({ - imports: [SharedModule, RouterModule.forChild(HomePageRoutes)], + imports: [SharedModule, RouterModule.forChild(HOME_PAGE_ROUTES)], declarations: [HomePageComponent] }) -export class HomePageModule {} +export class HomePageModule { } diff --git a/apps/demo/src/app/pages/home-page/home-page.routes.ts b/apps/demo/src/app/pages/home-page/home-page.routes.ts index bb4081e8..e5700f25 100644 --- a/apps/demo/src/app/pages/home-page/home-page.routes.ts +++ b/apps/demo/src/app/pages/home-page/home-page.routes.ts @@ -2,7 +2,7 @@ import { HomePageComponent } from './home-page.component'; import { translate } from '@rucken/core'; import { MetaGuard } from '@ngx-meta/core'; -export const HomePageRoutes = [ +export const HOME_PAGE_ROUTES = [ { path: '', component: HomePageComponent, diff --git a/apps/demo/src/app/pages/themes-page/themes-page.module.ts b/apps/demo/src/app/pages/themes-page/themes-page.module.ts index ac8a0505..0fd53e29 100644 --- a/apps/demo/src/app/pages/themes-page/themes-page.module.ts +++ b/apps/demo/src/app/pages/themes-page/themes-page.module.ts @@ -2,10 +2,10 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { SharedModule } from '../../shared/shared.module'; import { ThemesPageComponent } from './themes-page.component'; -import { ThemesPageRoutes } from './themes-page.routes'; +import { THEMES_PAGE_ROUTES } from './themes-page.routes'; @NgModule({ - imports: [SharedModule, RouterModule.forChild(ThemesPageRoutes)], + imports: [SharedModule, RouterModule.forChild(THEMES_PAGE_ROUTES)], declarations: [ThemesPageComponent] }) -export class ThemesPageModule {} +export class ThemesPageModule { } diff --git a/apps/demo/src/app/pages/themes-page/themes-page.routes.ts b/apps/demo/src/app/pages/themes-page/themes-page.routes.ts index 7c0e323b..c56fefb2 100644 --- a/apps/demo/src/app/pages/themes-page/themes-page.routes.ts +++ b/apps/demo/src/app/pages/themes-page/themes-page.routes.ts @@ -2,7 +2,7 @@ import { translate } from '@rucken/core'; import { ThemesPageComponent } from './themes-page.component'; import { MetaGuard } from '@ngx-meta/core'; -export const ThemesPageRoutes = [ +export const THEMES_PAGE_ROUTES = [ { path: '', component: ThemesPageComponent, diff --git a/apps/demo/src/app/shared/utils/meta-factory.ts b/apps/demo/src/app/shared/utils/meta-factory.ts new file mode 100644 index 00000000..de8eba6d --- /dev/null +++ b/apps/demo/src/app/shared/utils/meta-factory.ts @@ -0,0 +1,21 @@ +import { MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'; +import { TranslateService } from '@ngx-translate/core'; +import { config } from '../../config/config'; + +export function metaFactory(translateService: TranslateService): MetaLoader { + return new MetaStaticLoader({ + callback: (key: string) => { + return translateService.get(key); + }, + pageTitlePositioning: PageTitlePositioning.PrependPageTitle, + pageTitleSeparator: ' - ', + applicationName: config.app.title, + defaults: { + title: config.app.title, + description: config.app.description, + 'og:type': 'website', + 'og:locale': 'en_US', + 'og:locale:alternate': 'en_US,ru_RU' + } + }); +} diff --git a/apps/demo/src/environments/environment-server.prod.ts b/apps/demo/src/environments/environment-server.prod.ts index f7ca815a..f45cd127 100644 --- a/apps/demo/src/environments/environment-server.prod.ts +++ b/apps/demo/src/environments/environment-server.prod.ts @@ -1,4 +1,6 @@ -export const environment = { +import { IEnvironment } from './environment.interface'; + +export const environment: IEnvironment = { server: true, type: 'prod', production: true, diff --git a/apps/demo/src/environments/environment-server.ts b/apps/demo/src/environments/environment-server.ts index 26489afa..a7fc3441 100644 --- a/apps/demo/src/environments/environment-server.ts +++ b/apps/demo/src/environments/environment-server.ts @@ -1,4 +1,6 @@ -export const environment = { +import { IEnvironment } from './environment.interface'; + +export const environment: IEnvironment = { server: true, type: 'development', production: false, diff --git a/apps/demo/src/environments/environment.interface.ts b/apps/demo/src/environments/environment.interface.ts new file mode 100644 index 00000000..7cec5dad --- /dev/null +++ b/apps/demo/src/environments/environment.interface.ts @@ -0,0 +1,6 @@ +export interface IEnvironment { + server: boolean; + type: 'prod' | 'development'; + production: boolean; + apiUrl: string; +} diff --git a/apps/demo/src/environments/environment.prod.ts b/apps/demo/src/environments/environment.prod.ts index ed302cb4..ec381a7e 100644 --- a/apps/demo/src/environments/environment.prod.ts +++ b/apps/demo/src/environments/environment.prod.ts @@ -1,4 +1,6 @@ -export const environment = { +import { IEnvironment } from './environment.interface'; + +export const environment: IEnvironment = { server: false, type: 'prod', production: true, diff --git a/apps/demo/src/environments/environment.ts b/apps/demo/src/environments/environment.ts index 09b039b6..22861d97 100644 --- a/apps/demo/src/environments/environment.ts +++ b/apps/demo/src/environments/environment.ts @@ -1,6 +1,10 @@ -export const environment = { +import { IEnvironment } from './environment.interface'; + +export const environment: IEnvironment = { server: false, type: 'development', production: false, apiUrl: 'http://localhost:5000/api' }; + + diff --git a/apps/demo/src/main.ts b/apps/demo/src/main.ts index 044c31a9..7b3dc192 100644 --- a/apps/demo/src/main.ts +++ b/apps/demo/src/main.ts @@ -1,7 +1,7 @@ import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { environment } from 'apps/demo/src/environments/environment'; import { AppBrowserModule } from './app/app.browser.module'; -import { environment } from './environments/environment'; if (environment.production) { enableProdMode(); diff --git a/libs/rucken/core/src/index.ts b/libs/rucken/core/src/index.ts index 7ca9aaed..96cb596d 100644 --- a/libs/rucken/core/src/index.ts +++ b/libs/rucken/core/src/index.ts @@ -71,6 +71,7 @@ export * from './lib/modules/auth/dto/user-token.dto'; export * from './lib/modules/auth/guards/oauth.guard'; export * from './lib/modules/auth/interceptors/token.interceptor'; export * from './lib/modules/auth/interfaces/auth-config.interface'; +export * from './lib/modules/auth/interfaces/auth-oauth-provider.interface'; export * from './lib/modules/auth/interfaces/jwt-config.interface'; export * from './lib/modules/auth/interfaces/oauth-config.interface'; export * from './lib/modules/auth/services/auth.service'; diff --git a/libs/rucken/core/src/lib/entities/configs/content-types.config.ts b/libs/rucken/core/src/lib/entities/configs/content-types.config.ts index f3e11f25..75e9d1de 100644 --- a/libs/rucken/core/src/lib/entities/configs/content-types.config.ts +++ b/libs/rucken/core/src/lib/entities/configs/content-types.config.ts @@ -2,7 +2,7 @@ import { plainToClass } from 'class-transformer'; import { IRestProviderOptions, PaginationMeta, ProviderActionEnum } from 'ngx-repository'; import { ContentType } from '../models/content-type'; -export const defaultContentTypesConfig: IRestProviderOptions = { +export const DEFAULT_CONTENT_TYPES_CONFIG: IRestProviderOptions = { name: 'content_type', pluralName: 'content_types', autoload: true, diff --git a/libs/rucken/core/src/lib/entities/configs/groups.config.ts b/libs/rucken/core/src/lib/entities/configs/groups.config.ts index c972dd79..d9984040 100644 --- a/libs/rucken/core/src/lib/entities/configs/groups.config.ts +++ b/libs/rucken/core/src/lib/entities/configs/groups.config.ts @@ -2,7 +2,7 @@ import { plainToClass } from 'class-transformer'; import { IRestProviderOptions, PaginationMeta, ProviderActionEnum } from 'ngx-repository'; import { Group } from '../models/group'; -export const defaultGroupsConfig: IRestProviderOptions = { +export const DEFAULT_GROUPS_CONFIG: IRestProviderOptions = { name: 'group', pluralName: 'groups', autoload: true, diff --git a/libs/rucken/core/src/lib/entities/configs/index.ts b/libs/rucken/core/src/lib/entities/configs/index.ts index 1dfba1b9..9133f107 100644 --- a/libs/rucken/core/src/lib/entities/configs/index.ts +++ b/libs/rucken/core/src/lib/entities/configs/index.ts @@ -1,24 +1,24 @@ import { Provider } from '@angular/core'; -import { CONTENT_TYPES_CONFIG_TOKEN, defaultContentTypesConfig } from './content-types.config'; -import { defaultGroupsConfig, GROUPS_CONFIG_TOKEN } from './groups.config'; -import { defaultPermissionsConfig, PERMISSIONS_CONFIG_TOKEN } from './permissions.config'; -import { defaultUsersConfig, USERS_CONFIG_TOKEN } from './users.config'; +import { CONTENT_TYPES_CONFIG_TOKEN, DEFAULT_CONTENT_TYPES_CONFIG } from './content-types.config'; +import { DEFAULT_GROUPS_CONFIG, GROUPS_CONFIG_TOKEN } from './groups.config'; +import { DEFAULT_PERMISSIONS_CONFIG, PERMISSIONS_CONFIG_TOKEN } from './permissions.config'; +import { DEFAULT_USERS_CONFIG, USERS_CONFIG_TOKEN } from './users.config'; -export const entitiesProviders: Provider[] = [ +export const ENTITIES_PROVIDERS: Provider[] = [ { provide: CONTENT_TYPES_CONFIG_TOKEN, - useValue: defaultContentTypesConfig + useValue: DEFAULT_CONTENT_TYPES_CONFIG }, { provide: GROUPS_CONFIG_TOKEN, - useValue: defaultGroupsConfig + useValue: DEFAULT_GROUPS_CONFIG }, { provide: PERMISSIONS_CONFIG_TOKEN, - useValue: defaultPermissionsConfig + useValue: DEFAULT_PERMISSIONS_CONFIG }, { provide: USERS_CONFIG_TOKEN, - useValue: defaultUsersConfig + useValue: DEFAULT_USERS_CONFIG } ]; diff --git a/libs/rucken/core/src/lib/entities/configs/permissions.config.ts b/libs/rucken/core/src/lib/entities/configs/permissions.config.ts index d42874f9..a7c993ed 100644 --- a/libs/rucken/core/src/lib/entities/configs/permissions.config.ts +++ b/libs/rucken/core/src/lib/entities/configs/permissions.config.ts @@ -2,7 +2,7 @@ import { plainToClass } from 'class-transformer'; import { IRestProviderOptions, PaginationMeta, ProviderActionEnum } from 'ngx-repository'; import { Permission } from '../models/permission'; -export const defaultPermissionsConfig: IRestProviderOptions = { +export const DEFAULT_PERMISSIONS_CONFIG: IRestProviderOptions = { name: 'permission', pluralName: 'permissions', autoload: true, diff --git a/libs/rucken/core/src/lib/entities/configs/users.config.ts b/libs/rucken/core/src/lib/entities/configs/users.config.ts index e19432e2..c8f84e73 100644 --- a/libs/rucken/core/src/lib/entities/configs/users.config.ts +++ b/libs/rucken/core/src/lib/entities/configs/users.config.ts @@ -2,7 +2,7 @@ import { plainToClass } from 'class-transformer'; import { IRestProviderOptions, PaginationMeta, ProviderActionEnum } from 'ngx-repository'; import { User } from '../models/user'; -export const defaultUsersConfig: IRestProviderOptions = { +export const DEFAULT_USERS_CONFIG: IRestProviderOptions = { name: 'user', pluralName: 'users', autoload: true, diff --git a/libs/rucken/core/src/lib/modules/account/account.module.ts b/libs/rucken/core/src/lib/modules/account/account.module.ts index f0fd5c37..1e5512c1 100644 --- a/libs/rucken/core/src/lib/modules/account/account.module.ts +++ b/libs/rucken/core/src/lib/modules/account/account.module.ts @@ -1,8 +1,8 @@ import { CommonModule } from '@angular/common'; import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core'; -import { accountProviders } from './configs'; +import { ACCOUNT_PROVIDERS } from './configs'; import { AccountService } from './account.service'; -import { ACCOUNT_CONFIG_TOKEN, defaultAccountConfig } from './configs/account.config'; +import { ACCOUNT_CONFIG_TOKEN, DEFAULT_ACCOUNT_CONFIG } from './configs/account.config'; @NgModule({ imports: [CommonModule], providers: [AccountService] @@ -15,8 +15,8 @@ export class AccountModule { { provide: ACCOUNT_CONFIG_TOKEN, useValue: { - apiUrl: options.apiUrl ? options.apiUrl : defaultAccountConfig.apiUrl, - updateUrl: defaultAccountConfig.updateUrl + apiUrl: options.apiUrl ? options.apiUrl : DEFAULT_ACCOUNT_CONFIG.apiUrl, + updateUrl: DEFAULT_ACCOUNT_CONFIG.updateUrl } }, AccountService diff --git a/libs/rucken/core/src/lib/modules/account/configs/account.config.ts b/libs/rucken/core/src/lib/modules/account/configs/account.config.ts index cbc9468c..e7d79047 100644 --- a/libs/rucken/core/src/lib/modules/account/configs/account.config.ts +++ b/libs/rucken/core/src/lib/modules/account/configs/account.config.ts @@ -1,6 +1,6 @@ import { IAccountConfig } from '../interfaces/account-config.interface'; -export const defaultAccountConfig: IAccountConfig = { +export const DEFAULT_ACCOUNT_CONFIG: IAccountConfig = { apiUrl: '/api', updateUrl: '/account/update' }; diff --git a/libs/rucken/core/src/lib/modules/account/configs/index.ts b/libs/rucken/core/src/lib/modules/account/configs/index.ts index 7fd92553..ea5a8511 100644 --- a/libs/rucken/core/src/lib/modules/account/configs/index.ts +++ b/libs/rucken/core/src/lib/modules/account/configs/index.ts @@ -1,9 +1,9 @@ import { Provider } from '@angular/core'; -import { ACCOUNT_CONFIG_TOKEN, defaultAccountConfig } from './account.config'; +import { ACCOUNT_CONFIG_TOKEN, DEFAULT_ACCOUNT_CONFIG } from './account.config'; -export const accountProviders: Provider[] = [ +export const ACCOUNT_PROVIDERS: Provider[] = [ { provide: ACCOUNT_CONFIG_TOKEN, - useValue: defaultAccountConfig + useValue: DEFAULT_ACCOUNT_CONFIG } ]; diff --git a/libs/rucken/core/src/lib/modules/auth-modal/auth-modal.config.ts b/libs/rucken/core/src/lib/modules/auth-modal/auth-modal.config.ts index 214edf0c..a03cfde2 100644 --- a/libs/rucken/core/src/lib/modules/auth-modal/auth-modal.config.ts +++ b/libs/rucken/core/src/lib/modules/auth-modal/auth-modal.config.ts @@ -1,6 +1,6 @@ import { IAuthModalConfig } from './interfaces/auth-modal-config.interface'; -export const defaultAuthModalConfig: IAuthModalConfig = { +export const DEFAULT_AUTH_MODAL_CONFIG: IAuthModalConfig = { oauth: { providers: [] } diff --git a/libs/rucken/core/src/lib/modules/auth-modal/auth-modal.module.ts b/libs/rucken/core/src/lib/modules/auth-modal/auth-modal.module.ts index e2ed3283..c1dfc779 100644 --- a/libs/rucken/core/src/lib/modules/auth-modal/auth-modal.module.ts +++ b/libs/rucken/core/src/lib/modules/auth-modal/auth-modal.module.ts @@ -3,7 +3,7 @@ import { ModuleWithProviders, NgModule } from '@angular/core'; import { TranslateModule } from '@ngx-translate/core'; import { AuthModule } from '../auth/auth.module'; import { ModalsModule } from '../modals/modals.module'; -import { AUTH_MODAL_CONFIG_TOKEN, defaultAuthModalConfig } from './auth-modal.config'; +import { AUTH_MODAL_CONFIG_TOKEN, DEFAULT_AUTH_MODAL_CONFIG } from './auth-modal.config'; import { IAuthModalConfig } from './interfaces/auth-modal-config.interface'; @NgModule({ imports: [CommonModule, ModalsModule, AuthModule, TranslateModule.forChild()] @@ -16,7 +16,7 @@ export class AuthModalModule { { provide: AUTH_MODAL_CONFIG_TOKEN, useValue: { - oauth: options.oauth ? options.oauth : defaultAuthModalConfig.oauth + oauth: options.oauth ? options.oauth : DEFAULT_AUTH_MODAL_CONFIG.oauth } } ] diff --git a/libs/rucken/core/src/lib/modules/auth/auth.module.ts b/libs/rucken/core/src/lib/modules/auth/auth.module.ts index 137655ca..cdd5f2fb 100644 --- a/libs/rucken/core/src/lib/modules/auth/auth.module.ts +++ b/libs/rucken/core/src/lib/modules/auth/auth.module.ts @@ -4,11 +4,12 @@ import { APP_INITIALIZER, ModuleWithProviders, NgModule } from '@angular/core'; import { TranslateModule } from '@ngx-translate/core'; import { NgxPermissionsModule } from 'ngx-permissions'; import { AuthEmptyPageComponent } from './components/auth-empty-page.component'; -import { AUTH_CONFIG_TOKEN, defaultAuthConfig } from './configs/auth.config'; -import { defaultJwtConfig, JWT_CONFIG_TOKEN } from './configs/jwt.config'; -import { defaultOauthConfig, OAUTH_CONFIG_TOKEN } from './configs/oauth.config'; +import { AUTH_CONFIG_TOKEN, DEFAULT_AUTH_CONFIG } from './configs/auth.config'; +import { DEFAULT_JWT_CONFIG, JWT_CONFIG_TOKEN } from './configs/jwt.config'; +import { DEFAULT_OAUTH_CONFIG, OAUTH_CONFIG_TOKEN } from './configs/oauth.config'; import { OauthGuard } from './guards/oauth.guard'; import { TokenInterceptor } from './interceptors/token.interceptor'; +import { IAuthOauthProvider } from './interfaces/auth-oauth-provider.interface'; import { AuthService, authServiceInitializeApp } from './services/auth.service'; import { TokenService, tokenServiceInitializeApp } from './services/token.service'; @NgModule({ @@ -17,37 +18,37 @@ import { TokenService, tokenServiceInitializeApp } from './services/token.servic providers: [AuthService, TokenService, OauthGuard] }) export class AuthModule { - static forRoot(options?: { apiUrl?: string; oauth?: { providers?: string[] } }): ModuleWithProviders { + static forRoot(options?: { apiUrl?: string; oauth?: { providers?: IAuthOauthProvider[] } }): ModuleWithProviders { return { ngModule: AuthModule, providers: [ { provide: AUTH_CONFIG_TOKEN, useValue: { - apiUrl: options.apiUrl ? options.apiUrl : defaultAuthConfig.apiUrl, - infoUrl: defaultAuthConfig.infoUrl, - signInUrl: defaultAuthConfig.signInUrl, - signUpUrl: defaultAuthConfig.signUpUrl + apiUrl: options.apiUrl ? options.apiUrl : DEFAULT_AUTH_CONFIG.apiUrl, + infoUrl: DEFAULT_AUTH_CONFIG.infoUrl, + signInUrl: DEFAULT_AUTH_CONFIG.signInUrl, + signUpUrl: DEFAULT_AUTH_CONFIG.signUpUrl } }, { provide: JWT_CONFIG_TOKEN, useValue: { - apiUrl: options.apiUrl ? options.apiUrl : defaultJwtConfig.apiUrl, - headerName: defaultJwtConfig.headerName, - headerPrefix: defaultJwtConfig.headerPrefix, - storageKeyName: defaultJwtConfig.storageKeyName, - tokenName: defaultJwtConfig.tokenName, - withoutTokenUrls: defaultJwtConfig.withoutTokenUrls + apiUrl: options.apiUrl ? options.apiUrl : DEFAULT_JWT_CONFIG.apiUrl, + headerName: DEFAULT_JWT_CONFIG.headerName, + headerPrefix: DEFAULT_JWT_CONFIG.headerPrefix, + storageKeyName: DEFAULT_JWT_CONFIG.storageKeyName, + tokenName: DEFAULT_JWT_CONFIG.tokenName, + withoutTokenUrls: DEFAULT_JWT_CONFIG.withoutTokenUrls } }, { provide: OAUTH_CONFIG_TOKEN, useValue: { - apiUrl: options.apiUrl ? options.apiUrl : defaultOauthConfig.apiUrl, - redirectUrl: defaultOauthConfig.redirectUrl, - signInUrl: defaultOauthConfig.signInUrl, - providers: options.oauth && options.oauth.providers ? options.oauth.providers : defaultOauthConfig.providers + apiUrl: options.apiUrl ? options.apiUrl : DEFAULT_OAUTH_CONFIG.apiUrl, + redirectUrl: DEFAULT_OAUTH_CONFIG.redirectUrl, + signInUrl: DEFAULT_OAUTH_CONFIG.signInUrl, + providers: options.oauth && options.oauth.providers ? options.oauth.providers : DEFAULT_OAUTH_CONFIG.providers } }, AuthService, @@ -64,7 +65,7 @@ export class AuthModule { } static forRootWithAppInitializer(options?: { apiUrl?: string; - oauth?: { providers?: string[] }; + oauth?: { providers?: IAuthOauthProvider[] }; }): ModuleWithProviders { return { ngModule: AuthModule, @@ -72,30 +73,30 @@ export class AuthModule { { provide: AUTH_CONFIG_TOKEN, useValue: { - apiUrl: options.apiUrl ? options.apiUrl : defaultAuthConfig.apiUrl, - infoUrl: defaultAuthConfig.infoUrl, - signInUrl: defaultAuthConfig.signInUrl, - signUpUrl: defaultAuthConfig.signUpUrl + apiUrl: options.apiUrl ? options.apiUrl : DEFAULT_AUTH_CONFIG.apiUrl, + infoUrl: DEFAULT_AUTH_CONFIG.infoUrl, + signInUrl: DEFAULT_AUTH_CONFIG.signInUrl, + signUpUrl: DEFAULT_AUTH_CONFIG.signUpUrl } }, { provide: JWT_CONFIG_TOKEN, useValue: { - apiUrl: options.apiUrl ? options.apiUrl : defaultJwtConfig.apiUrl, - headerName: defaultJwtConfig.headerName, - headerPrefix: defaultJwtConfig.headerPrefix, - storageKeyName: defaultJwtConfig.storageKeyName, - tokenName: defaultJwtConfig.tokenName, - withoutTokenUrls: defaultJwtConfig.withoutTokenUrls + apiUrl: options.apiUrl ? options.apiUrl : DEFAULT_JWT_CONFIG.apiUrl, + headerName: DEFAULT_JWT_CONFIG.headerName, + headerPrefix: DEFAULT_JWT_CONFIG.headerPrefix, + storageKeyName: DEFAULT_JWT_CONFIG.storageKeyName, + tokenName: DEFAULT_JWT_CONFIG.tokenName, + withoutTokenUrls: DEFAULT_JWT_CONFIG.withoutTokenUrls } }, { provide: OAUTH_CONFIG_TOKEN, useValue: { - apiUrl: options.apiUrl ? options.apiUrl : defaultOauthConfig.apiUrl, - redirectUrl: defaultOauthConfig.redirectUrl, - signInUrl: defaultOauthConfig.signInUrl, - providers: options.oauth && options.oauth.providers ? options.oauth.providers : defaultOauthConfig.providers + apiUrl: options.apiUrl ? options.apiUrl : DEFAULT_OAUTH_CONFIG.apiUrl, + redirectUrl: DEFAULT_OAUTH_CONFIG.redirectUrl, + signInUrl: DEFAULT_OAUTH_CONFIG.signInUrl, + providers: options.oauth && options.oauth.providers ? options.oauth.providers : DEFAULT_OAUTH_CONFIG.providers } }, AuthService, diff --git a/libs/rucken/core/src/lib/modules/auth/configs/auth.config.ts b/libs/rucken/core/src/lib/modules/auth/configs/auth.config.ts index 39545594..48f92912 100644 --- a/libs/rucken/core/src/lib/modules/auth/configs/auth.config.ts +++ b/libs/rucken/core/src/lib/modules/auth/configs/auth.config.ts @@ -1,6 +1,6 @@ import { IAuthConfig } from '../interfaces/auth-config.interface'; -export const defaultAuthConfig: IAuthConfig = { +export const DEFAULT_AUTH_CONFIG: IAuthConfig = { apiUrl: '/api', signInUrl: '/auth/signin', signUpUrl: '/auth/signup', diff --git a/libs/rucken/core/src/lib/modules/auth/configs/index.ts b/libs/rucken/core/src/lib/modules/auth/configs/index.ts index 19049a7a..79d6a7c5 100644 --- a/libs/rucken/core/src/lib/modules/auth/configs/index.ts +++ b/libs/rucken/core/src/lib/modules/auth/configs/index.ts @@ -1,19 +1,19 @@ import { Provider } from '@angular/core'; -import { AUTH_CONFIG_TOKEN, defaultAuthConfig } from './auth.config'; -import { defaultJwtConfig, JWT_CONFIG_TOKEN } from './jwt.config'; -import { defaultOauthConfig, OAUTH_CONFIG_TOKEN } from './oauth.config'; +import { AUTH_CONFIG_TOKEN, DEFAULT_AUTH_CONFIG } from './auth.config'; +import { DEFAULT_JWT_CONFIG, JWT_CONFIG_TOKEN } from './jwt.config'; +import { DEFAULT_OAUTH_CONFIG, OAUTH_CONFIG_TOKEN } from './oauth.config'; -export const authProviders: Provider[] = [ +export const AUTH_PROVIDERS: Provider[] = [ { provide: AUTH_CONFIG_TOKEN, - useValue: defaultAuthConfig + useValue: DEFAULT_AUTH_CONFIG }, { provide: JWT_CONFIG_TOKEN, - useValue: defaultJwtConfig + useValue: DEFAULT_JWT_CONFIG }, { provide: OAUTH_CONFIG_TOKEN, - useValue: defaultOauthConfig + useValue: DEFAULT_OAUTH_CONFIG } ]; diff --git a/libs/rucken/core/src/lib/modules/auth/configs/jwt.config.ts b/libs/rucken/core/src/lib/modules/auth/configs/jwt.config.ts index 6e18bb50..888ca1bc 100644 --- a/libs/rucken/core/src/lib/modules/auth/configs/jwt.config.ts +++ b/libs/rucken/core/src/lib/modules/auth/configs/jwt.config.ts @@ -1,6 +1,6 @@ import { IJwtConfig } from '../interfaces/jwt-config.interface'; -export const defaultJwtConfig: IJwtConfig = { +export const DEFAULT_JWT_CONFIG: IJwtConfig = { withoutTokenUrls: ['auth/'], headerName: 'Authorization', headerPrefix: 'JWT', diff --git a/libs/rucken/core/src/lib/modules/auth/configs/oauth.config.ts b/libs/rucken/core/src/lib/modules/auth/configs/oauth.config.ts index 4ca688a4..d64c1a37 100644 --- a/libs/rucken/core/src/lib/modules/auth/configs/oauth.config.ts +++ b/libs/rucken/core/src/lib/modules/auth/configs/oauth.config.ts @@ -1,6 +1,6 @@ import { IOauthConfig } from '../interfaces/oauth-config.interface'; -export const defaultOauthConfig: IOauthConfig = { +export const DEFAULT_OAUTH_CONFIG: IOauthConfig = { apiUrl: '/api', signInUrl: '/auth/{provider}/signin', redirectUrl: '/auth/{provider}/uri', diff --git a/libs/rucken/core/src/lib/modules/auth/interceptors/token.interceptor.ts b/libs/rucken/core/src/lib/modules/auth/interceptors/token.interceptor.ts index bf1f4b0d..3321e7ee 100644 --- a/libs/rucken/core/src/lib/modules/auth/interceptors/token.interceptor.ts +++ b/libs/rucken/core/src/lib/modules/auth/interceptors/token.interceptor.ts @@ -2,12 +2,12 @@ import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/c import { Injectable, InjectionToken, Inject } from '@angular/core'; import { Observable } from 'rxjs'; import { TokenService } from '../services/token.service'; -import { JWT_CONFIG_TOKEN, defaultJwtConfig } from '../configs/jwt.config'; +import { JWT_CONFIG_TOKEN, DEFAULT_JWT_CONFIG } from '../configs/jwt.config'; import { IJwtConfig } from '../interfaces/jwt-config.interface'; @Injectable() export class TokenInterceptor implements HttpInterceptor { - constructor(@Inject(JWT_CONFIG_TOKEN) private _jwtConfig: IJwtConfig, private _tokenService: TokenService) {} + constructor(@Inject(JWT_CONFIG_TOKEN) private _jwtConfig: IJwtConfig, private _tokenService: TokenService) { } intercept(request: HttpRequest, next: HttpHandler): Observable> { if ( this._jwtConfig && diff --git a/libs/rucken/core/src/lib/modules/auth/interfaces/auth-oauth-provider.interface.ts b/libs/rucken/core/src/lib/modules/auth/interfaces/auth-oauth-provider.interface.ts new file mode 100644 index 00000000..1669f4a5 --- /dev/null +++ b/libs/rucken/core/src/lib/modules/auth/interfaces/auth-oauth-provider.interface.ts @@ -0,0 +1,4 @@ +export interface IAuthOauthProvider { + name: string; + signInTitle: string; +} diff --git a/libs/rucken/core/src/lib/modules/auth/interfaces/oauth-config.interface.ts b/libs/rucken/core/src/lib/modules/auth/interfaces/oauth-config.interface.ts index 22d8424a..b76b8d7d 100644 --- a/libs/rucken/core/src/lib/modules/auth/interfaces/oauth-config.interface.ts +++ b/libs/rucken/core/src/lib/modules/auth/interfaces/oauth-config.interface.ts @@ -1,6 +1,8 @@ +import { IAuthOauthProvider } from './auth-oauth-provider.interface'; + export interface IOauthConfig { apiUrl?: string; signInUrl?: string; redirectUrl?: string; - providers?: string[]; + providers?: IAuthOauthProvider[]; } diff --git a/libs/rucken/core/src/lib/modules/auth/services/auth.service.ts b/libs/rucken/core/src/lib/modules/auth/services/auth.service.ts index e93ee943..c35c71dc 100644 --- a/libs/rucken/core/src/lib/modules/auth/services/auth.service.ts +++ b/libs/rucken/core/src/lib/modules/auth/services/auth.service.ts @@ -109,26 +109,26 @@ export class AuthService { }) .pipe(map(data => plainToClass(UserTokenDto, data))); } - oauthRedirectUrl(provider: string): Observable { - if (this._oauthConfig.providers.indexOf(provider) === -1) { + oauthRedirectUrl(providerName: string): Observable { + if (this._oauthConfig.providers.map(provider => provider.name).indexOf(providerName) === -1) { return throwError( this._translateService .instant('Oauth provider with name "{provider}" not founded') - .replace('{provider}', provider) + .replace('{provider}', providerName) ); } - const uri = this._oauthConfig.apiUrl + this._oauthConfig.redirectUrl.replace('{provider}', provider); + const uri = this._oauthConfig.apiUrl + this._oauthConfig.redirectUrl.replace('{provider}', providerName); return this._httpClient.get(uri).pipe(map(data => plainToClass(RedirectUrlDto, data))); } - oauthSignIn(provider: string, code: string): Observable { - if (this._oauthConfig.providers.indexOf(provider) === -1) { + oauthSignIn(providerName: string, code: string): Observable { + if (this._oauthConfig.providers.map(provider => provider.name).indexOf(providerName) === -1) { return throwError( this._translateService .instant('Oauth provider with name "{provider}" not founded') - .replace('{provider}', provider) + .replace('{provider}', providerName) ); } - const uri = this._oauthConfig.apiUrl + this._oauthConfig.signInUrl.replace('{provider}', provider); + const uri = this._oauthConfig.apiUrl + this._oauthConfig.signInUrl.replace('{provider}', providerName); return this._httpClient .post(uri, { code diff --git a/libs/rucken/core/src/lib/modules/lang/configs/index.ts b/libs/rucken/core/src/lib/modules/lang/configs/index.ts index cb1ba6b9..92885ff5 100644 --- a/libs/rucken/core/src/lib/modules/lang/configs/index.ts +++ b/libs/rucken/core/src/lib/modules/lang/configs/index.ts @@ -1,9 +1,9 @@ -import { defaultLangConfig, LANG_CONFIG_TOKEN } from './lang.config'; +import { DEFAULT_LANG_CONFIG, LANG_CONFIG_TOKEN } from './lang.config'; import { Provider } from '@angular/core'; -export const langProviders: Provider[] = [ +export const LANG_PROVIDERS: Provider[] = [ { provide: LANG_CONFIG_TOKEN, - useValue: defaultLangConfig + useValue: DEFAULT_LANG_CONFIG } ]; diff --git a/libs/rucken/core/src/lib/modules/lang/configs/lang.config.ts b/libs/rucken/core/src/lib/modules/lang/configs/lang.config.ts index b4f2d208..f4c03d66 100644 --- a/libs/rucken/core/src/lib/modules/lang/configs/lang.config.ts +++ b/libs/rucken/core/src/lib/modules/lang/configs/lang.config.ts @@ -1,6 +1,6 @@ import { ILangConfig } from '../interfaces/lang-config.interface'; -export const defaultLangConfig: ILangConfig = { +export const DEFAULT_LANG_CONFIG: ILangConfig = { appLang: 'en', defaultLang: 'en', storageKeyName: 'lang' diff --git a/libs/rucken/core/src/lib/modules/lang/lang.module.ts b/libs/rucken/core/src/lib/modules/lang/lang.module.ts index 11daa6e7..5493395e 100644 --- a/libs/rucken/core/src/lib/modules/lang/lang.module.ts +++ b/libs/rucken/core/src/lib/modules/lang/lang.module.ts @@ -3,7 +3,7 @@ import { ModuleWithProviders, NgModule } from '@angular/core'; import { TranslateFakeLoader, TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { ILangConfig } from './interfaces/lang-config.interface'; import { LangService } from './services/lang.service'; -import { LANG_CONFIG_TOKEN, defaultLangConfig } from './configs/lang.config'; +import { LANG_CONFIG_TOKEN, DEFAULT_LANG_CONFIG } from './configs/lang.config'; @NgModule({ imports: [ CommonModule, @@ -21,10 +21,10 @@ export class LangModule { { provide: LANG_CONFIG_TOKEN, useValue: { - appLang: options.appLang ? options.appLang : defaultLangConfig.appLang, - defaultLang: options.defaultLang ? options.defaultLang : defaultLangConfig.defaultLang, - storageKeyName: options.storageKeyName ? options.storageKeyName : defaultLangConfig.storageKeyName, - languages: options.languages ? options.languages : defaultLangConfig.languages + appLang: options.appLang ? options.appLang : DEFAULT_LANG_CONFIG.appLang, + defaultLang: options.defaultLang ? options.defaultLang : DEFAULT_LANG_CONFIG.defaultLang, + storageKeyName: options.storageKeyName ? options.storageKeyName : DEFAULT_LANG_CONFIG.storageKeyName, + languages: options.languages ? options.languages : DEFAULT_LANG_CONFIG.languages } }, LangService diff --git a/libs/rucken/web/src/lib/components/entity-grid/entity-grid.component.ts b/libs/rucken/web/src/lib/components/entity-grid/entity-grid.component.ts index bfd8ac21..ba1efd26 100644 --- a/libs/rucken/web/src/lib/components/entity-grid/entity-grid.component.ts +++ b/libs/rucken/web/src/lib/components/entity-grid/entity-grid.component.ts @@ -205,8 +205,8 @@ export class EntityGridComponent implements OnChanges { ? ( this.readonly === true || ( !this.readonly && - this.enableDelete && - this.enableUpdate + !this.enableDelete && + !this.enableUpdate ) ? false : true diff --git a/libs/rucken/web/src/lib/modules/auth-modal/auth-modal.component.html b/libs/rucken/web/src/lib/modules/auth-modal/auth-modal.component.html index da210184..47c25174 100644 --- a/libs/rucken/web/src/lib/modules/auth-modal/auth-modal.component.html +++ b/libs/rucken/web/src/lib/modules/auth-modal/auth-modal.component.html @@ -106,7 +106,7 @@ aria-labelledby="button-split">
  • + *ngFor="let oauthProvider of (oauthProviders$ | async)"> { this.initCurrent().then(value => { - this.setCurrent(value as string); + this.setCurrent(String(value)); resolve(); }); }); @@ -84,7 +84,7 @@ export class ThemesService { if ( link && link.getAttribute('rel') && - (link.getAttribute('rel') as string).indexOf('style') !== -1 && + String(link.getAttribute('rel')).indexOf('style') !== -1 && link.getAttribute('title') && link.getAttribute('title') === 'bootstrap' && link.getAttribute('href') !== url diff --git a/libs/rucken/web/src/lib/modules/themes/themes.module.ts b/libs/rucken/web/src/lib/modules/themes/themes.module.ts index aaeb74f5..b4559956 100644 --- a/libs/rucken/web/src/lib/modules/themes/themes.module.ts +++ b/libs/rucken/web/src/lib/modules/themes/themes.module.ts @@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common'; import { ModuleWithProviders, NgModule, APP_INITIALIZER } from '@angular/core'; import { ThemesService, themesServiceInitializeApp } from './services/themes.service'; import { IThemesConfig } from './interfaces/themes-config.interface'; -import { THEMES_CONFIG_TOKEN, defaultThemesConfig } from './configs/themes.config'; +import { THEMES_CONFIG_TOKEN, DEFAULT_THEMES_CONFIG } from './configs/themes.config'; @NgModule({ imports: [CommonModule], providers: [ThemesService] @@ -15,9 +15,9 @@ export class ThemesModule { { provide: THEMES_CONFIG_TOKEN, useValue: { - mockedItems: options && options.mockedItems ? options.mockedItems : defaultThemesConfig.mockedItems, + mockedItems: options && options.mockedItems ? options.mockedItems : DEFAULT_THEMES_CONFIG.mockedItems, storageKeyName: - options && options.storageKeyName ? options.storageKeyName : defaultThemesConfig.storageKeyName + options && options.storageKeyName ? options.storageKeyName : DEFAULT_THEMES_CONFIG.storageKeyName } }, {