]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.module.ts
Client: move menu component in core module
[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
693b1aba 5import { MetaModule, MetaConfig } from 'ng2-meta';
b58c69a1 6
ab32b0fc 7import { ENV_PROVIDERS } from './environment';
693b1aba 8import { AppRoutingModule } from './app-routing.module';
ab32b0fc
C
9import { AppComponent } from './app.component';
10import { AppState } from './app.service';
23bcf666 11
693b1aba
C
12import { AccountModule } from './account';
13import { AdminModule } from './admin';
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
C
48 AccountModule,
49 AdminModule,
50 CoreModule,
51 LoginModule,
52 SharedModule,
53 VideosModule
ab32b0fc
C
54 ],
55 providers: [ // expose our Services and Providers into Angular's dependency injection
56 ENV_PROVIDERS,
57 APP_PROVIDERS
58 ]
59})
60export class AppModule {
61 constructor(public appRef: ApplicationRef, public appState: AppState) {}
62 hmrOnInit(store) {
63 if (!store || !store.state) return;
64 console.log('HMR store', store);
65 this.appState._state = store.state;
66 this.appRef.tick();
67 delete store.state;
68 }
69 hmrOnDestroy(store) {
70 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
71 // recreate elements
72 const state = this.appState._state;
73 store.state = state;
74 store.disposeOldHosts = createNewHosts(cmpLocation);
75 // remove styles
76 removeNgStyles();
77 }
78 hmrAfterDestroy(store) {
79 // display new elements
80 store.disposeOldHosts();
81 delete store.disposeOldHosts;
82 }
83}