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

#24: add update image , add , delete tag functionalities

parent 1b1c2cd9
No related branches found
No related tags found
No related merge requests found
...@@ -716,7 +716,7 @@ export class PrivateCatalogsService { ...@@ -716,7 +716,7 @@ export class PrivateCatalogsService {
); );
} }
deleteTag(tag: Tag, solutionId: string) { deleteTag(tag: string, solutionId: string) {
const url = const url =
apiConfig.apiBackendURL + apiConfig.apiBackendURL +
apiConfig.urlDeleteTag + apiConfig.urlDeleteTag +
...@@ -732,7 +732,7 @@ export class PrivateCatalogsService { ...@@ -732,7 +732,7 @@ export class PrivateCatalogsService {
); );
} }
updateAddTag(tag: Tag, solutionId: string) { addTag(tag: string, solutionId: string) {
const url = const url =
apiConfig.apiBackendURL + apiConfig.apiBackendURL +
apiConfig.urlAddTag + apiConfig.urlAddTag +
...@@ -774,10 +774,11 @@ export class PrivateCatalogsService { ...@@ -774,10 +774,11 @@ export class PrivateCatalogsService {
'/picture'; '/picture';
const formData = new FormData(); const formData = new FormData();
formData.append('file', image); formData.append('file', image);
return this._httpSharedService.post(url, undefined, formData).pipe(
const req = new HttpRequest('POST', url, formData); catchError((error) => {
throw error;
return this.http.request(req); }),
);
} }
updateSolutionFiles( updateSolutionFiles(
......
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
<mat-label>Add tag</mat-label> <mat-label>Add tag</mat-label>
<mat-chip-grid #chipGrid> <mat-chip-grid #chipGrid>
@for (tag of tagsItems(); track tag) { @for (tag of tagsItems(); track tag) {
<mat-chip-row (removed)="remove(tag)"> <mat-chip-row (removed)="removeTag(tag)">
{{ tag.tag }} {{ tag.tag }}
<button matChipRemove [attr.aria-label]="'remove ' + tag"> <button matChipRemove [attr.aria-label]="'remove ' + tag">
<mat-icon>cancel</mat-icon> <mat-icon>cancel</mat-icon>
......
...@@ -411,6 +411,12 @@ export class PublishToMarketplacePageComponent implements OnInit { ...@@ -411,6 +411,12 @@ export class PublishToMarketplacePageComponent implements OnInit {
const extensionFile = this.getFilenameExtension(this.licenseProfile.name); const extensionFile = this.getFilenameExtension(this.licenseProfile.name);
} }
} }
onClickUpdateImageSolution(file: File) {
return this.privateCatalogsService.setSolutionPicture(
this.solutionId,
file,
);
}
onClickUploadImageFile() { onClickUploadImageFile() {
const dialogRef: MatDialogRef<UploadLicenseProfileComponent> = const dialogRef: MatDialogRef<UploadLicenseProfileComponent> =
...@@ -420,14 +426,26 @@ export class PublishToMarketplacePageComponent implements OnInit { ...@@ -420,14 +426,26 @@ export class PublishToMarketplacePageComponent implements OnInit {
title: 'Upload image model', title: 'Upload image model',
isEditMode: false, isEditMode: false,
isCheckExtension: false, isCheckExtension: false,
action: (file: File) => {}, action: (file: File) => this.onClickUpdateImageSolution(file),
isLicenseProfile: false, isLicenseProfile: false,
isProcessEvent: false, isProcessEvent: false,
}, },
}, },
}); });
dialogRef.afterClosed().subscribe((result) => {}); dialogRef.afterClosed().subscribe((result) => {
this.updateSolutionImage();
});
}
updateSolutionImage() {
this.publicSolutionsService
.getPictureOfSolution(this.solutionId)
.subscribe({
next: (res) => {
this.createImageFromBlob(res);
},
error: (error) => {},
});
} }
onClickUpdateSolutionDocument(file: File) { onClickUpdateSolutionDocument(file: File) {
...@@ -478,19 +496,42 @@ export class PublishToMarketplacePageComponent implements OnInit { ...@@ -478,19 +496,42 @@ export class PublishToMarketplacePageComponent implements OnInit {
this.addEditLicenseProfile = true; this.addEditLicenseProfile = true;
} }
remove(tag: Tag) { removeTag(tag: Tag) {
this.tagsItems.update((tags: Tag[]) => { this.privateCatalogsService.deleteTag(tag.tag, this.solutionId).subscribe({
const index = tags.indexOf(tag); next: (res) => {
if (index < 0) { const alert: Alert = {
return tags; message: 'Tag deleted successfully',
} type: AlertType.Success,
};
tags.splice(index, 1); this.alertService.notify(alert, 5000);
this.announcer.announce(`Removed ${tag}`); this.alertService.notify;
return [...tags]; this.updateTags();
},
error: () => {},
}); });
} }
updateTags() {
this.publicSolutionsService
.getSolutionDetails(this.solutionId, this.revisionId)
.subscribe({
next: (res) => {
const alert: Alert = {
message: 'Tag deleted successfully',
type: AlertType.Success,
};
this.alertService.notify(alert, 5000);
this.alertService.notify;
const tagsList = res?.solutionTagList;
this.tagsItems.update((tags: Tag[]) => [...tagsList]);
this.publishToMarketPlaceForm.patchValue({
tags: res?.solutionTagList,
});
},
error: () => {},
});
}
removeDocument(document: DocumentModel) { removeDocument(document: DocumentModel) {
this.privateCatalogsService this.privateCatalogsService
.deleteSolutionsFiles( .deleteSolutionsFiles(
...@@ -516,12 +557,24 @@ export class PublishToMarketplacePageComponent implements OnInit { ...@@ -516,12 +557,24 @@ export class PublishToMarketplacePageComponent implements OnInit {
addTag(event: MatChipInputEvent): void { addTag(event: MatChipInputEvent): void {
const value = { tag: (event.value || '').trim() }; const value = { tag: (event.value || '').trim() };
// Add our keyword
if (value) { if (value) {
this.tagsItems.update((tags: Tag[]) => [...tags, value]); this.privateCatalogsService
this.filteredTags.next( .addTag(event.value, this.solutionId)
this.updateAllTagsSignal(event.value, this.allTags()), .subscribe({
); next: (res) => {
const alert: Alert = {
message: 'Tag added successfully',
type: AlertType.Success,
};
this.alertService.notify(alert, 5000);
this.alertService.notify;
this.updateTags();
this.filteredTags.next(
this.updateAllTagsSignal(event.value, this.allTags()),
);
},
error: () => {},
});
} }
// Clear the input value // Clear the input value
...@@ -602,7 +655,7 @@ export class PublishToMarketplacePageComponent implements OnInit { ...@@ -602,7 +655,7 @@ export class PublishToMarketplacePageComponent implements OnInit {
data.solution.solutionTagList.length >= 1 data.solution.solutionTagList.length >= 1
) { ) {
const tagsList = data.solution?.solutionTagList; const tagsList = data.solution?.solutionTagList;
this.tagsItems.update((tags: Tag[]) => [...tags, ...tagsList]); this.tagsItems.update((tags: Tag[]) => [...tagsList]);
this.publishToMarketPlaceForm.patchValue({ this.publishToMarketPlaceForm.patchValue({
tags: data.solution?.solutionTagList, tags: data.solution?.solutionTagList,
}); });
...@@ -665,14 +718,25 @@ export class PublishToMarketplacePageComponent implements OnInit { ...@@ -665,14 +718,25 @@ export class PublishToMarketplacePageComponent implements OnInit {
} }
selected(event: MatAutocompleteSelectedEvent): void { selected(event: MatAutocompleteSelectedEvent): void {
this.tagsItems.update((tags: Tag[]) => [ this.privateCatalogsService
...tags, .addTag(event.option.value, this.solutionId)
{ tag: event.option.value }, .subscribe({
]); next: (res) => {
event.option.deselect(); const alert: Alert = {
this.tagCtrl.setValue(null); message: 'Tag added successfully',
this.filteredTags.next( type: AlertType.Success,
this.updateAllTagsSignal(event.option.value, this.allTags()), };
); this.alertService.notify(alert, 5000);
this.alertService.notify;
this.updateTags();
event.option.deselect();
this.tagCtrl.setValue(null);
this.tagInput.nativeElement.value = '';
this.filteredTags.next(
this.updateAllTagsSignal(event.option.value, this.allTags()),
);
},
error: () => {},
});
} }
} }
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