Skip to content

Commit

Permalink
Merge pull request #322 from wcmc-its/dev_v2_mrj4001
Browse files Browse the repository at this point in the history
Dev v2 mrj4001
  • Loading branch information
mrj4001 authored Apr 28, 2023
2 parents 16f0af5 + 2406f33 commit bf5e006
Show file tree
Hide file tree
Showing 19 changed files with 634 additions and 63 deletions.
16 changes: 1 addition & 15 deletions controllers/db/reports/publication.report.search.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,20 +604,7 @@ export const publicationSearchWithFilter = async (
}
} else {
searchOutput = await models.AnalysisSummaryArticle.findAndCountAll({
where: Sequelize.where(
Sequelize.fn(
"DATEDIFF",
Sequelize.literal("CURRENT_DATE"),
Sequelize.fn(
"STR_TO_DATE",
Sequelize.col("datePublicationAddedToEntrez"),
"%Y-%m-%d"
)
),
{
[Op.lte]: 30,
},
),

limit: apiBody.limit,
offset: apiBody.offset,
distinct : true,
Expand All @@ -627,7 +614,6 @@ export const publicationSearchWithFilter = async (
benchmark: true
});
}

return searchOutput;
} catch (e) {
console.log(e);
Expand Down
53 changes: 53 additions & 0 deletions controllers/sendNotifications.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

import { Request, Response } from 'express';
const nodemailer = require("nodemailer");
const smtpTransport = require("nodemailer-smtp-transport");

export async function sendNotification(req) {
console.log("error*************22222222222222222")

let transporter = nodemailer.createTransport(smtpTransport({
host: 'smtp.med.cornell.edu',
port: 587,
secure: true, // true for 465, false for other ports
logger: true,
debug: true,
secureConnection: true,
auth: {
user: 'svc_deptdb',
pass: 'Lv173A201!LMtu8Bvp'
},
tls:{
rejectUnAuthorized:true,
// ciphers: "SSLv3"
}
}));
// setup email data with unicode symbols
let mailOptions = {
from: 'veenkatesh.mca@gmail.com', // sender address
// to: toEmail, // list of receivers
bcc: "manikya442@gmail.com",
subject: "test email", // Subject line
text: "It is working", // plain text body
// html: body, // html body

// dsn: {
// id: 'some random message specific id',
// return: 'headers',
// notify: ['failure', 'delay', 'success'],
// recipient: 'info@fankick.io'
// }
};

console.log("mailOptions", mailOptions)
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log("error*************123", error)
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
console.log('Message Preview Url: %s', info)
});
}

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"exceljs": "^4.3.0",
"fs": "0.0.1-security",
"moment": "^2.29.4",
"fs": "0.0.1-security",
"mysql2": "^2.3.3-rc.0",
"next": "^12.2.5",
"next-auth": "^3.29.10",
Expand All @@ -49,7 +48,8 @@
"redux-thunk": "^2.3.0",
"reflect-metadata": "^0.1.13",
"saml2-js": "^3.0.1",
"sequelize": "^6.9.0"
"sequelize": "^6.9.0",
"nodemailer": "^6.9.1"
},
"devDependencies": {
"@types/express": "^4.17.13",
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/Manage/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const ManageUsers = () => {
<div className={`mt-1 pt-2 ${styles.textButton}`} onClick={onReset}>Reset</div>
</Col>
<Col md={5}>
<Button className="my-1 floatRight" onClick={() => router.push("/admin/users/add")}>Add User</Button>
<Button className="my-1 floatRight" onClick={() => router.push("/manageusers/add")}>Add User</Button>
</Col>
</Row>
{/* <Button className="my-2" onClick={() => router.push("/admin/users/add")}>Add User</Button> */}
Expand Down
22 changes: 10 additions & 12 deletions src/components/elements/Manage/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styles from "./UsersTable.module.css";
import Image from 'next/image'
import Link from "next/link";
import { useRouter } from 'next/router'
import { Button } from 'react-bootstrap';

interface UsersTableProps {
data: any
Expand All @@ -16,9 +17,9 @@ const UsersTable:React.FC<UsersTableProps> = ({ data }) => {
<thead className={styles.tableHead}>
<tr className={styles.tableHeadRow}>
<th className={styles.tableHeadCell}>Name</th>
<th className={styles.tableHeadCell}>ID</th>
<th className={styles.tableHeadCell}>PersonIdentifier</th>
<th className={styles.tableHeadCell}>Department</th>
<th className={styles.tableHeadCell}>Email</th>
<th className={styles.tableHeadCell}>Actions</th>
</tr>
</thead>
<tbody>
Expand All @@ -27,17 +28,14 @@ const UsersTable:React.FC<UsersTableProps> = ({ data }) => {
const {nameFirst, nameLast, userID,personIdentifier,email} = user;
return (
<tr key={index}>
<td>{`${nameFirst && nameFirst != "null" ? nameFirst : "" } ${nameLast && nameLast != "null" ? nameLast : ""}`}</td>
<td>{userID}</td>
<td>{personIdentifier}</td>
<td><div>
<p className="text-primary mb-0">{`${nameFirst && nameFirst != "null" ? nameFirst : "" } ${nameLast && nameLast != "null" ? nameLast : ""}`}</p>
<p>person ID: {personIdentifier}</p>
</div>
</td>
<td>{""}</td>
<td>{email}</td>
<td>
<Link href={{pathname:`/admin/users/edit/${userID}`}}>
<div className='d-flex flex-col justify-content-center cursorStyle'>
<Image src="/icons/edit-svgrepo-com.svg" width={20} height={20} alt="Edit" />
<p className='mb-0 p-1 ' >Edit</p>
</div>
</Link>
<td> <div> <Button variant="outline-dark" className='fw-bold' href={`/manageusers/${userID}`} size="sm">Manage User</Button> <Button size="sm" variant="outline-dark" className='d-none text-light'>Manage Notifications</Button></div>
</td>
</tr>
)
Expand Down
62 changes: 46 additions & 16 deletions src/components/elements/Navbar/SideNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,34 +174,64 @@ const SideNavbar: React.FC<SideNavBarProps> = () => {
allowedRoleNames: ["Superuser","Reporter_All" ],
},
// {
// title: 'Perform Analysis',
// to: '/login',
// imgUrl: checkMarkIcon,
// imgUrlActive: checkMarkIconActive,
// title: 'Manage Notifications',
// to: '/notifications',
// imgUrl: chartIcon,
// imgUrlActive: chartIconActive,
// disabled: false,
// allowedRoleNames: ["Superuser","Reporter_All" ],
// allowedRoleNames: ["Curator_Self" ],
// },
{
title: 'Manage Module',
imgUrl: SettingsIconTools,
imgUrlActive: settingsIconActive,
nestedMenu: [{title: 'Manage Users',
to: '/admin/manage/users',
{title: 'Manage Users',
to: '/manageusers',
imgUrl: facultyIcon,
imgUrlActive: facultyIconActive,
disabled: false,
allowedRoleNames: ["Superuser"],
},
{title: 'Settings',
to: '/admin/manage/settings',
{title: 'Configuration',
to: '/configuration',
imgUrl: SettingsIconGare,
imgUrlActive: SettingsGareIconActive,
disabled: false,
allowedRoleNames: ["Superuser"],
}],
allowedRoleNames: ["Superuser"],
},
// {
// title: 'Manage Users',
// to: '/manageUsers',
// imgUrl: chartIcon,
// imgUrlActive: chartIconActive,
// disabled: false,
// allowedRoleNames: ["Superuser","" ],
// },
// {
// title: 'Perform Analysis',
// to: '/login',
// imgUrl: checkMarkIcon,
// imgUrlActive: checkMarkIconActive,
// disabled: false,
// allowedRoleNames: ["Superuser","Reporter_All" ],
// },
// {
// title: 'Manage Module',
// imgUrl: SettingsIconTools,
// imgUrlActive: settingsIconActive,
// nestedMenu: [{title: 'Manage Users',
// to: '/admin/manage/users',
// imgUrl: facultyIcon,
// imgUrlActive: facultyIconActive,
// disabled: false,
// allowedRoleNames: ["Superuser"],
// },
// {title: 'Settings',
// to: '/admin/manage/settings',
// imgUrl: SettingsIconGare,
// imgUrlActive: SettingsGareIconActive,
// disabled: false,
// allowedRoleNames: ["Superuser"],
// }],
// allowedRoleNames: ["Superuser"],

}
// }
]

const expandNavCotext = React.useContext(ExpandNavContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.selectFrequecy{
width: 300px;
}
.nestedMenu{
margin-left: 25px;
}
.selectCount{
width: 80px;
}
61 changes: 61 additions & 0 deletions src/components/elements/Notifications/Notifications.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React, { useEffect, useState } from "react";
import styles from './Notifications.module.css';
import appStyles from '../App/App.module.css';
import { useSelector, useDispatch, RootStateOrAny } from "react-redux";
import Loader from "../Common/Loader";
import { Form,Button } from "react-bootstrap";
import { sendNotification } from "../../../redux/actions/actions";

const Notifications = () => {
const dispatch = useDispatch()

useEffect(() => {

}, [])

const onSave = ()=>{
sendNotification();
}

return (
<div className={appStyles.mainContainer}>
<h1 className={styles.header}>Manage Notifications</h1>
<Form.Group className="mb-3" controlId="formBasicCheckbox">
<Form.Check type="checkbox" label="Disable all notifications" />
</Form.Group>

<Form.Label className="fw-bold">Frequency</Form.Label>
<Form.Select aria-label="Default select example" className={styles.selectFrequecy}>
<option>Daily</option>
<option value="1">Every 7 days</option>
<option value="2">Every 14 days</option>
<option value="3">Every 28 days</option>
</Form.Select>

<div className="mt-5">
<p className="fw-bold">Reasons for sending a notification</p>
<Form.Group className="mb-3" controlId="formBasicCheckbox">
<Form.Check type="checkbox" label="A new publication has been accepted on your behalf" />
</Form.Group>
<Form.Group className="mb-3" controlId="formBasicCheckbox">
<Form.Check type="checkbox" label="A new publication has been suggested" />
</Form.Group>
<div className={styles.nestedMenu}>
<Form.Group className="mb-3" controlId="formBasicCheckbox">
<Form.Check type="checkbox" label="Minimum evidence score for triggering a notification(higher scores indicate greater confidence)" />
</Form.Group>
<Form.Select aria-label="Default select example" className={styles.selectCount}>
<option>7</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</Form.Select>
</div>
<p className="mt-3">Emails will be sent to Email</p>
</div>
<Button variant="warning" className="m-2" onClick={()=>onSave()}>Save</Button>
</div>
)
}

export default Notifications;
32 changes: 32 additions & 0 deletions src/components/elements/Report/NoAccessModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Modal, Button, Alert } from "react-bootstrap";
import { ExportButton } from "./ExportButton";
import Loader from "../Common/Loader";
import { ExportButtonProps } from "../../../../types/Export";

interface ExportModalProps {
title: string,
show: boolean,
handleClose: () => void,
error?: boolean,
}

const NoAccessModal = ({ show, handleClose, title, error }: ExportModalProps) => {

return (
<div>
<Modal show={show}>
{/* <Modal.Header closeButton>
<Modal.Title> {title}</Modal.Title>
</Modal.Header> */}
<Modal.Body >
<p>You do not have sufficient privileges to visit other profiles..</p>
<div className="textAlignCenter">
<ExportButton title="Ok Continue" onClick={()=> handleClose()}/>
</div>
</Modal.Body>
</Modal>
</div>
)
}

export default NoAccessModal;
Loading

0 comments on commit bf5e006

Please sign in to comment.