test
This commit is contained in:
parent
057e51fd73
commit
574a2ae46f
|
@ -1,11 +1,11 @@
|
|||
import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges, OnInit } from '@angular/core';
|
||||
import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
|
||||
|
||||
@Component({
|
||||
selector: 'of-probe-selector',
|
||||
templateUrl: './selector.component.html',
|
||||
})
|
||||
export class ProbeSelectorComponent implements OnInit, OnChanges {
|
||||
export class ProbeSelectorComponent implements OnChanges {
|
||||
|
||||
@Output() select = new EventEmitter<ProbeHost>();
|
||||
@Input() probeHosts: ProbeHost[];
|
||||
|
@ -16,24 +16,22 @@ export class ProbeSelectorComponent implements OnInit, OnChanges {
|
|||
constructor() {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
this.checkPreselected();
|
||||
this.options = [];
|
||||
for (const ph of this.probeHosts) {
|
||||
this.options.push(ph.probe);
|
||||
}
|
||||
|
||||
if (changes['probeHosts'] !== null && changes['probeHosts'].currentValue.length > 0) {
|
||||
this.checkPreselected();
|
||||
}
|
||||
}
|
||||
|
||||
checkPreselected() {
|
||||
alert(this.probeHosts.length);
|
||||
const preselected: ProbeHost = this.probeHosts.find(probeHost => probeHost.id === this.probeHostID);
|
||||
if (!this.probeHosts || !this.probeHostID) {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
const preselected = this.probeHosts.find(probeHost => probeHost.id === Number(this.probeHostID));
|
||||
this.select.emit(preselected);
|
||||
});
|
||||
}
|
||||
|
||||
onSelect(probe: Probe) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user