member_webapp/@overflow/discovery/component2/ip-input.component.ts

58 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2018-06-21 09:35:24 +00:00
import {
AfterContentInit,
Component,
EventEmitter,
Input,
Output,
OnInit,
} from '@angular/core';
@Component({
selector: 'of-ip-input',
templateUrl: './ip-input.component.html',
})
export class IpInputComponent implements OnInit, AfterContentInit {
first: string;
second: string;
third: string;
fourth: string;
@Input() hostIp: string;
@Input() title: string;
@Input() fixed: number;
@Output() inputIp = new EventEmitter();
constructor(
) {
}
ngOnInit() {
if (this.hostIp !== '' && this.hostIp !== null && this.hostIp !== undefined) {
const tempIp = this.hostIp.split('.');
this.first = tempIp[0];
this.second = tempIp[1];
this.third = tempIp[2];
this.fourth = tempIp[3];
}
}
ngAfterContentInit() {
}
onIpInput(event) {
if (
(this.first !== '' && this.first !== undefined) &&
(this.second !== '' && this.second !== undefined) &&
(this.third !== '' && this.third !== undefined) &&
(this.fourth !== '' && this.fourth !== undefined) ) {
event.value = this.first + '.' + this.second + '.' + this.third + '.' + this.fourth;
this.inputIp.emit(event);
} else {
return;
}
}
}