This commit is contained in:
insanity 2018-05-16 17:45:36 +09:00
parent 56768d5f81
commit 613a4380f6
17 changed files with 41 additions and 31 deletions

View File

@ -6,7 +6,7 @@ const routes: Routes = [
{ path: '', loadChildren: './pages/pages.module#PagesModule', canActivate: [AuthGuard] },
{ path: 'auth', loadChildren: './pages/auth/auth-page.module#AuthPageModule' },
{ path: '**', loadChildren: './pages/error/error-page.module#ErrorPageModule' },
// { path: 'errors', loadChildren: './pages/errors/errors-page.module#ErrorsPageModule' },
{ path: 'error', loadChildren: './pages/error/error-page.module#ErrorPageModule' },
];
@NgModule({

View File

@ -1 +1,4 @@
Error Page
Error Page
<p-button label="Main" (onClick)="onNavigateMain()"></p-button>

View File

@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@ -10,9 +11,14 @@ import { Component, OnInit } from '@angular/core';
export class ErrorPageComponent implements OnInit {
constructor() { }
constructor(
private router: Router,
) { }
ngOnInit() {
}
onNavigateMain() {
this.router.navigate(['home']);
}
}

View File

@ -2,8 +2,8 @@ import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ProbePageComponent } from './probe-page.component';
import { ProbeListComponent } from './list/list.component';
import { ProbeDetailComponent } from './detail/detail.component';
import { ProbeListComponent } from './probe/list.component';
import { ProbeDetailComponent } from './probe/detail.component';
import { DownloadComponent } from 'packages/probe/component/download/download.component';
@ -13,7 +13,7 @@ const routes: Routes = [
component: ProbePageComponent,
children: [
{ path: 'list', component: ProbeListComponent },
{ path: 'noauth', loadChildren: 'app/pages/noauth-probe/noauth-probe-page.module#NoAuthProbePageModule' },
{ path: 'noauth', loadChildren: 'app/pages/probe/noauth-probe/noauth-probe-page.module#NoAuthProbePageModule' },
{ path: 'download', component: DownloadComponent },
{ path: ':id/info', component: ProbeDetailComponent },
// { path: ':id/targets', loadChildren: 'app/pages/targets/targets-page.module#TargetsPageModule'},

View File

@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnDestroy } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { Subscription } from 'rxjs/Subscription';
@ -6,15 +6,12 @@ import { Subscription } from 'rxjs/Subscription';
selector: 'of-pages-probe',
templateUrl: './probe-page.component.html',
})
export class ProbePageComponent implements OnInit, OnDestroy {
export class ProbePageComponent implements OnDestroy {
private tabs = undefined;
private routerSubscription$: Subscription;
constructor(private router: Router) {
}
ngOnInit() {
this.routerSubscription$ = this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.generateTabMenu(event);
@ -27,24 +24,28 @@ export class ProbePageComponent implements OnInit, OnDestroy {
}
generateTabMenu(event: NavigationEnd) {
const parsedUrl = event.url.split('probe/')[1].split('/')[0];
switch (parsedUrl) {
case 'list':
case 'noauth':
case 'download':
this.tabs = [
{ label: 'PROBES', routerLink: ['/probe/list'] },
{ label: 'UNAUTHORIZED', routerLink: ['/probe/noauth'] },
{ label: 'DOWNLOAD', routerLink: ['/probe/download'] },
];
break;
default:
this.tabs = [
{ label: 'INFO', routerLink: ['/probe/', parsedUrl, 'info'] },
{ label: 'TARGETS', routerLink: ['/probe/', parsedUrl, 'targets'], disabled: true },
{ label: 'HISTORY', path: ['/probe/', parsedUrl, 'history'], disabled: true },
];
break;
try {
const parsedUrl = event.url.split('probe/')[1].split('/')[0];
switch (parsedUrl) {
case 'list':
case 'noauth':
case 'download':
this.tabs = [
{ label: 'PROBES', routerLink: ['/probe/list'] },
{ label: 'UNAUTHORIZED', routerLink: ['/probe/noauth'] },
{ label: 'DOWNLOAD', routerLink: ['/probe/download'] },
];
break;
default:
this.tabs = [
{ label: 'INFO', routerLink: ['/probe/', parsedUrl, 'info'] },
{ label: 'TARGETS', routerLink: ['/probe/', parsedUrl, 'targets'], disabled: true },
{ label: 'HISTORY', path: ['/probe/', parsedUrl, 'history'], disabled: true },
];
break;
}
} catch {
this.router.navigate(['error']);
}
}

View File

@ -8,8 +8,8 @@ import { PrimeNGModules } from 'packages/commons/prime-ng/prime-ng.module';
import { ProbeModule } from 'packages/probe/probe.module';
import { TabbarModule } from 'app/commons/component/layout/tabbar/app.tabbar.module';
import { NoauthModule } from 'packages/noauth/noauth.module';
import { ProbeListComponent } from './list/list.component';
import { ProbeDetailComponent } from './detail/detail.component';
import { ProbeListComponent } from './probe/list.component';
import { ProbeDetailComponent } from './probe/detail.component';
@NgModule({
imports: [