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

FileManager - Update CustomFileSystemProviderOptions declarations #11952

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 50 additions & 18 deletions js/file_management/custom_provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,124 @@ import FileSystemProviderBase, {
FileSystemProviderBaseOptions
} from './provider_base';

import FileSystemItem from './file_system_item';
import UploadInfo from './upload_info';

export interface CustomFileSystemProviderOptions extends FileSystemProviderBaseOptions<CustomFileSystemProvider> {
/**
* @docid CustomFileSystemProviderOptions.abortFileUpload
* @type function
* @type_function_param1 file:File
* @type_function_param2 uploadInfo?:UploadInfo
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
abortFileUpload?: Function;
abortFileUpload?: ((file: File, uploadInfo?: UploadInfo) => Promise<any> | JQueryPromise<any> | any);

/**
* @docid CustomFileSystemProviderOptions.copyItem
* @type function
* @type_function_param1 item:FileSystemItem
* @type_function_param2 destinationDirectory:FileSystemItem
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
copyItem?: Function;
copyItem?: ((item: FileSystemItem, destinationDirectory: FileSystemItem) => Promise<any> | JQueryPromise<any> | any);

/**
* @docid CustomFileSystemProviderOptions.createDirectory
* @type function
* @type_function_param1 parentDirectory:FileSystemItem
* @type_function_param2 name:string
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
createDirectory?: Function;
createDirectory?: ((parentDirectory: FileSystemItem, name: string) => Promise<any> | JQueryPromise<any> | any);

/**
* @docid CustomFileSystemProviderOptions.deleteItem
* @type function
* @type_function_param1 item:FileSystemItem
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
deleteItem?: Function;
deleteItem?: ((item: FileSystemItem) => Promise<any> | JQueryPromise<any> | any);

/**
* @docid CustomFileSystemProviderOptions.downloadItems
* @type function
* @type_function_param1 items:Array<FileSystemItem>
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
downloadItems?: Function;
downloadItems?: ((items: Array<FileSystemItem>) => any);

/**
* @docid CustomFileSystemProviderOptions.getItems
* @type function
* @type_function_param1 parentDirectory:FileSystemItem
* @type_function_return Promise<Array<object>>|Array<object>
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
getItems?: Function;
getItems?: ((parentDirectory: FileSystemItem) => Promise<Array<any>> | JQueryPromise<Array<any>> | Array<any>);

/**
* @docid CustomFileSystemProviderOptions.getItemsContent
* @type function
* @type_function_param1 items:Array<FileSystemItem>
* @type_function_return Promise<object>|object
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
getItemsContent?: Function;
getItemsContent?: ((items: Array<FileSystemItem>) => Promise<any> | JQueryPromise<any> | any);

/**
* @docid CustomFileSystemProviderOptions.hasSubDirectoriesExpr
* @type string|function(fileItem)
* @type string|function(fileSystemItem)
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
hasSubDirectoriesExpr?: string | Function;

/**
* @docid CustomFileSystemProviderOptions.moveItem
* @type function
* @type_function_param1 item:FileSystemItem
* @type_function_param2 destinationDirectory:FileSystemItem
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
moveItem?: Function;
moveItem?: ((item: FileSystemItem, destinationDirectory: FileSystemItem) => Promise<any> | JQueryPromise<any> | any);

/**
* @docid CustomFileSystemProviderOptions.renameItem
* @type function
* @type_function_param1 item:FileSystemItem
* @type_function_param2 newName:string
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
renameItem?: Function;
/**
* @docid CustomFileSystemProviderOptions.uploadChunkSize
* @type number
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
uploadChunkSize?: number;
renameItem?: ((item: FileSystemItem, newName: string) => Promise<any> | JQueryPromise<any> | any);

/**
* @docid CustomFileSystemProviderOptions.uploadFileChunk
* @type function
* @type_function_param1 file:File
* @type_function_param2 uploadInfo:UploadInfo
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
uploadFileChunk?: Function;
uploadFileChunk?: ((file: File, uploadInfo: UploadInfo) => Promise<any> | JQueryPromise<any> | any);
}

/**
* @docid CustomFileSystemProvider
* @inherits FileSystemProviderBase
Expand Down
6 changes: 0 additions & 6 deletions js/file_management/custom_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class CustomFileSystemProvider extends FileSystemProviderBase {
this._downloadItemsFunction = this._ensureFunction(options.downloadItems);

this._getItemsContentFunction = this._ensureFunction(options.getItemsContent);

this._uploadChunkSize = options.uploadChunkSize;
}

getItems(parentDir) {
Expand Down Expand Up @@ -77,10 +75,6 @@ class CustomFileSystemProvider extends FileSystemProviderBase {
return this._executeActionAsDeferred(() => this._getItemsContentFunction(items));
}

getFileUploadChunkSize() {
return ensureDefined(this._uploadChunkSize, super.getFileUploadChunkSize());
}

_hasSubDirs(dataObj) {
const hasSubDirs = this._hasSubDirsGetter(dataObj);
return typeof hasSubDirs === 'boolean' ? hasSubDirs : true;
Expand Down
2 changes: 1 addition & 1 deletion js/file_management/file_system_item.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @module file_management/file_system_item
* @namespace DevExpress.fileManagement
* @export default
* @hidden
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
export default class FileSystemItem {
constructor(path: string, isDirectory: boolean, pathKeys?: Array<string>);
Expand Down
50 changes: 50 additions & 0 deletions js/file_management/upload_info.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @docid UploadInfo
* @type object
* @module file_management/upload_info
* @namespace DevExpress.fileManagement
* @export default
* @prevFileNamespace DevExpress.fileManagement
* @hidden
*/
export default interface UploadInfo {
/**
* @docid UploadInfo.bytesUploaded
* @type Number
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
bytesUploaded: number;

/**
* @docid UploadInfo.chunkCount
* @type Number
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
chunkCount: number;

/**
* @docid UploadInfo.customData
* @type object
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
customData: any;

/**
* @docid UploadInfo.chunkBlob
* @type Blob
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
chunkBlob: Blob;

/**
* @docid UploadInfo.chunkIndex
* @type Number
* @prevFileNamespace DevExpress.fileManagement
* @public
*/
chunkIndex: number;
}
20 changes: 6 additions & 14 deletions js/ui/file_uploader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ import Editor, {
EditorOptions
} from './editor/editor';

import UploadInfo from '../file_management/upload_info';

export interface dxFileUploaderOptions extends EditorOptions<dxFileUploader> {
/**
* @docid dxFileUploaderOptions.abortUpload
* @type function
* @type_function_param1 file:File
* @type_function_param2 uploadInfo:object
* @type_function_param2_field1 bytesUploaded:Number
* @type_function_param2_field2 chunkCount:Number
* @type_function_param2_field3 customData:object
* @type_function_param2_field4 chunkBlob:Blob
* @type_function_param2_field5 chunkIndex:Number
* @type_function_param2 uploadInfo?:UploadInfo
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.ui
* @public
*/
abortUpload?: ((file: File, uploadInfo: { bytesUploaded?: number, chunkCount?: number, customData?: any, chunkBlob?: Blob, chunkIndex?: number }) => Promise<any> | JQueryPromise<any> | any);
abortUpload?: ((file: File, uploadInfo?: UploadInfo) => Promise<any> | JQueryPromise<any> | any);
/**
* @docid dxFileUploaderOptions.accept
* @type string
Expand Down Expand Up @@ -264,17 +261,12 @@ export interface dxFileUploaderOptions extends EditorOptions<dxFileUploader> {
* @docid dxFileUploaderOptions.uploadChunk
* @type function
* @type_function_param1 file:File
* @type_function_param2 uploadInfo:object
* @type_function_param2_field1 bytesUploaded:Number
* @type_function_param2_field2 chunkCount:Number
* @type_function_param2_field3 customData:object
* @type_function_param2_field4 chunkBlob:Blob
* @type_function_param2_field5 chunkIndex:Number
* @type_function_param2 uploadInfo:UploadInfo
* @type_function_return Promise<any>|any
* @prevFileNamespace DevExpress.ui
* @public
*/
uploadChunk?: ((file: File, uploadInfo: { bytesUploaded?: number, chunkCount?: number, customData?: any, chunkBlob?: Blob, chunkIndex?: number }) => Promise<any> | JQueryPromise<any> | any);
uploadChunk?: ((file: File, uploadInfo: UploadInfo) => Promise<any> | JQueryPromise<any> | any);
/**
* @docid dxFileUploaderOptions.uploadFailedMessage
* @type string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const moduleConfig = {
moveItem: sinon.spy((item, destinationDir) => `moved ${item.name}`),
copyItem: sinon.spy((item, destinationDir) => `copied ${item.name}`),
uploadFileChunk: sinon.spy((fileData, chunksInfo, destinationDir) => 'uploaded'),
abortFileUpload: sinon.spy((fileData, chunksInfo, destinationDir) => 'aborted'),
uploadChunkSize: 1000
abortFileUpload: sinon.spy((fileData, chunksInfo, destinationDir) => 'aborted')
};

this.provider = new CustomFileSystemProvider(this.options);
Expand Down Expand Up @@ -187,13 +186,4 @@ QUnit.module('Custom file provider', moduleConfig, () => {
});
});

test('upload chunk size', function(assert) {
let size = this.provider.getFileUploadChunkSize();
assert.strictEqual(size, this.options.uploadChunkSize, 'result acquired');

const provider = new CustomFileSystemProvider();
size = provider.getFileUploadChunkSize();
assert.ok(size > 100000, 'default value used');
});

});
39 changes: 25 additions & 14 deletions ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1670,29 +1670,27 @@ declare module DevExpress.fileManagement {
/** @name CustomFileSystemProvider.Options */
export interface CustomFileSystemProviderOptions extends FileSystemProviderBaseOptions<CustomFileSystemProvider> {
/** @name CustomFileSystemProvider.Options.abortFileUpload */
abortFileUpload?: Function;
abortFileUpload?: ((file: File, uploadInfo?: UploadInfo) => Promise<any> | JQueryPromise<any> | any);
/** @name CustomFileSystemProvider.Options.copyItem */
copyItem?: Function;
copyItem?: ((item: FileSystemItem, destinationDirectory: FileSystemItem) => Promise<any> | JQueryPromise<any> | any);
/** @name CustomFileSystemProvider.Options.createDirectory */
createDirectory?: Function;
createDirectory?: ((parentDirectory: FileSystemItem, name: string) => Promise<any> | JQueryPromise<any> | any);
/** @name CustomFileSystemProvider.Options.deleteItem */
deleteItem?: Function;
deleteItem?: ((item: FileSystemItem) => Promise<any> | JQueryPromise<any> | any);
/** @name CustomFileSystemProvider.Options.downloadItems */
downloadItems?: Function;
downloadItems?: ((items: Array<FileSystemItem>) => any);
/** @name CustomFileSystemProvider.Options.getItems */
getItems?: Function;
getItems?: ((parentDirectory: FileSystemItem) => Promise<Array<any>> | JQueryPromise<Array<any>> | Array<any>);
/** @name CustomFileSystemProvider.Options.getItemsContent */
getItemsContent?: Function;
getItemsContent?: ((items: Array<FileSystemItem>) => Promise<any> | JQueryPromise<any> | any);
/** @name CustomFileSystemProvider.Options.hasSubDirectoriesExpr */
hasSubDirectoriesExpr?: string | Function;
/** @name CustomFileSystemProvider.Options.moveItem */
moveItem?: Function;
moveItem?: ((item: FileSystemItem, destinationDirectory: FileSystemItem) => Promise<any> | JQueryPromise<any> | any);
/** @name CustomFileSystemProvider.Options.renameItem */
renameItem?: Function;
/** @name CustomFileSystemProvider.Options.uploadChunkSize */
uploadChunkSize?: number;
renameItem?: ((item: FileSystemItem, newName: string) => Promise<any> | JQueryPromise<any> | any);
/** @name CustomFileSystemProvider.Options.uploadFileChunk */
uploadFileChunk?: Function;
uploadFileChunk?: ((file: File, uploadInfo: UploadInfo) => Promise<any> | JQueryPromise<any> | any);
}
/** @name CustomFileSystemProvider */
export class CustomFileSystemProvider extends FileSystemProviderBase {
Expand Down Expand Up @@ -1782,6 +1780,19 @@ declare module DevExpress.fileManagement {
export class RemoteFileSystemProvider extends FileSystemProviderBase {
constructor(options?: RemoteFileSystemProviderOptions)
}
/** @name UploadInfo */
export interface UploadInfo {
/** @name UploadInfo.bytesUploaded */
bytesUploaded?: number;
/** @name UploadInfo.chunkBlob */
chunkBlob?: Blob;
/** @name UploadInfo.chunkCount */
chunkCount?: number;
/** @name UploadInfo.chunkIndex */
chunkIndex?: number;
/** @name UploadInfo.customData */
customData?: any;
}
}
declare module DevExpress.fx {
/** @name fx.animate(element, config) */
Expand Down Expand Up @@ -3642,7 +3653,7 @@ declare module DevExpress.ui {
/** @name dxFileUploader.Options */
export interface dxFileUploaderOptions extends EditorOptions<dxFileUploader> {
/** @name dxFileUploader.Options.abortUpload */
abortUpload?: ((file: File, uploadInfo: { bytesUploaded?: number, chunkCount?: number, customData?: any, chunkBlob?: Blob, chunkIndex?: number }) => Promise<any> | JQueryPromise<any> | any);
abortUpload?: ((file: File, uploadInfo?: DevExpress.fileManagement.UploadInfo) => Promise<any> | JQueryPromise<any> | any);
/** @name dxFileUploader.Options.accept */
accept?: string;
/** @name dxFileUploader.Options.allowCanceling */
Expand Down Expand Up @@ -3692,7 +3703,7 @@ declare module DevExpress.ui {
/** @name dxFileUploader.Options.uploadButtonText */
uploadButtonText?: string;
/** @name dxFileUploader.Options.uploadChunk */
uploadChunk?: ((file: File, uploadInfo: { bytesUploaded?: number, chunkCount?: number, customData?: any, chunkBlob?: Blob, chunkIndex?: number }) => Promise<any> | JQueryPromise<any> | any);
uploadChunk?: ((file: File, uploadInfo: DevExpress.fileManagement.UploadInfo) => Promise<any> | JQueryPromise<any> | any);
/** @name dxFileUploader.Options.uploadFailedMessage */
uploadFailedMessage?: string;
/** @name dxFileUploader.Options.uploadFile */
Expand Down