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