Skip to content
Snippets Groups Projects
Commit 67ca9048 authored by Kawtar Laariche's avatar Kawtar Laariche
Browse files

#19: :sparkles: implement delete model functionality

parent 12561ec4
No related branches found
No related tags found
1 merge request!12Features/user auth manage my models
......@@ -7,6 +7,7 @@ import {
AuthorPublisherModel,
CommentModel,
PublicSolution,
PublicSolutionDetailsModel,
PublicSolutionsRequestPayload,
ThreadModel,
UserDetails,
......@@ -586,4 +587,34 @@ export class PrivateCatalogsService {
}),
);
}
deleteSolution(solution: PublicSolutionDetailsModel, revisionId: string) {
const url =
apiConfig.apiBackendURL +
apiConfig.urlSolutions +
'/' +
solution.solutionId +
'/' +
revisionId;
let body = {
request_body: {
active: false,
created: solution.created,
name: solution.name,
ownerId: solution.ownerId,
solutionId: solution.solutionId,
revisionId,
tookitType: null,
modelType: null,
},
};
return this._httpSharedService.put(url, undefined, body).pipe(
tap(),
catchError((error) => {
throw error;
}),
);
}
}
<div class="workflow-right-header workflow-header">Delete Model</div>
<div style="display: flex; flex-direction: column; padding: 20px; gap: 20px">
<p>
Are you sure that you want to delete this model and all of its revisions,
public or private?
</p>
<div>
<button
style="width: 20%"
color="primary"
mat-raised-button
(click)="onDeleteModelClick()"
>
Delete Model
</button>
</div>
</div>
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { DeleteUserDialogConfirmationActionComponent } from '../delete-user-dialog-confirmation-action/delete-user-dialog-confirmation-action.component';
import { PublicSolutionDetailsModel } from '../../models';
import { ActivatedRoute, Router } from '@angular/router';
import { PublicSolutionsService } from 'src/app/core/services/public-solutions.service';
import { PrivateCatalogsService } from 'src/app/core/services/private-catalogs.service';
import { Observable } from 'rxjs';
@Component({
selector: 'gp-delete-model-page',
standalone: true,
imports: [CommonModule],
imports: [CommonModule, MatButtonModule],
templateUrl: './delete-model-page.component.html',
styleUrl: './delete-model-page.component.scss'
styleUrl: './delete-model-page.component.scss',
})
export class DeleteModelPageComponent {
export class DeleteModelPageComponent implements OnInit {
solution!: PublicSolutionDetailsModel;
solutionId!: string;
revisionId!: string;
model!: any;
constructor(
public dialog: MatDialog,
private activatedRoute: ActivatedRoute,
private publicSolutionsService: PublicSolutionsService,
private privateCatalogsService: PrivateCatalogsService,
private router: Router,
) {}
ngOnInit(): void {
this.activatedRoute.parent?.params.subscribe((params) => {
this.solutionId = params['solutionId'];
this.revisionId = params['revisionId'];
this.loadSolutionDetails(this.solutionId, this.revisionId);
});
}
deleteModel(): Observable<any> {
return this.privateCatalogsService.deleteSolution(
this.solution,
this.revisionId,
);
}
onDeleteModelClick() {
const dialogRef: MatDialogRef<DeleteUserDialogConfirmationActionComponent> =
this.dialog.open(DeleteUserDialogConfirmationActionComponent, {
data: {
dataKey: {
title: `Delete model ${this.solution.name}`,
content: `Are you sure that you want to delete this model and all of its revisions, public or private?' ${this.solution.name}`,
alertMessage: 'Model deleted successfully. ',
action: () => this.deleteModel(),
},
},
autoFocus: false,
});
dialogRef.afterClosed().subscribe((result) => {
this.router.navigate(['/dashboard/myModels']);
});
}
loadSolutionDetails(solutionId: string, revisionId: string) {
this.publicSolutionsService
.getSolutionDetails(solutionId, revisionId)
.subscribe((res) => {
this.solution = res;
console.log('solution', this.solution);
});
}
}
......@@ -16,7 +16,7 @@ import {
} from '@angular/material/autocomplete';
import { Observable, Subscription, map, startWith } from 'rxjs';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatChipInputEvent, MatChipsModule } from '@angular/material/chips';
import { MatChipsModule } from '@angular/material/chips';
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { PrivateCatalogsService } from 'src/app/core/services/private-catalogs.service';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment