fix frontend issues

Signed-off-by: Meina Zhou <meinaz@vmware.com>
This commit is contained in:
Meina Zhou 2019-04-04 14:40:22 +08:00
parent dc35be09c4
commit 0028dc0d62
11 changed files with 54 additions and 33 deletions

View File

@ -33,7 +33,7 @@
<label class="form-group-label-override required">{{'REPLICATION.SOURCE_REGISTRY' | translate}}</label>
<div class="form-select">
<div class="select endpointSelect pull-left">
<select id="src_registry_id" (change)="sourceChange($event)" formControlName="src_registry">
<select id="src_registry_id" (change)="sourceChange($event)" formControlName="src_registry" [compareWith]="equals" ngModel>
<option *ngFor="let source of sourceList" [ngValue]="source">{{source.name}}-{{source.url}}</option>
</select>
</div>
@ -59,7 +59,7 @@
</div>
<!--images/Filter-->
<div class="form-group form-group-override">
<label class="form-group-label-override">{{'REPLICATION.SOURCE_IMAGES_FILTER' | translate}}</label>
<label class="form-group-label-override">{{'REPLICATION.SOURCE_RESOURCE_FILTER' | translate}}</label>
<div formArrayName="filters">
<div class="filterSelect" *ngFor="let filter of filters.controls; let i=index">
<div [formGroupName]="i">
@ -88,7 +88,7 @@
<label class="form-group-label-override required">{{'REPLICATION.DEST_REGISTRY' | translate}}</label>
<div class="form-select">
<div class="select endpointSelect pull-left">
<select id="dest_registry_id" (change)="targetChange($event)" formControlName="dest_registry">
<select id="dest_registry" (change)="targetChange($event)" formControlName="dest_registry" [compareWith]="equals" ngModel>
<option *ngFor="let target of targetList" [ngValue]="target">{{target.name}}-{{target.url}}</option>
</select>
</div>
@ -136,6 +136,12 @@
<label for="ruleDeletion" class="clr-control-label">{{'REPLICATION.DELETE_REMOTE_IMAGES' | translate}}</label>
</clr-checkbox-wrapper>
</div>
<div class="clr-form-control rule-width">
<clr-checkbox-wrapper>
<input type="checkbox" clrCheckbox [checked]="true" id="enablePolicy" formControlName="enabled" class="clr-checkbox">
<label for="enablePolicy" class="clr-control-label">{{'REPLICATION.ENABLED' | translate}}</label>
</clr-checkbox-wrapper>
</div>
</div>
<div class="loading-center">
<span class="spinner spinner-inline" [hidden]="inProgress === false"></span>

View File

@ -46,14 +46,15 @@ describe("CreateEditRuleComponent (inline template)", () => {
id: 1,
name: "sync_01",
description: "",
src_registry_id: 2,
src_registry: {id: 2},
src_namespaces: ["name1", "name2"],
trigger: {
kind: "Manual",
schedule_param: {}
},
filters: [],
deletion: false
deletion: false,
enabled: true
}
];
let mockJobs: ReplicationJobItem[] = [
@ -157,13 +158,14 @@ describe("CreateEditRuleComponent (inline template)", () => {
name: "sync_01",
description: "",
src_namespaces: ["namespace1", "namespace2"],
src_registry_id: 10,
src_registry: {id: 10 },
trigger: {
kind: "Manual",
schedule_param: {}
},
filters: [],
deletion: false
deletion: false,
enabled: true
};
let mockRegistryInfo = {
@ -192,9 +194,9 @@ describe("CreateEditRuleComponent (inline template)", () => {
}
],
"supported_triggers": [
"Manual",
"Scheduled",
"EventBased"
"manual",
"scheduled",
"event_based"
]
};

View File

@ -54,7 +54,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
TRIGGER_TYPES = {
MANUAL: "manual",
SCHEDULED: "scheduled",
EVENT_BASED: "eventBased"
EVENT_BASED: "event_based"
};
ruleNameTooltip = "REPLICATION.NAME_TOOLTIP";
@ -132,6 +132,10 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
});
}
equals(c1: any, c2: any): boolean {
return c1 && c2 ? c1.id === c2.id : c1 === c2;
}
modeChange(): void {
if (this.isPushMode) {
this.initRegistryInfo(0);
@ -178,7 +182,8 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
})
}),
filters: this.fb.array([]),
deletion: false
deletion: false,
enabled: true
});
}
@ -204,7 +209,8 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
cron: ""
}
},
deletion: false
deletion: false,
enabled: true
});
this.setFilter([]);
this.initRegistryInfo(0);
@ -217,17 +223,17 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
description: rule.description,
src_namespaces: rule.src_namespaces,
dest_namespace: rule.dest_namespace,
src_registry: rule.src_registry,
dest_registry: rule.dest_registry,
trigger: rule.trigger,
deletion: rule.deletion
deletion: rule.deletion,
enabled: rule.enabled
});
this.noSelectedEndpoint = false;
if (rule.filters) {
this.setFilter(rule.filters);
this.updateFilter(rule.filters);
}
// Force refresh view
let hnd = setInterval(() => this.ref.markForCheck(), 100);
setTimeout(() => clearInterval(hnd), 2000);
@ -307,9 +313,6 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
}
}
updateFilter(filters: any) {
}
public hasFormChange(): boolean {
return !isEmptyObject(this.hasChanges());
}

