Spaces:
Sleeping
Sleeping
Update Utils.py
Browse files
Utils.py
CHANGED
@@ -84,16 +84,29 @@ def generate_roadmap_image():
|
|
84 |
|
85 |
roadmap.set_footer("Generated by Roadmapper")
|
86 |
roadmap.draw()
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
image_buffer = BytesIO()
|
90 |
|
91 |
-
image_data = image_buffer.getvalue()
|
92 |
-
return image_data
|
93 |
|
94 |
def get_binary_file_downloader_html(bin_file, file_label, button_label):
|
95 |
with st.spinner("Processing..."):
|
96 |
# Provide a download link for the image
|
97 |
bin_str = base64.b64encode(bin_file).decode()
|
98 |
href = f'<a href="data:application/octet-stream;base64,{bin_str}" download="{file_label}">{button_label}</a>'
|
99 |
-
return href
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
roadmap.set_footer("Generated by Roadmapper")
|
86 |
roadmap.draw()
|
87 |
+
project_name = get_dynamic_filename()
|
88 |
+
roadmap.save(project_name)
|
89 |
+
|
90 |
+
st.download_button(
|
91 |
+
label="Download Roadmap Image",
|
92 |
+
data=open(project_name, "rb").read(),
|
93 |
+
key="download_roadmap",
|
94 |
+
file_name=project_name,
|
95 |
+
mime="image/png",
|
96 |
+
)
|
97 |
|
|
|
98 |
|
|
|
|
|
99 |
|
100 |
def get_binary_file_downloader_html(bin_file, file_label, button_label):
|
101 |
with st.spinner("Processing..."):
|
102 |
# Provide a download link for the image
|
103 |
bin_str = base64.b64encode(bin_file).decode()
|
104 |
href = f'<a href="data:application/octet-stream;base64,{bin_str}" download="{file_label}">{button_label}</a>'
|
105 |
+
return href
|
106 |
+
|
107 |
+
|
108 |
+
def get_dynamic_filename():
|
109 |
+
project_name = st.session_state["project_name"]
|
110 |
+
current_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
111 |
+
filename = f"{project_name}_roadmap_{current_time}.png"
|
112 |
+
return filename
|