From 259d989404ffbb541b26d7fb687581e2b57111ae Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Wed, 15 Mar 2017 15:46:39 +0000
Subject: [PATCH] Merge branch 'angular2' of https://rsanchez@git.curisit.net/gitblit/git/common/securis.git into angular2
---
securis/src/main/webapp/src/app/home.component.html | 56 -----------
securis/src/main/webapp/src/app/login.form.component.ts | 2
securis/src/main/webapp/src/app/menu.component.ts | 35 +++++++
securis/src/main/webapp/src/app/nomenu.component.html | 4
securis/src/main/webapp/src/app/footer.component.html | 7 +
securis/src/main/webapp/src/app/footer.component.ts | 28 +++++
securis/src/main/webapp/src/app/menu.component.html | 38 +++++++
securis/src/main/webapp/src/app/app.module.ts | 9 +
securis/src/main/webapp/src/app/home.component.ts | 14 --
securis/src/main/webapp/src/app/nomenu.component.ts | 29 +++++
securis/src/main/webapp/src/app/user.service.ts | 43 +++++---
securis/src/main/webapp/src/app/app.routes.ts | 21 +++-
12 files changed, 193 insertions(+), 93 deletions(-)
diff --git a/securis/src/main/webapp/src/app/app.module.ts b/securis/src/main/webapp/src/app/app.module.ts
index 6a95eba..0170275 100644
--- a/securis/src/main/webapp/src/app/app.module.ts
+++ b/securis/src/main/webapp/src/app/app.module.ts
@@ -23,8 +23,10 @@
import { PackListComponent } from './pack.list.component';
import { HeroDetailComponent } from './detail.component';
import { LoginFormComponent } from './login.form.component';
+import { MenuComponent } from './menu.component';
+import { NoMenuComponent } from './nomenu.component';
+import { FooterComponent } from './footer.component';
import { LicenseListComponent } from './license.list.component';
-import { LicenseFormComponent } from './forms/license.form.component';
import { appRoutes, appRoutingProviders } from './app.routes';
@@ -58,7 +60,10 @@
LicenseListComponent,
LicenseFormComponent,
I18nDirective,
- HomeComponent
+ HomeComponent,
+ MenuComponent,
+ NoMenuComponent,
+ FooterComponent
],
bootstrap: [ HomeComponent ],
entryComponents: [ PackFormComponent, LicenseFormComponent ],
diff --git a/securis/src/main/webapp/src/app/app.routes.ts b/securis/src/main/webapp/src/app/app.routes.ts
index e3f5054..060a1ff 100644
--- a/securis/src/main/webapp/src/app/app.routes.ts
+++ b/securis/src/main/webapp/src/app/app.routes.ts
@@ -1,17 +1,28 @@
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home.component';
+import { MenuComponent } from './menu.component';
+import { NoMenuComponent } from './nomenu.component';
import { PackListComponent } from './pack.list.component';
import { LicenseListComponent } from './license.list.component';
import { LoginFormComponent } from './login.form.component';
const routes: Routes = [
// {path: '', redirectTo: '/packs', pathMatch: 'full'},
- {path: 'packs', children: [
- {path: '', component: PackListComponent },
- {path: ':id/licenses', component: LicenseListComponent },
- ]},
- {path: 'login', component: LoginFormComponent }
+ {path: 'menu', component: MenuComponent,
+ children: [
+ {path: 'packs', children: [
+ {path: '', component: PackListComponent },
+ {path: ':id/licenses', component: LicenseListComponent },
+ ]}
+ ]
+ },
+ {path: 'nomenu', component: NoMenuComponent,
+ children: [
+ {path: 'login', component: LoginFormComponent }
+ ]
+ }
+
];
/* {path: 'product', component: DashboardProductComponent, children: [
{path: '', component: ProductOverviewComponent},
diff --git a/securis/src/main/webapp/src/app/footer.component.html b/securis/src/main/webapp/src/app/footer.component.html
new file mode 100644
index 0000000..73b77de
--- /dev/null
+++ b/securis/src/main/webapp/src/app/footer.component.html
@@ -0,0 +1,7 @@
+ <td-layout-footer>
+ <div layout="row" layout-align="start center" flex>
+ <div flex layout="row" layout-align="start center">v. {{securisVersion}}</div>
+ <div flex layout="row" layout-align="center center"><a href="http://www.curistec.com/" target="_blank">CurisTec</a> ©2017</div>
+ <div flex></div>
+ </div>
+ </td-layout-footer>
\ No newline at end of file
diff --git a/securis/src/main/webapp/src/app/footer.component.ts b/securis/src/main/webapp/src/app/footer.component.ts
new file mode 100644
index 0000000..309167b
--- /dev/null
+++ b/securis/src/main/webapp/src/app/footer.component.ts
@@ -0,0 +1,28 @@
+import { Component } from '@angular/core';
+import { BaseRequestOptions, Http } from '@angular/http';
+
+
+@Component({
+ selector: 'app-footer',
+ templateUrl: 'src/app/footer.component.html'
+})
+export class FooterComponent {
+
+ securisVersion : string = '0.0.0';
+
+ constructor(
+ private http: Http,
+ ) {
+ }
+
+ ngOnInit(): void {
+ //TODO Move to service
+ this.http.get("version", /* workaround to avoid OPTIONS method request*/ new BaseRequestOptions())
+ .map((res) => <string>res.json().version)
+ .subscribe(
+ version => this.securisVersion = version,
+ err => this.securisVersion = '0.0.0'
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/securis/src/main/webapp/src/app/home.component.html b/securis/src/main/webapp/src/app/home.component.html
index 48fe618..468e1fa 100644
--- a/securis/src/main/webapp/src/app/home.component.html
+++ b/securis/src/main/webapp/src/app/home.component.html
@@ -1,55 +1 @@
-<td-layout>
- <td-navigation-drawer #mainMenu sidenavTitle="SeCuris">
- </td-navigation-drawer>
-
- <md-nav-list td-sidenav-content>
- <a routerLink="/packs" md-list-item (click)="closeMenu()">
- <md-icon md-list-avatar>view_compact</md-icon>
- <h3 md-line i18n="menu.packs"> </h3>
- <p md-line i18n="menu.packs.description"> </p>
- </a>
- <a routerLink="/packs" md-list-item (click)="closeMenu()">
- <md-icon md-list-avatar>view_compact</md-icon>
- <h3 md-line i18n="menu.applications"> </h3>
- <p md-line i18n="menu.applications.description"> </p>
- </a>
- <a routerLink="/packs" md-list-item (click)="closeMenu()">
- <md-icon md-list-avatar>view_compact</md-icon>
- <h3 md-line i18n="menu.license_types"> </h3>
- <p md-line i18n="menu.license_types.description"> </p>
- </a>
- <a routerLink="/packs" md-list-item (click)="closeMenu()">
- <md-icon md-list-avatar>view_compact</md-icon>
- <h3 md-line i18n="menu.organizations"> </h3>
- <p md-line i18n="menu.organizations.description"> </p>
- </a>
- <a routerLink="/packs" md-list-item (click)="closeMenu()">
- <md-icon md-list-avatar>view_compact</md-icon>
- <h3 md-line i18n="menu.users"> </h3>
- <p md-line i18n="menu.users.description"> </p>
- </a>
- </md-nav-list>
-
-<td-layout-nav toolbarTitle="SeCuris" logo="assets:logo-white">
- <router-outlet></router-outlet>
- <td-layout-footer>
- <div layout="row" layout-align="start center" flex>
- <div flex layout="row" layout-align="start center">v. {{securisVersion}}</div>
- <div flex layout="row" layout-align="center center"><a href="http://www.curistec.com/" target="_blank">CurisTec</a> ©2017</div>
- <div flex></div>
- </div>
- </td-layout-footer>
-</td-layout-nav>
-</td-layout>
-
-<!--<td-layout-nav *ngIf="!isLoggedIn" toolbarTitle="SeCuris" logo="assets:logo-white">
-
- <td-layout-footer>
- <div layout="row" layout-align="start center" flex>
- <div flex layout="row" layout-align="start center">v. {{securisVersion}}</div>
- <div flex layout="row" layout-align="center center"><a href="http://www.curistec.com/" target="_blank">CurisTec</a> ©2017</div>
- <div flex></div>
- </div>
- </td-layout-footer>
-</td-layout-nav>
--->
\ No newline at end of file
+ <router-outlet></router-outlet>
\ No newline at end of file
diff --git a/securis/src/main/webapp/src/app/home.component.ts b/securis/src/main/webapp/src/app/home.component.ts
index d905c50..de7dfb2 100644
--- a/securis/src/main/webapp/src/app/home.component.ts
+++ b/securis/src/main/webapp/src/app/home.component.ts
@@ -28,20 +28,12 @@
toaster: ToastsManager,
vRef: ViewContainerRef,
private router: Router,
- http: Http,
private media: TdMediaService,
private _iconRegistry: MdIconRegistry,
private _domSanitizer: DomSanitizer,
private store: LocalStorageService) {
this.registerIcons();
toaster.setRootViewContainerRef(vRef);
- http.get("version", /* workaround to avoid OPTIONS method request*/ new BaseRequestOptions())
- .map((res) => <string>res.json().version)
- .subscribe(
- version => this.securisVersion = version,
- err => this.securisVersion = '0.0.0'
- );
-
}
private registerIcons() : void {
@@ -61,11 +53,7 @@
}
ngOnInit(): void {
- this.userService.isLoggedIn().subscribe(authOk => {
- this.isLoggedIn = true//authOk.valueOf();
- this.router.navigateByUrl(this.isLoggedIn ? 'packs' : 'login');
- } ,
- err => /* Show message */ this.router.navigateByUrl('login'));
+ this.router.navigateByUrl('nomenu/login');
}
ngAfterViewInit(): void {
diff --git a/securis/src/main/webapp/src/app/login.form.component.ts b/securis/src/main/webapp/src/app/login.form.component.ts
index 972ac97..c89259b 100644
--- a/securis/src/main/webapp/src/app/login.form.component.ts
+++ b/securis/src/main/webapp/src/app/login.form.component.ts
@@ -26,7 +26,7 @@
public login() {
this.userService.login(this.data.username, this.data.password).subscribe(
token => {
- this.router.navigateByUrl("packs");
+ this.router.navigateByUrl("menu/packs");
},
errMsg => this.toaster.error(errMsg, 'Login error'));
}
diff --git a/securis/src/main/webapp/src/app/menu.component.html b/securis/src/main/webapp/src/app/menu.component.html
new file mode 100644
index 0000000..074ca74
--- /dev/null
+++ b/securis/src/main/webapp/src/app/menu.component.html
@@ -0,0 +1,38 @@
+<td-layout>
+ <td-navigation-drawer #mainMenu sidenavTitle="SeCuris">
+ </td-navigation-drawer>
+
+ <md-nav-list td-sidenav-content>
+ <a routerLink="/menu/packs" md-list-item (click)="closeMenu()">
+ <md-icon md-list-avatar>view_compact</md-icon>
+ <h3 md-line i18n="menu.packs"> </h3>
+ <p md-line i18n="menu.packs.description"> </p>
+ </a>
+ <a routerLink="/menu/packs" md-list-item (click)="closeMenu()">
+ <md-icon md-list-avatar>view_compact</md-icon>
+ <h3 md-line i18n="menu.applications"> </h3>
+ <p md-line i18n="menu.applications.description"> </p>
+ </a>
+ <a routerLink="/menu/packs" md-list-item (click)="closeMenu()">
+ <md-icon md-list-avatar>view_compact</md-icon>
+ <h3 md-line i18n="menu.license_types"> </h3>
+ <p md-line i18n="menu.license_types.description"> </p>
+ </a>
+ <a routerLink="/menu/packs" md-list-item (click)="closeMenu()">
+ <md-icon md-list-avatar>view_compact</md-icon>
+ <h3 md-line i18n="menu.organizations"> </h3>
+ <p md-line i18n="menu.organizations.description"> </p>
+ </a>
+ <a routerLink="/menu/packs" md-list-item (click)="closeMenu()">
+ <md-icon md-list-avatar>view_compact</md-icon>
+ <h3 md-line i18n="menu.users"> </h3>
+ <p md-line i18n="menu.users.description"> </p>
+ </a>
+ </md-nav-list>
+
+<td-layout-nav toolbarTitle="SeCuris" logo="assets:logo-white">
+ <router-outlet></router-outlet>
+ <app-footer></app-footer>
+</td-layout-nav>
+</td-layout>
+
diff --git a/securis/src/main/webapp/src/app/menu.component.ts b/securis/src/main/webapp/src/app/menu.component.ts
new file mode 100644
index 0000000..ab65248
--- /dev/null
+++ b/securis/src/main/webapp/src/app/menu.component.ts
@@ -0,0 +1,35 @@
+import { Observable } from 'rxjs/Observable';
+import { BaseRequestOptions, Http } from '@angular/http';
+import { Component, ViewChild } from '@angular/core';
+import { UserService } from './user.service';
+import { Router } from '@angular/router';
+import { TdNavigationDrawerComponent } from '@covalent/core'
+
+
+@Component({
+ templateUrl: 'src/app/menu.component.html'
+})
+export class MenuComponent {
+
+ @ViewChild('mainMenu') mainMenu: TdNavigationDrawerComponent;
+
+
+ constructor(private userService: UserService,
+ private router: Router) {
+ }
+
+ ngOnInit(): void {
+ this.userService.isLoggedIn().subscribe(authOk => {
+ let isLoggedIn = authOk.valueOf();
+ if (!isLoggedIn) {
+ this.router.navigateByUrl('nomenu/login');
+ }
+ } ,
+ err => /* Show message */ this.router.navigateByUrl('nomenu/login'));
+ }
+
+ public closeMenu() {
+ this.mainMenu.close();
+ }
+
+}
diff --git a/securis/src/main/webapp/src/app/nomenu.component.html b/securis/src/main/webapp/src/app/nomenu.component.html
new file mode 100644
index 0000000..59ed3ce
--- /dev/null
+++ b/securis/src/main/webapp/src/app/nomenu.component.html
@@ -0,0 +1,4 @@
+<td-layout-nav toolbarTitle="SeCuris" logo="assets:logo-white">
+ <router-outlet></router-outlet>
+ <app-footer></app-footer>
+</td-layout-nav>
diff --git a/securis/src/main/webapp/src/app/nomenu.component.ts b/securis/src/main/webapp/src/app/nomenu.component.ts
new file mode 100644
index 0000000..0cfe7a3
--- /dev/null
+++ b/securis/src/main/webapp/src/app/nomenu.component.ts
@@ -0,0 +1,29 @@
+import { Observable } from 'rxjs/Observable';
+import { BaseRequestOptions, Http } from '@angular/http';
+import { ToastsManager } from 'ng2-toastr/ng2-toastr';
+import { AfterViewInit, Component, ViewContainerRef, ViewChild } from '@angular/core';
+import { DomSanitizer } from '@angular/platform-browser';
+import { MdIconRegistry } from '@angular/material';
+import { UserService } from './user.service';
+import { LocalStorageService } from 'angular-2-local-storage';
+import { TdMediaService } from '@covalent/core';
+import { Router } from '@angular/router';
+import { TdNavigationDrawerComponent } from '@covalent/core'
+
+// https://github.com/Teradata/covalent-quickstart/tree/develop/src/app
+// https://teradata.github.io/covalent-quickstart/#/
+
+@Component({
+ templateUrl: 'src/app/nomenu.component.html'
+})
+export class NoMenuComponent {
+
+
+ securisVersion : string;
+
+ constructor() {
+
+ }
+
+
+}
diff --git a/securis/src/main/webapp/src/app/user.service.ts b/securis/src/main/webapp/src/app/user.service.ts
index 04f5cb7..1d7e3e6 100644
--- a/securis/src/main/webapp/src/app/user.service.ts
+++ b/securis/src/main/webapp/src/app/user.service.ts
@@ -12,6 +12,8 @@
@Injectable()
export class UserService {
+ count : number = 0;
+
constructor(private $L: LocaleService,
private router: Router,
private store: LocalStorageService,
@@ -25,31 +27,35 @@
params.append('password', password);
let options = new RequestOptions({ headers: new Headers({ "Content-Type": "application/x-www-form-urlencoded" })});
return this.http.post('user/login', params.toString(), options)
- .map((res: Response) => {
- let data = res.json();
- this.store.set('username', username);
- this.store.set('token', data.token);
- return <string>data.token;
- })
- .catch((r) => this.handleError(r));
+ .map(this.mapLogin)
+ .catch(this.handleError);
}
+
+ private mapLogin(res : Response) {
+ let data = res.json();
+ //this.store.set('username', data.username);
+ //this.store.set('token', data.token);
+ return <string>data.token;
+ }
isLoggedIn() : Observable<Boolean> {
if (!this.existsToken()) {
return Observable.of(false);
}
var token = this.store.get("token");
- return this.http.get('check', new RequestOptions({ headers: new Headers({ 'X-SECURIS-TOKEN': token }) }))
- .map((res: Response) => {
- let body = res.json();
- if (body.valid) {
- this.store.set('user', body.user);
- }
- return body.valid;
- })
- .catch((r) => this.handleError(r))
- .catch(() => Observable.of(false));
+ let option = new RequestOptions({ headers: new Headers({ 'X-SECURIS-TOKEN': token }) });
+ return this.http.get('check', option)
+ .map(this.mapCheck)
+ .catch(this.handleError);
}
+
+ private mapCheck(res : Response) {
+ let body = res.json();
+ if (body.valid) {
+ //this.store.set('user', body.user);
+ }
+ return body.valid;
+ }
existsToken() : Boolean {
return this.store.get("token") !== null;
@@ -60,6 +66,9 @@
this.router.navigate(['Login']);
}
+
+
+
private handleError (error: Response | any) {
// In a real world app, we might use a remote logging infrastructure
let errMsg: string;
--
Gitblit v1.3.2