diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-11-20 17:18:15 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-11-21 22:09:45 +0100 |
commit | 693b1aba4675f7e3d850e0f6d07dbfc7bdff9b8c (patch) | |
tree | d6004d282a55d995eecba78bae95173bd0f11767 /client/src/app | |
parent | 2c8d4697db4b5a2d645b7bfcaf91093a64597958 (diff) | |
download | PeerTube-693b1aba4675f7e3d850e0f6d07dbfc7bdff9b8c.tar.gz PeerTube-693b1aba4675f7e3d850e0f6d07dbfc7bdff9b8c.tar.zst PeerTube-693b1aba4675f7e3d850e0f6d07dbfc7bdff9b8c.zip |
Client: split in angular modules
Diffstat (limited to 'client/src/app')
32 files changed, 369 insertions, 172 deletions
diff --git a/client/src/app/account/account-routing.module.ts b/client/src/app/account/account-routing.module.ts new file mode 100644 index 000000000..8c1033cd2 --- /dev/null +++ b/client/src/app/account/account-routing.module.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | import { RouterModule, Routes } from '@angular/router'; | ||
3 | |||
4 | import { AccountComponent } from './account.component'; | ||
5 | |||
6 | const accountRoutes: Routes = [ | ||
7 | { | ||
8 | path: 'account', | ||
9 | component: AccountComponent, | ||
10 | data: { | ||
11 | meta: { | ||
12 | titleSuffix: ' - My account' | ||
13 | } | ||
14 | } | ||
15 | } | ||
16 | ]; | ||
17 | |||
18 | @NgModule({ | ||
19 | imports: [ RouterModule.forChild(accountRoutes) ], | ||
20 | exports: [ RouterModule ] | ||
21 | }) | ||
22 | export class AccountRoutingModule {} | ||
diff --git a/client/src/app/account/account.module.ts b/client/src/app/account/account.module.ts new file mode 100644 index 000000000..53f6ba58e --- /dev/null +++ b/client/src/app/account/account.module.ts | |||
@@ -0,0 +1,26 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | |||
3 | import { AccountRoutingModule } from './account-routing.module'; | ||
4 | import { AccountComponent } from './account.component'; | ||
5 | import { AccountService } from './account.service'; | ||
6 | import { SharedModule } from '../shared'; | ||
7 | |||
8 | @NgModule({ | ||
9 | imports: [ | ||
10 | AccountRoutingModule, | ||
11 | SharedModule | ||
12 | ], | ||
13 | |||
14 | declarations: [ | ||
15 | AccountComponent | ||
16 | ], | ||
17 | |||
18 | exports: [ | ||
19 | AccountComponent | ||
20 | ], | ||
21 | |||
22 | providers: [ | ||
23 | AccountService | ||
24 | ] | ||
25 | }) | ||
26 | export class AccountModule { } | ||
diff --git a/client/src/app/account/account.routes.ts b/client/src/app/account/account.routes.ts deleted file mode 100644 index c382a6deb..000000000 --- a/client/src/app/account/account.routes.ts +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | import { AccountComponent } from './account.component'; | ||
2 | |||
3 | export const AccountRoutes = [ | ||
4 | { | ||
5 | path: 'account', | ||
6 | component: AccountComponent, | ||
7 | data: { | ||
8 | meta: { | ||
9 | titleSuffix: ' - My account' | ||
10 | } | ||
11 | } | ||
12 | } | ||
13 | ]; | ||
diff --git a/client/src/app/account/account.service.ts b/client/src/app/account/account.service.ts index 355bcef74..0635c2533 100644 --- a/client/src/app/account/account.service.ts +++ b/client/src/app/account/account.service.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { Injectable } from '@angular/core'; | 1 | import { Injectable } from '@angular/core'; |
2 | 2 | ||
3 | import { AuthHttp, AuthService, RestExtractor } from '../shared'; | 3 | import { AuthService } from '../core'; |
4 | import { AuthHttp, RestExtractor } from '../shared'; | ||
4 | 5 | ||
5 | @Injectable() | 6 | @Injectable() |
6 | export class AccountService { | 7 | export class AccountService { |
diff --git a/client/src/app/account/index.ts b/client/src/app/account/index.ts index 823d9fe5f..be03713cb 100644 --- a/client/src/app/account/index.ts +++ b/client/src/app/account/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | export * from './account-routing.module'; | ||
1 | export * from './account.component'; | 2 | export * from './account.component'; |
2 | export * from './account.routes'; | 3 | export * from './account.module'; |
3 | export * from './account.service'; | 4 | export * from './account.service'; |
diff --git a/client/src/app/admin/admin.routes.ts b/client/src/app/admin/admin-routing.module.ts index edb8ba49f..6bff25033 100644 --- a/client/src/app/admin/admin.routes.ts +++ b/client/src/app/admin/admin-routing.module.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { Routes } from '@angular/router'; | 1 | import { NgModule } from '@angular/core'; |
2 | import { RouterModule, Routes } from '@angular/router'; | ||
2 | 3 | ||
3 | import { AdminComponent } from './admin.component'; | 4 | import { AdminComponent } from './admin.component'; |
4 | import { FriendsRoutes } from './friends'; | 5 | import { FriendsRoutes } from './friends'; |
5 | import { RequestsRoutes } from './requests'; | 6 | import { RequestsRoutes } from './requests'; |
6 | import { UsersRoutes } from './users'; | 7 | import { UsersRoutes } from './users'; |
7 | 8 | ||
8 | export const AdminRoutes: Routes = [ | 9 | const adminRoutes: Routes = [ |
9 | { | 10 | { |
10 | path: 'admin', | 11 | path: 'admin', |
11 | component: AdminComponent, | 12 | component: AdminComponent, |
@@ -21,3 +22,9 @@ export const AdminRoutes: Routes = [ | |||
21 | ] | 22 | ] |
22 | } | 23 | } |
23 | ]; | 24 | ]; |
25 | |||
26 | @NgModule({ | ||
27 | imports: [ RouterModule.forChild(adminRoutes) ], | ||
28 | exports: [ RouterModule ] | ||
29 | }) | ||
30 | export class AdminRoutingModule {} | ||
diff --git a/client/src/app/admin/admin.module.ts b/client/src/app/admin/admin.module.ts new file mode 100644 index 000000000..63d99a3db --- /dev/null +++ b/client/src/app/admin/admin.module.ts | |||
@@ -0,0 +1,45 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | |||
3 | import { AdminComponent } from './admin.component'; | ||
4 | import { AdminRoutingModule } from './admin-routing.module'; | ||
5 | import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendService } from './friends'; | ||
6 | import { RequestsComponent, RequestStatsComponent, RequestService } from './requests'; | ||
7 | import { UsersComponent, UserAddComponent, UserListComponent, UserService } from './users'; | ||
8 | import { MenuAdminComponent } from './menu-admin.component'; | ||
9 | import { SharedModule } from '../shared'; | ||
10 | |||
11 | @NgModule({ | ||
12 | imports: [ | ||
13 | AdminRoutingModule, | ||
14 | SharedModule | ||
15 | ], | ||
16 | |||
17 | declarations: [ | ||
18 | AdminComponent, | ||
19 | |||
20 | FriendsComponent, | ||
21 | FriendAddComponent, | ||
22 | FriendListComponent, | ||
23 | |||
24 | RequestsComponent, | ||
25 | RequestStatsComponent, | ||
26 | |||
27 | UsersComponent, | ||
28 | UserAddComponent, | ||
29 | UserListComponent, | ||
30 | |||
31 | MenuAdminComponent | ||
32 | ], | ||
33 | |||
34 | exports: [ | ||
35 | AdminComponent, | ||
36 | MenuAdminComponent | ||
37 | ], | ||
38 | |||
39 | providers: [ | ||
40 | FriendService, | ||
41 | RequestService, | ||
42 | UserService | ||
43 | ] | ||
44 | }) | ||
45 | export class AdminModule { } | ||
diff --git a/client/src/app/admin/index.ts b/client/src/app/admin/index.ts index 493caed15..b75ff9b51 100644 --- a/client/src/app/admin/index.ts +++ b/client/src/app/admin/index.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | export * from './friends'; | 1 | export * from './friends'; |
2 | export * from './requests'; | 2 | export * from './requests'; |
3 | export * from './users'; | 3 | export * from './users'; |
4 | export * from './admin-routing.module'; | ||
5 | export * from './admin.module'; | ||
4 | export * from './admin.component'; | 6 | export * from './admin.component'; |
5 | export * from './admin.routes'; | ||
6 | export * from './menu-admin.component'; | 7 | export * from './menu-admin.component'; |
diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts new file mode 100644 index 000000000..900a4c5b6 --- /dev/null +++ b/client/src/app/app-routing.module.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | import { Routes, RouterModule } from '@angular/router'; | ||
3 | |||
4 | const routes: Routes = [ | ||
5 | { | ||
6 | path: '', | ||
7 | redirectTo: '/videos/list', | ||
8 | pathMatch: 'full' | ||
9 | } | ||
10 | ]; | ||
11 | |||
12 | @NgModule({ | ||
13 | imports: [ RouterModule.forRoot(routes) ], | ||
14 | exports: [ RouterModule ] | ||
15 | }) | ||
16 | export class AppRoutingModule {} | ||
17 | |||
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 3f57897fb..555f412e7 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts | |||
@@ -1,62 +1,22 @@ | |||
1 | import { ApplicationRef, NgModule } from '@angular/core'; | 1 | import { ApplicationRef, NgModule } from '@angular/core'; |
2 | import { BrowserModule } from '@angular/platform-browser'; | 2 | import { BrowserModule } from '@angular/platform-browser'; |
3 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
4 | import { HttpModule, RequestOptions, XHRBackend } from '@angular/http'; | ||
5 | import { RouterModule } from '@angular/router'; | ||
6 | import { removeNgStyles, createNewHosts } from '@angularclass/hmr'; | 3 | import { removeNgStyles, createNewHosts } from '@angularclass/hmr'; |
7 | 4 | ||
8 | import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; | 5 | import { MetaModule, MetaConfig } from 'ng2-meta'; |
9 | 6 | ||
10 | import { DropdownModule } from 'ng2-bootstrap/components/dropdown'; | ||
11 | import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar'; | ||
12 | import { PaginationModule } from 'ng2-bootstrap/components/pagination'; | ||
13 | import { ModalModule } from 'ng2-bootstrap/components/modal'; | ||
14 | |||
15 | import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; | ||
16 | |||
17 | import { MetaConfig, MetaModule } from 'ng2-meta'; | ||
18 | |||
19 | /* | ||
20 | * Platform and Environment providers/directives/pipes | ||
21 | */ | ||
22 | import { ENV_PROVIDERS } from './environment'; | 7 | import { ENV_PROVIDERS } from './environment'; |
23 | import { routes } from './app.routes'; | 8 | import { AppRoutingModule } from './app-routing.module'; |
24 | // App is our top level component | ||
25 | import { AppComponent } from './app.component'; | 9 | import { AppComponent } from './app.component'; |
26 | import { AppState } from './app.service'; | 10 | import { AppState } from './app.service'; |
27 | 11 | ||
28 | import { | 12 | import { AccountModule } from './account'; |
29 | AdminComponent, | 13 | import { AdminModule } from './admin'; |
30 | FriendsComponent, | 14 | import { CoreModule } from './core'; |
31 | FriendAddComponent, | 15 | import { LoginModule } from './login'; |
32 | FriendListComponent, | 16 | import { SharedModule } from './shared'; |
33 | FriendService, | 17 | import { VideosModule } from './videos'; |
34 | MenuAdminComponent, | 18 | |
35 | RequestsComponent, | ||
36 | RequestStatsComponent, | ||
37 | RequestService, | ||
38 | UsersComponent, | ||
39 | UserAddComponent, | ||
40 | UserListComponent, | ||
41 | UserService | ||
42 | } from './admin'; | ||
43 | import { AccountComponent, AccountService } from './account'; | ||
44 | import { LoginComponent } from './login'; | ||
45 | import { MenuComponent } from './menu.component'; | 19 | import { MenuComponent } from './menu.component'; |
46 | import { AuthService, AuthHttp, RestExtractor, RestService, SearchComponent, SearchService } from './shared'; | ||
47 | import { | ||
48 | LoaderComponent, | ||
49 | VideosComponent, | ||
50 | VideoAddComponent, | ||
51 | VideoListComponent, | ||
52 | VideoMiniatureComponent, | ||
53 | VideoSortComponent, | ||
54 | VideoWatchComponent, | ||
55 | VideoShareComponent, | ||
56 | VideoMagnetComponent, | ||
57 | VideoService, | ||
58 | WebTorrentService | ||
59 | } from './videos'; | ||
60 | 20 | ||
61 | const metaConfig: MetaConfig = { | 21 | const metaConfig: MetaConfig = { |
62 | //Append a title suffix such as a site name to all titles | 22 | //Append a title suffix such as a site name to all titles |
@@ -69,75 +29,31 @@ const metaConfig: MetaConfig = { | |||
69 | 29 | ||
70 | // Application wide providers | 30 | // Application wide providers |
71 | const APP_PROVIDERS = [ | 31 | const APP_PROVIDERS = [ |
72 | AppState, | 32 | AppState |
73 | |||
74 | { | ||
75 | provide: AuthHttp, | ||
76 | useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => { | ||
77 | return new AuthHttp(backend, defaultOptions, authService); | ||
78 | }, | ||
79 | deps: [ XHRBackend, RequestOptions, AuthService ] | ||
80 | }, | ||
81 | |||
82 | AuthService, | ||
83 | RestExtractor, | ||
84 | RestService, | ||
85 | |||
86 | VideoService, | ||
87 | SearchService, | ||
88 | FriendService, | ||
89 | RequestService, | ||
90 | UserService, | ||
91 | AccountService, | ||
92 | WebTorrentService | ||
93 | ]; | 33 | ]; |
94 | /** | 34 | |
95 | * `AppModule` is the main entry point into Angular2's bootstraping process | ||
96 | */ | ||
97 | @NgModule({ | 35 | @NgModule({ |
98 | bootstrap: [ AppComponent ], | 36 | bootstrap: [ AppComponent ], |
99 | declarations: [ | 37 | declarations: [ |
100 | AccountComponent, | ||
101 | AdminComponent, | ||
102 | AppComponent, | 38 | AppComponent, |
103 | BytesPipe, | 39 | MenuComponent |
104 | FriendAddComponent, | ||
105 | FriendListComponent, | ||
106 | FriendsComponent, | ||
107 | LoaderComponent, | ||
108 | LoginComponent, | ||
109 | MenuAdminComponent, | ||
110 | MenuComponent, | ||
111 | RequestsComponent, | ||
112 | RequestStatsComponent, | ||
113 | SearchComponent, | ||
114 | UserAddComponent, | ||
115 | UserListComponent, | ||
116 | UsersComponent, | ||
117 | VideoAddComponent, | ||
118 | VideoListComponent, | ||
119 | VideoMiniatureComponent, | ||
120 | VideosComponent, | ||
121 | VideoSortComponent, | ||
122 | VideoWatchComponent, | ||
123 | VideoShareComponent, | ||
124 | VideoMagnetComponent | ||
125 | ], | 40 | ], |
126 | imports: [ // import Angular's modules | 41 | imports: [ |
127 | BrowserModule, | 42 | BrowserModule, |
128 | FormsModule, | ||
129 | ReactiveFormsModule, | ||
130 | HttpModule, | ||
131 | RouterModule.forRoot(routes), | ||
132 | 43 | ||
133 | DropdownModule, | 44 | CoreModule, |
134 | ProgressbarModule, | 45 | SharedModule, |
135 | PaginationModule, | 46 | |
136 | ModalModule, | 47 | AppRoutingModule, |
137 | 48 | ||
138 | FileUploadModule, | 49 | MetaModule.forRoot(metaConfig), |
139 | 50 | ||
140 | MetaModule.forRoot(metaConfig) | 51 | AccountModule, |
52 | AdminModule, | ||
53 | CoreModule, | ||
54 | LoginModule, | ||
55 | SharedModule, | ||
56 | VideosModule | ||
141 | ], | 57 | ], |
142 | providers: [ // expose our Services and Providers into Angular's dependency injection | 58 | providers: [ // expose our Services and Providers into Angular's dependency injection |
143 | ENV_PROVIDERS, | 59 | ENV_PROVIDERS, |
diff --git a/client/src/app/app.routes.ts b/client/src/app/app.routes.ts deleted file mode 100644 index 03e2bce51..000000000 --- a/client/src/app/app.routes.ts +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | import { Routes } from '@angular/router'; | ||
2 | |||
3 | import { AccountRoutes } from './account'; | ||
4 | import { LoginRoutes } from './login'; | ||
5 | import { AdminRoutes } from './admin'; | ||
6 | import { VideosRoutes } from './videos'; | ||
7 | |||
8 | export const routes: Routes = [ | ||
9 | { | ||
10 | path: '', | ||
11 | redirectTo: '/videos/list', | ||
12 | pathMatch: 'full' | ||
13 | }, | ||
14 | ...AdminRoutes, | ||
15 | ...AccountRoutes, | ||
16 | ...LoginRoutes, | ||
17 | ...VideosRoutes | ||
18 | ]; | ||
diff --git a/client/src/app/shared/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index b7e0a44a7..1f0e322a9 100644 --- a/client/src/app/shared/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts | |||
@@ -4,9 +4,10 @@ import { Router } from '@angular/router'; | |||
4 | import { Observable } from 'rxjs/Observable'; | 4 | import { Observable } from 'rxjs/Observable'; |
5 | import { Subject } from 'rxjs/Subject'; | 5 | import { Subject } from 'rxjs/Subject'; |
6 | 6 | ||
7 | import { AuthStatus } from './auth-status.model'; | 7 | // Do not use the barrel (dependency loop) |
8 | import { AuthUser } from './auth-user.model'; | 8 | import { AuthStatus } from '../../shared/auth/auth-status.model'; |
9 | import { RestExtractor } from '../rest'; | 9 | import { AuthUser } from '../../shared/auth/auth-user.model'; |
10 | import { RestExtractor } from '../../shared/rest'; | ||
10 | 11 | ||
11 | @Injectable() | 12 | @Injectable() |
12 | export class AuthService { | 13 | export class AuthService { |
diff --git a/client/src/app/core/auth/index.ts b/client/src/app/core/auth/index.ts new file mode 100644 index 000000000..cf52c9c7c --- /dev/null +++ b/client/src/app/core/auth/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './auth.service' | |||
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts new file mode 100644 index 000000000..be29b88da --- /dev/null +++ b/client/src/app/core/core.module.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { NgModule, Optional, SkipSelf } from '@angular/core'; | ||
2 | import { CommonModule } from '@angular/common'; | ||
3 | import { HttpModule } from '@angular/http'; | ||
4 | |||
5 | import { AuthService } from './auth'; | ||
6 | import { throwIfAlreadyLoaded } from './module-import-guard'; | ||
7 | |||
8 | @NgModule({ | ||
9 | imports: [ | ||
10 | CommonModule, | ||
11 | HttpModule | ||
12 | ], | ||
13 | declarations: [ ], | ||
14 | exports: [ ], | ||
15 | providers: [ AuthService ] | ||
16 | }) | ||
17 | export class CoreModule { | ||
18 | constructor( @Optional() @SkipSelf() parentModule: CoreModule) { | ||
19 | throwIfAlreadyLoaded(parentModule, 'CoreModule'); | ||
20 | } | ||
21 | } | ||
diff --git a/client/src/app/core/index.ts b/client/src/app/core/index.ts new file mode 100644 index 000000000..fa951b215 --- /dev/null +++ b/client/src/app/core/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './auth'; | ||
2 | export * from './core.module' | ||
diff --git a/client/src/app/core/module-import-guard.ts b/client/src/app/core/module-import-guard.ts new file mode 100644 index 000000000..445640c4f --- /dev/null +++ b/client/src/app/core/module-import-guard.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export function throwIfAlreadyLoaded(parentModule: any, moduleName: string) { | ||
2 | if (parentModule) { | ||
3 | throw new Error(`${moduleName} has already been loaded. Import Core modules in the AppModule only.`); | ||
4 | } | ||
5 | } | ||
diff --git a/client/src/app/login/index.ts b/client/src/app/login/index.ts index 64d3f2a3c..5639915f7 100644 --- a/client/src/app/login/index.ts +++ b/client/src/app/login/index.ts | |||
@@ -1,2 +1,3 @@ | |||
1 | export * from './login-routing.module'; | ||
1 | export * from './login.component'; | 2 | export * from './login.component'; |
2 | export * from './login.routes'; | 3 | export * from './login.module'; |
diff --git a/client/src/app/login/login-routing.module.ts b/client/src/app/login/login-routing.module.ts new file mode 100644 index 000000000..da68519bd --- /dev/null +++ b/client/src/app/login/login-routing.module.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | import { RouterModule, Routes } from '@angular/router'; | ||
3 | |||
4 | import { LoginComponent } from './login.component'; | ||
5 | |||
6 | const loginRoutes: Routes = [ | ||
7 | { | ||
8 | path: 'login', | ||
9 | component: LoginComponent, | ||
10 | data: { | ||
11 | meta: { | ||
12 | titleSuffix: ' - Login' | ||
13 | } | ||
14 | } | ||
15 | } | ||
16 | ]; | ||
17 | |||
18 | @NgModule({ | ||
19 | imports: [ RouterModule.forChild(loginRoutes) ], | ||
20 | exports: [ RouterModule ] | ||
21 | }) | ||
22 | export class LoginRoutingModule {} | ||
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index c4ff7050b..fd4a314cc 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts | |||
@@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core'; | |||
2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
3 | import { Router } from '@angular/router'; | 3 | import { Router } from '@angular/router'; |
4 | 4 | ||
5 | import { AuthService, FormReactive } from '../shared'; | 5 | import { AuthService } from '../core'; |
6 | import { FormReactive } from '../shared'; | ||
6 | 7 | ||
7 | @Component({ | 8 | @Component({ |
8 | selector: 'my-login', | 9 | selector: 'my-login', |
diff --git a/client/src/app/login/login.module.ts b/client/src/app/login/login.module.ts new file mode 100644 index 000000000..31a723b43 --- /dev/null +++ b/client/src/app/login/login.module.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | |||
3 | import { LoginRoutingModule } from './login-routing.module'; | ||
4 | import { LoginComponent } from './login.component'; | ||
5 | import { SharedModule } from '../shared'; | ||
6 | |||
7 | @NgModule({ | ||
8 | imports: [ | ||
9 | LoginRoutingModule, | ||
10 | SharedModule | ||
11 | ], | ||
12 | |||
13 | declarations: [ | ||
14 | LoginComponent | ||
15 | ], | ||
16 | |||
17 | exports: [ | ||
18 | LoginComponent | ||
19 | ], | ||
20 | |||
21 | providers: [ | ||
22 | ] | ||
23 | }) | ||
24 | export class LoginModule { } | ||
diff --git a/client/src/app/login/login.routes.ts b/client/src/app/login/login.routes.ts deleted file mode 100644 index 2f63af5e2..000000000 --- a/client/src/app/login/login.routes.ts +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | import { LoginComponent } from './login.component'; | ||
2 | |||
3 | export const LoginRoutes = [ | ||
4 | { | ||
5 | path: 'login', | ||
6 | component: LoginComponent, | ||
7 | data: { | ||
8 | meta: { | ||
9 | titleSuffix: ' - Login' | ||
10 | } | ||
11 | } | ||
12 | } | ||
13 | ]; | ||
diff --git a/client/src/app/menu.component.ts b/client/src/app/menu.component.ts index 6cfc854dd..d1a1d51e7 100644 --- a/client/src/app/menu.component.ts +++ b/client/src/app/menu.component.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | import { Router } from '@angular/router'; | 2 | import { Router } from '@angular/router'; |
3 | 3 | ||
4 | import { AuthService, AuthStatus } from './shared'; | 4 | import { AuthService } from './core'; |
5 | import { AuthStatus } from './shared'; | ||
5 | 6 | ||
6 | @Component({ | 7 | @Component({ |
7 | selector: 'my-menu', | 8 | selector: 'my-menu', |
diff --git a/client/src/app/shared/auth/auth-http.service.ts b/client/src/app/shared/auth/auth-http.service.ts index 2392898ca..602726570 100644 --- a/client/src/app/shared/auth/auth-http.service.ts +++ b/client/src/app/shared/auth/auth-http.service.ts | |||
@@ -7,11 +7,12 @@ import { | |||
7 | RequestMethod, | 7 | RequestMethod, |
8 | RequestOptions, | 8 | RequestOptions, |
9 | RequestOptionsArgs, | 9 | RequestOptionsArgs, |
10 | Response | 10 | Response, |
11 | XHRBackend | ||
11 | } from '@angular/http'; | 12 | } from '@angular/http'; |
12 | import { Observable } from 'rxjs/Observable'; | 13 | import { Observable } from 'rxjs/Observable'; |
13 | 14 | ||
14 | import { AuthService } from './auth.service'; | 15 | import { AuthService } from '../../core'; |
15 | 16 | ||
16 | @Injectable() | 17 | @Injectable() |
17 | export class AuthHttp extends Http { | 18 | export class AuthHttp extends Http { |
@@ -78,3 +79,13 @@ export class AuthHttp extends Http { | |||
78 | headers.set('Authorization', this.authService.getRequestHeaderValue()); | 79 | headers.set('Authorization', this.authService.getRequestHeaderValue()); |
79 | } | 80 | } |
80 | } | 81 | } |
82 | |||
83 | export const AUTH_HTTP_PROVIDERS = [ | ||
84 | { | ||
85 | provide: AuthHttp, | ||
86 | useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => { | ||
87 | return new AuthHttp(backend, defaultOptions, authService); | ||
88 | }, | ||
89 | deps: [ XHRBackend, RequestOptions, AuthService ] | ||
90 | }, | ||
91 | ]; | ||
diff --git a/client/src/app/shared/auth/index.ts b/client/src/app/shared/auth/index.ts index ebd9e14cd..ce0bd8adf 100644 --- a/client/src/app/shared/auth/index.ts +++ b/client/src/app/shared/auth/index.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | export * from './auth-http.service'; | 1 | export * from './auth-http.service'; |
2 | export * from './auth-status.model'; | 2 | export * from './auth-status.model'; |
3 | export * from './auth.service'; | ||
4 | export * from './auth-user.model'; | 3 | export * from './auth-user.model'; |
diff --git a/client/src/app/shared/index.ts b/client/src/app/shared/index.ts index af34b4b64..52a647b83 100644 --- a/client/src/app/shared/index.ts +++ b/client/src/app/shared/index.ts | |||
@@ -3,3 +3,4 @@ export * from './forms'; | |||
3 | export * from './rest'; | 3 | export * from './rest'; |
4 | export * from './search'; | 4 | export * from './search'; |
5 | export * from './users'; | 5 | export * from './users'; |
6 | export * from './shared.module'; | ||
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts new file mode 100644 index 000000000..141922322 --- /dev/null +++ b/client/src/app/shared/shared.module.ts | |||
@@ -0,0 +1,62 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | import { CommonModule } from '@angular/common'; | ||
3 | import { HttpModule } from '@angular/http'; | ||
4 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
5 | import { RouterModule } from '@angular/router'; | ||
6 | |||
7 | import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; | ||
8 | import { DropdownModule } from 'ng2-bootstrap/components/dropdown'; | ||
9 | import { ProgressbarModule } from 'ng2-bootstrap/components/progressbar'; | ||
10 | import { PaginationModule } from 'ng2-bootstrap/components/pagination'; | ||
11 | import { ModalModule } from 'ng2-bootstrap/components/modal'; | ||
12 | import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; | ||
13 | |||
14 | import { AUTH_HTTP_PROVIDERS } from './auth'; | ||
15 | import { RestExtractor, RestService } from './rest'; | ||
16 | import { SearchComponent, SearchService } from './search'; | ||
17 | |||
18 | @NgModule({ | ||
19 | imports: [ | ||
20 | CommonModule, | ||
21 | FormsModule, | ||
22 | ReactiveFormsModule, | ||
23 | HttpModule, | ||
24 | RouterModule, | ||
25 | |||
26 | DropdownModule, | ||
27 | FileUploadModule, | ||
28 | ModalModule, | ||
29 | PaginationModule, | ||
30 | ProgressbarModule | ||
31 | ], | ||
32 | |||
33 | declarations: [ | ||
34 | BytesPipe, | ||
35 | SearchComponent | ||
36 | ], | ||
37 | |||
38 | exports: [ | ||
39 | CommonModule, | ||
40 | FormsModule, | ||
41 | ReactiveFormsModule, | ||
42 | HttpModule, | ||
43 | RouterModule, | ||
44 | |||
45 | DropdownModule, | ||
46 | FileUploadModule, | ||
47 | ModalModule, | ||
48 | PaginationModule, | ||
49 | ProgressbarModule, | ||
50 | BytesPipe, | ||
51 | |||
52 | SearchComponent | ||
53 | ], | ||
54 | |||
55 | providers: [ | ||
56 | AUTH_HTTP_PROVIDERS, | ||
57 | RestExtractor, | ||
58 | RestService, | ||
59 | SearchService | ||
60 | ] | ||
61 | }) | ||
62 | export class SharedModule { } | ||
diff --git a/client/src/app/videos/index.ts b/client/src/app/videos/index.ts index a9088a907..ca386a51d 100644 --- a/client/src/app/videos/index.ts +++ b/client/src/app/videos/index.ts | |||
@@ -2,5 +2,6 @@ export * from './shared'; | |||
2 | export * from './video-add'; | 2 | export * from './video-add'; |
3 | export * from './video-list'; | 3 | export * from './video-list'; |
4 | export * from './video-watch'; | 4 | export * from './video-watch'; |
5 | export * from './videos-routing.module'; | ||
5 | export * from './videos.component'; | 6 | export * from './videos.component'; |
6 | export * from './videos.routes'; | 7 | export * from './videos.module'; |
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts index b1f688095..f173ef06b 100644 --- a/client/src/app/videos/shared/video.service.ts +++ b/client/src/app/videos/shared/video.service.ts | |||
@@ -4,7 +4,8 @@ import { Observable } from 'rxjs/Observable'; | |||
4 | 4 | ||
5 | import { Search } from '../../shared'; | 5 | import { Search } from '../../shared'; |
6 | import { SortField } from './sort-field.type'; | 6 | import { SortField } from './sort-field.type'; |
7 | import { AuthHttp, AuthService, RestExtractor, RestPagination, RestService, ResultList } from '../../shared'; | 7 | import { AuthService } from '../../core'; |
8 | import { AuthHttp, RestExtractor, RestPagination, RestService, ResultList } from '../../shared'; | ||
8 | import { Video } from './video.model'; | 9 | import { Video } from './video.model'; |
9 | 10 | ||
10 | @Injectable() | 11 | @Injectable() |
diff --git a/client/src/app/videos/video-add/video-add.component.ts b/client/src/app/videos/video-add/video-add.component.ts index b7bf1534f..6eab54f7e 100644 --- a/client/src/app/videos/video-add/video-add.component.ts +++ b/client/src/app/videos/video-add/video-add.component.ts | |||
@@ -4,7 +4,8 @@ import { Router } from '@angular/router'; | |||
4 | 4 | ||
5 | import { FileUploader } from 'ng2-file-upload/ng2-file-upload'; | 5 | import { FileUploader } from 'ng2-file-upload/ng2-file-upload'; |
6 | 6 | ||
7 | import { AuthService, FormReactive, VIDEO_NAME, VIDEO_DESCRIPTION, VIDEO_TAGS } from '../../shared'; | 7 | import { AuthService } from '../../core'; |
8 | import { FormReactive, VIDEO_NAME, VIDEO_DESCRIPTION, VIDEO_TAGS } from '../../shared'; | ||
8 | 9 | ||
9 | @Component({ | 10 | @Component({ |
10 | selector: 'my-videos-add', | 11 | selector: 'my-videos-add', |
diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts index 6b086e938..a8b92480b 100644 --- a/client/src/app/videos/video-list/video-list.component.ts +++ b/client/src/app/videos/video-list/video-list.component.ts | |||
@@ -7,7 +7,8 @@ import { | |||
7 | Video, | 7 | Video, |
8 | VideoService | 8 | VideoService |
9 | } from '../shared'; | 9 | } from '../shared'; |
10 | import { AuthService, AuthUser, RestPagination, Search, SearchField } from '../../shared'; | 10 | import { AuthService } from '../../core'; |
11 | import { AuthUser, RestPagination, Search, SearchField } from '../../shared'; | ||
11 | import { SearchService } from '../../shared'; | 12 | import { SearchService } from '../../shared'; |
12 | 13 | ||
13 | @Component({ | 14 | @Component({ |
diff --git a/client/src/app/videos/videos.routes.ts b/client/src/app/videos/videos-routing.module.ts index ab68fbe0c..766d29d22 100644 --- a/client/src/app/videos/videos.routes.ts +++ b/client/src/app/videos/videos-routing.module.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { Routes } from '@angular/router'; | 1 | import { NgModule } from '@angular/core'; |
2 | import { RouterModule, Routes } from '@angular/router'; | ||
2 | 3 | ||
3 | import { VideoAddComponent } from './video-add'; | 4 | import { VideoAddComponent } from './video-add'; |
4 | import { VideoListComponent } from './video-list'; | 5 | import { VideoListComponent } from './video-list'; |
5 | import { VideosComponent } from './videos.component'; | 6 | import { VideosComponent } from './videos.component'; |
6 | import { VideoWatchComponent } from './video-watch'; | 7 | import { VideoWatchComponent } from './video-watch'; |
7 | 8 | ||
8 | export const VideosRoutes: Routes = [ | 9 | const videosRoutes: Routes = [ |
9 | { | 10 | { |
10 | path: 'videos', | 11 | path: 'videos', |
11 | component: VideosComponent, | 12 | component: VideosComponent, |
@@ -35,3 +36,9 @@ export const VideosRoutes: Routes = [ | |||
35 | ] | 36 | ] |
36 | } | 37 | } |
37 | ]; | 38 | ]; |
39 | |||
40 | @NgModule({ | ||
41 | imports: [ RouterModule.forChild(videosRoutes) ], | ||
42 | exports: [ RouterModule ] | ||
43 | }) | ||
44 | export class VideosRoutingModule {} | ||
diff --git a/client/src/app/videos/videos.module.ts b/client/src/app/videos/videos.module.ts new file mode 100644 index 000000000..fb2f453b0 --- /dev/null +++ b/client/src/app/videos/videos.module.ts | |||
@@ -0,0 +1,42 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | |||
3 | import { VideosRoutingModule } from './videos-routing.module'; | ||
4 | import { VideosComponent } from './videos.component'; | ||
5 | import { VideoAddComponent } from './video-add'; | ||
6 | import { VideoListComponent, VideoMiniatureComponent, VideoSortComponent } from './video-list'; | ||
7 | import { VideoWatchComponent, VideoMagnetComponent, VideoShareComponent, WebTorrentService } from './video-watch'; | ||
8 | import { LoaderComponent, VideoService } from './shared'; | ||
9 | import { SharedModule } from '../shared'; | ||
10 | |||
11 | @NgModule({ | ||
12 | imports: [ | ||
13 | VideosRoutingModule, | ||
14 | SharedModule | ||
15 | ], | ||
16 | |||
17 | declarations: [ | ||
18 | VideosComponent, | ||
19 | |||
20 | VideoAddComponent, | ||
21 | |||
22 | VideoListComponent, | ||
23 | VideoMiniatureComponent, | ||
24 | VideoSortComponent, | ||
25 | |||
26 | VideoWatchComponent, | ||
27 | VideoMagnetComponent, | ||
28 | VideoShareComponent, | ||
29 | |||
30 | LoaderComponent | ||
31 | ], | ||
32 | |||
33 | exports: [ | ||
34 | VideosComponent | ||
35 | ], | ||
36 | |||
37 | providers: [ | ||
38 | VideoService, | ||
39 | WebTorrentService | ||
40 | ] | ||
41 | }) | ||
42 | export class VideosModule { } | ||