import { OnInit, OnChanges, ElementRef, EventEmitter } from '@angular/core'; import { CfCoreComponent } from '../core/core.component'; import { Transfer } from './ng2-file-uploader/source/transfer.core'; import { FileUploaderModel } from '../../models/file-uploader/file-uploader.model'; import { FileUploaderStylingModel } from '../../models/file-uploader/file-uploader-styling.model'; import { ButtonModel } from '../../models/button/button.model'; import { TemplateService } from '../../services/template-service/template.service'; /** *

CF File-uploader component

*

 * import {{'{'}} FileUploaderModel {{'}'}} from 'cedrus-fusion'
 * import {{'{'}} FileUploaderStylingModel {{'}'}} from 'cedrus-fusion'
 * <cf-file-uploader></cf-file-uploader>
 * 
*/ export declare class CfFileUploaderComponent extends CfCoreComponent implements OnInit, OnChanges { elementRef: ElementRef; /** @hidden * It is a trigger for input[type="file"] which is opening browser window for selecting files */ loadWindowTrigger: any; /** *
{{'{'}}
     *  main: {{'{'}}
     *    url: string,                  // Path to server where the files be uploaded. Default: ''.
     *    alias: string,                // File alias. Default: file.
     *    headers: Object,              // An object with header informations. Default: {{'{'}}{{'}'}}.
     *    filters: FileFilter[],        // A list of filters which are extend the default list. Default: [].
     *    formData: Object[],           // A list of data to be sent along with the files. Default: [].
     *    autoUpload: boolean,          // Automatically upload new files when they are adding to the queue. Default: false.
     *    method: string,               // Request methode - HTML5 only. Default: POST.
     *    removeBySuccess: boolean,     // Remove file from queue when upload was successfull. Default: false.
     *    queueLimit: number,           // Limitation of files at the queue (-1 is unlimited). Default: -1.
     *    enableCors: boolean,          // Activate CORS - HTML5 only. Default: false.
     *    withCredentials: boolean,     // If to use credentials. Default: false.
     *    uniqueFiles: boolean,         // To add only unique files to files list. Default: false.
     *  {{'}'}},
     *  showDropZone: boolean,          // Means if component must show dropZone. Default: true.
     *  readFiles: boolean,             // Means if read files content after file was added to the list. Default: false.
     *  filesNames: string[],           // Means part or all text of file name to match. Default: [].
     *  filesTypes: string[],           // Means what file types are resolved to add. Default: [].
     *  filesSizes: string[],           // Means what files by size are resolved to add. Default: [].
     *  filesDates: string[],           // Means what files by date are resolved to add. Default: [].
     *  dropZoneLabel: string,          // Means label for dropZone. Default: Drop files here or click to select: .
     *  showFilesActions: boolean,      // Means if to show actions for all selected files. Default: true.
     *  showFileActions: boolean,       // Means if to show actions for a single file. Default: true.
     *  uploadFileButton: ButtonModel,  // ButtonModel for each file uploa. Default: new ButtonModel({{'{'}} label: "Upload" {{'}'}}).
     *  removeFileButton: ButtonModel,  // ButtonModel for each file remov. Default: new ButtonModel({{'{'}} label: "Remove" {{'}'}}).
     *  uploadFilesButton: ButtonModel, // ButtonModel for upload all file. Default: new ButtonModel({{'{'}} label: "Upload All" {{'}'}}).
     *  removeFilesButton: ButtonModel, // ButtonModel for remove all file. Default: new ButtonModel({{'{'}} label: "Remove All" {{'}'}}).
     * {{'}'}}
*

Example of object:

*
{{'{'}}
     *  main: {{'{'}}
     *    "url": "http://localhost:3001/upload",
     *    "removeBySuccess": true,
     *  {{'}'}},
     *  "readFiles": true,
     *  "filesNames": ['json', 'png'],
     * {{'}'}}
*/ properties: FileUploaderModel; /** *
{{'{'}}
     *  dropZone: StylingModel,                // Styling dropZone html element
     *  files: StylingModel,                   // Styling files html element
     *  file: StylingModel,                    // Styling file html element
     *  fileImage: StylingModel,               // Styling fileImage html element
     *  fileName: StylingModel,                // Styling fileName html element
     *  fileProgress: StylingModel,            // Styling fileProgress html element
     *  fileActions: StylingModel,             // Styling fileActions html element
     *  filesActions: StylingModel,            // Styling filesActions html element
     *  uploadFileButton: ButtonStylingModel,  // Styling uploadFileButton html element
     *  removeFileButton: ButtonStylingModel,  // Styling removeFileButton html element
     *  uploadFilesButton: ButtonStylingModel, // Styling uploadFilesButton html element
     *  removeFilesButton: ButtonStylingModel, // Styling removeFilesButton html element
     * {{'}'}}
*

Example of object:

*
{{'{'}}
     *  myUploaderStyling = new FileUploaderStylingModel({{'{'}}
     *    dropZone: {{'{'}}
     *      class: 'dropzone-styling'
     *    {{'}'}},
     *    uploadButton: new ButtonStylingModel({{'{'}}
     *      button: {{'{'}} class: 'mat-primary mat-raised-button' {{'}'}}
     *    {{'}'}}),
     *    removeButton: new ButtonStylingModel({{'{'}}
     *      button: {{'{'}} class: 'mat-primary mat-raised-button' {{'}'}}
     *    {{'}'}}),
     *    uploadAllButton: new ButtonStylingModel({{'{'}}
     *      button: {{'{'}} class: 'mat-primary mat-raised-button' {{'}'}}
     *    {{'}'}}),
     *    removeAllButton: new ButtonStylingModel({{'{'}}
     *      button: {{'{'}} class: 'mat-primary mat-raised-button' {{'}'}}
     *    {{'}'}})
     *  {{'}'}});
     * {{'}'}}
*/ styling: FileUploaderStylingModel; /** * Object with Transfer type properties for uploader engine */ main: Transfer; /** * Means if read files content after file was added to the list */ readFiles: boolean; /** * Means part or all text of file name to match */ filesNames: string[]; /** * Means what file types are resolved to add */ filesTypes: string[]; /** * Means what files by size are resolved to add */ filesSizes: string[]; /** * Means what files by date are resolved to add */ filesDates: string[]; /** * Means if component must show dropZone. */ showDropZone: boolean; /** * Means label for dropZone. */ dropZoneLabel: string; /** * Means if to show actions for all selected files. */ showFilesActions: boolean; /** * Means if to show actions for a single file. */ showFileActions: boolean; /** * ButtonModel for each file upload */ uploadFileButton: ButtonModel; /** * ButtonModel for each file remove */ removeFileButton: ButtonModel; /** * ButtonModel for upload all files */ uploadFilesButton: ButtonModel; /** * ButtonModel for remove all files */ removeFilesButton: ButtonModel; /** * Event emited when file was added to list. Event contain added file */ onAddFile: EventEmitter; /** * Event emited when all files was added to list. Event contain whole component */ onAddFiles: EventEmitter; /** * Event emited on error adding file to list. Event contain error file */ onAddFileError: EventEmitter; /** * Event emited when file was uploaded. Event contain uploaded file */ onComplete: EventEmitter; /** * Event emited when all files was uploaded. Event contain whole component */ onCompleteAll: EventEmitter; /** @hidden*/ _reader: any; /**@hidden*/ acceptedFiles: string; /**@hidden*/ constructor(elementRef: ElementRef, /**@hidden */ templateService: TemplateService); /** @hidden * On init it is generating FileUploaderModel and based on it - * generating FileUploader model for external library. * Also are registered event emiters for external library events. And generated styling object. */ ngOnInit(): void; /** @hidden * Update the properties object with the changes on the inputs to keep the component dynamic * @param changes */ ngOnChanges(changes: any): void; /** @hidden * It is function for trigger opening browser window */ openWindow(): void; /** @hidden * It is function for clearing list with added files */ removeAll(): void; /** @hidden * Function to calculate uploading percentage process * @param process it is json process object */ processingFile(process: any): any; /** @hidden * Function to calculate file size * @param process it is json process object */ processedFile(process: any): any; /** @hidden * Function to check if file is image * @param name it is file name */ isImage(type: any): any; /** @hidden * Function to generate filters * @param type it is type of filter * @param filters it is array with filtering values */ generateFilters(type: any, filters: any): void; /** @hidden * Function to check if there any filters */ checkForFilters(): void; }