From eb7cd6b268c296c8ae758facdcff03b3e1235fe7 Mon Sep 17 00:00:00 2001 From: JBlixems Date: Tue, 20 Aug 2024 20:58:51 +0200 Subject: [PATCH 1/3] Add demo 3 video to readme --- .github/workflows/deploy.yml | 2 ++ README.md | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7382d0e..5e4ef9b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,6 +7,7 @@ jobs: publish-containers: runs-on: ubuntu-latest timeout-minutes: 20 + if: github.head_ref != 'documentation' steps: - name: Checkout uses: actions/checkout@v2 @@ -87,6 +88,7 @@ jobs: deploy-containers: runs-on: ubuntu-latest timeout-minutes: 10 + if: github.head_ref != 'documentation' needs: publish-containers steps: - name: Deploy using ssh diff --git a/README.md b/README.md index 54cdef4..90d637b 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ The CoVAR project by BlueVision ITM aims to develop a comprehensive vulnerabilit ## Demos * [Demo 1 Video](https://drive.google.com/file/d/18-8LR9x710CWpvD0dDpWLcKnwXGHsy_M/view?usp=sharing) * [Demo 2 Video](https://drive.google.com/file/d/1Dpynfe4pK_SkFPkS9EYfpClK6Z_cxYXn/view?usp=sharing) +* [Demo 3 Video](https://drive.google.com/file/d/1Njv7EX8lYqedBnqkF562axwaYqV2sQBU/view?usp=sharing) ## Documentation * [Requirements and Design (SRS) Document](https://docs.google.com/document/d/1rhLhNdHQONaVFSU4WyOLPm6ZoKlxLMqk/edit?usp=sharing&ouid=112929114105055327648&rtpof=true&sd=true) From 0f82a35fefd26c8ce2b7bd71ae672cd520a324c5 Mon Sep 17 00:00:00 2001 From: JBlixems Date: Tue, 20 Aug 2024 20:58:51 +0200 Subject: [PATCH 2/3] Add demo 3 video to readme --- .github/workflows/deploy.yml | 2 ++ README.md | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7382d0e..de69b2a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,6 +7,7 @@ jobs: publish-containers: runs-on: ubuntu-latest timeout-minutes: 20 + if: ${{ !contains(github.event.head_commit.message, 'from COS301-SE-2024/documentation') }} steps: - name: Checkout uses: actions/checkout@v2 @@ -87,6 +88,7 @@ jobs: deploy-containers: runs-on: ubuntu-latest timeout-minutes: 10 + if: ${{ !contains(github.event.head_commit.message, 'from COS301-SE-2024/documentation') }} needs: publish-containers steps: - name: Deploy using ssh diff --git a/README.md b/README.md index 54cdef4..90d637b 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ The CoVAR project by BlueVision ITM aims to develop a comprehensive vulnerabilit ## Demos * [Demo 1 Video](https://drive.google.com/file/d/18-8LR9x710CWpvD0dDpWLcKnwXGHsy_M/view?usp=sharing) * [Demo 2 Video](https://drive.google.com/file/d/1Dpynfe4pK_SkFPkS9EYfpClK6Z_cxYXn/view?usp=sharing) +* [Demo 3 Video](https://drive.google.com/file/d/1Njv7EX8lYqedBnqkF562axwaYqV2sQBU/view?usp=sharing) ## Documentation * [Requirements and Design (SRS) Document](https://docs.google.com/document/d/1rhLhNdHQONaVFSU4WyOLPm6ZoKlxLMqk/edit?usp=sharing&ouid=112929114105055327648&rtpof=true&sd=true) From 4b3d808192bc894d6f77a81d62fdee5f8ccec853 Mon Sep 17 00:00:00 2001 From: A Repko Date: Sat, 28 Sep 2024 17:00:43 +0200 Subject: [PATCH 3/3] Added invite list to admin dashboard --- .../dashboard/components/InviteList.tsx | 56 +++++++++++++++ .../dashboard/components/adminPage.tsx | 68 +++++++++---------- CoVAR-app/src/functions/requests.tsx | 11 +++ langchain/requirements.txt | 3 +- server/routes/invites.js | 29 ++++++-- 5 files changed, 125 insertions(+), 42 deletions(-) create mode 100644 CoVAR-app/src/app/(pages)/dashboard/components/InviteList.tsx diff --git a/CoVAR-app/src/app/(pages)/dashboard/components/InviteList.tsx b/CoVAR-app/src/app/(pages)/dashboard/components/InviteList.tsx new file mode 100644 index 0000000..a5b5b0f --- /dev/null +++ b/CoVAR-app/src/app/(pages)/dashboard/components/InviteList.tsx @@ -0,0 +1,56 @@ +'use client'; +import React, { useEffect, useState } from 'react'; +import { Paper, Typography, Box, CircularProgress, List, ListItem, ListItemText } from '@mui/material'; +import { fetchAllInvites } from '@/functions/requests'; + +type Invite = { + invite_id: string; + username: string; + organization_name: string; + invite_status: string; +}; + +const InviteList: React.FC = () => { + const [invites, setInvites] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const loadInvites = async () => { + try { + const token = localStorage.getItem('accessToken'); + const invites = await fetchAllInvites(token as string); + setInvites(invites); + setLoading(false); + } catch (error) { + console.error('Error fetching invites:', error); + setLoading(false); + } + }; + + loadInvites(); + }, []); + + return ( + + Pending Invites + {loading ? ( + + ) : invites.length === 0 ? ( + No pending invites at the moment. + ) : ( + + {invites.map((invite) => ( + + + + ))} + + )} + + ); +}; + +export default InviteList; diff --git a/CoVAR-app/src/app/(pages)/dashboard/components/adminPage.tsx b/CoVAR-app/src/app/(pages)/dashboard/components/adminPage.tsx index 558ebf2..de242b9 100644 --- a/CoVAR-app/src/app/(pages)/dashboard/components/adminPage.tsx +++ b/CoVAR-app/src/app/(pages)/dashboard/components/adminPage.tsx @@ -10,6 +10,8 @@ import { Height } from '@mui/icons-material'; import { mainContentStyles } from '@/styles/sidebarStyle'; import SeverityDistribution from './severityDistribution'; import { chartContainerStyles } from '@/styles/dashboardStyle'; +import InviteList from './InviteList'; // Import the new component + type User = { user_id: string; @@ -160,49 +162,47 @@ const AdminPage: React.FC = () => { { name: 'Clients', value: userMetrics.clients }, ]; - return ( - - - - - User Metrics - - - - - - Total Users: {userMetrics.total} - Admins: {userMetrics.admins} - VAs: {userMetrics.vas} - Clients: {userMetrics.clients} - + return ( + + + + User Metrics + + + + + Total Users: {userMetrics.total} + Admins: {userMetrics.admins} + VAs: {userMetrics.vas} + Clients: {userMetrics.clients} + + + Role Distribution - - - - - - - Unauthorised Users (Last Week) - - + + + + + + + + Unauthorised Users (Last Week) + + {loading ? ( ) : ( - - row.user_id} - sx = {{...dataGridStyles, - height : '50vh' - }} - /> + row.user_id} + sx={{ ...dataGridStyles, height: '50vh' }} + /> )} { }; return await handleRequest(request); }; + + +// Function to fetch all invites +export const fetchAllInvites = async (accessToken: string) => { + const request = { + method: 'get', + url: `/api/invites`, + headers: { Authorization: `Bearer ${accessToken}` }, + }; + return await handleRequest(request); +}; diff --git a/langchain/requirements.txt b/langchain/requirements.txt index 486b3b5..a92d38e 100644 --- a/langchain/requirements.txt +++ b/langchain/requirements.txt @@ -9,4 +9,5 @@ requests python-dotenv openai PyJWT -cryptography \ No newline at end of file +cryptography +gunicorn \ No newline at end of file diff --git a/server/routes/invites.js b/server/routes/invites.js index 1a65236..39cd5a3 100644 --- a/server/routes/invites.js +++ b/server/routes/invites.js @@ -1,12 +1,9 @@ const express = require('express'); - -const { authenticateToken} = require('../lib/securityFunctions'); - +const { authenticateToken } = require('../lib/securityFunctions'); const pgClient = require('../lib/postgres'); - const router = express.Router(); -// Fetch invites for a user +// Fetch invites for a specific user router.get('/invites/:username', authenticateToken, async (req, res) => { const { username } = req.params; @@ -19,7 +16,7 @@ router.get('/invites/:username', authenticateToken, async (req, res) => { const userId = userResult.rows[0].user_id; - // Fetch invites for the user + // Fetch pending invites for the user const invitesQuery = ` SELECT i.invite_id, o.name as organization_name, i.invite_status FROM organization_invites i @@ -82,5 +79,23 @@ router.patch('/invites/:inviteId/reject', authenticateToken, async (req, res) => } }); +// Fetch all invites +router.get('/invites', authenticateToken, async (req, res) => { + try { + const invitesQuery = ` + SELECT i.invite_id, u.username, o.name as organization_name, i.invite_status + FROM organization_invites i + JOIN organizations o ON i.organization_id = o.organization_id + JOIN users u ON i.user_id = u.user_id + `; + const invitesResult = await pgClient.query(invitesQuery); + + res.json(invitesResult.rows); + } catch (err) { + console.error(err.message); + res.status(500).send('Server Error'); + } +}); + -module.exports = router; \ No newline at end of file +module.exports = router;