From 15ff90025aad34c4e17135e396ce31ab58e7361a Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Tue, 14 Sep 2021 05:58:40 +0500 Subject: [PATCH] fix(fileUploader): added loginCallback --- src/SASjs.ts | 25 +++++++++++++++++++------ src/job-execution/FileUploader.ts | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/SASjs.ts b/src/SASjs.ts index 9f4f143..74831a5 100644 --- a/src/SASjs.ts +++ b/src/SASjs.ts @@ -571,19 +571,32 @@ export default class SASjs { * Process). Is prepended at runtime with the value of `appLoc`. * @param files - array of files to be uploaded, including File object and file name. * @param params - request URL parameters. - * @param overrideSasjsConfig - object to override existing config (optional) + * @param config - provide any changes to the config here, for instance to + * enable/disable `debug`. Any change provided will override the global config, + * for that particular function call. + * @param loginRequiredCallback - a function that is called if the + * user is not logged in (eg to display a login form). The request will be + * resubmitted after successful login. */ public async uploadFile( sasJob: string, files: UploadFile[], - params: any, - overrideSasjsConfig?: any + params: { [key: string]: any } | null, + config: { [key: string]: any } = {}, + loginRequiredCallback?: () => any ) { - const config = { + config = { ...this.sasjsConfig, - ...overrideSasjsConfig + ...config } - return await this.fileUploader!.execute(sasJob, files, params, config) + const data = { files, params } + + return await this.fileUploader!.execute( + sasJob, + data, + config, + loginRequiredCallback + ) } /** diff --git a/src/job-execution/FileUploader.ts b/src/job-execution/FileUploader.ts index ecb7c95..868cfa6 100644 --- a/src/job-execution/FileUploader.ts +++ b/src/job-execution/FileUploader.ts @@ -15,7 +15,7 @@ import { BaseJobExecutor } from './JobExecutor' interface dataFileUpload { files: UploadFile[] - params: any + params: { [key: string]: any } | null } export class FileUploader extends BaseJobExecutor {