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

Action Delete Image #182

Open
MahmoudCalipso opened this issue Feb 23, 2024 · 0 comments
Open

Action Delete Image #182

MahmoudCalipso opened this issue Feb 23, 2024 · 0 comments

Comments

@MahmoudCalipso
Copy link

MahmoudCalipso commented Feb 23, 2024

image
**i get issue about the button check and remove :when i need to remove the file the button doesn't work **
ngx-dropzone-wrapper 10.0.1 & Angular 9.0.2
`export class DocumentListComponent extends BaseFormComponent implements OnInit {
@ViewChild(DatatableComponent, { static: false })
table: DatatableComponent;
@ViewChild('dz', { static: false}) drpzone: DropzoneComponent;
@ViewChild(DropzoneDirective, { static: false }) directiveRef?: DropzoneDirective;
singleConfig: DropzoneConfigInterface = {
...defaultConfig,
...{
maxFiles: 1,
cancelReset: 1,
errorReset: 1
}
}; ..... onUploadInit(args: any): void {
}

onUploadError(args: any): void {
this.toastrService.error(
'Error.',
'The file is too large ( Max Size 10 MB )',
{
progressBar: true
}
);

const previewElement = args.previewElement;
if (previewElement) {
  // Remove the preview element from the DOM
  previewElement.parentNode.removeChild(previewElement);
}

this.uploaded = false;

}

onRemove(args: any) {
console.log(args);
if (this.drpzone && this.drpzone.directiveRef) {
this.file = null;
this.drpzone.directiveRef.reset(true);
}
}

onUploadSuccess(args: any): void {
this.file = args[0];
this.pdfurl = args[1].documentUrl;
this.uploaded = false;
this.toastrService.success('Success.', 'Successfully uploaded PDF', {
progressBar: true
});
}

onSending(args: any): void {
const file = args[0];
this.uploaded = true
}
**and this DocumentsModule** const DEFAULT_DROPZONE_CONFIG: DropzoneConfigInterface = {
url: ${environment.serverUrl}/mediamgt/api/Media/UploadDocument/FormFile,
maxFilesize: 10,
acceptedFiles: 'application/pdf'
};

@NgModule({
declarations: [DocumentDetailsComponent, DocumentListComponent],
imports: [
CommonModule,
ModalModule.forRoot(),
OnlynumberDirectiveModule,
FormControlsModule,
SharedModule,
CardsModule,
UtilsModule,
NgxDatatableModule,
IconsModule,
NgSelectModule,
ProgressModule,
TrainerRoutingModule,
DropzoneModule
],
providers: [
DocumentService,
UploadImageService,
HttpClient,
{
provide: HTTP_INTERCEPTORS,
useClass: AuthHttpInterceptor,
multi: true
},
{
provide: DROPZONE_CONFIG,
useValue: DEFAULT_DROPZONE_CONFIG
}
],
exports: [DocumentListComponent, DocumentDetailsComponent]
})
export class DocumentsModule {} **the html code :**



<div
[dropzone]="singleConfig"
#dz
message="Click or drag images here to upload"
(init)="onUploadInit($event)"
(error)="onUploadError($event)"
(success)="onUploadSuccess($event)"
(sending)="onSending($event)"
(removedFile)="onRemove($event)"
>



Drop files here or Click to upload.





`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant