Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User download file #1529

Merged
merged 38 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1e9463f
user management screen
abishekTa-egov Oct 4, 2024
ee09ead
some changes to user screen
abishekTa-egov Oct 5, 2024
6abb4fd
some name changes
abishekTa-egov Oct 7, 2024
e8553b4
user management screen
abishekTa-egov Oct 8, 2024
882cacb
table rendered
abishekTa-egov Oct 8, 2024
b1d12af
Table rendering and other changes
abishekTa-egov Oct 8, 2024
f4007d8
roles default value set to all roles
abishekTa-egov Oct 9, 2024
379a800
checkpoint
abishekTa-egov Oct 9, 2024
5892b11
EOD checkpoint
abishekTa-egov Oct 9, 2024
4d80b9a
filter deafult changes and roles as list of roles
abishekTa-egov Oct 10, 2024
2c460b3
Merge branch 'console' into user-management-screen
abishekTa-egov Oct 10, 2024
6f5dea8
index file merge changed
abishekTa-egov Oct 10, 2024
681abd5
resolved comments after pull
abishekTa-egov Oct 10, 2024
38a5930
index.html
abishekTa-egov Oct 10, 2024
641030d
index file change
abishekTa-egov Oct 10, 2024
5b8c4e6
resolved comments
abishekTa-egov Oct 10, 2024
3868ffa
Merge branch 'console' into user-management-screen
nipunarora-eGov Oct 10, 2024
696933f
changes in names
abishekTa-egov Oct 10, 2024
af84ab1
commit
abishekTa-egov Oct 10, 2024
882c082
changes
abishekTa-egov Oct 10, 2024
248ed10
Merge branch 'console' into user-management-screen
nipunarora-eGov Oct 10, 2024
00059ad
changes
abishekTa-egov Oct 10, 2024
6a004cc
Merge branch 'user-management-screen' of https://github.com/egovernme…
abishekTa-egov Oct 10, 2024
19a94e5
Merge branch 'console' of https://github.com/egovernments/DIGIT-Front…
abishekTa-egov Oct 11, 2024
0957fed
Merge branch 'console' of https://github.com/egovernments/DIGIT-Front…
abishekTa-egov Oct 11, 2024
d759b6f
making api calls
abishekTa-egov Oct 11, 2024
da4d078
Merge branch 'console' of https://github.com/egovernments/DIGIT-Front…
abishekTa-egov Oct 11, 2024
d4f7c23
Merge branch 'console' of https://github.com/egovernments/DIGIT-Front…
abishekTa-egov Oct 11, 2024
2e255ce
EOD checkpoint
abishekTa-egov Oct 11, 2024
cbdea5e
downloading
abishekTa-egov Oct 12, 2024
8244d80
EOD checkpoint
abishekTa-egov Oct 14, 2024
f9ed461
random commit
abishekTa-egov Oct 15, 2024
bc6a021
pull
abishekTa-egov Oct 15, 2024
a07b903
working user download screen
abishekTa-egov Oct 15, 2024
dbb6fd1
Merge branch 'console' of https://github.com/egovernments/DIGIT-Front…
abishekTa-egov Oct 16, 2024
bb98caa
css styling and pull from console
abishekTa-egov Oct 16, 2024
dc2cf44
some changes
abishekTa-egov Oct 16, 2024
936f5e5
changes
abishekTa-egov Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" />
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved


<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"
}
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved



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>
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved

{/* 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>
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved

{/* 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();
}}
/>
}
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
</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 };




abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
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 = []
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
let uuids = new Set(); //for making request to search user
for (const ob of response?.ResourceDetails) {
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
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
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
},
});


if (response1?.user?.length === 0) {
throw new Error("No users found with the given uuid");
}
let uuidName={};
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
for (const ob of response1?.user){
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
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}
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved

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 });
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
};

export default useFileDownload;

Loading