diff --git a/backend/apps/ifc_validation_bff/urls.py b/backend/apps/ifc_validation_bff/urls.py index e6d13bd9..cc30b428 100644 --- a/backend/apps/ifc_validation_bff/urls.py +++ b/backend/apps/ifc_validation_bff/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from .views_legacy import me, models_paginated, download, upload, delete, revalidate +from .views_legacy import me, models_paginated, upload, delete from .views_legacy import report, report_error urlpatterns = [ @@ -8,10 +8,8 @@ # 'Flask'-way of doing things; backend for legacy API (< 0.6) path('api/me', me), path('api/models_paginated//', models_paginated), - path('api/download/', download), path('api/', upload), path('api/delete/', delete), - path('api/revalidate/', revalidate), path('api/report/', report), path('api/report_error', report_error), diff --git a/backend/apps/ifc_validation_bff/views_legacy.py b/backend/apps/ifc_validation_bff/views_legacy.py index 5869aa4d..918504e7 100644 --- a/backend/apps/ifc_validation_bff/views_legacy.py +++ b/backend/apps/ifc_validation_bff/views_legacy.py @@ -272,39 +272,6 @@ def models_paginated(request, start: int, end: int): return JsonResponse(response_data) -@ensure_csrf_cookie -def download(request, id: int): - - if request.method != "GET": - return HttpResponseNotAllowed() - - # fetch current user - user = get_current_user(request) - 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() - 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}'") - - if request.file.name.endswith('.gz'): - file_handle = open(file_path, 'rb') - response = FileResponse(file_handle, content_type="application/gzip") - response['Content-Length'] = os.path.getsize(file_path) - logger.debug(f"Sending file with id='{id}' back as '{request.file_name}'") - else: - response = HttpResponse(open(file_path), content_type="application/x-step") - response['Content-Disposition'] = f'attachment; filename="{request.file_name}"' - logger.debug(f"Sending file with id='{id}' back as '{request.file_name}'") - - return response - else: - logger.debug(f"Could not download file with id='{id}' for user.id='{user.id}' as it does not exist") - return HttpResponseNotFound() - - @ensure_csrf_cookie @csrf_protect def upload(request): diff --git a/frontend/src/DashboardTable.js b/frontend/src/DashboardTable.js index d8db4a58..ff812453 100644 --- a/frontend/src/DashboardTable.js +++ b/frontend/src/DashboardTable.js @@ -17,7 +17,6 @@ import InfoIcon from '@mui/icons-material/Info'; import MailLockIcon from '@mui/icons-material/MailLock'; 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'; @@ -26,6 +25,8 @@ 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 Button from '@mui/material/Button'; + import { FETCH_PATH } from './environment' import { useEffect, useState, useContext } from 'react'; import { PageContext } from './Page'; @@ -210,13 +211,6 @@ function EnhancedTableToolbar({ numSelected, onDelete, onRevalidate }) { )} - {/* {numSelected > 0 && ( - - - - - )} */} - {numSelected > 0 ? ( 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0; useEffect(() => { - if (deleted) { + + if (deleted && deleted.length > 0) { + fetch(`${FETCH_PATH}/api/delete/${deleted}`, { method: 'DELETE', headers: { 'x-csrf-token': getCookieValue('csrftoken') }, @@ -334,33 +329,19 @@ export default function DashboardTable({ models }) { setSelected([]) setDeleted([]) }); - } else if (revalidated) { - fetch(`${FETCH_PATH}/api/revalidate/${revalidated}`, { - method: 'POST', - headers: { 'x-csrf-token': getCookieValue('csrftoken') }, - credential: 'include' - }) - .then((response) => response.json()) - .then((json) => { - setSelected([]) - setRevalidated([]) - }); } - }, [deleted, revalidated]); + }, [deleted]); function onDelete() { - setDeleted(selected.join(',')) + if (window.confirm(`Delete ${selected.length} selected IFC file(s)? This action cannot be undone.`)) { + setDeleted(selected.join(',')) + } } - // function onRevalidate() { - // setRevalidated(selected.join(',')) - // } - return ( - {/* */} { - (row.status_magic_clamav != 'i') ? - evt.stopPropagation()}> - {'Download file'} - : 'File unavailable' + (row.deleted ? '-' :
+ + + + + + + +
+ ) }