Skip to content

Commit 8806b26

Browse files
model as param added
1 parent e997b67 commit 8806b26

File tree

10 files changed

+62
-73
lines changed

10 files changed

+62
-73
lines changed

frontend/src/components/Content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { setDriver, disconnect } from '../utils/Driver';
77
import { useCredentials } from '../context/UserCredentials';
88
import { useFileContext } from '../context/UsersFiles';
99
import CustomAlert from './Alert';
10-
import { extractAPI } from '../services/FileAPI';
10+
import { extractAPI } from '../utils/FileAPI';
1111
import { ContentProps } from '../types';
1212

1313
const Content: React.FC<ContentProps> = ({ isExpanded }) => {

frontend/src/components/DropZone.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useCredentials } from '../context/UserCredentials';
66
import { useFileContext } from '../context/UsersFiles';
77
import { getFileFromLocal, saveFileToLocal } from '../utils/Utils';
88
import CustomAlert from './Alert';
9-
import { uploadAPI } from '../services/FileAPI';
9+
import { uploadAPI } from '../utils/FileAPI';
1010
import { CustomFile } from '../types';
1111

1212
const DropZone: FunctionComponent = () => {
@@ -89,7 +89,7 @@ const DropZone: FunctionComponent = () => {
8989
})
9090
);
9191

