Skip to content

Commit

Permalink
User download file (#1529)
Browse files Browse the repository at this point in the history
* user management screen

* some changes to user screen

* some name changes

* user management screen

* table rendered

* Table rendering and other changes

* roles default value set to all roles

* checkpoint

* EOD checkpoint

* filter deafult changes and roles as list of roles

* resolved comments after pull

* index.html

* resolved comments

* changes in names

* changes

* changes

* making api calls

* EOD checkpoint

* downloading

* random commit

* working user download screen

* css styling and pull from console

* some changes

* changes

---------

Co-authored-by: Nipun Arora <[email protected]>
  • Loading branch information
abishekTa-egov and nipunarora-eGov authored Oct 16, 2024
1 parent f887c42 commit f6da599
Show file tree
Hide file tree
Showing 14 changed files with 302 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />

<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].79-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].80-campaign/dist/index.css" />


<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-css",
"version": "1.0.79-campaign",
"version": "1.0.80-campaign",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,15 @@
text-overflow: ellipsis; /* Add ellipsis to overflowing text */
}

.dm-audit-info11 {
max-width: 70%; /* Ensure this section doesn't take too much space */
overflow: hidden;
text-overflow: ellipsis; /* Handle long text with ellipsis */
white-space: nowrap; /* Prevent wrapping */
color: #C84C0E;
margin-bottom: "1rem";
font-size: "0.875rem"
}



Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { EditIcon } from "@egovernments/digit-ui-react-components";
import { DeleteIconv2 } from "@egovernments/digit-ui-react-components";
import { FileIcon } from "@egovernments/digit-ui-react-components";
import { Button } from "@egovernments/digit-ui-react-components";
import { Card } from "@egovernments/digit-ui-react-components";
import { CardSubHeader } from "@egovernments/digit-ui-react-components";
import { InboxSearchComposer } from "@egovernments/digit-ui-react-components";
import { Table } from '@egovernments/digit-ui-react-components';
import { DeleteIconv2, DownloadIcon, FileIcon, Button, Card, CardSubHeader } from "@egovernments/digit-ui-react-components";

const FileComponent = ({ title, fileName, auditDetails, editHandler, deleteHandler, downloadHandler }) => {
const { t } = useTranslation();
const { userName, lastmodTime } = auditDetails; // Destructuring the audit details for easy access

const FileComponent = ({ title,fileName,editHandler,deleteHandler}) => {
const {t}=useTranslation();
return (
<div>

{/* First card */}
<div className="view-composer-header-section">
<CardSubHeader style={{ marginTop: 0, fontSize: "1.5rem", color: " #0B4B66", marginBottom: "0rem" }}>{title}</CardSubHeader>

</div>
<Card>
{/* First card */}
<div className="view-composer-header-section">
<CardSubHeader style={{ marginTop: 0, fontSize: "1.5rem", color: " #0B4B66", marginBottom: "0rem" }}>{title}</CardSubHeader>
</div>

<Card>
<div className="dm-parent-container">
{/* Left side: File Icon */}
<div
Expand All @@ -30,41 +26,65 @@ const FileComponent = ({ title,fileName,editHandler,deleteHandler}) => {
<div>{fileName}</div>
</div>

{/* Right side: Edit and Delete Buttons */}
{/* Right side: Edit, Delete, and Audit details */}
<div className="dm-actions-container">

{/* Display audit details (Uploaded by user and last modified time) */}
<div className="dm-audit-info11">
{/* Displaying the audit information */}
{userName && <span style={{color:"#C84C0E"}}>{"Uploaded by"} {userName} | </span>}
{lastmodTime && <span style={{color:"#C84C0E"}}>{lastmodTime}</span>}
</div>

{/* Edit Icon and Button */}
<div className="dm-campaign-preview-edit-container" onClick={() => handleRedirect(1)}>
{/* <span>{t("CAMPAIGN_EDIT")}</span> */}
{editHandler &&
<Button
label={t("WBH_EDIT")}
variation="secondary"
icon={<EditIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => {
editHandler();
}}
/>
}
</div>

{/* Delete Button */}
{deleteHandler &&
<Button
label={t("WBH_EDIT")}
label={t("WBH_DELETE")}
variation="secondary"
icon={<EditIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
icon={<DeleteIconv2 styles={{ height: "1.25rem", width: "2.5rem" }} />}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => {
editHandler();
deleteHandler();
}}
/>
</div>
}

{/* Delete Button */}
<Button
label={t("WBH_DELETE")}
variation="secondary"
icon={<DeleteIconv2 styles={{ height: "1.25rem", width: "2.5rem" }} />}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => {
deleteHandler();
}}
/>
{/* Download Button */}
{downloadHandler &&
<Button
label={t("WBH_DOWNLOAD")}
variation="secondary"
icon={<DownloadIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => {
downloadHandler();
}}
/>
}
</div>
</div>
</Card>
</div>
</Card>

</div>
);
};

export default FileComponent;

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ const HeaderComp = ({ title,styles = {} }) => {
fontSize: "1.5rem",
color: "#0B4B66",
};

// Merge default styles with the custom styles passed as a prop
const mergedStyles = { ...defaultStyles, ...styles };




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ const defaultSearchValues = {
{label: "DRAFTED_SETUP"},
{label: "EXECUTION_TO_BE_DONE",},
{label:"EXECUTION_IN_PROGRESS"},
{label:"MICROPLAN_EXECUTED"}
{label:"MICROPLAN_EXECUTED"},


],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const UICustomizations = {
}
)
})

