mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +01:00
Modify small bugs about code
This commit is contained in:
parent
963830b9d1
commit
ffbcdf62a0
@ -126,14 +126,13 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
this.createForm();
|
this.createForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
baseFilterData(name: string, option: string[], state: boolean, inputValue: string) {
|
baseFilterData(name: string, option: string[], state: boolean) {
|
||||||
return {
|
return {
|
||||||
name: name,
|
name: name,
|
||||||
options: option,
|
options: option,
|
||||||
state: state,
|
state: state,
|
||||||
isValid: true,
|
isValid: true,
|
||||||
isOpen: false, // label list
|
isOpen: false // label list
|
||||||
inputValue: inputValue
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,8 +298,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (rule.filters) {
|
if (rule.filters) {
|
||||||
this.reOrganizeLabel(rule.filters);
|
this.reOrganizeLabel(rule.filters);
|
||||||
|
|
||||||
|
|
||||||
this.setFilter(rule.filters);
|
this.setFilter(rule.filters);
|
||||||
this.updateFilter(rule.filters);
|
this.updateFilter(rule.filters);
|
||||||
}
|
}
|
||||||
@ -318,12 +315,12 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
let delLabel = '';
|
let delLabel = '';
|
||||||
filterLabels.forEach((data: any) => {
|
filterLabels.forEach((data: any) => {
|
||||||
if (data.kind === 'label') {
|
if (data.kind === this.filterSelect[2]) {
|
||||||
if (data.value.deleted !== true) {
|
if (!data.value.deleted) {
|
||||||
count++;
|
count++;
|
||||||
this.filterLabelInfo.push(data.value);
|
this.filterLabelInfo.push(data.value);
|
||||||
}
|
}
|
||||||
if (data.value.deleted === true) {
|
if (data.value.deleted) {
|
||||||
this.deletedLabelCount++;
|
this.deletedLabelCount++;
|
||||||
delLabel += data.value.name + ',';
|
delLabel += data.value.name + ',';
|
||||||
}
|
}
|
||||||
@ -344,7 +341,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
let lab = filterLabels.find(data => data.kind === this.filterSelect[2]);
|
let lab = filterLabels.find(data => data.kind === this.filterSelect[2]);
|
||||||
if (lab) {filterLabels.splice(filterLabels.indexOf(lab), 1); }
|
if (lab) {filterLabels.splice(filterLabels.indexOf(lab), 1); }
|
||||||
}
|
}
|
||||||
filterLabels.push({kind: this.filterSelect[2], value: count + ' labels'});
|
filterLabels.push({kind: 'label', value: count + ' labels'});
|
||||||
this.labelInputVal = count.toString();
|
this.labelInputVal = count.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -401,14 +398,14 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
data.options.push(name);
|
data.options.push(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if before select, $event is label, then after select set inputValue is empty and isOpen is false
|
// if before select, $event is label
|
||||||
if (this.filterSelect.length === 3 && name === this.filterSelect[2] && data.name === value) {
|
if (!this.withAdmiral && name === this.filterSelect[2] && data.name === value) {
|
||||||
this.labelInputVal = controlArray.controls[index].get('value').value.split(' ')[0];
|
this.labelInputVal = controlArray.controls[index].get('value').value.split(' ')[0];
|
||||||
data.isOpen = false;
|
data.isOpen = false;
|
||||||
controlArray.controls[index].get('value').setValue('');
|
controlArray.controls[index].get('value').setValue('');
|
||||||
}
|
}
|
||||||
// if before select, $event is not label, then after select set inputValue is labelInputVal and isOpen is true
|
// if before select, $event is not label
|
||||||
if (this.filterSelect.length === 3 && data.name === this.filterSelect[2]) {
|
if (!this.withAdmiral && data.name === this.filterSelect[2]) {
|
||||||
if (this.labelInputVal) {
|
if (this.labelInputVal) {
|
||||||
controlArray.controls[index].get('value').setValue(this.labelInputVal + ' labels');
|
controlArray.controls[index].get('value').setValue(this.labelInputVal + ' labels');
|
||||||
} else {
|
} else {
|
||||||
@ -425,7 +422,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// when input value is label, then open label panel
|
// when input value is label, then open label panel
|
||||||
openLabelList(labelTag: string, indexId: number, $event: any) {
|
openLabelList(labelTag: string, indexId: number, $event: any) {
|
||||||
if (this.filterSelect.length === 3 && labelTag === this.filterSelect[2]) {
|
if (!this.withAdmiral && labelTag === this.filterSelect[2]) {
|
||||||
this.filterListData.forEach((data, index) => {
|
this.filterListData.forEach((data, index) => {
|
||||||
if (index === indexId) {
|
if (index === indexId) {
|
||||||
data.isOpen = true;
|
data.isOpen = true;
|
||||||
@ -498,7 +495,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
this.filterSelect[0],
|
this.filterSelect[0],
|
||||||
this.filterSelect.slice(),
|
this.filterSelect.slice(),
|
||||||
true,
|
true,
|
||||||
''
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
controlArray.push(this.initFilter(this.filterSelect[0]));
|
controlArray.push(this.initFilter(this.filterSelect[0]));
|
||||||
@ -511,14 +507,14 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
this.filterListData.filter(data => {
|
this.filterListData.filter(data => {
|
||||||
data.options.splice(data.options.indexOf(nameArr[0]), 1);
|
data.options.splice(data.options.indexOf(nameArr[0]), 1);
|
||||||
});
|
});
|
||||||
this.filterListData.push(this.baseFilterData(nameArr[0], nameArr, true, ''));
|
this.filterListData.push(this.baseFilterData(nameArr[0], nameArr, true));
|
||||||
controlArray.push(this.initFilter(nameArr[0]));
|
controlArray.push(this.initFilter(nameArr[0]));
|
||||||
}
|
}
|
||||||
this.filterCount += 1;
|
this.filterCount += 1;
|
||||||
if (this.filterCount >= this.filterSelect.length) {
|
if (this.filterCount >= this.filterSelect.length) {
|
||||||
this.isFilterHide = true;
|
this.isFilterHide = true;
|
||||||
}
|
}
|
||||||
if (controlArray.controls[this.filterCount - 1].get('kind').value === 'label' && this.labelInputVal) {
|
if (controlArray.controls[this.filterCount - 1].get('kind').value === this.filterSelect[2] && this.labelInputVal) {
|
||||||
controlArray.controls[this.filterCount - 1].get('value').setValue(this.labelInputVal + ' labels');
|
controlArray.controls[this.filterCount - 1].get('value').setValue(this.labelInputVal + ' labels');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,7 +522,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// delete a filter
|
// delete a filter
|
||||||
deleteFilter(i: number): void {
|
deleteFilter(i: number): void {
|
||||||
if (i || i === 0) {
|
if (i >= 0) {
|
||||||
let delFilter = this.filterListData.splice(i, 1)[0];
|
let delFilter = this.filterListData.splice(i, 1)[0];
|
||||||
if (this.filterCount === this.filterSelect.length) {
|
if (this.filterCount === this.filterSelect.length) {
|
||||||
this.isFilterHide = false;
|
this.isFilterHide = false;
|
||||||
@ -541,7 +537,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
const control = <FormArray>this.ruleForm.get('filters');
|
const control = <FormArray>this.ruleForm.get('filters');
|
||||||
if (control.controls[i].get('kind').value === 'label') {
|
if (control.controls[i].get('kind').value === this.filterSelect[2]) {
|
||||||
this.labelInputVal = control.controls[i].get('value').value.split(' ')[0];
|
this.labelInputVal = control.controls[i].get('value').value.split(' ')[0];
|
||||||
}
|
}
|
||||||
control.removeAt(i);
|
control.removeAt(i);
|
||||||
@ -605,7 +601,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
filters.forEach((filter: any) => {
|
filters.forEach((filter: any) => {
|
||||||
let option: string[] = opt.slice();
|
let option: string[] = opt.slice();
|
||||||
option.unshift(filter.kind);
|
option.unshift(filter.kind);
|
||||||
this.filterListData.push(this.baseFilterData(filter.kind, option, true, ''));
|
this.filterListData.push(this.baseFilterData(filter.kind, option, true));
|
||||||
});
|
});
|
||||||
this.filterCount = filters.length;
|
this.filterCount = filters.length;
|
||||||
if (filters.length === this.filterSelect.length) {
|
if (filters.length === this.filterSelect.length) {
|
||||||
@ -618,7 +614,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
const controlArray = <FormArray> this.ruleForm.get('filters');
|
const controlArray = <FormArray> this.ruleForm.get('filters');
|
||||||
|
|
||||||
this.filterListData.forEach((data, index) => {
|
this.filterListData.forEach((data, index) => {
|
||||||
if (data.name === 'label') {
|
if (data.name === this.filterSelect[2]) {
|
||||||
let labelsLength = selectedLabels.filter(lab => lab.iconsShow === true).length;
|
let labelsLength = selectedLabels.filter(lab => lab.iconsShow === true).length;
|
||||||
if (labelsLength > 0) {
|
if (labelsLength > 0) {
|
||||||
controlArray.controls[index].get('value').setValue(labelsLength + ' labels');
|
controlArray.controls[index].get('value').setValue(labelsLength + ' labels');
|
||||||
@ -894,7 +890,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
let ruleValue: { [key: string]: any | any[] } = clone(this.ruleForm.value);
|
let ruleValue: { [key: string]: any | any[] } = clone(this.ruleForm.value);
|
||||||
if (ruleValue.filters && ruleValue.filters.length) {
|
if (ruleValue.filters && ruleValue.filters.length) {
|
||||||
ruleValue.filters.forEach((data, index) => {
|
ruleValue.filters.forEach((data, index) => {
|
||||||
if (data.kind === 'label') {
|
if (data.kind === this.filterSelect[2]) {
|
||||||
ruleValue.filters.splice(index, 1);
|
ruleValue.filters.splice(index, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -163,9 +163,8 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
|
|||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
return 'enabled';
|
return 'enabled';
|
||||||
}else { return 'disabled'; }
|
}else { return 'disabled'; }
|
||||||
}else {
|
|
||||||
return 'enabled';
|
|
||||||
}
|
}
|
||||||
|
return 'enabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
deletionConfirm(message: ConfirmationAcknowledgement) {
|
deletionConfirm(message: ConfirmationAcknowledgement) {
|
||||||
|
Loading…
Reference in New Issue
Block a user