92-
const apiResponse = await uploadAPI(file, userCredentials);
92+
const apiResponse = await uploadAPI(file, userCredentials, model);
9393
apirequests.push(apiResponse);
9494
const results = await Promise.allSettled(apirequests);
9595
results.forEach((apiRes) => {

frontend/src/components/S3Modal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ const S3Modal: React.FC<S3ModalProps> = ({ hideModal, open }) => {
4848
try {
4949
setStatus('info');
5050
setStatusMessage('Scaning...');
51-
const apiResponse = await urlScanAPI(url, userCredentials, accessKey, secretKey);
51+
const apiResponse = await urlScanAPI({
52+
urlParam: url,
53+
userCredentials: userCredentials,
54+
model: model,
55+
accessKey: accessKey,
56+
secretKey: secretKey,
57+
});
5258
console.log('response', apiResponse);
5359
setStatus('success');
5460
if (apiResponse?.data.status == 'Failed' || !apiResponse.data) {

frontend/src/components/YoutubeModal.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,19 @@ const YoutubeModal: React.FC<S3ModalProps> = ({ hideModal, open }) => {
3535
try {
3636
setStatus('info');
3737
setStatusMessage('Scaning...');
38-
const apiResponse = await urlScanAPI(youtubeURL, userCredentials, '', '', sourceLimit, querySource);
39-
console.log('response', apiResponse);
38+
const apiResponse = await urlScanAPI({
39+
urlParam: youtubeURL,
40+
userCredentials,
41+
model,
42+
accessKey: '',
43+
secretKey: '',
44+
max_limit: sourceLimit,
45+
query_source: querySource,
46+
});
4047
setStatus('success');
41-
if (apiResponse.data.status == 'Failed'|| !apiResponse.data) {
48+
if (apiResponse.data.status == 'Failed' || !apiResponse.data) {
4249
setStatus('danger');
43-
setStatusMessage(apiResponse.data.message??apiResponse?.message);
50+
setStatusMessage(apiResponse.data.message ?? apiResponse?.message);
4451
} else {
4552
setStatusMessage(`Successfully Created Source Nodes for ${apiResponse.data.success_count ?? ''} Link`);
4653
}
File renamed without changes.

frontend/src/services/URLScan.ts

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
1-
import axios, { AxiosError, AxiosResponse } from 'axios';
1+
import axios from 'axios';
22
import { url } from '../utils/Utils';
33

4-
const urlScanAPI = async (
5-
urlParam: string,
6-
userCredentials?: any,
7-
accessKey?: string,
8-
secretKey?: string,
9-
max_limit?: number,
10-
query_source?: string
11-
) => {
4+
interface ScanProps {
5+
urlParam: string;
6+
userCredentials?: any;
7+
model?: string;
8+
accessKey?: string;
9+
secretKey?: string;
10+
max_limit?: number;
11+
query_source?: string;
12+
}
13+
14+
const urlScanAPI = async (props: ScanProps) => {
1215
try {
1316
const formData = new FormData();
14-
formData.append('uri', userCredentials?.uri);
15-
formData.append('userName', userCredentials?.userName);
16-
formData.append('password', userCredentials?.password);
17-
formData.append('source_url', urlParam);
18-
if (accessKey?.length) {
19-
formData.append('aws_access_key_id', accessKey);
17+
formData.append('uri', props?.userCredentials?.uri);
18+
formData.append('userName', props?.userCredentials.userName);
19+
formData.append('password', props?.userCredentials?.password);
20+
formData.append('source_url', props?.urlParam);
21+
if (props.model != undefined) {
22+
formData.append('model', props?.model);
23+
}
24+
if (props.accessKey?.length) {
25+
formData.append('aws_access_key_id', props?.accessKey);
2026
}
21-
if (secretKey?.length) {
22-
formData.append('aws_secret_access_key', secretKey);
27+
if (props?.secretKey?.length) {
28+
formData.append('aws_secret_access_key', props?.secretKey);
2329
}
24-
if (query_source?.length) {
25-
formData.append('query_source', query_source);
30+
if (props?.query_source?.length) {
31+
formData.append('query_source', props?.query_source);
2632
}
27-
if (max_limit != undefined) {
28-
formData.append('max_limit', max_limit.toString());
33+
if (props?.max_limit != undefined) {
34+
formData.append('max_limit', props?.max_limit.toString());
2935
}
3036

31-
const response:any = await axios.post(`${url()}/url/scan`, formData, {
37+
const response: any = await axios.post(`${url()}/url/scan`, formData, {
3238
headers: {
3339
'Content-Type': 'multipart/form-data',
3440
},
3541
});
3642
return response;
3743
} catch (error) {
3844
console.log('Error uploading file:', error);
39-
throw error;
45+
return error;
4046
}
4147
};
4248

frontend/src/services/Upload.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import axios from 'axios';
22
import { url } from '../utils/Utils';
33

4-
const uploadAPI = async (file: any, userCredentials: any) => {
4+
const uploadAPI = async (file: any, userCredentials: any, model: string) => {
55
try {
66
const formData = new FormData();
77
formData.append('file', file);
88
formData.append('uri', userCredentials?.uri);
99
formData.append('userName', userCredentials?.userName);
1010
formData.append('password', userCredentials?.password);
11+
if (model != undefined) {
12+
formData.append('model', model);
13+
}
1114
const response = await axios.post(`${url()}/sources`, formData, {
1215
headers: {
1316
'Content-Type': 'multipart/form-data',

frontend/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export type ExtractParams = {
3030

3131
export type UploadParams = {
3232
file: string;
33+
model: string;
3334
} & { [key: string]: any };
3435

3536
export type FormDataParams = ExtractParams | UploadParams;

frontend/src/utils/ApiUtils.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

frontend/src/services/FileAPI.ts renamed to frontend/src/utils/FileAPI.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { Method } from 'axios';
2-
import { url } from '../utils/Utils';
2+
import { url } from './Utils';
33
import { UserCredentials, ExtractParams, UploadParams } from '../types';
4-
import { apiCall } from '../utils/ApiUtils';
5-
export const uploadAPI = async (file: any, userCredentials: any): Promise<any> => {
4+
import { apiCall } from '../services/CommonAPI';
5+
6+
// Upload Call
7+
export const uploadAPI = async (file: any, userCredentials: any, model: string): Promise<any> => {
68
const urlUpload = `${url()}/sources`;
79
const method: Method = 'post';
810
const commonParams: UserCredentials = userCredentials;
9-
const additionalParams: UploadParams = { file };
11+
const additionalParams: UploadParams = { file, model };
1012
const response = await apiCall(urlUpload, method, commonParams, additionalParams);
1113
return response;
1214
};
1315

16+
// Extract call
1417
export const extractAPI = async (
1518
file: any,
1619
model: string,

0 commit comments

Comments
 (0)