Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(low-prio) Fix console issues + some refactoring #57

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 21 additions & 9 deletions backend/apps/ifc_validation_bff/views_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ def format_request(request):
}


def get_internal_id(public_id):

# try to get intenral id, or None
id = None
try:
id = ValidationRequest.to_private_id(public_id)
except:
pass

return id


#@login_required - doesn't work as OAuth is not integrated with Django
@ensure_csrf_cookie
def me(request):
Expand Down Expand Up @@ -248,8 +260,8 @@ def download(request, id: int):
if not user:
return create_redirect_response(login=True)

logger.debug(f"Locating file for pub='{id}' pk='{ValidationRequest.to_private_id(id)}'")
request = ValidationRequest.objects.filter(created_by__id=user.id, deleted=False, id=ValidationRequest.to_private_id(id)).first()
logger.debug(f"Locating file for pub='{id}' pk='{get_internal_id(id)}'")
request = ValidationRequest.objects.filter(created_by__id=user.id, deleted=False, id=get_internal_id(id)).first()
if request:
file_path = os.path.join(os.path.abspath(MEDIA_ROOT), request.file.name)
logger.debug(f"File to be downloaded is located at '{file_path}'")
Expand Down Expand Up @@ -327,8 +339,8 @@ def delete(request, ids: str):

for id in ids.split(','):

logger.info(f"Locating file for pub='{id}' pk='{ValidationRequest.to_private_id(id)}' and user.id='{user.id}'")
request = ValidationRequest.objects.filter(created_by__id=user.id, deleted=False, id=ValidationRequest.to_private_id(id)).first()
logger.info(f"Locating file for pub='{id}' pk='{get_internal_id(id)}' and user.id='{user.id}'")
request = ValidationRequest.objects.filter(created_by__id=user.id, deleted=False, id=get_internal_id(id)).first()

request.delete()
logger.info(f"Validation Request with id='{id}' and related entities were marked as deleted.")
Expand Down Expand Up @@ -360,13 +372,13 @@ def revalidate(request, ids: str):
def on_commit(ids):

for id in ids.split(','):
request = ValidationRequest.objects.filter(created_by__id=user.id, deleted=False, id=ValidationRequest.to_private_id(id)).first()
request = ValidationRequest.objects.filter(created_by__id=user.id, deleted=False, id=get_internal_id(id)).first()
ifc_file_validation_task.delay(request.id, request.file_name)
logger.info(f"Task 'ifc_file_validation_task' re-submitted for Validation Request - id: {request.id} file_name: {request.file_name}")

for id in ids.split(','):

request = ValidationRequest.objects.filter(created_by__id=user.id, id=ValidationRequest.to_private_id(id)).first()
request = ValidationRequest.objects.filter(created_by__id=user.id, id=get_internal_id(id)).first()
request.mark_as_pending(reason='Resubmitted for processing via React UI')
if request.model: request.model.reset_status()

Expand All @@ -386,10 +398,10 @@ def report(request, id: str):
# fetch current user
user = get_current_user(request)
if not user:
return create_redirect_response(login=True)

