aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.module.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-02 15:39:09 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-02 15:39:09 +0200
commita6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch)
tree03204a408d56311692c3528bedcf95d2455e94f2 /client/src/app/app.module.ts
parent052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff)
parentc4403b29ad4db097af528a7f04eea07e0ed320d0 (diff)
downloadPeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.gz
PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.zst
PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.zip
Merge branch 'master' into webseed-merged
Diffstat (limited to 'client/src/app/app.module.ts')
-rw-r--r--client/src/app/app.module.ts146
1 files changed, 146 insertions, 0 deletions
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
new file mode 100644
index 000000000..980625f13
--- /dev/null
+++ b/client/src/app/app.module.ts
@@ -0,0 +1,146 @@
1import { ApplicationRef, NgModule } from '@angular/core';
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
8import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
9import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar';
10import { PaginationModule } from 'ng2-bootstrap/components/pagination';
11import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
12
13/*
14 * Platform and Environment providers/directives/pipes
15 */
16import { ENV_PROVIDERS } from './environment';
17import { routes } from './app.routes';
18// App is our top level component
19import { AppComponent } from './app.component';
20import { AppState } from './app.service';
21
22import {
23 AdminComponent,
24 FriendsComponent,
25 FriendAddComponent,
26 FriendListComponent,
27 FriendService,
28 MenuAdminComponent,
29 RequestsComponent,
30 RequestStatsComponent,
31 RequestService,
32 UsersComponent,
33 UserAddComponent,
34 UserListComponent,
35 UserService
36} from './admin';
37import { AccountComponent, AccountService } from './account';
38import { LoginComponent } from './login';
39import { MenuComponent } from './menu.component';
40import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared';
41import {
42 LoaderComponent,
43 VideosComponent,
44 VideoAddComponent,
45 VideoListComponent,
46 VideoMiniatureComponent,
47 VideoSortComponent,
48 VideoWatchComponent,
49 VideoService,
50 WebTorrentService
51} from './videos';
52
53// Application wide providers
54const APP_PROVIDERS = [
55 AppState,
56
57 {
58 provide: AuthHttp,
59 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
60 return new AuthHttp(backend, defaultOptions, authService);
61 },
62 deps: [ XHRBackend, RequestOptions, AuthService ]
63 },
64
65 AuthService,
66 RestExtractor,
67 RestService,
68
69 VideoService,
70 SearchService,
71 FriendService,
72 RequestService,
73 UserService,
74 AccountService,
75 WebTorrentService
76];
77/**
78 * `AppModule` is the main entry point into Angular2's bootstraping process
79 */
80@NgModule({
81 bootstrap: [ AppComponent ],
82 declarations: [
83 AccountComponent,
84 AdminComponent,
85 AppComponent,
86 BytesPipe,
87 FriendAddComponent,
88 FriendListComponent,
89 FriendsComponent,
90 LoaderComponent,
91 LoginComponent,
92 MenuAdminComponent,
93 MenuComponent,
94 RequestsComponent,
95 RequestStatsComponent,
96 SearchComponent,
97 UserAddComponent,
98 UserListComponent,
99 UsersComponent,
100 VideoAddComponent,
101 VideoListComponent,
102 VideoMiniatureComponent,
103 VideosComponent,
104 VideoSortComponent,
105 VideoWatchComponent,
106 ],
107 imports: [ // import Angular's modules
108 BrowserModule,
109 FormsModule,
110 ReactiveFormsModule,
111 HttpModule,
112 RouterModule.forRoot(routes),
113
114 ProgressbarModule,
115 PaginationModule,
116 FileUploadModule
117 ],
118 providers: [ // expose our Services and Providers into Angular's dependency injection
119 ENV_PROVIDERS,
120 APP_PROVIDERS
121 ]
122})
123export class AppModule {
124 constructor(public appRef: ApplicationRef, public appState: AppState) {}
125 hmrOnInit(store) {
126 if (!store || !store.state) return;
127 console.log('HMR store', store);
128 this.appState._state = store.state;
129 this.appRef.tick();
130 delete store.state;
131 }
132 hmrOnDestroy(store) {
133 const cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
134 // recreate elements
135 const state = this.appState._state;
136 store.state = state;
137 store.disposeOldHosts = createNewHosts(cmpLocation);
138 // remove styles
139 removeNgStyles();
140 }
141 hmrAfterDestroy(store) {
142 // display new elements
143 store.disposeOldHosts();
144 delete store.disposeOldHosts;
145 }
146}