Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Project):added counter or uuid when shortname is already taken an… #6289

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/app/api-connector/applications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,14 @@ export class ApplicationsService {
})
}

checkForTakenShortname(shortname: string): Observable<any> {
checkForTakenShortname(shortname: string,exclude_project_id?:string|number): Observable<any> {

let params:any={ shortname: shortname }
if (exclude_project_id){
params={ shortname: shortname ,exclude_project_id:exclude_project_id}
}
return this.http.get(`${ApiSettings.getApiBaseURL()}project_applications/shortname/`, {
params: { shortname: shortname },
params: params,
withCredentials: true
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ <h5 class="col-md-6 form-control-label">General Information</h5>
</div>
<div *ngIf="shortNameTaken">
<strong>
<font color="red">Please choose another shortname</font>
<font color="red"
>Warning: This shortname is already in use. A unique suffix will be automatically appended upon
submission.</font
>
</strong>
</div>
<input
Expand All @@ -158,26 +161,26 @@ <h5 class="col-md-6 form-control-label">General Information</h5>
#shortname
(keyup)="checkShortname(shortname.value)"
class="form-control"
maxlength="15"
min="5"
[maxlength]="shortNameMaxLength"
(ngModelChange)="setDefaulShortnameLength()"
[(ngModel)]="application.project_application_shortname"
minlength="5"
placeholder="e.g. ThalianaBench"
pattern="[a-zA-Z0-9]+"
[ngClass]="{
'is-invalid':
(form.controls.project_application_shortname?.invalid || shortNameTaken) &&
form.controls.project_application_shortname?.invalid &&
(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 && !shortNameTaken &&
form.controls.project_application_shortname?.valid &&
(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 @@ -1799,7 +1802,6 @@ <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 @@ -33,9 +33,9 @@
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 All @@ -54,6 +54,8 @@
@Input() application: Application
@Input() is_validation: boolean = false
@Input() hash: string
DEFAULT_SHORTNAME_MAX_LENGTH:number=15
shortNameMaxLength:number=15

userinfo: Userinfo
valid_pi_affiliations
Expand Down Expand Up @@ -145,14 +147,19 @@
}
}

setDefaulShortnameLength():void{
this.shortNameMaxLength=this.DEFAULT_SHORTNAME_MAX_LENGTH
}

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

this.applicationsService.checkForTakenShortname(shortname,this.application?.project_application_id).subscribe((result: boolean): void => {
let nameExists: boolean = result['exists'];
this.shortnameChecking = false;
this.shortNameTaken = nameExists;
});

}

checkValidityComment(): boolean {
Expand Down Expand Up @@ -190,6 +197,10 @@
if (this.application && !this.initiated_validation && this.is_validation) {
this.openstack_project = this.application.project_application_openstack_project

if(this.application.project_application_shortname.length > 15){
this.shortNameMaxLength=this.application.project_application_shortname.length
}

this.simple_vm_project = !this.openstack_project
this.application.project_application_pi = new User()

Expand Down Expand Up @@ -259,7 +270,7 @@
this.shortnameChecking = true;
this.nameCheckPipe.next(shortname);
}

}

public checkLongname(longname: string): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ <h4 class="modal-title">Setting of public key of public key</h4>
<button class="btn btn-primary col-md-4" type="reset" (click)="pubKeyResponseModal.hide()">Cancel</button>
</div>
</div>
<!-- /.modal-content -->L
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
Loading