impaktapps-ui-builder 0.0.377 → 0.0.378

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  export declare const downloadFile: (obj: any) => void;
2
- export declare const download: (response: any) => void;
2
+ export declare const clickDownloadLink: (response: any, service: any) => void;
@@ -22,6 +22,6 @@ declare const _default: (funcParams: funcParamsProps) => {
22
22
  onReset: (functionParameters: any) => Promise<void>;
23
23
  callHandler: (eventType: string, functionParameters?: any) => Promise<void>;
24
24
  downloadFile: (obj: any) => void;
25
- download: (response: any) => void;
25
+ download: (response: any, service: any) => void;
26
26
  };
27
27
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "0.0.377",
3
+ "version": "0.0.378",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -1,27 +1,37 @@
1
- export const downloadFile = (obj: any) => {
1
+ export const downloadFile = (obj: any) => {
2
2
  const typeArr = obj.name.split(".");
3
3
  const data = obj.data;
4
4
  const finalData = window.atob(data);
5
- let file ;
6
- file = new File([finalData], typeArr[typeArr.length - 1] );
7
-
5
+ let file;
6
+ file = new File([finalData], typeArr[typeArr.length - 1]);
7
+
8
8
  const url = URL.createObjectURL(file);
9
9
  const link = document.createElement("a");
10
- link.href = typeArr[typeArr.length - 1] === 'pdf' ?'data:application/octet-stream;base64,' + data: url;
10
+ link.href = typeArr[typeArr.length - 1] === 'pdf' ? 'data:application/octet-stream;base64,' + data : url;
11
11
  link.download = `${obj.name}`;
12
12
  document.body.appendChild(link);
13
13
  link.click();
14
-
14
+
15
15
  URL.revokeObjectURL(url);
16
16
  document.body.removeChild(link);
17
- };
17
+ };
18
+
19
+ export const clickDownloadLink = (response: any, service) => {
20
+ let url = `${service.defaults.baseURL}/${response.path}`;
21
+ if (response?.params) {
22
+ const keysArray = Object.keys(response?.params);
23
+ keysArray.map((e, i) => {
24
+ if (i === 0) {
25
+ url = url + `?${e}=${response?.params[e]}`
26
+ } else {
27
+ url = url + `&${e}=${response?.params[e]}`
28
+ }
18
29
 
19
- export const download = (response: any) => {
20
- const url = window.URL.createObjectURL(new Blob([response.data]));
21
- const link = document.createElement('a');
22
- link.href = url;
23
- link.setAttribute('download', `${response.headers.filename}`);
24
- document.body.appendChild(link);
25
- link.click();
26
- link.parentNode.removeChild(link);
27
- };
30
+ })
31
+ }
32
+ const link = document.createElement('a');
33
+ link.href = url;
34
+ document.body.appendChild(link);
35
+ link.click();
36
+ link.parentNode.removeChild(link);
37
+ };
@@ -87,7 +87,7 @@ async function executeInBuiltFunctionHandler(params: handlersProps) {
87
87
  const makeFunc = eval(params.config.funcParametersCode)
88
88
  parameter = makeFunc(params.store, params.dynamicData, params.userValue, params.parentEventOutput, params.service);
89
89
  }
90
- params.serviceHolder[params.config.inBuiltFunctionType](parameter)
90
+ params.serviceHolder[params.config.inBuiltFunctionType](parameter,params.service)
91
91
  }
92
92
 
93
93
  async function executeCustomHandler(params: handlersProps) {
@@ -1,5 +1,5 @@
1
1
  import _, { isEmpty } from "lodash";
2
- import { download, downloadFile } from "./downloadFile";
2
+ import { clickDownloadLink, downloadFile } from "./downloadFile";
3
3
  import { executeEvents, executeRefreshHandler } from "./events";
4
4
  import { handlersProps } from "./interface";
5
5
  let compType: string;
@@ -62,7 +62,7 @@ export default (funcParams: funcParamsProps) => {
62
62
  let executeEventsParameters: handlersProps = {
63
63
  config: {}, componentName: "",
64
64
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
65
- serviceHolder: { downloadFile ,download}, eventGroups
65
+ serviceHolder: { downloadFile ,download:clickDownloadLink}, eventGroups
66
66
  };
67
67
  return {
68
68
  setPage: async function () {
@@ -192,7 +192,7 @@ export default (funcParams: funcParamsProps) => {
192
192
  }
193
193
  },
194
194
  downloadFile: downloadFile,
195
- download:download,
195
+ download:clickDownloadLink,
196
196
  };
197
197
  };
198
198