Skip to content

Commit

Permalink
debugging. minor changes to remove or disable features that shouldn't…
Browse files Browse the repository at this point in the history
… be accessible to the user yet since they're in development. Slightly rework of the monaco editing system to ensure it works with updated NextJS version. (#178)
  • Loading branch information
siddheshraze authored Oct 2, 2024
1 parent ed90d90 commit bcb7258
Show file tree
Hide file tree
Showing 10 changed files with 13,129 additions and 12,670 deletions.
11 changes: 11 additions & 0 deletions frontend/app/(hub)/measurementshub/validations/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ export default function ValidationsPage() {
fetchValidations().catch(console.error); // Initial load
}, []);

useEffect(() => {
if (typeof window !== 'undefined') {
// Set up Monaco Editor worker path
window.MonacoEnvironment = {
getWorkerUrl: function () {
return '_next/static/[name].worker.js';
}
};
}
}, []);

// Fetch schema details when component mounts
useEffect(() => {
const fetchSchema = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ export default function AllTaxonomiesViewDataGrid() {
editable: true
},
{
field: 'genusAuthority',
headerName: 'Genus Auth',
renderHeader: () => formatHeader('Genus', 'Authority'),
field: 'speciesName',
headerName: 'Species',
headerClassName: 'header',
flex: 1,
align: 'center',
Expand All @@ -196,8 +195,8 @@ export default function AllTaxonomiesViewDataGrid() {
editable: true
},
{
field: 'speciesName',
headerName: 'Species',
field: 'subspeciesName',
headerName: 'Subspecies',
headerClassName: 'header',
flex: 1,
align: 'center',
Expand All @@ -206,8 +205,9 @@ export default function AllTaxonomiesViewDataGrid() {
editable: true
},
{
field: 'subspeciesName',
headerName: 'Subspecies',
field: 'genusAuthority',
headerName: 'Genus Auth',
renderHeader: () => formatHeader('Genus', 'Authority'),
headerClassName: 'header',
flex: 1,
align: 'center',
Expand Down
133 changes: 77 additions & 56 deletions frontend/components/datagrids/applications/viewfulltabledatagrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,105 @@ import { useSession } from 'next-auth/react';
import { useState } from 'react';
import { ViewFullTableGridColumns } from '@/components/client/datagridcolumns';
import MeasurementsCommons from '@/components/datagrids/measurementscommons';
import { ViewFullTableViewRDS } from '@/config/sqlrdsdefinitions/views';
import { ViewFullTableRDS } from '@/config/sqlrdsdefinitions/views';

export default function ViewFullTableDataGrid() {
const initialViewFullTableViewRDSRow: ViewFullTableViewRDS = {
const initialViewFullTable: ViewFullTableRDS = {
// datagrid
id: 0,

// IDs
coreMeasurementID: 0,
plotID: 0,
PlotDimensionUnits: '',
attributeCode: '',
attributeDescription: '',
attributeStatus: '',
censusDescription: '',
censusEndDate: undefined,
censusID: 0,
censusStartDate: undefined,
countryName: '',
dbhUnits: '',
description: '',
dimensionX: 0,
dimensionY: 0,
family: '',
familyID: 0,
firstName: '',
genus: '',
genusAuthority: '',
quadratID: 0,
treeID: 0,
stemID: 0,
personnelID: 0,
speciesID: 0,
genusID: 0,
familyID: 0,

// coremeasurements
measurementDate: undefined,
measuredDBH: 0,
dbhUnits: '',
measuredHOM: 0,
homUnits: '',
idLevel: '',
description: '',
isValidated: false,
lastName: '',

// plots
plotName: '',
locationName: '',
measuredDBH: 0,
measuredHOM: 0,
measurementDate: undefined,
personnelID: 0,
personnelRoles: '',
countryName: '',
dimensionX: 0,
dimensionY: 0,
plotDimensionUnits: '',
plotArea: 0,
plotAreaUnits: '',
plotCensusNumber: 0,
plotCoordinateUnits: '',
plotDescription: '',
plotGlobalX: 0,
plotGlobalY: 0,
plotGlobalZ: 0,
plotName: '',
plotCoordinateUnits: '',
plotShape: '',
quadratArea: 0,
quadratAreaUnits: '',
quadratCoordinateUnits: '',
quadratDimensionUnits: '',
plotDescription: '',

// census
censusStartDate: undefined,
censusEndDate: undefined,
censusDescription: '',
plotCensusNumber: 0,

// quadrats
quadratName: '',
quadratDimensionX: 0,
quadratDimensionY: 0,
quadratID: 0,
quadratName: '',
quadratShape: '',
quadratDimensionUnits: '',
quadratArea: 0,
quadratAreaUnits: '',
quadratStartX: 0,
quadratStartY: 0,
speciesCode: '',
speciesID: 0,
speciesName: '',
stemCoordinateUnits: '',
stemID: 0,
quadratCoordinateUnits: '',
quadratShape: '',

// trees
treeTag: '',

// stems
stemTag: '',
stemLocalX: 0,
stemLocalY: 0,
stemTag: '',
subquadratCoordinateUnits: '',
subquadratDimensionUnits: '',
subquadratDimensionX: 0,
subquadratDimensionY: 0,
subquadratID: 0,
subquadratName: '',
subquadratX: 0,
subquadratY: 0,
subspeciesAuthority: '',
stemCoordinateUnits: '',

// personnel
firstName: '',
lastName: '',

// roles
personnelRoles: '',

// species
speciesCode: '',
speciesName: '',
subspeciesName: '',
treeID: 0,
treeTag: ''
subspeciesAuthority: '',
idLevel: '',

// genus
genus: '',
genusAuthority: '',

// family
family: '',

// attributes
attributeCode: '',
attributeDescription: '',
attributeStatus: ''
};
const [rows, setRows] = useState<GridRowsProp>([initialViewFullTableViewRDSRow] as GridRowsProp);

const [rows, setRows] = useState<GridRowsProp>([initialViewFullTable] as GridRowsProp);
const [rowCount, setRowCount] = useState(0);
const [rowModesModel, setRowModesModel] = useState({});
const [snackbar, setSnackbar] = useState<Pick<AlertProps, 'children' | 'severity'> | null>(null);
Expand All @@ -103,7 +123,7 @@ export default function ViewFullTableDataGrid() {
const addNewRowToGrid = () => {
const id = randomId();
const newRow = {
...initialViewFullTableViewRDSRow,
...initialViewFullTable,
id,
isNew: true
};
Expand All @@ -115,6 +135,7 @@ export default function ViewFullTableDataGrid() {
}));
console.log('viewfulltableview addnewrowtogrid triggered');
};
console.log('viewfulltable: ', ViewFullTableGridColumns);

return (
<>
Expand Down
8 changes: 4 additions & 4 deletions frontend/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function MenuRenderToggle(
const currentCensus = useOrgCensusContext();
return (
<ListItemButton
disabled={plotSelectionRequired || censusSelectionRequired}
disabled={plotSelectionRequired || censusSelectionRequired || siteConfigProps.href === '/postvalidation'}
color={pathname === siteConfigProps.href ? 'primary' : undefined}
onClick={() => {
if (setMenuOpen) {
Expand Down Expand Up @@ -893,7 +893,6 @@ export default function Sidebar(props: SidebarProps) {
const isDataIncomplete = shouldApplyTooltip(item, link.href);
const isLinkDisabled = getDisabledState(link.href);
const tooltipMessage = getTooltipMessage(link.href, isDataIncomplete || (link.href === '/summary' && !isAllValiditiesTrue));

return (
<TransitionComponent key={link.href} in={!!toggle} style={{ transitionDelay: `${delay}ms` }} direction="down">
<ListItem
Expand All @@ -910,9 +909,10 @@ export default function Sidebar(props: SidebarProps) {
sx={{ flex: 1, width: '100%' }}
selected={pathname == item.href + link.href}
color={pathname === item.href ? 'primary' : undefined}
disabled={isLinkDisabled}
disabled={isLinkDisabled || link.href === '/postvalidation'}
// post-validation endpoint is not yet ready for production use!
onClick={() => {
if (!isLinkDisabled) {
if (!isLinkDisabled || link.href !== '/postvalidation') {
router.push(item.href + link.href);
}
}}
Expand Down
2 changes: 1 addition & 1 deletion frontend/config/datagridhelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const columnVisibilityMap: { [key: string]: { [key: string]: boolean } } = {
default: {
id: false
},
viewfulltableview: {
viewfulltable: {
id: false,
...getAllViewFullTableViewsHCs()
},
Expand Down
6 changes: 3 additions & 3 deletions frontend/config/datamapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
MeasurementsSummaryResult,
StemTaxonomiesViewRDS,
StemTaxonomiesViewResult,
ViewFullTableViewRDS,
ViewFullTableViewResult
ViewFullTableRDS,
ViewFullTableResult
} from '@/config/sqlrdsdefinitions/views';
import {
SiteSpecificValidationsRDS,
Expand Down Expand Up @@ -229,7 +229,7 @@ class MapperFactory {
return new GenericMapper<SiteSpecificValidationsRDS, SiteSpecificValidationsResult>() as unknown as IDataMapper<RDS, Result>;
case 'viewfulltable':
case 'viewfulltableview':
return new GenericMapper<ViewFullTableViewRDS, ViewFullTableViewResult>() as unknown as IDataMapper<RDS, Result>;
return new GenericMapper<ViewFullTableRDS, ViewFullTableResult>() as unknown as IDataMapper<RDS, Result>;
default:
throw new Error('Mapper not found for type: ' + type);
}
Expand Down
Loading

0 comments on commit bcb7258

Please sign in to comment.