From 50b0c262fd446e9f57630aa5775e1b4708bdf4cb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 29 Nov 2016 21:41:11 +0100 Subject: Client: move menu component in core module --- client/src/app/app.module.ts | 5 +-- client/src/app/core/core.module.ts | 9 ++++-- client/src/app/core/menu/index.ts | 1 + client/src/app/core/menu/menu.component.html | 39 +++++++++++++++++++++++ client/src/app/core/menu/menu.component.ts | 46 ++++++++++++++++++++++++++++ client/src/app/menu.component.html | 39 ----------------------- client/src/app/menu.component.ts | 46 ---------------------------- 7 files changed, 93 insertions(+), 92 deletions(-) create mode 100644 client/src/app/core/menu/index.ts create mode 100644 client/src/app/core/menu/menu.component.html create mode 100644 client/src/app/core/menu/menu.component.ts delete mode 100644 client/src/app/menu.component.html delete mode 100644 client/src/app/menu.component.ts (limited to 'client') diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 555f412e7..e9bb800f4 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -16,8 +16,6 @@ import { LoginModule } from './login'; import { SharedModule } from './shared'; import { VideosModule } from './videos'; -import { MenuComponent } from './menu.component'; - const metaConfig: MetaConfig = { //Append a title suffix such as a site name to all titles //Defaults to false @@ -35,8 +33,7 @@ const APP_PROVIDERS = [ @NgModule({ bootstrap: [ AppComponent ], declarations: [ - AppComponent, - MenuComponent + AppComponent ], imports: [ BrowserModule, diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index be29b88da..27e6ee1fb 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts @@ -1,17 +1,20 @@ import { NgModule, Optional, SkipSelf } from '@angular/core'; import { CommonModule } from '@angular/common'; import { HttpModule } from '@angular/http'; +import { RouterModule } from '@angular/router'; import { AuthService } from './auth'; +import { MenuComponent } from './menu'; import { throwIfAlreadyLoaded } from './module-import-guard'; @NgModule({ imports: [ CommonModule, - HttpModule + HttpModule, + RouterModule ], - declarations: [ ], - exports: [ ], + declarations: [ MenuComponent ], + exports: [ MenuComponent ], providers: [ AuthService ] }) export class CoreModule { diff --git a/client/src/app/core/menu/index.ts b/client/src/app/core/menu/index.ts new file mode 100644 index 000000000..d07a1144c --- /dev/null +++ b/client/src/app/core/menu/index.ts @@ -0,0 +1 @@ +export * from './menu.component'; diff --git a/client/src/app/core/menu/menu.component.html b/client/src/app/core/menu/menu.component.html new file mode 100644 index 000000000..1e9a53246 --- /dev/null +++ b/client/src/app/core/menu/menu.component.html @@ -0,0 +1,39 @@ + +
+
+ + + Login + + + + + Logout + +
+ +
+ + My account +
+
+ +
+
+ + See videos +
+ + +
+ +
+ +
+
diff --git a/client/src/app/core/menu/menu.component.ts b/client/src/app/core/menu/menu.component.ts new file mode 100644 index 000000000..f1bf6966d --- /dev/null +++ b/client/src/app/core/menu/menu.component.ts @@ -0,0 +1,46 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; + +import { AuthService } from '../auth'; +import { AuthStatus } from '../../shared'; + +@Component({ + selector: 'my-menu', + templateUrl: './menu.component.html' +}) +export class MenuComponent implements OnInit { + isLoggedIn: boolean; + + constructor ( + private authService: AuthService, + private router: Router + ) {} + + ngOnInit() { + this.isLoggedIn = this.authService.isLoggedIn(); + + this.authService.loginChangedSource.subscribe( + status => { + if (status === AuthStatus.LoggedIn) { + this.isLoggedIn = true; + console.log('Logged in.'); + } else if (status === AuthStatus.LoggedOut) { + this.isLoggedIn = false; + console.log('Logged out.'); + } else { + console.error('Unknown auth status: ' + status); + } + } + ); + } + + isUserAdmin() { + return this.authService.isAdmin(); + } + + logout() { + this.authService.logout(); + // Redirect to home page + this.router.navigate(['/videos/list']); + } +} diff --git a/client/src/app/menu.component.html b/client/src/app/menu.component.html deleted file mode 100644 index 1e9a53246..000000000 --- a/client/src/app/menu.component.html +++ /dev/null @@ -1,39 +0,0 @@ - -
-
- - - Login - - - - - Logout - -
- -
- - My account -
-
- -
-
- - See videos -
- - -
- -
- -
-
diff --git a/client/src/app/menu.component.ts b/client/src/app/menu.component.ts deleted file mode 100644 index d1a1d51e7..000000000 --- a/client/src/app/menu.component.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; - -import { AuthService } from './core'; -import { AuthStatus } from './shared'; - -@Component({ - selector: 'my-menu', - templateUrl: './menu.component.html' -}) -export class MenuComponent implements OnInit { - isLoggedIn: boolean; - - constructor ( - private authService: AuthService, - private router: Router - ) {} - - ngOnInit() { - this.isLoggedIn = this.authService.isLoggedIn(); - - this.authService.loginChangedSource.subscribe( - status => { - if (status === AuthStatus.LoggedIn) { - this.isLoggedIn = true; - console.log('Logged in.'); - } else if (status === AuthStatus.LoggedOut) { - this.isLoggedIn = false; - console.log('Logged out.'); - } else { - console.error('Unknown auth status: ' + status); - } - } - ); - } - - isUserAdmin() { - return this.authService.isAdmin(); - } - - logout() { - this.authService.logout(); - // Redirect to home page - this.router.navigate(['/videos/list']); - } -} -- cgit v1.2.3