diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
commit | df98563e2104b82b119c00a3cd83cd0dc1242d25 (patch) | |
tree | a9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/app.module.ts | |
parent | 46757b477c1adb5f98060d15998a3852e18902a6 (diff) | |
download | PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip |
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/app.module.ts')
-rw-r--r-- | client/src/app/app.module.ts | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 8a072eaac..d7c9f6548 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts | |||
@@ -1,29 +1,29 @@ | |||
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 { | 3 | import { |
4 | removeNgStyles, | 4 | removeNgStyles, |
5 | createNewHosts, | 5 | createNewHosts, |
6 | createInputTransfer | 6 | createInputTransfer |
7 | } from '@angularclass/hmr'; | 7 | } from '@angularclass/hmr' |
8 | 8 | ||
9 | import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@nglibs/meta'; | 9 | import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@nglibs/meta' |
10 | // TODO: remove, we need this to avoid error in ng2-smart-table | 10 | // TODO: remove, we need this to avoid error in ng2-smart-table |
11 | import 'rxjs/add/operator/toPromise'; | 11 | import 'rxjs/add/operator/toPromise' |
12 | import 'bootstrap-loader'; | 12 | import 'bootstrap-loader' |
13 | 13 | ||
14 | import { ENV_PROVIDERS } from './environment'; | 14 | import { ENV_PROVIDERS } from './environment' |
15 | import { AppRoutingModule } from './app-routing.module'; | 15 | import { AppRoutingModule } from './app-routing.module' |
16 | import { AppComponent } from './app.component'; | 16 | import { AppComponent } from './app.component' |
17 | import { AppState, InternalStateType } from './app.service'; | 17 | import { AppState, InternalStateType } from './app.service' |
18 | 18 | ||
19 | import { AccountModule } from './account'; | 19 | import { AccountModule } from './account' |
20 | import { CoreModule } from './core'; | 20 | import { CoreModule } from './core' |
21 | import { LoginModule } from './login'; | 21 | import { LoginModule } from './login' |
22 | import { SignupModule } from './signup'; | 22 | import { SignupModule } from './signup' |
23 | import { SharedModule } from './shared'; | 23 | import { SharedModule } from './shared' |
24 | import { VideosModule } from './videos'; | 24 | import { VideosModule } from './videos' |
25 | 25 | ||
26 | export function metaFactory(): MetaLoader { | 26 | export function metaFactory (): MetaLoader { |
27 | return new MetaStaticLoader({ | 27 | return new MetaStaticLoader({ |
28 | pageTitlePositioning: PageTitlePositioning.PrependPageTitle, | 28 | pageTitlePositioning: PageTitlePositioning.PrependPageTitle, |
29 | pageTitleSeparator: ' - ', | 29 | pageTitleSeparator: ' - ', |
@@ -32,19 +32,19 @@ export function metaFactory(): MetaLoader { | |||
32 | title: 'PeerTube', | 32 | title: 'PeerTube', |
33 | description: 'PeerTube, a decentralized video streaming platform using P2P (BitTorrent) directly in the web browser' | 33 | description: 'PeerTube, a decentralized video streaming platform using P2P (BitTorrent) directly in the web browser' |
34 | } | 34 | } |
35 | }); | 35 | }) |
36 | } | 36 | } |
37 | 37 | ||
38 | type StoreType = { | 38 | type StoreType = { |
39 | state: InternalStateType, | 39 | state: InternalStateType, |
40 | restoreInputValues: () => void, | 40 | restoreInputValues: () => void, |
41 | disposeOldHosts: () => void | 41 | disposeOldHosts: () => void |
42 | }; | 42 | } |
43 | 43 | ||
44 | // Application wide providers | 44 | // Application wide providers |
45 | const APP_PROVIDERS = [ | 45 | const APP_PROVIDERS = [ |
46 | AppState | 46 | AppState |
47 | ]; | 47 | ] |
48 | 48 | ||
49 | @NgModule({ | 49 | @NgModule({ |
50 | bootstrap: [ AppComponent ], | 50 | bootstrap: [ AppComponent ], |
@@ -77,59 +77,59 @@ const APP_PROVIDERS = [ | |||
77 | ] | 77 | ] |
78 | }) | 78 | }) |
79 | export class AppModule { | 79 | export class AppModule { |
80 | constructor( | 80 | constructor ( |
81 | public appRef: ApplicationRef, | 81 | public appRef: ApplicationRef, |
82 | public appState: AppState | 82 | public appState: AppState |
83 | ) {} | 83 | ) {} |
84 | 84 | ||
85 | public hmrOnInit(store: StoreType) { | 85 | public hmrOnInit (store: StoreType) { |
86 | if (!store || !store.state) { | 86 | if (!store || !store.state) { |
87 | return; | 87 | return |
88 | } | 88 | } |
89 | console.log('HMR store', JSON.stringify(store, null, 2)); | 89 | console.log('HMR store', JSON.stringify(store, null, 2)) |
90 | /** | 90 | /** |
91 | * Set state | 91 | * Set state |
92 | */ | 92 | */ |
93 | this.appState._state = store.state; | 93 | this.appState._state = store.state |
94 | /** | 94 | /** |
95 | * Set input values | 95 | * Set input values |
96 | */ | 96 | */ |
97 | if ('restoreInputValues' in store) { | 97 | if ('restoreInputValues' in store) { |
98 | let restoreInputValues = store.restoreInputValues; | 98 | let restoreInputValues = store.restoreInputValues |
99 | setTimeout(restoreInputValues); | 99 | setTimeout(restoreInputValues) |
100 | } | 100 | } |
101 | 101 | ||
102 | this.appRef.tick(); | 102 | this.appRef.tick() |
103 | delete store.state; | 103 | delete store.state |
104 | delete store.restoreInputValues; | 104 | delete store.restoreInputValues |
105 | } | 105 | } |
106 | 106 | ||
107 | public hmrOnDestroy(store: StoreType) { | 107 | public hmrOnDestroy (store: StoreType) { |
108 | const cmpLocation = this.appRef.components.map((cmp) => cmp.location.nativeElement); | 108 | const cmpLocation = this.appRef.components.map((cmp) => cmp.location.nativeElement) |
109 | /** | 109 | /** |
110 | * Save state | 110 | * Save state |
111 | */ | 111 | */ |
112 | const state = this.appState._state; | 112 | const state = this.appState._state |
113 | store.state = state; | 113 | store.state = state |
114 | /** | 114 | /** |
115 | * Recreate root elements | 115 | * Recreate root elements |
116 | */ | 116 | */ |
117 | store.disposeOldHosts = createNewHosts(cmpLocation); | 117 | store.disposeOldHosts = createNewHosts(cmpLocation) |
118 | /** | 118 | /** |
119 | * Save input values | 119 | * Save input values |
120 | */ | 120 | */ |
121 | store.restoreInputValues = createInputTransfer(); | 121 | store.restoreInputValues = createInputTransfer() |
122 | /** | 122 | /** |
123 | * Remove styles | 123 | * Remove styles |
124 | */ | 124 | */ |
125 | removeNgStyles(); | 125 | removeNgStyles() |
126 | } | 126 | } |
127 | 127 | ||
128 | public hmrAfterDestroy(store: StoreType) { | 128 | public hmrAfterDestroy (store: StoreType) { |
129 | /** | 129 | /** |
130 | * Display new elements | 130 | * Display new elements |
131 | */ | 131 | */ |
132 | store.disposeOldHosts(); | 132 | store.disposeOldHosts () |
133 | delete store.disposeOldHosts; | 133 | delete store.disposeOldHosts |
134 | } | 134 | } |
135 | } | 135 | } |