app/src/commons/component/zone-detail.component.ts

34 lines
736 B
TypeScript
Raw Normal View History

2018-09-13 11:01:01 +00:00
import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';
2018-09-11 10:33:00 +00:00
import { Zone, Host } from '@overflow/model/discovery';
2018-09-09 10:20:21 +00:00
2018-09-11 10:33:00 +00:00
const IPCIDR = require('ip-cidr');
2018-09-09 10:20:21 +00:00
@Component({
selector: 'app-zone-detail',
templateUrl: './zone-detail.component.html',
styleUrls: ['./zone-detail.component.scss'],
})
2018-09-11 10:33:00 +00:00
export class ZoneDetailComponent implements OnInit {
2018-09-09 10:20:21 +00:00
@Input() zone: Zone;
2018-09-13 11:01:01 +00:00
@Output() otherHostSelect = new EventEmitter<Host>();
2018-09-11 10:33:00 +00:00
ipRange: string;
2018-09-09 10:20:21 +00:00
constructor(
) {
}
2018-09-11 10:33:00 +00:00
ngOnInit(): void {
if (!this.zone) {
return;
}
const cidr = new IPCIDR(this.zone.network);
this.ipRange = cidr.start() + ' - ' + cidr.end();
2018-09-13 11:01:01 +00:00
}
2018-09-11 10:33:00 +00:00
2018-09-13 11:01:01 +00:00
hostSelected(host: Host) {
this.otherHostSelect.emit(host);
2018-09-11 10:33:00 +00:00
}
2018-09-09 10:20:21 +00:00
}