Skip to content

Action Delete Image  #182

@MahmoudCalipso

Description

@MahmoudCalipso

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.





`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions