Skip to content

Commit

Permalink
Merge branch 'main' into forestgeo-app-development
Browse files Browse the repository at this point in the history
  • Loading branch information
siddheshraze authored Feb 3, 2025
2 parents 3690d04 + 214cc6e commit 85fc22c
Show file tree
Hide file tree
Showing 11 changed files with 464 additions and 41 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/main-forestgeo-livesite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Node.js version
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.4
with:
node-version: '18.x'
node-version: '20.x'

- name: create env file (in frontend/ directory) -- production
id: create-env-file-prod
Expand All @@ -41,28 +41,28 @@ jobs:
echo AZURE_SQL_CATALOG_SCHEMA=${{ secrets.AZURE_SQL_CATALOG_SCHEMA }} >> frontend/.env
echo AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} >> frontend/.env
echo NEXTAUTH_DEBUG=true >> frontend/.env
echo NODE_ENV=production >> frontend/.env
echo NODE_ENV=development >> frontend/.env
echo PORT=3000 >> frontend/.env
echo FG_PAT=${{ secrets.FG_PAT }} >> frontend/.env
echo OWNER=${{ secrets.OWNER }} >> frontend/.env
echo REPO=${{ secrets.REPO }} >> frontend/.env
- name: Cache node modules
uses: actions/cache@v2
with:
path: frontend/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache Next.js build
uses: actions/cache@v2
with:
path: frontend/.next/cache
key: ${{ runner.os }}-next-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/.next/cache') }}
restore-keys: |
${{ runner.os }}-next-
${{ runner.os }}-next-${{ hashFiles('**/package-lock.json') }}
# - name: Cache node modules
# uses: actions/cache@v2
# with:
# path: frontend/node_modules
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
#
# - name: Cache Next.js build
# uses: actions/cache@v2
# with:
# path: frontend/.next/cache
# key: ${{ runner.os }}-next-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/.next/cache') }}
# restore-keys: |
# ${{ runner.os }}-next-
# ${{ runner.os }}-next-${{ hashFiles('**/package-lock.json') }}

- name: move into frontend --> npm install, build, and test
run: |
Expand Down
3 changes: 3 additions & 0 deletions frontend/app/(hub)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { useEffect, useState } from 'react';
import { UnifiedChangelogRDS } from '@/config/sqlrdsdefinitions/core';
import moment from 'moment';
import Avatar from '@mui/joy/Avatar';
import { useLoading } from '@/app/contexts/loadingprovider';

