scan condition restore last
This commit is contained in:
parent
16b37e5061
commit
5b3ad22280
|
@ -1,4 +1,4 @@
|
|||
<of-p-dropdownPanel #panel [style]="{'width':'400px'}" [headerStyle]="{'width':'300px'}" [blockTarget]="blockTarget" (cancel)="setDefault()">
|
||||
<of-p-dropdownPanel #panel [style]="{'width':'400px'}" [headerStyle]="{'width':'300px'}" [blockTarget]="blockTarget" (cancel)="cancel()">
|
||||
<p-header class="toolbar-button">
|
||||
<button _ngcontent-c1="" class="button-component" type="button">
|
||||
<!-- <svg _ngcontent-c1="" aria-hidden="true" class="octicon icon" version="1.1" viewBox="0 0 10 16" width="16px" height="16px">
|
||||
|
@ -87,7 +87,7 @@
|
|||
</p-panel>
|
||||
-->
|
||||
<div class="ui-g-12">
|
||||
<button type="button" pButton label="Reset" style="float: right;" (click)="setDefault()"></button>
|
||||
<button type="button" pButton label="Reset" style="float: right;" (click)="setDefault($event)"></button>
|
||||
<button type="button" pButton label="Apply" style="float: right;" (click)="done()" [disabled]="portErrMsg || ipErrMsg"></button>
|
||||
</div>
|
||||
<!-- <p-footer>
|
||||
|
|
|
@ -29,11 +29,10 @@ export class ScannerSettingDropdownComponent implements OnInit {
|
|||
includePortType: MetaPortTypeEnum[];
|
||||
firstPort: string;
|
||||
lastPort: string;
|
||||
|
||||
ipErrMsg: string;
|
||||
portErrMsg: string;
|
||||
|
||||
zone: Zone;
|
||||
lastCondition: Condition = null;
|
||||
|
||||
constructor(
|
||||
private discoveryConfigService: DiscoveryConfigService
|
||||
|
@ -72,13 +71,13 @@ export class ScannerSettingDropdownComponent implements OnInit {
|
|||
switch (this.ipType) {
|
||||
case 'V4':
|
||||
if (!(/^(?=\d+\.\d+\.\d+\.\d+$)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.?){4}$/.test(value))) {
|
||||
this.ipErrMsg = 'INVALID_IP_FORMAT';
|
||||
this.ipErrMsg = 'Invalid IP format.';
|
||||
return;
|
||||
}
|
||||
let from = idx === 0 ? value : this.firstIP;
|
||||
let to = idx === 1 ? value : this.lastIP;
|
||||
if (this.ipToNum(from) > this.ipToNum(to)) {
|
||||
this.ipErrMsg = 'INVALID_IP_RANGE';
|
||||
this.ipErrMsg = 'Invalid IP range.';
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -106,7 +105,7 @@ export class ScannerSettingDropdownComponent implements OnInit {
|
|||
let from = Number(fromStr);
|
||||
let to = Number(toStr)
|
||||
if (from === NaN || to === NaN) {
|
||||
this.portErrMsg = 'INVALID_PORT_TYPE';
|
||||
this.portErrMsg = 'Invalid Port Type.';
|
||||
return;
|
||||
}
|
||||
if (from <= 0) {
|
||||
|
@ -118,7 +117,7 @@ export class ScannerSettingDropdownComponent implements OnInit {
|
|||
return;
|
||||
}
|
||||
if (from > to) {
|
||||
this.portErrMsg = 'INVALID_PORT_RANGE';
|
||||
this.portErrMsg = 'Invalid Port range.';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -136,9 +135,38 @@ export class ScannerSettingDropdownComponent implements OnInit {
|
|||
|
||||
done() {
|
||||
// TODO: re-validation
|
||||
this.saveLastCondition();
|
||||
this.setSummary();
|
||||
this.panel.hide();
|
||||
}
|
||||
|
||||
cancel() {
|
||||
if (null === this.lastCondition) {
|
||||
this.setDefault();
|
||||
} else {
|
||||
this.restore();
|
||||
}
|
||||
}
|
||||
|
||||
saveLastCondition() {
|
||||
var c: Condition = {
|
||||
ipType: this.ipType,
|
||||
firstIP: this.firstIP,
|
||||
lastIP: this.lastIP,
|
||||
includePortType: this.includePortType,
|
||||
firstPort: this.firstPort,
|
||||
lastPort: this.lastPort,
|
||||
}
|
||||
this.lastCondition = c;
|
||||
}
|
||||
|
||||
restore() {
|
||||
this.ipType = this.lastCondition.ipType;
|
||||
this.firstIP = this.lastCondition.firstIP;
|
||||
this.lastIP = this.lastCondition.lastIP;
|
||||
this.includePortType = this.lastCondition.includePortType;
|
||||
this.firstPort = this.lastCondition.firstPort;
|
||||
this.lastPort = this.lastCondition.lastPort;
|
||||
}
|
||||
|
||||
setSummary(): void {
|
||||
|
@ -165,3 +193,12 @@ export class ScannerSettingDropdownComponent implements OnInit {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class Condition {
|
||||
ipType: MetaIPTypeEnum;
|
||||
firstIP: string;
|
||||
lastIP: string;
|
||||
includePortType: MetaPortTypeEnum[];
|
||||
firstPort: string;
|
||||
lastPort: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user