diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 91b0dda4..2d7c5ecc 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -13,19 +13,23 @@ import { BsDatepickerModule } from 'ngx-bootstrap/datepicker'; import { TooltipModule } from 'ngx-bootstrap/tooltip'; import { provideCdkDialog } from './common/dialog/provider'; +import { provideAdminFeature } from './core/admin'; +import { provideAuditFeature } from './core/audit'; import { authInterceptor } from './core/auth/auth.interceptor'; import { euaInterceptor } from './core/auth/eua.interceptor'; import { signinInterceptor } from './core/auth/signin.interceptor'; +import { CORE_ROUTES } from './core/core-routes'; +import { provideHelpFeature } from './core/help'; import { masqueradeInterceptor } from './core/masquerade/masquerade.interceptor'; import { PageTitleStrategy } from './core/page-title.strategy'; import { provideAppConfig, - provideCoreRoutes, provideNavigationService, provideSession, provideViewportScroller } from './core/provider'; -import { provideExampleRoutes } from './site/example/provider'; +import { provideTeamsFeature } from './core/teams/provider'; +import { provideExampleSiteFeature } from './site/example/provider'; export const appConfig: ApplicationConfig = { providers: [ @@ -43,20 +47,23 @@ export const appConfig: ApplicationConfig = { ), provideCdkDialog(), provideRouter( - [], + CORE_ROUTES, withHashLocation(), withInMemoryScrolling({ scrollPositionRestoration: 'enabled' }), withComponentInputBinding() ), provideViewportScroller(), - provideCoreRoutes(), - provideExampleRoutes(), provideAppConfig(), provideNavigationService(), provideSession(), { provide: TitleStrategy, useClass: PageTitleStrategy - } + }, + provideAuditFeature(), + provideTeamsFeature(), + provideAdminFeature(), + provideHelpFeature(), + provideExampleSiteFeature() ] }; diff --git a/src/app/common/loading-overlay/loading-overlay.component.spec.ts b/src/app/common/loading-overlay/loading-overlay.component.spec.ts index 21be2f17..4572cd22 100644 --- a/src/app/common/loading-overlay/loading-overlay.component.spec.ts +++ b/src/app/common/loading-overlay/loading-overlay.component.spec.ts @@ -1,5 +1,4 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; import { LoadingOverlayComponent } from './loading-overlay.component'; diff --git a/src/app/common/table/column-chooser/column-chooser.component.ts b/src/app/common/table/column-chooser/column-chooser.component.ts index 90bd7dab..914fc599 100644 --- a/src/app/common/table/column-chooser/column-chooser.component.ts +++ b/src/app/common/table/column-chooser/column-chooser.component.ts @@ -6,16 +6,7 @@ import { moveItemInArray } from '@angular/cdk/drag-drop'; import { TitleCasePipe } from '@angular/common'; -import { - Component, - EventEmitter, - Input, - OnInit, - Output, - booleanAttribute, - input, - output -} from '@angular/core'; +import { Component, Input, OnInit, booleanAttribute, input, output } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { LocalStorageService } from '../../storage/local-storage.service'; diff --git a/src/app/common/table/filter/asy-filter.directive.ts b/src/app/common/table/filter/asy-filter.directive.ts index 5f954778..ebe69271 100644 --- a/src/app/common/table/filter/asy-filter.directive.ts +++ b/src/app/common/table/filter/asy-filter.directive.ts @@ -1,4 +1,4 @@ -import { Directive, Input, input } from '@angular/core'; +import { Directive, input } from '@angular/core'; import isEmpty from 'lodash/isEmpty'; diff --git a/src/app/common/table/filter/asy-header-text-filter/asy-header-text-filter.component.ts b/src/app/common/table/filter/asy-header-text-filter/asy-header-text-filter.component.ts index 2d0731c2..aa5469d3 100644 --- a/src/app/common/table/filter/asy-header-text-filter/asy-header-text-filter.component.ts +++ b/src/app/common/table/filter/asy-header-text-filter/asy-header-text-filter.component.ts @@ -1,14 +1,7 @@ import { A11yModule } from '@angular/cdk/a11y'; import { CdkConnectedOverlay, CdkOverlayOrigin, OverlayModule } from '@angular/cdk/overlay'; import { NgClass } from '@angular/common'; -import { - ChangeDetectionStrategy, - Component, - Inject, - Optional, - effect, - signal -} from '@angular/core'; +import { ChangeDetectionStrategy, Component, Inject, Optional, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { NgSelectModule } from '@ng-select/ng-select'; diff --git a/src/app/core/admin/admin-routes.ts b/src/app/core/admin/admin-routes.ts index e520a770..0bee9c47 100644 --- a/src/app/core/admin/admin-routes.ts +++ b/src/app/core/admin/admin-routes.ts @@ -1,5 +1,6 @@ import { Routes } from '@angular/router'; +import { EXAMPLE_ADMIN_ROUTES } from '../../site/example/admin/admin-routes'; import { authGuard } from '../auth'; import { AdminComponent } from './admin.component'; import { ADMIN_CACHE_ENTRIES_ROUTES } from './cache-entries/admin-cache-entries-routes'; @@ -26,7 +27,8 @@ export const ADMIN_ROUTES: Routes = [ ...ADMIN_CACHE_ENTRIES_ROUTES, ...ADMIN_EUA_ROUTES, ...ADMIN_MESSAGES_ROUTES, - ...ADMIN_FEEDBACK_ROUTES + ...ADMIN_FEEDBACK_ROUTES, + ...EXAMPLE_ADMIN_ROUTES ] } ]; diff --git a/src/app/core/admin/index.ts b/src/app/core/admin/index.ts new file mode 100644 index 00000000..7e1a213e --- /dev/null +++ b/src/app/core/admin/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/src/app/core/admin/provider.ts b/src/app/core/admin/provider.ts new file mode 100644 index 00000000..91c7d93a --- /dev/null +++ b/src/app/core/admin/provider.ts @@ -0,0 +1,66 @@ +import { InjectionToken, inject, makeEnvironmentProviders } from '@angular/core'; +import { ROUTES } from '@angular/router'; + +import { ADMIN_TOPICS } from './admin-topic.model'; + +export const APP_FEATURE_ADMIN = new InjectionToken('APP_FEATURE_ADMIN'); + +export function injectAdminEnabled() { + return inject(APP_FEATURE_ADMIN, { optional: true }) ?? false; +} + +export function provideAdminFeature() { + return makeEnvironmentProviders([ + { + provide: APP_FEATURE_ADMIN, + useValue: true + }, + { + provide: ADMIN_TOPICS, + multi: true, + useValue: [ + { + id: 'users', + title: 'Users', + ordinal: 0, + path: 'users' + }, + + { + id: 'cache-entries', + title: 'Cache Entries', + ordinal: 1, + path: 'cacheEntries' + }, + { + id: 'end-user-agreements', + title: 'EUAs', + ordinal: 2, + path: 'euas' + }, + { + id: 'messages', + title: 'Messages', + ordinal: 3, + path: 'messages' + }, + { + id: 'feedback', + title: 'Feedback', + ordinal: 4, + path: 'feedback' + } + ] + }, + { + provide: ROUTES, + multi: true, + useValue: [ + { + path: 'admin', + loadChildren: () => import('./admin-routes').then((m) => m.ADMIN_ROUTES) + } + ] + } + ]); +} diff --git a/src/app/core/admin/public-api.ts b/src/app/core/admin/public-api.ts new file mode 100644 index 00000000..03be03e5 --- /dev/null +++ b/src/app/core/admin/public-api.ts @@ -0,0 +1 @@ +export * from './provider'; diff --git a/src/app/core/audit/index.ts b/src/app/core/audit/index.ts new file mode 100644 index 00000000..7e1a213e --- /dev/null +++ b/src/app/core/audit/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/src/app/core/audit/provider.ts b/src/app/core/audit/provider.ts new file mode 100644 index 00000000..498e99d8 --- /dev/null +++ b/src/app/core/audit/provider.ts @@ -0,0 +1,27 @@ +import { InjectionToken, inject, makeEnvironmentProviders } from '@angular/core'; +import { ROUTES } from '@angular/router'; + +export const APP_FEATURE_AUDIT = new InjectionToken('APP_FEATURE_AUDIT'); + +export function injectAuditEnabled() { + return inject(APP_FEATURE_AUDIT, { optional: true }) ?? false; +} + +export function provideAuditFeature() { + return makeEnvironmentProviders([ + { + provide: APP_FEATURE_AUDIT, + useValue: true + }, + { + provide: ROUTES, + multi: true, + useValue: [ + { + path: 'audit', + loadChildren: () => import('./audit-routes').then((m) => m.AUDIT_ROUTES) + } + ] + } + ]); +} diff --git a/src/app/core/audit/public-api.ts b/src/app/core/audit/public-api.ts new file mode 100644 index 00000000..03be03e5 --- /dev/null +++ b/src/app/core/audit/public-api.ts @@ -0,0 +1 @@ +export * from './provider'; diff --git a/src/app/core/core-routes.ts b/src/app/core/core-routes.ts index 6edb4104..e2614cd9 100644 --- a/src/app/core/core-routes.ts +++ b/src/app/core/core-routes.ts @@ -54,21 +54,5 @@ export const CORE_ROUTES: Routes = [ { path: 'masquerade', component: MasqueradeComponent - }, - { - path: 'team', - loadChildren: () => import('./teams/teams-routes').then((m) => m.TEAMS_ROUTES) - }, - { - path: 'help', - loadChildren: () => import('./help/help-routes').then((m) => m.HELP_ROUTES) - }, - { - path: 'admin', - loadChildren: () => import('./admin/admin-routes').then((m) => m.ADMIN_ROUTES) - }, - { - path: 'audit', - loadChildren: () => import('./audit/audit-routes').then((m) => m.AUDIT_ROUTES) } ]; diff --git a/src/app/core/help/help.component.scss b/src/app/core/help/help.component.scss index 914d6fdd..df6d7aed 100644 --- a/src/app/core/help/help.component.scss +++ b/src/app/core/help/help.component.scss @@ -1,11 +1,6 @@ -@use 'sass:map'; @import '../../../styles/shared'; @import '../../../styles/bootstrap/shared'; -.help-content { - padding-top: $site-content-padding-y; -} - //===================================== // Callouts //===================================== diff --git a/src/app/core/help/index.ts b/src/app/core/help/index.ts new file mode 100644 index 00000000..7e1a213e --- /dev/null +++ b/src/app/core/help/index.ts @@ -0,0 +1 @@ +export * from './public-api'; diff --git a/src/app/core/help/provider.ts b/src/app/core/help/provider.ts new file mode 100644 index 00000000..d714218f --- /dev/null +++ b/src/app/core/help/provider.ts @@ -0,0 +1,42 @@ +import { InjectionToken, inject, makeEnvironmentProviders } from '@angular/core'; +import { ROUTES } from '@angular/router'; + +import { GettingStartedHelpComponent } from './getting-started/getting-started-help.component'; +import { HELP_TOPICS } from './help-topic.component'; + +export const APP_FEATURE_HELP = new InjectionToken('APP_FEATURE_HELP'); + +export function injectHelpEnabled() { + return inject(APP_FEATURE_HELP, { optional: true }) ?? false; +} + +export function provideHelpFeature() { + return makeEnvironmentProviders([ + { + provide: APP_FEATURE_HELP, + useValue: true + }, + { + provide: HELP_TOPICS, + multi: true, + useValue: [ + { + id: 'getting-started', + title: 'Getting Started', + ordinal: 0, + component: GettingStartedHelpComponent + } + ] + }, + { + provide: ROUTES, + multi: true, + useValue: [ + { + path: 'help', + loadChildren: () => import('./help-routes').then((m) => m.HELP_ROUTES) + } + ] + } + ]); +} diff --git a/src/app/core/help/public-api.ts b/src/app/core/help/public-api.ts new file mode 100644 index 00000000..03be03e5 --- /dev/null +++ b/src/app/core/help/public-api.ts @@ -0,0 +1 @@ +export * from './provider'; diff --git a/src/app/core/provider.ts b/src/app/core/provider.ts index b3f8c3cb..0f94bc84 100644 --- a/src/app/core/provider.ts +++ b/src/app/core/provider.ts @@ -1,94 +1,16 @@ import { ViewportScroller } from '@angular/common'; import { APP_INITIALIZER, Provider, makeEnvironmentProviders } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; -import { ROUTES } from '@angular/router'; import { firstValueFrom } from 'rxjs'; import { tap } from 'rxjs/operators'; -import { ADMIN_TOPICS } from './admin/admin-topic.model'; import { SessionService } from './auth'; import { ConfigService } from './config.service'; -import { CORE_ROUTES } from './core-routes'; import { CustomViewportScroller, SCROLL_ELEMENT } from './custom_viewport_scroller'; -import { GettingStartedHelpComponent } from './help/getting-started/getting-started-help.component'; -import { HELP_TOPICS } from './help/help-topic.component'; import { NavigationService } from './navigation.service'; -import { TEAM_TOPICS } from './teams'; -import { TeamsHelpComponent } from './teams/help/teams-help.component'; import { APP_CONFIG, APP_SESSION } from './tokens'; -export function provideCoreRoutes() { - // Registering Topics here. Need to find better alternative for this. - return makeEnvironmentProviders([ - { - provide: ADMIN_TOPICS, - multi: true, - useValue: [ - { - id: 'users', - title: 'Users', - ordinal: 0, - path: 'users' - }, - - { - id: 'cache-entries', - title: 'Cache Entries', - ordinal: 1, - path: 'cacheEntries' - }, - { - id: 'end-user-agreements', - title: 'EUAs', - ordinal: 2, - path: 'euas' - }, - { - id: 'messages', - title: 'Messages', - ordinal: 3, - path: 'messages' - }, - { - id: 'feedback', - title: 'Feedback', - ordinal: 4, - path: 'feedback' - } - ] - }, - { - provide: TEAM_TOPICS, - multi: true, - useValue: { - id: 'general', - title: 'General', - ordinal: 0, - path: 'general' - } - }, - { - provide: HELP_TOPICS, - multi: true, - useValue: [ - { - id: 'getting-started', - title: 'Getting Started', - ordinal: 0, - component: GettingStartedHelpComponent - }, - { id: 'teams', title: 'Teams', ordinal: 9, component: TeamsHelpComponent } - ] - }, - { - provide: ROUTES, - multi: true, - useValue: CORE_ROUTES - } - ]); -} - export function provideAppConfig() { return makeEnvironmentProviders([ { diff --git a/src/app/core/site-navbar/site-navbar.component.html b/src/app/core/site-navbar/site-navbar.component.html index 322c5030..d7f6d6ae 100644 --- a/src/app/core/site-navbar/site-navbar.component.html +++ b/src/app/core/site-navbar/site-navbar.component.html @@ -32,7 +32,7 @@