Skip to content

Commit

Permalink
Merge pull request #294 from PrerakMathur20/linkLink
Browse files Browse the repository at this point in the history
Open method to Open case files
  • Loading branch information
swapnalshahil authored Aug 27, 2022
2 parents 9a0b07c + f88161f commit a329041
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 6 deletions.
52 changes: 49 additions & 3 deletions React-frontend/src/components/Management/FilterCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ const useStyles = makeStyles((theme) => ({
flexDirection: "row",
paddingLeft: "10px",
},
caseText: {
fontWeight: "bold",
},
copyButton: {
color: theme.palette.text.secondary,
margin: theme.spacing(1.5, 0),
width: '30%',
"&:hover": {
},
}
}));

const StyledTableCell = withStyles((theme) => ({
Expand Down Expand Up @@ -137,6 +147,25 @@ function FilterCase() {
dispatch(loadTagCases(tags));
}
}

// Function to hancle copy and open file
function callCase(id) {
var caseLink = "file://" + id;
var copyText = document.createElement("input");
copyText.value = caseLink;
document.body.appendChild(copyText);
copyText.select();
document.execCommand("copy");
alert("Copied the text: \n" + copyText.value + "\nto clipboard.\n\nPlease paste in new window");
window.open("", "_blank");

}

// Function to return case tag
function getCaseName(str) {
return str.substring(str.lastIndexOf("/") + 1);
}

return (
<Container component="main" className={classes.root}>
<Container>
Expand Down Expand Up @@ -278,7 +307,8 @@ function FilterCase() {
<TableHead>
<StyledTableRow>
<StyledTableCell align="left">Index</StyledTableCell>
<StyledTableCell align="left">Case Files</StyledTableCell>
<StyledTableCell align="left">Case Tag</StyledTableCell>
<StyledTableCell align="left">Copy path to Clipboard</StyledTableCell>
</StyledTableRow>
</TableHead>

Expand All @@ -292,8 +322,24 @@ function FilterCase() {
</StyledTableCell>
}
{
<StyledTableCell component="th" scope="row">
{row}
<StyledTableCell component="th" scope="row"
className={classes.caseText}
>
{getCaseName(row)}
</StyledTableCell>
}
{
<StyledTableCell component="th" scope="row" className={classes.copyButton}>
<Button
variant="contained"
color="primary"
className={classes.submit}
style={{ width: "10%" }}
onClick={() => {
callCase(row)}}
>
Copy
</Button>
</StyledTableCell>
}
</StyledTableRow>
Expand Down
52 changes: 49 additions & 3 deletions React-frontend/src/components/Management/Keywordsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ const useStyles = makeStyles((theme) => ({
flexDirection: "row",
paddingLeft: "10px",
},
caseText: {
fontWeight: "bold",
},
copyButton: {
color: theme.palette.text.secondary,
margin: theme.spacing(1.5, 0),
width: '30%',
"&:hover": {
},
}
}));

const StyledTableCell = withStyles((theme) => ({
Expand Down Expand Up @@ -151,6 +161,25 @@ function Keywordsearch() {
}
}
}

// Function to hancle copy and open file
function callCase(id) {
var caseLink = "file://" + id;
var copyText = document.createElement("input");
copyText.value = caseLink;
document.body.appendChild(copyText);
copyText.select();
document.execCommand("copy");
alert("Copied the text: \n" + copyText.value + "\nto clipboard.\n\nPlease paste in new window");
window.open("", "_blank");

}

// Function to return case tag
function getCaseName(str) {
return str.substring(str.lastIndexOf("/") + 1);
}


return (
<Container component="main" className={classes.root}>
Expand Down Expand Up @@ -251,7 +280,8 @@ function Keywordsearch() {
<TableHead>
<StyledTableRow>
<StyledTableCell align="left">Index</StyledTableCell>
<StyledTableCell align="left">Case Files</StyledTableCell>
<StyledTableCell align="left">Case Tag</StyledTableCell>
<StyledTableCell align="left">Copy path to Clipboard</StyledTableCell>
</StyledTableRow>
</TableHead>

Expand All @@ -265,8 +295,24 @@ function Keywordsearch() {
</StyledTableCell>
}
{
<StyledTableCell component="th" scope="row">
{value}
<StyledTableCell component="th" scope="row"
className={classes.caseText}
>
{getCaseName(value)}
</StyledTableCell>
}
{
<StyledTableCell component="th" scope="row" className={classes.copyButton}>
<Button
variant="contained"
color="primary"
className={classes.submit}
style={{ width: "10%" }}
onClick={() => {
callCase(value)}}
>
Copy
</Button>
</StyledTableCell>
}
</StyledTableRow>
Expand Down

0 comments on commit a329041

Please sign in to comment.