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

58 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2018-05-25 10:56:28 +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;
2018-05-30 09:39:26 +00:00
@Input() hostIp: string;
@Input() title: string;
@Input() fixed: number;
2018-05-25 10:56:28 +00:00
@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) ) {
2018-05-29 12:18:43 +00:00
event.value = this.first + '.' + this.second + '.' + this.third + '.' + this.fourth;
2018-05-25 10:56:28 +00:00
this.inputIp.emit(event);
} else {
return;
}
}
}