]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.module.ts
Client: lazy load admin area
[github/Chocobozzz/PeerTube.git] / client / src / app / app.module.ts
CommitLineData
23bcf666 1import { ApplicationRef, NgModule } from '@angular/core';
ab32b0fc 2import { BrowserModule } from '@angular/platform-browser';
ab32b0fc
C
3import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
4
cdcbc810 5import { MetaModule, MetaConfig } from 'ng2-meta';
c16ce1de 6import 'bootstrap-loader';
b58c69a1 7
ab32b0fc 8import { ENV_PROVIDERS } from './environment';
693b1aba 9import { AppRoutingModule } from './app-routing.module';
ab32b0fc
C
10import { AppComponent } from './app.component';
11import { AppState } from './app.service';
23bcf666 12
693b1aba 13import { AccountModule } from './account';
693b1aba
C
14import { CoreModule } from './core';
15import { LoginModule } from './login';
16import { SharedModule } from './shared';
17import { VideosModule } from './videos';
18
b58c69a1
C
19const metaConfig: MetaConfig = {
20 //Append a title suffix such as a site name to all titles
21 //Defaults to false
22 useTitleSuffix: true,
23 defaults: {
24 title: 'PeerTube'
25 }
26};
27
ab32b0fc
C
28// Application wide providers
29const APP_PROVIDERS = [
693b1aba 30 AppState
ab32b0fc 31];
693b1aba 32
ab32b0fc
C
33@NgModule({
34 bootstrap: [ AppComponent ],
35 declarations: [
50b0c262 36 AppComponent
ab32b0fc 37 ],
693b1aba 38 imports: [
ab32b0fc 39 BrowserModule,
23bcf666 40
693b1aba
C
41 CoreModule,
42 SharedModule,
43
44 AppRoutingModule,
b58c69a1 45
693b1aba 46 MetaModule.forRoot(metaConfig),
b58c69a1 47
693b1aba 48 AccountModule,
693b1aba
C
49 CoreModule,
50 LoginModule,
51 SharedModule,
52 VideosModule
ab32b0fc
C
53 ],
54 providers: [ // expose our Services and Providers into Angular's dependency injection
55 ENV_PROVIDERS,
56 APP_PROVIDERS
57 ]
58})
59export class AppModule {
60 constructor(public appRef: ApplicationRef, public appState: AppState) {}
61 hmrOnInit(store) {
62 if (!store || !store.state) return;
63 console.log('HMR store', store);
64 this.appState._state = store.state;
65 this.appRef.tick();
66 delete store.state;
67 }
68 hmrOnDestroy(store) {
69 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
70 // recreate elements
71 const state = this.appState._state;
72 store.state = state;
73 store.disposeOldHosts = createNewHosts(cmpLocation);
74 // remove styles
75 removeNgStyles();
76 }
77 hmrAfterDestroy(store) {
78 // display new elements
79 store.disposeOldHosts();
80 delete store.disposeOldHosts;
81 }
82}