export default function DashboardPage() {
const { triggerPulse, isPulsing } = useLockAnimation();
Expand All @@ -43,6 +44,8 @@ export default function DashboardPage() {
const userRole = session?.user?.userStatus;
const allowedSites = session?.user?.sites;

const { setLoading } = useLoading();

const [changelogHistory, setChangelogHistory] = useState<UnifiedChangelogRDS[]>(Array(5));
const [isLoading, setIsLoading] = useState(false);

Expand Down
4 changes: 2 additions & 2 deletions frontend/components/client/datagridcolumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export const MeasurementsSummaryViewGridColumns: GridColDef[] = standardizeGridC
editable: true
},
{
field: 'stemLocalX',
field: 'localX',
headerName: 'X',
renderHeader: () => formatHeader('X', 'Stem'),
flex: 0.7,
Expand All @@ -380,7 +380,7 @@ export const MeasurementsSummaryViewGridColumns: GridColDef[] = standardizeGridC
filterOperators: customNumericOperators
},
{
field: 'stemLocalY',
field: 'localY',
headerName: 'Y',
renderHeader: () => formatHeader('Y', 'Stem'),
flex: 0.7,
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/datagrids/applications/msvdatagrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default function MeasurementsSummaryViewDataGrid() {
const currentPlot = usePlotContext();
const currentCensus = useOrgCensusContext();
const currentSite = useSiteContext();
const { setLoading } = useLoading();
const [isUploadModalOpen, setIsUploadModalOpen] = useState(false);
const [isManualEntryFormOpen, setIsManualEntryFormOpen] = useState(false);
const [triggerGlobalError, setTriggerGlobalError] = useState(false);
Expand All @@ -63,6 +62,7 @@ export default function MeasurementsSummaryViewDataGrid() {
});
const [isNewRowAdded, setIsNewRowAdded] = useState<boolean>(false);
const [shouldAddRowAfterFetch, setShouldAddRowAfterFetch] = useState(false);
const { setLoading } = useLoading();

const addNewRowToGrid = () => {
const id = randomId();
Expand Down
133 changes: 133 additions & 0 deletions frontend/components/validationcard_cardmodal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
'use client';

import React, { useState } from 'react';
import { Box, Button, Card, Modal, Stack, Switch, Typography } from '@mui/joy';
import { ValidationProceduresRDS } from '@/config/sqlrdsdefinitions/validations';
import dynamic from 'next/dynamic';

type ValidationCardProps = {
validation: ValidationProceduresRDS;
onSaveChanges: (validation: ValidationProceduresRDS) => Promise<void>;
onDelete: (validationID?: number) => Promise<void>;
schemaDetails: { table_name: string; column_name: string }[];
};

const ValidationCard: React.FC<ValidationCardProps> = ({ validation, onSaveChanges, onDelete, schemaDetails }) => {
const [isFlipped, setIsFlipped] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);
const [scriptContent, setScriptContent] = useState(validation.definition);
const CustomMonacoEditor = dynamic(() => import('@/components/client/custommonacoeditor'), { ssr: false });

const handleCardClick = () => {
setIsFlipped(true);
setIsModalOpen(true);
};

const handleCloseModal = async () => {
setIsModalOpen(false);
setTimeout(() => setIsFlipped(false), 300); // Delay for smooth flip-back animation
};

const handleSaveChanges = async () => {
const updatedValidation = { ...validation, definition: scriptContent };
await onSaveChanges(updatedValidation);
await handleCloseModal();
};

return (
<Box sx={{ position: 'relative', width: 300, minHeight: 200 }}>
<Card
variant="outlined"
onClick={handleCardClick}
sx={{
width: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
padding: 2,
cursor: 'pointer',
transform: isFlipped ? 'rotateY(180deg)' : 'rotateY(0)',
transition: 'transform 0.6s',
perspective: 1000,
minHeight: 'inherit',
overflow: 'auto'
}}
>
<Stack direction="row" justifyContent="space-between" alignItems="flex-start">
<Box sx={{ flexGrow: 1 }}>
<Typography
level="h4"
sx={{
fontWeight: 'bold',
fontSize: '1.1rem',
whiteSpace: 'normal',
overflow: 'visible',
wordBreak: 'break-word'
}}
>
{validation.procedureName?.replace(/(DBH|HOM)([A-Z])/g, '$1 $2').replace(/([a-z])([A-Z])/g, '$1 $2')}
</Typography>
<Typography
level="body-sm"
sx={{
color: '#ccc',
fontSize: '0.9rem',
marginTop: 0.5
}}
>
{validation.description}
</Typography>
</Box>
<Switch
checked={validation.isEnabled}
onChange={async e => {
const updatedValidation = { ...validation, isEnabled: e.target.checked };
await onSaveChanges(updatedValidation); // Pass the updated object to the parent
}}
sx={{
marginLeft: 2
}}
onClick={e => e.stopPropagation()}
/>
</Stack>
</Card>
<Modal
open={isModalOpen}
onClose={handleCloseModal}
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
>
<Card
variant="outlined"
sx={{
display: 'flex',
flex: 1,
maxWidth: '50vw',
padding: 4,
maxHeight: '80vh', // Limit the modal height
overflowY: 'auto' // Enable scrolling for the entire modal
}}
>
<CustomMonacoEditor schemaDetails={schemaDetails} content={scriptContent} setContent={setScriptContent} />

<Box sx={{ display: 'flex', justifyContent: 'space-between', marginTop: 2 }}>
<Button variant="solid" onClick={handleSaveChanges}>
Save Changes
</Button>
<Button variant="soft" color="danger" onClick={() => onDelete(validation.validationID)}>
Delete
</Button>
<Button variant="plain" onClick={handleCloseModal}>
Cancel
</Button>
</Box>
</Card>
</Modal>
</Box>
);
};

export default ValidationCard;
Loading

0 comments on commit 85fc22c

Please sign in to comment.