make webui default for work schedules and simplfy condition

This commit is contained in:
Ziad-I
2024-08-10 22:57:45 +03:00
parent a4f881517b
commit 53907accd9
2 changed files with 5 additions and 15 deletions
+1 -1
View File
@@ -254,7 +254,7 @@ class ExportIfcCsv(bpy.types.Operator):
schedule_creator = scheduler.Scheduler()
schedule_creator.schedule(self.filepath, tool.Drawing.get_path_with_ext(self.filepath, "svg"))
if props.format == "web":
if not context.scene.WebProperties.is_running and not context.scene.WebProperties.is_connected:
if not context.scene.WebProperties.is_connected:
bpy.ops.bim.connect_websocket_server()
tool.Web.send_webui_data(data=ifc_csv.dataframe.to_csv(index=False), data_key="csv_data", event="csv_data")
+4 -14
View File
@@ -1541,20 +1541,10 @@ class Sequence(bonsai.core.tool.Sequence):
def generate_gantt_browser_chart(
cls, task_json: list[dict[str, Any]], work_schedule: ifcopenshell.entity_instance
) -> None:
if bpy.context.scene.WebProperties.is_connected:
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)}
tool.Web.send_webui_data(data=gantt_data, data_key="gantt_data", event="gantt_data")
return
with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"), "w") as f:
with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t:
task_b64 = base64.b64encode(bytes(json.dumps(task_json), "utf-8")).decode("utf-8")
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"))
if not bpy.context.scene.WebProperties.is_connected:
bpy.ops.bim.connect_websocket_server()
gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)}
tool.Web.send_webui_data(data=gantt_data, data_key="gantt_data", event="gantt_data")
@classmethod
def is_filter_by_active_schedule(cls) -> bool: