Skip to content

Commit

Permalink
Continuing correction process to upload system to ensure it's working…
Browse files Browse the repository at this point in the history
… correctly. Working on adding a wrapper function to encase use cases for the DataGridCommons to make applying it to tables easier -- currently, implementations for the attributes, personnel, quadrats tables, etc, require an extensive amount of duplication to build out and thus make modifications and updates trickier. Continuing structural shift of validation system to be app-side and modular to better facilitate CRUD maintenance system.
  • Loading branch information
siddheshraze committed Aug 20, 2024
1 parent 649404d commit 63a9017
Show file tree
Hide file tree
Showing 38 changed files with 413 additions and 868 deletions.
5 changes: 3 additions & 2 deletions frontend/app/(hub)/fixeddatainput/attributes/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AttributesDataGrid from '@/components/datagrids/applications/attributesdatagrid';
import AttributesWrappedDataGrid from '@/components/datagrids/wrapped/attributeswrappedgrid';

export default function AttributesPage() {
return <AttributesDataGrid />;
// return <AttributesDataGrid />;
return <AttributesWrappedDataGrid />;
}
4 changes: 1 addition & 3 deletions frontend/app/(hub)/fixeddatainput/census/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import CensusDataGrid from '@/components/datagrids/applications/censusdatagrid';

export default function CensusPage() {
return <CensusDataGrid />;
return <></>;
}
5 changes: 3 additions & 2 deletions frontend/app/(hub)/fixeddatainput/personnel/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PersonnelDataGrid from '@/components/datagrids/applications/personneldatagrid';
import PersonnelWrappedDataGrid from '@/components/datagrids/wrapped/personnelwrappedgrid';

export default function PersonnelPage() {
return <PersonnelDataGrid />;
// return <PersonnelDataGrid />;
return <PersonnelWrappedDataGrid />;
}
5 changes: 3 additions & 2 deletions frontend/app/(hub)/fixeddatainput/quadrats/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import QuadratsDataGrid from '@/components/datagrids/applications/quadratsdatagrid';
import QuadratsWrappedDataGrid from '@/components/datagrids/wrapped/quadratswrappedgrid';

export default function QuadratsPage() {
return <QuadratsDataGrid />;
// return <QuadratsDataGrid />;
return <QuadratsWrappedDataGrid />;
}
32 changes: 20 additions & 12 deletions frontend/app/api/fixeddata/[dataType]/[[...slugs]]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ export async function GET(
AND c.PlotCensusNumber = ? LIMIT ?, ?;`;
queryParams.push(plotID, plotID, plotCensusNumber, page * pageSize, pageSize);
break;
case 'personnelrole':
paginatedQuery = `
SELECT SQL_CALC_FOUND_ROWS
p.PersonnelID,
p.CensusID,
p.FirstName,
p.LastName,
r.RoleID,
r.RoleName,
r.RoleDescription
FROM
personnel p
LEFT JOIN
roles r ON p.RoleID = r.RoleID
census c ON p.CensusID = c.CensusID
WHERE c.PlotID = ? AND c.PlotCensusNumber = ? LIMIT ?, ?;`;
queryParams.push(plotID, plotCensusNumber, page * pageSize, pageSize);
break;
case 'measurementssummary':
case 'measurementssummaryview':
case 'viewfulltable':
Expand Down Expand Up @@ -332,25 +350,15 @@ export async function DELETE(request: NextRequest, { params }: { params: { dataT
const { [viewConfig.primaryKey]: primaryKeyValue } = deleteRowData;
if (!primaryKeyValue) throw new Error(`Primary key value missing for ${viewConfig.primaryKey} in view ${params.dataType}`);

const deleteQuery = format(
`DELETE
FROM ? ?
WHERE ?? = ?`,
[`${schema}.${viewConfig.table}`, viewConfig.primaryKey, primaryKeyValue]
);
const deleteQuery = `DELETE FROM ${schema}.${viewConfig.table} WHERE ${viewConfig.primaryKey} = ${primaryKeyValue}`;
await runQuery(conn, deleteQuery);
await conn.commit();
return NextResponse.json({ message: 'Delete successful' }, { status: HTTPResponses.OK });
}
// Handle deletion for tables
const deleteRowData = MapperFactory.getMapper<any, any>(params.dataType).demapData([newRow])[0];
const { [demappedGridID]: gridIDKey } = deleteRowData;
const deleteQuery = format(
`DELETE
FROM ? ?
WHERE ?? = ?`,
[`${schema}.${params.dataType}`, demappedGridID, gridIDKey]
);
const deleteQuery = `DELETE FROM ${schema}.${params.dataType} WHERE ${demappedGridID} = ${gridIDKey}`;
await runQuery(conn, deleteQuery);
await conn.commit();
return NextResponse.json({ message: 'Delete successful' }, { status: HTTPResponses.OK });
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/client/datagridcolumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const quadratGridColumns: GridColDef[] = [
},
{
field: 'coordinateUnits',
headerName: 'Unit',
headerName: 'Coordinate Units',
headerClassName: 'header',
flex: 1,
renderHeader: () => formatHeader('Coordinate', 'Units'),
Expand All @@ -92,7 +92,7 @@ export const quadratGridColumns: GridColDef[] = [
},
{
field: 'areaUnits',
headerName: 'Unit',
headerName: 'Area Unit',
headerClassName: 'header',
flex: 1,
renderHeader: () => formatHeader('Area', 'Unit'),
Expand Down Expand Up @@ -125,7 +125,7 @@ export const quadratGridColumns: GridColDef[] = [
},
{
field: 'dimensionUnits',
headerName: 'Unit',
headerName: 'Dimension Unit',
headerClassName: 'header',
flex: 1,
renderHeader: () => formatHeader('Dimension', 'Unit'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useSession } from 'next-auth/react';
import UploadParentModal from '@/components/uploadsystemhelpers/uploadparentmodal';
import { AllTaxonomiesViewGridColumns } from '@/components/client/datagridcolumns';
import { initialAllTaxonomiesViewRDSRow } from '@/config/sqlrdsdefinitions/views/alltaxonomiesviewrds';
import { FormType } from '@/config/macros/formdetails';

export default function AllTaxonomiesViewDataGrid() {
const [rows, setRows] = useState([initialAllTaxonomiesViewRDSRow] as GridRowsProp);
Expand Down Expand Up @@ -77,7 +78,7 @@ export default function AllTaxonomiesViewDataGrid() {
setIsUploadModalOpen(false);
setRefresh(true);
}}
formType={'species'}
formType={FormType.species}
/>

<DataGridCommons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useSession } from 'next-auth/react';
import UploadParentModal from '@/components/uploadsystemhelpers/uploadparentmodal';
import { useOrgCensusContext } from '@/app/contexts/userselectionprovider';
import { AttributeGridColumns } from '@/components/client/datagridcolumns';
import { FormType } from '@/config/macros/formdetails';

export default function AttributesDataGrid() {
const [rows, setRows] = useState([initialAttributesRDSRow] as GridRowsProp);
Expand Down Expand Up @@ -74,7 +75,7 @@ export default function AttributesDataGrid() {
setIsUploadModalOpen(false);
setRefresh(true);
}}
formType={'attributes'}
formType={FormType.attributes}
/>

<DataGridCommons
Expand Down
199 changes: 0 additions & 199 deletions frontend/components/datagrids/applications/censusdatagrid.tsx

This file was deleted.

Loading

0 comments on commit 63a9017

Please sign in to comment.