return roles
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const UserManagementConfig = {
},
{
"text": "DOWNLOAD_USER_DATA",
"url": "/employee",
"url": "/employee/microplan/user-download",
"roles": [
"MICROPLAN_ADMIN"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { useGenerateIdCampaign } from "./useGenerateIdCampaign";
import useCreateCampaign from "./useCreateCampaign";
import useUpdateCampaign from "./useUpdateCampaign";
import useCreateUpdatePlanProject from "./useCreateUpdatePlanProject";
import useFileDownload from "./useFileDownload";
import utils from "../utils/utilities"


const microplanv1 = {
useCreatePlanConfig,
useSearchPlanConfig,
Expand All @@ -17,7 +20,9 @@ const microplanv1 = {
useGenerateIdCampaign,
useCreateCampaign,
useUpdateCampaign,
useCreateUpdatePlanProject
useCreateUpdatePlanProject,
useFileDownload,

};

const Hooks = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { UploadFileComposer } from "@egovernments/digit-ui-components";
import formatTimestamp from "../../utils/formatTimeStamp";

//returns [[FileId,auditDetails]]
const SearchFileIds = async (body) => {
try {
const response = await Digit.CustomService.getResponse({
url: "/project-factory/v1/data/_search",
useCache: false,
method: "POST",
userService: false,
body:body,
});

if (response?.ResourceDetails?.length === 0) {
throw new Error("File not found for given microplan");
}
let fileIds = []
let uuids = new Set(); //for making request to search user
for (const ob of response?.ResourceDetails) {
fileIds.push(ob?.processedFilestoreId);
uuids.add(ob?.auditDetails?.lastModifiedBy);
}

uuids = [...uuids];

if (uuids.length === 0) {
throw new Error("No UUIDs found to search for users");
}


const response1 = await Digit.CustomService.getResponse({
url: "/user/_search",
useCache: false,
method: "POST",
userService: false,
body: {
tenantId: Digit.ULBService.getCurrentTenantId(),
pageSize: "100",
uuid: uuids
},
});


if (response1?.user?.length === 0) {
throw new Error("No users found with the given uuid");
}
let uuidName={};
for (const ob of response1?.user){
uuidName[ob.uuid]=ob.userName;
}
// let userNames = {}

response?.ResourceDetails.forEach((ob) => {
ob["username"] = uuidName[ob?.auditDetails?.lastModifiedBy]; // Set the username
ob.auditDetails.lastmodtime = formatTimestamp(ob?.auditDetails?.lastModifiedTime); // Format and set the last modified time
});


let res = {...response}

return res
} catch (error) {
if (error?.response?.data?.Errors) {
throw new Error(error.response.data.Errors[0].message);
}
throw new Error("An unknown error occurred");
}
};

export default SearchFileIds;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useQuery } from "react-query";
import SearchFileIds from "./services/SearchFileIds";

const useFileDownload = (data, config = {}) => {
return useQuery(["SEARCH_FILES",data,config?.queryKey], () => SearchFileIds(data), { ...config });
};

export default useFileDownload;

Loading

0 comments on commit f6da599

Please sign in to comment.