Skip to content

Commit

Permalink
Merge pull request #265 from krishna9304/ui/reportImport
Browse files Browse the repository at this point in the history
feat(ui): Added logical components to the report import page and Integrated the API

Reviewed-by: [email protected]
Tested-by: [email protected]
  • Loading branch information
shaheemazmalmmd authored Sep 29, 2022
2 parents cf11dae + bc8b15a commit 0200608
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const Routes = () => {
/>
<PrivateLayout
exact
path={routes.upload.report}
path={routes.upload.importReport}
component={ImportReport}
/>
<PublicLayout
Expand Down
13 changes: 13 additions & 0 deletions src/api/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,17 @@ export const downloadReportApi = (reportId) => {
});
};

export const importReportApi = (uploadId, reqBody) => {
const url = endpoints.jobs.importReport(uploadId);
return sendRequest({
url,
method: "POST",
headers: {
Authorization: getToken(),
},
isMultipart: true,
body: reqBody,
});
};

export default getJobApi;
2 changes: 1 addition & 1 deletion src/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const Header = () => {
<NavDropdown.Item as={Link} to={routes.upload.vcs}>
From VCS
</NavDropdown.Item>
<NavDropdown.Item as={Link} to={routes.upload.report}>
<NavDropdown.Item as={Link} to={routes.upload.importReport}>
Import Report
</NavDropdown.Item>
<NavDropdown.Item as={Link} to={routes.upload.instructions}>
Expand Down
27 changes: 16 additions & 11 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2022 Soham Banerjee([email protected])
Copyright (C) 2022 Soham Banerjee([email protected]), Krishna Mahato ([email protected])
SPDX-License-Identifier: GPL-2.0
Expand Down Expand Up @@ -80,6 +80,11 @@ export const actionsOptions = [
name: "Export Unified Report",
reportFormat: "unifiedreport",
},
{
id: 6,
name: "Import Report",
reportFormat: "importReport",
},
];
export const initialMessage = {
type: "success",
Expand Down Expand Up @@ -139,16 +144,16 @@ export const initialFolderListFile = [
];
// constants for upload/ImportReport
export const initialStateImportReport = {
folder: "",
editUpload: "",
reportUpload: "",
newLicense: "licenseCanditate",
licenseInfoInFile: true,
licenseConcluded: false,
licenseDecision: true,
existingDecisions: true,
importDiscussed: true,
copyright: false,
folder: 1,
upload: "",
report: null,
addNewLicensesAs: "candidate",
addConcludedAsDecisions: true,
addLicenseInfoFromInfoInFile: true,
addLicenseInfoFromConcluded: false,
addConcludedAsDecisionsOverwrite: true,
addConcludedAsDecisionsTBD: true,
addCopyrights: false,
};

// constants for upload/UploadFromServer
Expand Down
1 change: 1 addition & 0 deletions src/constants/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const endpoints = {
allJobs: () => `${apiUrl}/jobs/all`,
scheduleReport: () => `${apiUrl}/report`,
downloadReport: (reportId) => `${apiUrl}/report/${reportId}`,
importReport: (uploadId) => `${apiUrl}/report/import?upload=${uploadId}`,
},
auth: {
tokens: () => `${apiUrl}/tokens`,
Expand Down
3 changes: 2 additions & 1 deletion src/constants/routes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright (C) 2021 Aman Dwivedi ([email protected]), Shruti Agarwal ([email protected])
Copyright (C) 2022 Krishna Mahato <[email protected]>
SPDX-License-Identifier: GPL-2.0
Expand Down Expand Up @@ -27,7 +28,7 @@ const routes = {
server: "/upload/server",
url: "/upload/url",
vcs: "/upload/vcs",
report: "/upload/report",
importReport: "/upload/reportImport",
instructions: "/upload/instructions",
oneShotAnalysis: "/upload/oneShotAnalysis",
oneShotCopyright: "/upload/oneShotCopyright",
Expand Down
12 changes: 10 additions & 2 deletions src/pages/Browse/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright (C) 2021 Shruti Agarwal ([email protected]), Aman Dwivedi ([email protected]),
Copyright (C) 2022 Soham Banerjee ([email protected])
Copyright (C) 2022 Soham Banerjee ([email protected]), Krishna Mahato ([email protected])
SPDX-License-Identifier: GPL-2.0
Expand All @@ -19,7 +19,7 @@

import React, { useState, useEffect } from "react";
import routes from "constants/routes";
import { Link } from "react-router-dom";
import { Link, useHistory } from "react-router-dom";
import arrayToTree from "array-to-tree";
import messages from "constants/messages";

Expand Down Expand Up @@ -79,6 +79,8 @@ const Browse = () => {
const [query, setQuery] = useState("");
const [pages, setPages] = useState();

const history = useHistory();

useEffect(() => {
setMessage({
type: "success",
Expand Down Expand Up @@ -146,6 +148,12 @@ const Browse = () => {
};

const handleActionChange = (e, uploadId) => {
if (e.target.value === "importReport") {
history.push(
`/upload/reportImport?folder=${browseData.folderId}&upload=${uploadId}`
);
return;
}
scheduleReport(uploadId, e.target.value)
.then((res) => {
return res?.message;
Expand Down
Loading

0 comments on commit 0200608

Please sign in to comment.