diff --git a/src/app/packages/probe/component/detail/detail.component.html b/src/app/packages/probe/component/detail/detail.component.html index 6f936ed..9a92530 100644 --- a/src/app/packages/probe/component/detail/detail.component.html +++ b/src/app/packages/probe/component/detail/detail.component.html @@ -1,3 +1,3 @@

- detail works! + {{probeId}} detail

diff --git a/src/app/packages/probe/component/detail/detail.component.ts b/src/app/packages/probe/component/detail/detail.component.ts index c7b90c6..3878294 100644 --- a/src/app/packages/probe/component/detail/detail.component.ts +++ b/src/app/packages/probe/component/detail/detail.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; @Component({ selector: 'of-detail', @@ -7,9 +8,12 @@ import { Component, OnInit } from '@angular/core'; }) export class DetailComponent implements OnInit { - constructor() { } + probeId = undefined; + + constructor(private route: ActivatedRoute, private router: Router) { } ngOnInit() { + this.probeId = this.route.snapshot.paramMap.get('id'); } } diff --git a/src/app/packages/probe/component/list/list.component.ts b/src/app/packages/probe/component/list/list.component.ts index b455f4d..913d43f 100644 --- a/src/app/packages/probe/component/list/list.component.ts +++ b/src/app/packages/probe/component/list/list.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core'; import { MatTableDataSource, MatSort } from '@angular/material'; import { AfterContentInit } from '@angular/core/src/metadata/lifecycle_hooks'; +import { Router } from '@angular/router'; export interface Probe { id: string; @@ -19,7 +20,7 @@ export interface Probe { templateUrl: './list.component.html', styleUrls: ['./list.component.scss'] }) -export class ListComponent implements OnInit, AfterContentInit { +export class ListComponent implements OnInit, AfterContentInit { displayedColumns = ['name', 'ip', 'os', 'cidr', 'targetCnt', 'date', 'authBy']; dataSource: MatTableDataSource; @@ -39,7 +40,7 @@ export class ListComponent implements OnInit, AfterContentInit { ip: String('ip' + i), os: String('os' + i), cidr: String('cidr' + i), - targetCnt : i, + targetCnt: i, date: String('date' + i), authBy: String('insanity') }; @@ -50,12 +51,12 @@ export class ListComponent implements OnInit, AfterContentInit { this.dataSource.sort = this.sort; } - constructor() { } + constructor(private router: Router) { } ngOnInit() { } handleRowClick(obj: Probe) { - alert(obj.id); + this.router.navigate(['probe', obj.id]); } } diff --git a/src/app/pages/probe/probe-page.component.ts b/src/app/pages/probe/probe-page.component.ts index 9309cba..131a15a 100644 --- a/src/app/pages/probe/probe-page.component.ts +++ b/src/app/pages/probe/probe-page.component.ts @@ -1,18 +1,24 @@ import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; @Component({ selector: 'of-pages-probe', templateUrl: './probe-page.component.html', styleUrls: ['./probe-page.component.scss'] }) -export class ProbePageComponent { +export class ProbePageComponent implements OnInit { - tabs = [ - { label: 'Info', path: '/probe' }, - { label: 'Targets', path: '/target' }, - { label: 'History', path: '/probe/history' }, - ]; + tabs = undefined; - constructor() { } + constructor(private router: Router) { + } + + ngOnInit() { + this.tabs = [ + { label: 'Info', path: this.router.url }, + { label: 'Targets', path: '/target' }, + { label: 'History', path: '/probe/history' }, + ]; + } }