return create_redirect_response(login=True)
# return 404-NotFound if report is not for current user or if it is deleted
request = ValidationRequest.objects.filter(created_by__id=user.id, deleted=False, id=ValidationRequest.to_private_id(id)).first()
request = ValidationRequest.objects.filter(created_by__id=user.id, deleted=False, id=get_internal_id(id)).first()
if not request:
return HttpResponseNotFound()

Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"scripts": {
"start": "NODE_ENV=development react-scripts start",
"start-nobrowser": "BROWSER=none NODE_ENV=development react-scripts start",
"build": "NODE_ENV=production react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
Expand Down
30 changes: 14 additions & 16 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ function App() {

const [isLoggedIn, setLogin] = useState(false);
const [user, setUser] = useState(null)

const [prTitle, setPrTitle] = useState("")

useEffect(() => {
fetch(context.sandboxId ? `${FETCH_PATH}/api/sandbox/me/${context.sandboxId}` : `${FETCH_PATH}/api/me`, { credentials: 'include' })
fetch(`${FETCH_PATH}/api/me`, { credentials: 'include' })
.then(response => response.json())
.then((data) => {
if (data["redirect"] !== undefined && data["redirect"] !== null) {
Expand All @@ -44,7 +43,7 @@ function App() {
document.body.style.overflow = "hidden";
if (isLoggedIn) {
return (
<div class="home">
<div className="home">
<Grid direction="column"
container
style={{
Expand Down Expand Up @@ -131,26 +130,26 @@ function App() {

<Typography style={{fontWeight: 'bold'}}>What it does</Typography>

<Typography align='left' paragraph>Given an IFC file, the Validation Service provides a judgment of conformity for such file against the IFC standard (schema and specification).</Typography>
<Typography align='left' paragraph>Given an IFC file, the bSI Validation Service provides a judgment of conformity for such file against the IFC standard (schema and specification).</Typography>

<Typography style={{fontWeight: 'bold'}}>What is being checked</Typography>

<Typography align='left' paragraph>The IFC file is valid when it conforms to:

<Typography align='left' as='span'>The IFC file is valid when it conforms to:
<ul>
<li><b>STEP Syntax</b> The STEP Physical File syntax</li>
<li><b>IFC Schema</b> An up-to-date (not withdrawn and latest revision) IFC schema referenced in the file, including formal propositions and functions encoded in the EXPRESS schema language</li>
<li><b>Normative IFC Rules</b> Other normative rules of the IFC specification (e.g. implementer agreements and informal propositions)</li>
<li><b>STEP Syntax</b> The STEP Physical File syntax;</li>
<li><b>IFC Schema</b> An up-to-date (not withdrawn and latest revision) IFC schema referenced in the file, including formal propositions and functions encoded in the EXPRESS schema language;</li>
<li><b>Normative IFC Rules</b> Other normative rules of the IFC specification (e.g. implementer agreements and informal propositions).</li>
</ul>

</Typography>
<Typography align='left' paragraph>Additionally, the Validation Service performs non-normative checks including:
<Typography align='left' as='span'>Additionally, the bSI Validation Service performs non-normative checks including:

<ul>
<li><b>Industry Practices</b> Checking the IFC file against common practice and sensible defaults. None of these checks render the IFC file invalid. Therefore, any issues identified result in warnings rather than errors</li>
<li><b>bSDD Compliance</b> Checking whether references to classifications and properties from bSDD, found in an IFC file, comply with the source definitions in bSDD</li>
<li><b>Industry Practices</b> Checking the IFC file against common practice and sensible defaults. None of these checks render the IFC file invalid. Therefore, any issues identified result in warnings rather than errors;</li>
<li><b>bSDD Compliance</b> Checking whether references to classifications and properties from bSDD, found in an IFC file, comply with the source definitions in bSDD.</li>
</ul>

</Typography>

<Typography style={{fontWeight: 'bold'}}>What is NOT being checked</Typography>
Expand All @@ -159,7 +158,7 @@ function App() {

<Typography style={{fontWeight: 'bold'}}>Visualisation</Typography>

<Typography align='left' paragraph sx={{paddingBottom: '2em'}}>For multiple reasons, geometric visualisation is not within the scope nor the mandate of the Validation Service. Many errors are invisible in a viewer or unrelated to a geometric representation or prevent visualisation altogether.</Typography>
<Typography align='left' paragraph sx={{paddingBottom: '2em'}}>For multiple reasons, geometric visualisation is not within the scope nor the mandate of the bSI Validation Service. Many errors are invisible in a viewer or unrelated to a geometric representation or prevent visualisation altogether.</Typography>

<Footer/>
</div>
Expand All @@ -170,7 +169,6 @@ function App() {
</Grid>
</Grid>
</div>

);
} else {
return (
Expand Down
Binary file modified frontend/src/BuildingSMART_CMYK_validation_service.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 4 additions & 8 deletions frontend/src/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import Disclaimer from './Disclaimer';
import Footer from './Footer'
import Grid from '@mui/material/Grid';
import VerticalLinearStepper from './VerticalLinearStepper'
import Button from '@mui/material/Button';
import HomeIcon from '@mui/icons-material/Home';
import CheckIcon from '@mui/icons-material/Check';
import Box from '@mui/material/Box';
import SideMenu from './SideMenu';
import Typography from '@mui/material/Typography';

import { useEffect, useState, useContext } from 'react';

Expand All @@ -19,13 +15,13 @@ import { PageContext } from './Page';


function Dashboard() {

const context = useContext(PageContext);

const [isLoggedIn, setLogin] = useState(false);
const [user, setUser] = useState(null);

const [prTitle, setPrTitle] = useState("")

const context = useContext(PageContext);

useEffect(() => {
fetch(context.sandboxId ? `${FETCH_PATH}/api/sandbox/me/${context.sandboxId}` : `${FETCH_PATH}/api/me`, { credentials: 'include' })
.then(response => response.json())
Expand All @@ -46,7 +42,7 @@ function Dashboard() {
document.body.style.overflow = "hidden";
if (isLoggedIn) {
return (
<div class="dashboard">
<div className="dashboard">
<Grid direction="column"
container
style={{
Expand Down
39 changes: 10 additions & 29 deletions frontend/src/DashboardTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,17 @@ import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import Checkbox from '@mui/material/Checkbox';
import IconButton from '@mui/material/IconButton';
import InfoIcon from '@mui/icons-material/Info';
import Tooltip from '@mui/material/Tooltip';
import DeleteIcon from '@mui/icons-material/Delete';
//import ReplayIcon from '@mui/icons-material/Replay';
import CircularStatic from "./CircularStatic";
import ErrorIcon from '@mui/icons-material/Error';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import BrowserNotSupportedIcon from '@mui/icons-material/BrowserNotSupported';
import WarningIcon from '@mui/icons-material/Warning';
import HourglassBottomIcon from '@mui/icons-material/HourglassBottom';
import BlockIcon from '@mui/icons-material/Block';
import Link from '@mui/material/Link';
import { FETCH_PATH } from './environment'
import { useEffect, useState, useContext } from 'react';
import { PageContext } from './Page';
import HandleAsyncError from './HandleAsyncError';
import { getCookieValue } from './Cookies';

const statusToIcon = {
"n": <BrowserNotSupportedIcon color="disabled" />,
"v": <CheckCircleIcon sx={{ color: "#2ab672" }} />,
"i": <ErrorIcon color="error" />,
"w": <WarningIcon color="warning" />,
"p": <HourglassBottomIcon color="disabled" />,
"-": <Tooltip title='N/A'><BlockIcon color="disabled" /></Tooltip>,
"info":<InfoIcon color="primary"/>
}
import { statusToIcon } from './mappings';

function wrap_status(status, href) {
if (status === 'n' || status === 'p' || status === '-') {
Expand Down Expand Up @@ -74,7 +58,7 @@ function computeRelativeDates(modelDate) {
}
if (unit) {
var relativeTime = Math.floor(difference / divisor);
if (relativeTime == 1) { unit = unit.slice(0, -1); } // Remove the 's' in units if only 1
if (relativeTime === 1) { unit = unit.slice(0, -1); } // Remove the 's' in units if only 1
return (<span className="abs_time" title={modelDate.toLocaleString()}>{relativeTime} {unit} ago</span>)
} else {
return modelDate.toLocaleString();
Expand Down Expand Up @@ -131,7 +115,7 @@ const headCells = [
];

function EnhancedTableHead(props) {
const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } =
const { onSelectAllClick, numSelected, rowCount } =
props;

return (
Expand Down Expand Up @@ -160,7 +144,7 @@ function EnhancedTableHead(props) {
headCell.tooltip
? <Tooltip title={headCell.tooltip}>
<span style={{borderBottom: 'dotted 2px gray', display: 'inline-block'}}>{headCell.label}
<span style={{fontSize: '.83em', verticalAlign: 'super'}}>{headCell.tooltip ? 'ⓘ' : ''}</span>
<span style={{fontSize: '.83em', verticalAlign: 'super'}}>{headCell.tooltip ? ' ⓘ' : ''}</span>
</span>
</Tooltip>
: headCell.label
Expand Down Expand Up @@ -235,11 +219,8 @@ EnhancedTableToolbar.propTypes = {

export default function DashboardTable({ models }) {
const [rows, setRows] = React.useState([])
const [order, setOrder] = React.useState('asc');
const [orderBy, setOrderBy] = React.useState('');
const [selected, setSelected] = React.useState([]);
const [page, setPage] = React.useState(0);
const [dense, setDense] = React.useState(false);
const [rowsPerPage, setRowsPerPage] = React.useState(5);
const [count, setCount] = React.useState(0);
const [deleted, setDeleted] = useState('');
Expand Down Expand Up @@ -298,8 +279,8 @@ export default function DashboardTable({ models }) {
const isSelected = (name) => selected.indexOf(name) !== -1;

// Avoid a layout jump when reaching the last page with empty rows.
const emptyRows =
page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0;
// const emptyRows =
// page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0;

useEffect(() => {
if (deleted) {
Expand Down Expand Up @@ -358,7 +339,7 @@ export default function DashboardTable({ models }) {
}
}}
aria-labelledby="tableTitle"
size={dense ? 'small' : 'medium'}
size={'medium'}
>
<EnhancedTableHead
numSelected={selected.length}
Expand Down Expand Up @@ -417,12 +398,12 @@ export default function DashboardTable({ models }) {
}

{
(row.progress == 100) ?
(row.progress === 100) ?
<TableCell align="left">{computeRelativeDates(new Date(row.date))}</TableCell> :
<TableCell align="left">
{
(row.progress == -1) ? <Typography>{"in queue"}</Typography> :
((row.progress == -2) ? <Typography>{"an error occured"}</Typography> : <CircularStatic value={row.progress} />)
(row.progress === -1) ? <Typography>{"in queue"}</Typography> :
((row.progress === -2) ? <Typography>{"an error occured"}</Typography> : <CircularStatic value={row.progress} />)
}
</TableCell>
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/ErrorBoundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export default class ErrorBoundary extends React.Component {

render() {
const { hasError, error, info } = this.state;
console.log(error, info);
if (hasError) {
console.log('ERROR: ', error, info);
}
const { children } = this.props;

return hasError ? <ErrorMessage /> : children;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function Footer(){
const style = {padding:'4px', textAlign:'center'};
return (
<div style={style}>
<span>{context["environment"]} - Version 0.6.0-alpha | Copyright © 2024 buildingSMART All Rights Reserved | <a href="https://www.buildingsmart.org/wp-content/uploads/2018/05/PrivacyandCookiePolicyV2.pdf" target="_blank" rel="noopener">Privacy and Cookie Statement</a>&nbsp;| <a href="https://www.buildingsmart.org/wp-content/uploads/2021/09/20210923_TermsOfService.pdf" target="_blank" rel="noopener">Terms and Conditions</a>&nbsp;|</span>
<span>{context["environment"]} - Version 0.6.0-alpha | Copyright © 2024 buildingSMART All Rights Reserved | <a href="https://f3h3w7a5.rocketcdn.me/wp-content/uploads/2023/06/bSIPrivacyandCookiePolicyMarch2023_v2.pdf" target="_blank" rel="noreferrer">Privacy and Cookie Statement</a>&nbsp;| <a href="https://www.buildingsmart.org/wp-content/uploads/2021/09/20210923_TermsOfService.pdf" target="_blank" rel="noreferrer">Terms and Conditions</a>&nbsp;|</span>
{context["pageTitle"] === "report" &&<div> This validation report is generated by bSI Validation Service based on the input IFC model | bSI assumes no responsability or liability for the content of this report</div>}
</div>
)
Expand Down
21 changes: 6 additions & 15 deletions frontend/src/GeneralTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@ import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import ErrorIcon from '@mui/icons-material/Error';
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
import BrowserNotSupportedIcon from '@mui/icons-material/BrowserNotSupported';
import WarningIcon from '@mui/icons-material/Warning';
import HourglassBottomIcon from '@mui/icons-material/HourglassBottom';
import statusToIcon from './mappings';

const statusToIcon = {
"n": <BrowserNotSupportedIcon color="disabled" />,
"v": <CheckCircleIcon color="success" />,
"i": <ErrorIcon color="error" />,
"w": <WarningIcon color="warning" />,
"p": <HourglassBottomIcon color="disabled" />
}

function prettyPrintFileSize(fileSizeInBytes) {
var i = -1;
Expand Down Expand Up @@ -79,9 +68,11 @@ export default function GeneralTable({ data, type }) {
<TableContainer sx={{ maxWidth: 850 }} component={Paper}>
<Table aria-label="simple table">
<TableHead>
<TableCell colSpan={2} sx={{ borderColor: 'black', fontWeight: 'bold' }}>
{type.charAt(0).toUpperCase()}{type.slice(1)}
</TableCell>
<TableRow>
<TableCell colSpan={2} sx={{ borderColor: 'black', fontWeight: 'bold', textTransform: 'capitalize' }}>
{type}
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
Expand Down