forked from enviPath/enviPy
[Feature] Modern UI roll out (#236)
This PR moves all the collection pages into the new UI in a rough push. I did not put the same amount of care into these as into search, index, and predict. ## Major changes - All modals are now migrated to a state based alpine.js implementation. - jQuery is no longer present in the base layout; ajax is replace by native fetch api - most of the pps.js is now obsolte (as I understand it; the code is not referenced any more @jebus please double check) - in-memory pagination for large result lists (set to 50; we can make that configurable later; performance degrades at around 1k) stukk a bit rough tracked in #235 ## Minor things - Sarch and index also use alpine now - The loading spinner is now CSS animated (not sure if it currently gets correctly called) ## Not done - Ihave not even cheked the admin pages. Not sure If these need migrations - The temporary migration pages still use the old template. Not sure what is supposed to happen with those? @jebus ## What I did to test - opend all pages in browse, and user ; plus all pages reachable from there. - Interacted and tested the functionality of each modal superfically with exception of the API key modal (no functional test). --- This PR is massive sorry for that; just did not want to push half-brokenn state. @jebus @liambrydon I would be glad if you could click around and try to break it :) Finally closes #133 Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#236 Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Co-committed-by: Tobias O <tobias.olenyi@envipath.com>
This commit is contained in:
@ -62,6 +62,26 @@ def log_post_params(request):
|
||||
logger.debug(f"{k}\t{v}")
|
||||
|
||||
|
||||
def get_error_handler_context(request, for_user=None) -> Dict[str, Any]:
|
||||
current_user = _anonymous_or_real(request)
|
||||
|
||||
if for_user:
|
||||
current_user = for_user
|
||||
|
||||
ctx = {
|
||||
"title": "enviPath",
|
||||
"meta": {
|
||||
"site_id": s.MATOMO_SITE_ID,
|
||||
"version": "0.0.1",
|
||||
"server_url": s.SERVER_URL,
|
||||
"user": current_user,
|
||||
"enabled_features": s.FLAGS,
|
||||
"debug": s.DEBUG,
|
||||
},
|
||||
}
|
||||
return ctx
|
||||
|
||||
|
||||
def error(request, message: str, detail: str, code: int = 400):
|
||||
context = get_base_context(request)
|
||||
error_context = {
|
||||
@ -76,6 +96,48 @@ def error(request, message: str, detail: str, code: int = 400):
|
||||
return render(request, "errors/error.html", context, status=code)
|
||||
|
||||
|
||||
def handler400(request, exception):
|
||||
"""Custom 400 Bad Request error handler"""
|
||||
context = get_error_handler_context(request)
|
||||
context["public_mode"] = True
|
||||
return render(request, "errors/400_bad_request.html", context, status=400)
|
||||
|
||||
|
||||
def handler403(request, exception):
|
||||
"""Custom 403 Forbidden error handler"""
|
||||
context = get_error_handler_context(request)
|
||||
context["public_mode"] = True
|
||||
return render(request, "errors/403_access_denied.html", context, status=403)
|
||||
|
||||
|
||||
def handler404(request, exception):
|
||||
"""Custom 404 Not Found error handler"""
|
||||
context = get_error_handler_context(request)
|
||||
context["public_mode"] = True
|
||||
return render(request, "errors/404_not_found.html", context, status=404)
|
||||
|
||||
|
||||
def handler500(request):
|
||||
"""Custom 500 Internal Server Error handler"""
|
||||
context = get_error_handler_context(request)
|
||||
|
||||
error_context = {}
|
||||
error_context["error_message"] = "Internal Server Error"
|
||||
error_context["error_detail"] = "An unexpected error occurred. Please try again later."
|
||||
|
||||
if request.headers.get("Accept") == "application/json":
|
||||
return JsonResponse(error_context, status=500)
|
||||
|
||||
context["public_mode"] = True
|
||||
context["error_code"] = 500
|
||||
context["error_description"] = (
|
||||
"We encountered an unexpected error while processing your request. Our team has been notified and is working to resolve the issue."
|
||||
)
|
||||
context.update(**error_context)
|
||||
|
||||
return render(request, "errors/error.html", context, status=500)
|
||||
|
||||
|
||||
def login(request):
|
||||
context = get_base_context(request)
|
||||
|
||||
@ -192,8 +254,8 @@ def register(request):
|
||||
|
||||
|
||||
def editable(request, user):
|
||||
if user.is_superuser:
|
||||
return True
|
||||
# if user.is_superuser:
|
||||
# return True
|
||||
|
||||
url = request.build_absolute_uri(request.path)
|
||||
if PackageManager.is_package_url(url):
|
||||
|
||||
Reference in New Issue
Block a user