remove the project related code

Signed-off-by: Meina Zhou <meinaz@vmware.com>
This commit is contained in:
Meina Zhou 2019-03-22 10:12:51 +08:00
parent 084ae573ad
commit b0ce3da8bd
2 changed files with 1 additions and 103 deletions

View File

@ -126,7 +126,7 @@
<div formGroupName="trigger"> <div formGroupName="trigger">
<!--on trigger--> <!--on trigger-->
<div class="select floatSetPar"> <div class="select floatSetPar">
<select id="ruleTrigger" formControlName="kind" (change)="selectTrigger($event)"> <select id="ruleTrigger" formControlName="checkRuleName" (change)="selectTrigger($event)">
<option value="Manual">{{'REPLICATION.MANUAL' | translate}}</option> <option value="Manual">{{'REPLICATION.MANUAL' | translate}}</option>
<option value="Immediate">{{'REPLICATION.IMMEDIATE' | translate}}</option> <option value="Immediate">{{'REPLICATION.IMMEDIATE' | translate}}</option>
<option value="Scheduled">{{'REPLICATION.SCHEDULE' | translate}}</option> <option value="Scheduled">{{'REPLICATION.SCHEDULE' | translate}}</option>

View File

@ -71,19 +71,12 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
inNameChecking = false; inNameChecking = false;
isRuleNameValid = true; isRuleNameValid = true;
nameChecker: Subject<string> = new Subject<string>(); nameChecker: Subject<string> = new Subject<string>();
proNameChecker: Subject<string> = new Subject<string>();
firstClick = 0; firstClick = 0;
policyId: number; policyId: number;
labelInputVal = ''; labelInputVal = '';
filterLabelInfo: Label[] = []; // store filter selected labels` id filterLabelInfo: Label[] = []; // store filter selected labels` id
deletedLabelCount = 0; deletedLabelCount = 0;
deletedLabelInfo: string; deletedLabelInfo: string;
namespaceList: [any] = [{
id: 1,
name: "namespace1"
}];
confirmSub: Subscription; confirmSub: Subscription;
ruleForm: FormGroup; ruleForm: FormGroup;
formArrayLabel: FormArray; formArrayLabel: FormArray;
@ -98,24 +91,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
@Output() reload = new EventEmitter<boolean>(); @Output() reload = new EventEmitter<boolean>();
@ViewChild(InlineAlertComponent) inlineAlert: InlineAlertComponent; @ViewChild(InlineAlertComponent) inlineAlert: InlineAlertComponent;
emptyProject = {
project_id: -1,
name: ""
};
emptyEndpoint = {
id: -1,
credential: {
access_key: "",
access_secret: "",
type: ""
},
description: "",
insecure: false,
name: "",
type: "",
url: "",
};
constructor( constructor(
private fb: FormBuilder, private fb: FormBuilder,
private repService: ReplicationService, private repService: ReplicationService,
@ -139,11 +114,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
} }
ngOnInit(): void { ngOnInit(): void {
if (this.withAdmiral) {
this.filterSelect = ["type", "repository", "tag"];
}
this.endpointService.getEndpoints().subscribe(endPoints => { this.endpointService.getEndpoints().subscribe(endPoints => {
this.targetList = endPoints || []; this.targetList = endPoints || [];
this.sourceList = endPoints || []; this.sourceList = endPoints || [];
@ -191,37 +161,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
this.noSelectedEndpoint = false; this.noSelectedEndpoint = false;
} }
this.proNameChecker
.pipe(debounceTime(500))
.pipe(distinctUntilChanged())
.subscribe((resp: string) => {
let name = this.ruleForm.controls["projects"].value[0].name;
this.noProjectInfo = "";
this.selectedProjectList = [];
this.proService.listProjects(name, undefined)
.subscribe((res: any) => {
if (res) {
this.selectedProjectList = res.slice(0, 10);
// if input value exit in project list
let pro = res.find((data: any) => data.name === name);
if (!pro) {
this.noProjectInfo = "REPLICATION.NO_PROJECT_INFO";
this.noSelectedProject = true;
} else {
this.noProjectInfo = "";
this.noSelectedProject = false;
this.setProject([pro]);
}
} else {
this.noProjectInfo = "REPLICATION.NO_PROJECT_INFO";
this.noSelectedProject = true;
}
}, (error: any) => {
this.errorHandler.error(error);
this.noProjectInfo = "REPLICATION.NO_PROJECT_INFO";
this.noSelectedProject = true;
});
});
} }
ngOnDestroy(): void { ngOnDestroy(): void {
@ -231,9 +170,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
if (this.nameChecker) { if (this.nameChecker) {
this.nameChecker.unsubscribe(); this.nameChecker.unsubscribe();
} }
if (this.proNameChecker) {
this.proNameChecker.unsubscribe();
}
} }
get src_namespaces(): FormArray { return this.ruleForm.get('src_namespaces') as FormArray; } get src_namespaces(): FormArray { return this.ruleForm.get('src_namespaces') as FormArray; }
@ -345,15 +281,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
} }
} }
get projects(): FormArray {
return this.ruleForm.get("projects") as FormArray;
}
setProject(projects: Project[]) {
const projectFGs = projects.map(project => this.fb.group(project));
const projectFormArray = this.fb.array(projectFGs);
this.ruleForm.setControl("projects", projectFormArray);
}
get filters(): FormArray { get filters(): FormArray {
return this.ruleForm.get("filters") as FormArray; return this.ruleForm.get("filters") as FormArray;
} }
@ -363,8 +290,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
this.ruleForm.setControl("filters", filterFormArray); this.ruleForm.setControl("filters", filterFormArray);
} }
initFilter(name: string) { initFilter(name: string) {
return this.fb.group({ return this.fb.group({
kind: name, kind: name,
@ -434,14 +359,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
} }
} }
// Handle the form validation
handleValidation(): void {
let cont = this.ruleForm.controls["projects"];
if (cont && cont.valid) {
this.proNameChecker.next(cont.value[0].name);
}
}
focusClear($event: any): void { focusClear($event: any): void {
if (this.policyId < 0 && this.firstClick === 0) { if (this.policyId < 0 && this.firstClick === 0) {
if ($event && $event.target && $event.target["value"]) { if ($event && $event.target && $event.target["value"]) {
@ -455,25 +372,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
this.selectedProjectList = []; this.selectedProjectList = [];
} }
selectedProjectName(projectName: string) {
this.noSelectedProject = false;
let pro: Project = this.selectedProjectList.find(
data => data.name === projectName
);
this.setProject([pro]);
this.selectedProjectList = [];
this.noProjectInfo = "";
}
selectedProject(project: Project): void {
if (!project) {
this.noSelectedProject = true;
} else {
this.noSelectedProject = false;
this.setProject([project]);
}
}
addNewNamespace(): void { addNewNamespace(): void {
this.src_namespaces.push(new FormControl()); this.src_namespaces.push(new FormControl());
} }