Skip to content

Commit

Permalink
fix(Projects): Shortname checking
Browse files Browse the repository at this point in the history
  • Loading branch information
vktrrdk committed Dec 10, 2024
1 parent ec18c6a commit 77a1e98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ <h5 class="col-md-6 form-control-label">General Information</h5>
<font color="red">Umlauts and special characters are prohibited in the shortname.</font>
</strong>
</div>
<div *ngIf="shortNameTaken">
<strong>
<font color="red">Please choose another shortname</font>
</strong>
</div>
<input
required
type="text"
Expand All @@ -160,17 +165,19 @@ <h5 class="col-md-6 form-control-label">General Information</h5>
pattern="[a-zA-Z0-9]+"
[ngClass]="{
'is-invalid':
form.controls.project_application_shortname?.invalid &&
(form.controls.project_application_shortname?.invalid || shortNameTaken) &&
(form.controls.project_application_shortname?.dirty ||
form.controls.project_application_shortname?.touched),
form.controls.project_application_shortname?.touched)
,
'is-valid':
form.controls.project_application_shortname?.valid &&
form.controls.project_application_shortname?.valid && !shortNameTaken &&
(form.controls.project_application_shortname?.dirty ||
form.controls.project_application_shortname?.touched),
}"
/>

<span class="help-block">Enter a short name (between 5 and 15 characters).</span>

</div>
</div>

Expand Down Expand Up @@ -1792,6 +1799,7 @@ <h6><strong>Platforms</strong></h6>
data-test-id="submit_application_btn"
[disabled]="
submitting ||
shortNameTaken ||
form.invalid ||
(!unknownPiAffiliationsConfirmation &&
!valid_pi_affiliations &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent
survey_link_visible: boolean = false
private nameCheckPipe = new Subject<string>();
shortnameChecking: boolean = false;
shortNameTaken: boolean = false;

MAX_LIFETIME_DEFAULT: number = 6
max_lifetime: number = this.MAX_LIFETIME_DEFAULT
Expand Down Expand Up @@ -124,7 +125,7 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent
this.getListOfFlavors()
this.getListOfTypes()
this.is_vo_admin = is_vo
this.nameCheckPipe.pipe(debounceTime(300), distinctUntilChanged()).subscribe(value => {this.checkIfNameIsTaken(value)});
this.nameCheckPipe.pipe(debounceTime(600), distinctUntilChanged()).subscribe(value => {this.checkIfNameIsTaken(value)});

if (this.openstack_project) {
this.simple_vm_min_vm = true
Expand All @@ -147,7 +148,9 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent
checkIfNameIsTaken(shortname: string): void {
this.shortnameChecking = true;
this.applicationsService.checkForTakenShortname(shortname).subscribe((result: boolean): void => {
console.log(result);
let nameExists: boolean = result['exists'];
this.shortnameChecking = false;
this.shortNameTaken = nameExists;
});

}
Expand Down Expand Up @@ -252,8 +255,11 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent
*/
public checkShortname(shortname: string): void {
this.invalid_shortname = !/^[a-zA-Z0-9\s]*$/.test(shortname)
this.shortnameChecking = true;
this.nameCheckPipe.next(shortname)
if (!this.invalid_shortname) {
this.shortnameChecking = true;
this.nameCheckPipe.next(shortname);
}

}

public checkLongname(longname: string): void {
Expand Down

0 comments on commit 77a1e98

Please sign in to comment.