Add keyboard navigation and hepler to typeahead
[oweals/peertube.git] / client / src / app / app.module.ts
1 import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core'
2 import { BrowserModule } from '@angular/platform-browser'
3 import { ServerService } from '@app/core'
4 import { ResetPasswordModule } from '@app/reset-password'
5
6 import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
7 import 'focus-visible'
8
9 import { AppRoutingModule } from './app-routing.module'
10 import { AppComponent } from './app.component'
11 import { CoreModule } from './core'
12 import { HeaderComponent, SearchTypeaheadComponent, SuggestionsComponent, SuggestionComponent } from './header'
13 import { LoginModule } from './login'
14 import { AvatarNotificationComponent, LanguageChooserComponent, MenuComponent } from './menu'
15 import { SharedModule } from './shared'
16 import { VideosModule } from './videos'
17 import { SearchModule } from '@app/search'
18 import { WelcomeModalComponent } from '@app/modal/welcome-modal.component'
19 import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-warning-modal.component'
20 import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/models'
21 import { APP_BASE_HREF } from '@angular/common'
22
23 export function metaFactory (serverService: ServerService): MetaLoader {
24   return new MetaStaticLoader({
25     pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
26     pageTitleSeparator: ' - ',
27     get applicationName () { return serverService.getTmpConfig().instance.name },
28     defaults: {
29       get title () { return serverService.getTmpConfig().instance.name },
30       get description () { return serverService.getTmpConfig().instance.shortDescription }
31     }
32   })
33 }
34
35 @NgModule({
36   bootstrap: [ AppComponent ],
37   declarations: [
38     AppComponent,
39
40     MenuComponent,
41     LanguageChooserComponent,
42     AvatarNotificationComponent,
43     HeaderComponent,
44     SearchTypeaheadComponent,
45     SuggestionsComponent,
46     SuggestionComponent,
47
48     WelcomeModalComponent,
49     InstanceConfigWarningModalComponent
50   ],
51   imports: [
52     BrowserModule,
53
54     CoreModule,
55     SharedModule,
56
57     CoreModule,
58     LoginModule,
59     ResetPasswordModule,
60     SearchModule,
61     SharedModule,
62     VideosModule,
63
64     MetaModule.forRoot({
65       provide: MetaLoader,
66       useFactory: (metaFactory),
67       deps: [ ServerService ]
68     }),
69
70     AppRoutingModule // Put it after all the module because it has the 404 route
71   ],
72
73   providers: [
74     {
75       provide: APP_BASE_HREF,
76       useValue: '/'
77     },
78
79     {
80       provide: TRANSLATIONS,
81       useFactory: (locale: string) => {
82                 // Default locale, nothing to translate
83         const completeLocale = getCompleteLocale(locale)
84         if (isDefaultLocale(completeLocale)) return ''
85
86         const fileLocale = buildFileLocale(locale)
87         return require(`raw-loader!../locale/angular.${fileLocale}.xlf`)
88       },
89       deps: [ LOCALE_ID ]
90     },
91     { provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
92   ]
93 })
94 export class AppModule {}