add old gantt ui if web ui is not running

This commit is contained in:
Ziad-I
2024-07-05 10:08:54 +03:00
committed by Dion Moult
parent 6b274535c6
commit 31e7cd7a8c
+12 -9
View File
@@ -1544,15 +1544,18 @@ class Sequence(blenderbim.core.tool.Sequence):
def generate_gantt_browser_chart( def generate_gantt_browser_chart(
cls, task_json: list[dict[str, Any]], work_schedule: ifcopenshell.entity_instance cls, task_json: list[dict[str, Any]], work_schedule: ifcopenshell.entity_instance
) -> None: ) -> None:
# with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"), "w") as f: if bpy.context.scene.WebProperties.is_connected:
# with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t: gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)}
# task_b64 = base64.b64encode(bytes(json.dumps(task_json), "utf-8")).decode("utf-8") tool.Web.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data")
# f.write( return
# pystache.render(t.read(), {"json_data": task_b64, "data": json.dumps(work_schedule.get_info())})
# ) with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"), "w") as f:
# webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html")) with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t:
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)} task_b64 = base64.b64encode(bytes(json.dumps(task_json), "utf-8")).decode("utf-8")
tool.Web.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data") f.write(
pystache.render(t.read(), {"json_data": task_b64, "data": json.dumps(work_schedule.get_info(recursive=True))})
)
webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"))
@classmethod @classmethod
def is_filter_by_active_schedule(cls) -> bool: def is_filter_by_active_schedule(cls) -> bool: