From 4747ffc08b66f142ebc5293dd4365627f78b00b6 Mon Sep 17 00:00:00 2001 From: sadnub Date: Wed, 4 Oct 2023 11:01:28 -0400 Subject: [PATCH] fix dockerfile in dev and remove chart rendering if data query is empty --- .devcontainer/api.dockerfile | 10 +++++----- api/tacticalrmm/ee/reporting/utils.py | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.devcontainer/api.dockerfile b/.devcontainer/api.dockerfile index 18ed05ad..bdc197ab 100644 --- a/.devcontainer/api.dockerfile +++ b/.devcontainer/api.dockerfile @@ -1,9 +1,9 @@ # pulls community scripts from git repo FROM python:3.11.4-slim AS GET_SCRIPTS_STAGE -RUN apt-get update && -apt-get install -y --no-install-recommends git && -git clone https://github.com/amidaware/community-scripts.git /community-scripts +RUN apt-get update && \ + apt-get install -y --no-install-recommends git && \ + git clone https://github.com/amidaware/community-scripts.git /community-scripts FROM python:3.11.4-slim @@ -20,8 +20,8 @@ EXPOSE 8000 8383 8005 RUN apt-get update && \ apt-get install -y build-essential weasyprint -RUN groupadd -g 1000 tactical && -useradd -u 1000 -g 1000 tactical +RUN groupadd -g 1000 tactical && \ + useradd -u 1000 -g 1000 tactical # copy community scripts COPY --from=GET_SCRIPTS_STAGE /community-scripts /community-scripts diff --git a/api/tacticalrmm/ee/reporting/utils.py b/api/tacticalrmm/ee/reporting/utils.py index 725f6f58..1470afd3 100644 --- a/api/tacticalrmm/ee/reporting/utils.py +++ b/api/tacticalrmm/ee/reporting/utils.py @@ -526,6 +526,9 @@ def process_chart_variables(*, variables: Dict[str, Any]) -> Dict[str, Any]: if not isinstance(charts, dict): return variables + # these will be remove so they don't render in the template + invalid_chart_keys = [] + for key, chart in charts.items(): options = chart.get("options") if not isinstance(options, dict): @@ -546,6 +549,10 @@ def process_chart_variables(*, variables: Dict[str, Any]) -> Dict[str, Any]: if not path_exists: continue + if not data: + invalid_chart_keys.append(key) + continue + options["data_frame"] = data traces = chart.get("traces") @@ -558,6 +565,9 @@ def process_chart_variables(*, variables: Dict[str, Any]) -> Dict[str, Any]: layout=layout, ) + for key in invalid_chart_keys: + del charts[key] + return variables