Skip to content

Commit

Permalink
working on name checkign
Browse files Browse the repository at this point in the history
  • Loading branch information
vktrrdk committed Dec 10, 2024
1 parent 018df4f commit ec18c6a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/api-connector/applications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,12 @@ export class ApplicationsService {
withCredentials: true
})
}

checkForTakenShortname(shortname: string): Observable<any> {
return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/shortname/`, {
params: { shortname: shortname },
withCredentials: true
});

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import { UserService } from '../../api-connector/user.service'
import { Userinfo } from '../../userinfo/userinfo.model'
import { User } from '../application.model/user.model'
import { NotificationModalComponent } from '../../shared/modal/notification-modal'
import { Subject, Subscription } from 'rxjs';

Check failure on line 36 in src/app/applications/application-formular/application-formular.component.ts

View workflow job for this annotation

GitHub Actions / tslinting-check

'Subscription' is defined but never used

Check failure on line 36 in src/app/applications/application-formular/application-formular.component.ts

View workflow job for this annotation

GitHub Actions / tslinting-check

'Subscription' is defined but never used
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import { thresholdScott } from 'd3'

Check failure on line 38 in src/app/applications/application-formular/application-formular.component.ts

View workflow job for this annotation

GitHub Actions / tslinting-check

'thresholdScott' is defined but never used

Check failure on line 38 in src/app/applications/application-formular/application-formular.component.ts

View workflow job for this annotation

GitHub Actions / tslinting-check

'thresholdScott' is defined but never used

/**
* Application formular component.
Expand Down Expand Up @@ -87,6 +90,8 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent
WIKI_BACKUP_LINK: string = WIKI_BACKUP_LINK
GDPR_LINK: string = GDPR_LINK
survey_link_visible: boolean = false
private nameCheckPipe = new Subject<string>();
shortnameChecking: boolean = false;

MAX_LIFETIME_DEFAULT: number = 6
max_lifetime: number = this.MAX_LIFETIME_DEFAULT
Expand Down Expand Up @@ -119,6 +124,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)});

if (this.openstack_project) {
this.simple_vm_min_vm = true
Expand All @@ -138,6 +144,14 @@ export class ApplicationFormularComponent extends ApplicationBaseClassComponent
}
}

checkIfNameIsTaken(shortname: string): void {
this.shortnameChecking = true;
this.applicationsService.checkForTakenShortname(shortname).subscribe((result: boolean): void => {
console.log(result);
});

}

checkValidityComment(): boolean {
if (this.extraResourceCommentRequired) {
if (this.application.project_application_comment?.length < 50) {
Expand Down Expand Up @@ -238,6 +252,8 @@ 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)
}

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

0 comments on commit ec18c6a

Please sign in to comment.