probe detail router

This commit is contained in:
insanity 2018-01-31 17:40:53 +09:00
parent 516a0bffa6
commit c89be32cf3
4 changed files with 24 additions and 13 deletions

View File

@ -1,3 +1,3 @@
<p>
detail works!
{{probeId}} detail
</p>

View File

@ -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');
}
}

View File

@ -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<Probe>;
@ -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]);
}
}

View File

@ -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' },
];
}
}