probe routing

This commit is contained in:
insanity 2018-06-04 15:14:00 +09:00
parent 0fe54aaa86
commit 0a897c4be2
10 changed files with 46 additions and 79 deletions

View File

@ -53,11 +53,11 @@ export class ProbeListComponent implements OnInit {
} }
getUptime(probe: Probe) { getUptime(probe: Probe) {
if (!probe.connectDate) { // if (!probe.connectDate) {
return 'Not Connected.'; // return 'Not Connected.';
} // }
const hours = Math.abs(new Date().getTime() - probe.connectDate.getTime()); // const hours = Math.abs(new Date().getTime() - probe.connectDate.getTime());
return this.convertUptimeString(hours); // return this.convertUptimeString(hours);
} }
convertUptimeString(hours: number) { convertUptimeString(hours: number) {

View File

@ -1,16 +1,18 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { ProbeTabPageComponent } from './probe-tab-page.component'; import { ProbeTabPageComponent } from './probe-tab-page.component';
import { ProbeListPageComponent } from '@app/pages/probes/probe/probe-list-page.component';
import { ProbeDetailPageComponent } from '@app/pages/probes/probe/probe-detail-page.component';
const routes: Routes = [ const routes: Routes = [
{ {
path: '', path: '',
component: ProbeTabPageComponent, component: ProbeTabPageComponent,
children: [ children: [
{ path: 'list', loadChildren: './probe/probe-page.module#ProbePageModule' }, { path: 'list', component: ProbeListPageComponent },
{ path: 'noauth', loadChildren: './noauth-probe/noauth-probe-page.module#NoAuthProbePageModule' }, { path: 'noauth', loadChildren: './noauth-probe/noauth-probe-page.module#NoAuthProbePageModule' },
{ path: 'download', loadChildren: './download/download-page.module#ProbeDownloadPageModule' }, { path: 'download', loadChildren: './download/download-page.module#ProbeDownloadPageModule' },
{ path: ':id/info', loadChildren: './probe/probe-page.module#ProbePageModule' }, { path: ':id/info', component: ProbeDetailPageComponent },
// { path: ':id/targets', loadChildren: 'app/pages/targets/targets-page.module#TargetsPageModule'}, // { path: ':id/targets', loadChildren: 'app/pages/targets/targets-page.module#TargetsPageModule'},
{ path: ':id/history', component: null }, { path: ':id/history', component: null },
] ]

View File

@ -7,6 +7,8 @@ import { ProbeModule } from '@overflow/probe/probe.module';
import { ProbeTabPageComponent } from './probe-tab-page.component'; import { ProbeTabPageComponent } from './probe-tab-page.component';
import { ProbeTabPageRoutingModule } from './probe-tab-page-routing.module'; import { ProbeTabPageRoutingModule } from './probe-tab-page-routing.module';
import { TabbarModule } from '../../commons/component/layout/tabbar/app.tabbar.module'; import { TabbarModule } from '../../commons/component/layout/tabbar/app.tabbar.module';
import { ProbeListPageComponent } from '@app/pages/probes/probe/probe-list-page.component';
import { ProbeDetailPageComponent } from '@app/pages/probes/probe/probe-detail-page.component';
@NgModule({ @NgModule({
imports: [ imports: [
@ -18,6 +20,8 @@ import { TabbarModule } from '../../commons/component/layout/tabbar/app.tabbar.m
], ],
declarations: [ declarations: [
ProbeTabPageComponent, ProbeTabPageComponent,
ProbeListPageComponent,
ProbeDetailPageComponent
] ]
}) })
export class ProbeTabPageModule { } export class ProbeTabPageModule { }

View File

@ -0,0 +1 @@
<of-probe-detail [probeHostID]="probeHostID" (discovery)="onDiscovery($event)"></of-probe-detail>

View File

@ -6,10 +6,10 @@ import { Target } from '@overflow/commons-typescript/model/target';
import { BreadcrumbService } from '@app/commons/service/breadcrumb.service'; import { BreadcrumbService } from '@app/commons/service/breadcrumb.service';
@Component({ @Component({
selector: 'of-pages-probe', selector: 'of-pages-probe-detail',
templateUrl: './probe-page.component.html', templateUrl: './probe-detail-page.component.html',
}) })
export class ProbePageComponent { export class ProbeDetailPageComponent {
isDetail: boolean; isDetail: boolean;
probeHostID: string; probeHostID: string;
@ -20,34 +20,10 @@ export class ProbePageComponent {
private breadcrumbService: BreadcrumbService private breadcrumbService: BreadcrumbService
) { ) {
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
if (params['id']) { this.probeHostID = params['id'];
this.onDetailContainer(params['id']);
} else {
this.onListContainer();
}
}); });
} }
onListContainer() {
this.breadcrumbService.setItems([
{ label: 'Probe', routerLink: ['/probe/list'], }
]);
this.isDetail = false;
}
onDetailContainer(probeHostID: string) {
this.probeHostID = probeHostID;
this.breadcrumbService.setItems([
{ label: 'Probe', routerLink: ['/probe/list'] },
{ label: this.probeHostID }
]);
this.isDetail = true;
}
onProbeSelect(probeHost: ProbeHost) {
this.router.navigate(['probe', probeHost.id, 'info']);
}
onTargetSelect(target: Target) { onTargetSelect(target: Target) {
console.log(target); console.log(target);
} }

View File

@ -0,0 +1 @@
<of-probe-list (select)="onProbeSelect($event)"></of-probe-list>

View File

@ -0,0 +1,27 @@
import { Component, OnDestroy } from '@angular/core';
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
import { Subscription } from 'rxjs/Subscription';
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
import { Target } from '@overflow/commons-typescript/model/target';
import { BreadcrumbService } from '@app/commons/service/breadcrumb.service';
@Component({
selector: 'of-pages-probe-list',
templateUrl: './probe-list-page.component.html',
})
export class ProbeListPageComponent {
constructor(
private router: Router,
private route: ActivatedRoute,
private breadcrumbService: BreadcrumbService
) {
this.breadcrumbService.setItems([
{ label: 'Probe', routerLink: ['/probe/list'], }
]);
}
onProbeSelect(probeHost: ProbeHost) {
this.router.navigate(['probe', probeHost.id, 'info']);
}
}

View File

@ -1,16 +0,0 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ProbePageComponent } from './probe-page.component';
const routes: Routes = [
{
path: '',
component: ProbePageComponent,
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ProbePageRoutingModule { }

View File

@ -1,7 +0,0 @@
<div *ngIf="!isDetail; else detailView">
<of-probe-list (select)="onProbeSelect($event)"></of-probe-list>
</div>
<ng-template #detailView>
<of-probe-detail [probeHostID]="probeHostID" (discovery)="onDiscovery($event)"></of-probe-detail>
</ng-template>

View File

@ -1,21 +0,0 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { UIModule } from '@overflow/shared/ui/ui.module';
import { ProbeModule } from '@overflow/probe/probe.module';
import { ProbePageComponent } from './probe-page.component';
import { ProbePageRoutingModule } from './probe-page-routing.module';
@NgModule({
imports: [
CommonModule,
UIModule,
ProbePageRoutingModule,
ProbeModule,
],
entryComponents: [
],
declarations: [ProbePageComponent]
})
export class ProbePageModule { }