Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
</div>

<!-- Form Create Project -->
<div *ngIf="submitErrorMessage" class="form-group mb-2">
<div class="alert alert-danger mb-0" role="alert">{{ submitErrorMessage }}</div>
</div>

<div class="form-group mb-0">
<button id="success-btn" type="submit" class="btn btn-success btn-block" value="Submit" [disabled]="projectForm.invalid">
<div *ngIf="!isLoading">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class ProjectFormCreateComponent implements OnInit {
currentUser$ : Observable<User>
currentUser : User
isLoading : boolean
submitErrorMessage: string

@Output() setProject = new EventEmitter<Project>()

Expand All @@ -37,6 +38,7 @@ export class ProjectFormCreateComponent implements OnInit {
this.router.navigate(['/login'], {queryParams: {returnUrl : this.router.url}})

this.isLoading = false;
this.submitErrorMessage = '';

await this.accountService.currentUser.then((x) => this.currentUser$ = x)
this.currentUser$.subscribe(x => this.currentUser = x)
Expand Down Expand Up @@ -80,11 +82,16 @@ export class ProjectFormCreateComponent implements OnInit {

onSubmit() {
let projectForm = this.projectForm.value;
this.submitErrorMessage = '';
this.isLoading = true;

this.projectService.createProject(this.currentUser, projectForm.name, projectForm.visibility, projectForm.description).subscribe(
result =>{
this.isLoading = false;
this.setProject.emit(result)
},error =>{
this.isLoading = false;
this.submitErrorMessage = error?.error?.message || 'Failed to create project.';
console.log(error)
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/Analysim.Web/Controllers/ProjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ public async Task<IActionResult> CreateProject([FromForm] ProjectVM formdata)
// Check if the project already exists
bool projectExists = await _dbContext.Projects
.AnyAsync(p => p.ProjectUsers.Any(aup =>
aup.User.Id == formdata.UserID &&
aup.UserID == userId &&
aup.Project.Name == formdata.Name &&
aup.UserRole == "owner"));

Expand Down
Loading