]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/app.module.ts
Client: add video not found message if the video... is not found
[github/Chocobozzz/PeerTube.git] / client / src / app / app.module.ts
CommitLineData
23bcf666 1import { ApplicationRef, NgModule } from '@angular/core';
ab32b0fc
C
2import { BrowserModule } from '@angular/platform-browser';
3import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4import { HttpModule, RequestOptions, XHRBackend } from '@angular/http';
5import { RouterModule } from '@angular/router';
6import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
7
23bcf666 8import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
b58c69a1 9
2ac6c525 10import { DropdownModule } from 'ng2-bootstrap/components/dropdown';
ab32b0fc
C
11import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar';
12import { PaginationModule } from 'ng2-bootstrap/components/pagination';
3154f382 13import { ModalModule } from 'ng2-bootstrap/components/modal';
b58c69a1 14
c53d2a4e 15import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
ab32b0fc 16
b58c69a1
C
17import { MetaConfig, MetaModule } from 'ng2-meta';
18
ab32b0fc
C
19/*
20 * Platform and Environment providers/directives/pipes
21 */
22import { ENV_PROVIDERS } from './environment';
23import { routes } from './app.routes';
24// App is our top level component
25import { AppComponent } from './app.component';
26import { AppState } from './app.service';
23bcf666
C
27
28import {
29 AdminComponent,
30 FriendsComponent,
31 FriendAddComponent,
32 FriendListComponent,
33 FriendService,
34 MenuAdminComponent,
eb4f957e
C
35 RequestsComponent,
36 RequestStatsComponent,
37 RequestService,
23bcf666
C
38 UsersComponent,
39 UserAddComponent,
40 UserListComponent,
41 UserService
42} from './admin';
ab32b0fc
C
43import { AccountComponent, AccountService } from './account';
44import { LoginComponent } from './login';
23bcf666
C
45import { MenuComponent } from './menu.component';
46import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
ab32b0fc
C
47import {
48 LoaderComponent,
49 VideosComponent,
50 VideoAddComponent,
51 VideoListComponent,
52 VideoMiniatureComponent,
53 VideoSortComponent,
54 VideoWatchComponent,
4b2f33f3
C
55 VideoService,
56 WebTorrentService
ab32b0fc 57} from './videos';
ab32b0fc 58
b58c69a1
C
59const metaConfig: MetaConfig = {
60 //Append a title suffix such as a site name to all titles
61 //Defaults to false
62 useTitleSuffix: true,
63 defaults: {
64 title: 'PeerTube'
65 }
66};
67
ab32b0fc
C
68// Application wide providers
69const APP_PROVIDERS = [
70 AppState,
71
72 {
73 provide: AuthHttp,
74 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
75 return new AuthHttp(backend, defaultOptions, authService);
76 },
77 deps: [ XHRBackend, RequestOptions, AuthService ]
78 },
79
80 AuthService,
81 RestExtractor,
23bcf666
C
82 RestService,
83
84 VideoService,
85 SearchService,
86 FriendService,
eb4f957e 87 RequestService,
23bcf666
C
88 UserService,
89 AccountService,
90 WebTorrentService
ab32b0fc
C
91];
92/**
93 * `AppModule` is the main entry point into Angular2's bootstraping process
94 */
95@NgModule({
96 bootstrap: [ AppComponent ],
97 declarations: [
23bcf666
C
98 AccountComponent,
99 AdminComponent,
ab32b0fc
C
100 AppComponent,
101 BytesPipe,
23bcf666
C
102 FriendAddComponent,
103 FriendListComponent,
104 FriendsComponent,
ab32b0fc 105 LoaderComponent,
23bcf666
C
106 LoginComponent,
107 MenuAdminComponent,
108 MenuComponent,
eb4f957e
C
109 RequestsComponent,
110 RequestStatsComponent,
23bcf666
C
111 SearchComponent,
112 UserAddComponent,
113 UserListComponent,
114 UsersComponent,
ab32b0fc
C
115 VideoAddComponent,
116 VideoListComponent,
ab32b0fc 117 VideoMiniatureComponent,
23bcf666
C
118 VideosComponent,
119 VideoSortComponent,
ab32b0fc 120 VideoWatchComponent,
ab32b0fc
C
121 ],
122 imports: [ // import Angular's modules
123 BrowserModule,
124 FormsModule,
125 ReactiveFormsModule,
126 HttpModule,
127 RouterModule.forRoot(routes),
23bcf666 128
2ac6c525 129 DropdownModule,
ab32b0fc 130 ProgressbarModule,
c53d2a4e 131 PaginationModule,
3154f382 132 ModalModule,
b58c69a1
C
133
134 FileUploadModule,
135
136 MetaModule.forRoot(metaConfig)
ab32b0fc
C
137 ],
138 providers: [ // expose our Services and Providers into Angular's dependency injection
139 ENV_PROVIDERS,
140 APP_PROVIDERS
141 ]
142})
143export class AppModule {
144 constructor(public appRef: ApplicationRef, public appState: AppState) {}
145 hmrOnInit(store) {
146 if (!store || !store.state) return;
147 console.log('HMR store', store);
148 this.appState._state = store.state;
149 this.appRef.tick();
150 delete store.state;
151 }
152 hmrOnDestroy(store) {
153 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
154 // recreate elements
155 const state = this.appState._state;
156 store.state = state;
157 store.disposeOldHosts = createNewHosts(cmpLocation);
158 // remove styles
159 removeNgStyles();
160 }
161 hmrAfterDestroy(store) {
162 // display new elements
163 store.disposeOldHosts();
164 delete store.disposeOldHosts;
165 }
166}