View File

@ -28,7 +28,8 @@ describe('ListReplicationRuleComponent (inline template)', () => {
"error_job_count": 2,
"deletion": false,
"src_namespaces": ["name1", "name2"],
"src_registry_id": 3
"src_registry": {id: 3},
"enabled": true
},
{
"id": 2,
@ -39,7 +40,8 @@ describe('ListReplicationRuleComponent (inline template)', () => {
"error_job_count": 2,
"deletion": false,
"src_namespaces": ["name1", "name2"],
"dest_registry_id": 3
"dest_registry": {id: 3},
"enabled": true
},
];

View File

@ -37,8 +37,9 @@ describe('Replication Component (inline template)', () => {
"trigger": {"kind": "Manual", "schedule_param": null},
"error_job_count": 2,
"deletion": false,
"src_registry_id": 3,
"src_namespaces": ["name1"]
"src_registry": {id: 3},
"src_namespaces": ["name1"],
"enabled": true
},
{
"id": 2,
@ -48,8 +49,9 @@ describe('Replication Component (inline template)', () => {
"trigger": {"kind": "Manual", "schedule_param": null},
"error_job_count": 2,
"deletion": false,
"dest_registry_id": 5,
"src_namespaces": ["name1"]
"dest_registry": {id: 5},
"src_namespaces": ["name1"],
"enabled": true
}
];

View File

@ -109,10 +109,11 @@ export interface ReplicationRule extends Base {
trigger: Trigger;
filters: Filter[];
deletion?: boolean;
src_registry_id?: number;
dest_registry_id?: number;
src_registry?: any;
dest_registry?: any;
src_namespaces: string [];
dest_namespace?: string;
enabled: boolean;
}
export class Filter {

View File

@ -431,7 +431,7 @@
"JOB_LOG_VIEWER": "View Replication Job Log",
"NO_ENDPOINT_INFO": "Please add an endpoint first",
"NO_PROJECT_INFO": "This project is not exist",
"SOURCE_IMAGES_FILTER": "Source images filter",
"SOURCE_RESOURCE_FILTER": "Source resource filter",
"SCHEDULED": "Scheduled",
"MANUAL": "Manual",
"EVENT_BASED":"Event Based",
@ -445,6 +445,7 @@
"SOURCE_PROJECT": "Source project",
"REPLICATE": "Replicate",
"DELETE_REMOTE_IMAGES": "Delete remote images when locally deleted",
"DELETE_ENABLED": "Enabled this policy",
"REPLICATE_IMMEDIATE": "Replicate existing images immediately",
"NEW": "New",
"NAME_TOOLTIP": "replication rule name should be at least 2 characters long with lower case characters, numbers and ._- and must be start with characters or numbers.",

View File

@ -432,7 +432,7 @@
"JOB_LOG_VIEWER": "View Replication Job Log",
"NO_ENDPOINT_INFO": "Please add an endpoint first",
"NO_PROJECT_INFO": "This project is not exist",
"SOURCE_IMAGES_FILTER": "Source images filter",
"SOURCE_RESOURCE_FILTER": "Source resource filter",
"SCHEDULED": "Scheduled",
"MANUAL": "Manual",
"EVENT_BASED":"Event Based",
@ -446,6 +446,7 @@
"SOURCE_PROJECT": "Source project",
"REPLICATE": "Replicate",
"DELETE_REMOTE_IMAGES": "Delete remote images when locally deleted",
"DELETE_ENABLED": "Enabled this policy",
"REPLICATE_IMMEDIATE": "Replicate existing images immediately",
"NEW": "New",
"NAME_TOOLTIP": "replication rule name should be at least 2 characters long with lower case characters, numbers and ._- and must be start with characters or numbers.",

View File

@ -413,7 +413,7 @@
"JOB_LOG_VIEWER": "Afficher les logs des travaux de réplication",
"NO_ENDPOINT_INFO": "Please add an endpoint first",
"NO_PROJECT_INFO": "This project is not exist",
"SOURCE_IMAGES_FILTER": "Source images filter",
"SOURCE_RESOURCE_FILTER": "Source resource filter",
"SCHEDULED": "Scheduled",
"MANUAL": "Manual",
"EVENT_BASED":"Event Based",
@ -427,6 +427,7 @@
"SOURCE_PROJECT": "Source project",
"REPLICATE": "Replicate",
"DELETE_REMOTE_IMAGES": "Delete remote images when locally deleted",
"DELETE_ENABLED": "Enabled this policy",
"REPLICATE_IMMEDIATE": "Replicate existing images immediately",
"NEW": "New",
"NAME_TOOLTIP": "replication rule name should be at least 2 characters long with lower case characters, numbers and ._- and must be start with characters or numbers.",

View File

@ -431,7 +431,7 @@
"JOB_LOG_VIEWER": "Ver log da tarefa de replicação",
"NO_ENDPOINT_INFO": "Por favor adicione antes um endpoint",
"NO_PROJECT_INFO": "Esse projeto não existe",
"SOURCE_IMAGES_FILTER": "Filtro de imagens de origem",
"SOURCE_RESOURCE_FILTER": "Source resource filter",
"SCHEDULED": "Agendado",
"MANUAL": "Manual",
"EVENT_BASED":"Event Based",
@ -445,6 +445,7 @@
"SOURCE_PROJECT": "Projeto de origem",
"REPLICATE": "Replicar",
"DELETE_REMOTE_IMAGES":"Remover imagens remotas quando removido localmente",
"DELETE_ENABLED": "Enabled this policy",
"REPLICATE_IMMEDIATE":"Replicar imagens existentes imediatamente",
"NEW": "Novo",
"NAME_TOOLTIP": "nome da regra de replicação deve conter ao menos 2 caracteres sendo caracteres minusculos, números e ._- e devem iniciar com letras e números.",

View File

@ -432,7 +432,7 @@
"JOB_LOG_VIEWER": "查看复制任务日志",
"NO_ENDPOINT_INFO": "请先添加一个目标",
"NO_PROJECT_INFO": "此项目不存在",
"SOURCE_IMAGES_FILTER": "源镜像过滤器",
"SOURCE_RESOURCE_FILTER": "源资源过滤器",
"SCHEDULED": "定时",
"MANUAL": "手动",
"EVENT_BASED":"事件驱动",
@ -446,6 +446,7 @@
"SOURCE_PROJECT": "源项目",
"REPLICATE": "复制",
"DELETE_REMOTE_IMAGES": "删除本地镜像时同时也删除远程的镜像。",
"DELETE_ENABLED": "默认启用该规则",
"REPLICATE_IMMEDIATE": "立即复制现有的镜像。",
"NEW": "新增",
"NAME_TOOLTIP": "项目名称由小写字符、数字和._-组成且至少2个字符并以字符或者数字开头。",