diff --git a/src/ui_ng/src/app/project/create-project/create-project.component.html b/src/ui_ng/src/app/project/create-project/create-project.component.html index 7ebb4cc55..dfd036b2c 100644 --- a/src/ui_ng/src/app/project/create-project/create-project.component.html +++ b/src/ui_ng/src/app/project/create-project/create-project.component.html @@ -1,12 +1,12 @@ - - - + + \ No newline at end of file diff --git a/src/ui_ng/src/app/project/create-project/create-project.component.ts b/src/ui_ng/src/app/project/create-project/create-project.component.ts index 1643e83d4..053a74277 100644 --- a/src/ui_ng/src/app/project/create-project/create-project.component.ts +++ b/src/ui_ng/src/app/project/create-project/create-project.component.ts @@ -26,10 +26,10 @@ import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'create-project', templateUrl: 'create-project.component.html', - styleUrls: [ 'create-project.css' ] + styleUrls: ['create-project.css'] }) export class CreateProjectComponent implements AfterViewChecked { - + projectForm: NgForm; @ViewChild('projectForm') @@ -39,7 +39,7 @@ export class CreateProjectComponent implements AfterViewChecked { initVal: Project = new Project(); createProjectOpened: boolean; - + hasChanged: boolean; staticBackdrop: boolean = true; @@ -49,60 +49,64 @@ export class CreateProjectComponent implements AfterViewChecked { @ViewChild(InlineAlertComponent) inlineAlert: InlineAlertComponent; - constructor(private projectService: ProjectService, - private translateService: TranslateService, - private messageHandlerService: MessageHandlerService) {} + constructor(private projectService: ProjectService, + private translateService: TranslateService, + private messageHandlerService: MessageHandlerService) { } + + public get accessLevelDisplayText(): string { + return this.project.public ? 'PROJECT.PUBLIC' : 'PROJECT.PRIVATE'; + } onSubmit() { this.projectService - .createProject(this.project.name, this.project.public ? 1 : 0) - .subscribe( - status=>{ - this.create.emit(true); - this.messageHandlerService.showSuccess('PROJECT.CREATED_SUCCESS'); + .createProject(this.project.name, this.project.public ? 1 : 0) + .subscribe( + status => { + this.create.emit(true); + this.messageHandlerService.showSuccess('PROJECT.CREATED_SUCCESS'); + this.createProjectOpened = false; + }, + error => { + let errorMessage: string; + if (error instanceof Response) { + switch (error.status) { + case 409: + this.translateService.get('PROJECT.NAME_ALREADY_EXISTS').subscribe(res => errorMessage = res); + break; + case 400: + this.translateService.get('PROJECT.NAME_IS_ILLEGAL').subscribe(res => errorMessage = res); + break; + default: + this.translateService.get('PROJECT.UNKNOWN_ERROR').subscribe(res => errorMessage = res); + } + if (this.messageHandlerService.isAppLevel(error)) { + this.messageHandlerService.handleError(error); this.createProjectOpened = false; - }, - error=>{ - let errorMessage: string; - if (error instanceof Response) { - switch(error.status) { - case 409: - this.translateService.get('PROJECT.NAME_ALREADY_EXISTS').subscribe(res=>errorMessage = res); - break; - case 400: - this.translateService.get('PROJECT.NAME_IS_ILLEGAL').subscribe(res=>errorMessage = res); - break; - default: - this.translateService.get('PROJECT.UNKNOWN_ERROR').subscribe(res=>errorMessage = res); - } - if(this.messageHandlerService.isAppLevel(error)) { - this.messageHandlerService.handleError(error); - this.createProjectOpened = false; - } else { - this.inlineAlert.showInlineError(errorMessage); - } - } - }); + } else { + this.inlineAlert.showInlineError(errorMessage); + } + } + }); } onCancel() { - if(this.hasChanged) { - this.inlineAlert.showInlineConfirmation({message: 'ALERT.FORM_CHANGE_CONFIRMATION'}); + if (this.hasChanged) { + this.inlineAlert.showInlineConfirmation({ message: 'ALERT.FORM_CHANGE_CONFIRMATION' }); } else { this.createProjectOpened = false; this.projectForm.reset(); } - + } ngAfterViewChecked(): void { this.projectForm = this.currentForm; - if(this.projectForm) { - this.projectForm.valueChanges.subscribe(data=>{ - for(let i in data) { - let origin = this.initVal[i]; + if (this.projectForm) { + this.projectForm.valueChanges.subscribe(data => { + for (let i in data) { + let origin = this.initVal[i]; let current = data[i]; - if(current && current !== origin) { + if (current && current !== origin) { this.hasChanged = true; break; } else { diff --git a/src/ui_ng/src/app/project/create-project/create-project.css b/src/ui_ng/src/app/project/create-project/create-project.css index 0bcac82e9..9a9500f19 100644 --- a/src/ui_ng/src/app/project/create-project/create-project.css +++ b/src/ui_ng/src/app/project/create-project/create-project.css @@ -1,4 +1,13 @@ .form-group-label-override { font-size: 14px; font-weight: 400; +} + +.access-level-label { + font-size: 14px; + font-weight: 400; + margin-left: -4px; + margin-right: 12px; + top: -6px; + position: relative; } \ No newline at end of file diff --git a/src/ui_ng/src/i18n/lang/en-us-lang.json b/src/ui_ng/src/i18n/lang/en-us-lang.json index 07d76b2f5..2b720049c 100644 --- a/src/ui_ng/src/i18n/lang/en-us-lang.json +++ b/src/ui_ng/src/i18n/lang/en-us-lang.json @@ -126,6 +126,7 @@ "PUBLIC_OR_PRIVATE": "Access Level", "REPO_COUNT": "Repositories Count", "CREATION_TIME": "Creation Time", + "ACCESS_LEVEL": "Access Level", "PUBLIC": "Public", "PRIVATE": "Private", "MAKE": "Make", diff --git a/src/ui_ng/src/i18n/lang/zh-cn-lang.json b/src/ui_ng/src/i18n/lang/zh-cn-lang.json index c25a4fe7c..658d0cca8 100644 --- a/src/ui_ng/src/i18n/lang/zh-cn-lang.json +++ b/src/ui_ng/src/i18n/lang/zh-cn-lang.json @@ -126,6 +126,7 @@ "PUBLIC_OR_PRIVATE": "访问级别", "REPO_COUNT": "镜像仓库数", "CREATION_TIME": "创建时间", + "ACCESS_LEVEL": "访问级别", "PUBLIC": "公开", "PRIVATE": "私有", "MAKE": "设为",