1.0.14 • Published 2 years ago

rt-upload-file v1.0.14

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

RT upload file

Module for uploading files to the server, error handling, download process

Api

NameTypeDefault
disabledbooleanfalse
progressnumber0
errorServerFileUploadErrornull
formatsFormatsFile
isUploadedbooleanfalse
(outFile)File
(removeFile)nullnull

exemple

exemple.component.html

      <rt-upload-file
        [disabled]="false"
        [progress]="proccessUploading"
        [errorServer]="errorUploading"
        [formats]="formatsFile"
        [isUploaded]="isUploaded"
        (outFile)="onFile($event)">
      </rt-upload-file>

exemple.component.ts

import {Component, OnInit, ChangeDetectionStrategy, ChangeDetectorRef} from '@angular/core';

@Component({
  selector: 'app-example-component',
  templateUrl: './example.component.html',
  styleUrls: ['./example.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})

export class ExampleComponent implements OnInit {
  /** Procentage uploading file from server */
  proccessUploading = 0;
  /** Error uploading from server */
  errorUploading: FileUploadError = null;
  /** Formats for uploading file */
  formatsFile: FormatsFile[] = [FormatsFile.pdf, FormatsFile.docx];
  /** State uploaded file */
  isUploaded = false;

  constructor(cd: ChangeDetectorRef) {
  }

  onFile(file: File) {


    if (this.proccessUploading === 100) {
      // this.errorUploading = {message: 'An error occurred on the server.'};
      // this.proccessUploading = 0;

      setTimeout(() => {
        this.isUploaded = true;
        // const formData = new FormData();
        // formData.append('logo', file, 'relativePath');
        // console.log(formData.get('logo'));
        this.cd.detectChanges();
      }, 500);
      this.cd.detectChanges();
    } else {
      this.proccessUploading++;
      this.cd.detectChanges();
    }


  }
// const interval = setInterval(() => {
//   if (this.proccessUploading === 100) {
//     // this.errorUploading = {message: 'An error occurred on the server.'};
//     // this.proccessUploading = 0;
//     clearInterval(interval);
//
//     setTimeout(() => {
//       this.isUploaded = true;
//       // const formData = new FormData();
//       // formData.append('logo', file, 'relativePath');
//       // console.log(formData.get('logo'));
//       this.cd.detectChanges();
//     }, 500);
//     this.cd.detectChanges();
//   } else {
//     this.proccessUploading++;
//     this.cd.detectChanges();
//   }
// }, 20);
1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

0.0.1

2 years ago

1.0.0

2 years ago