staticdash 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- staticdash/assets/css/style.css +10 -0
- staticdash/assets/js/script.js +19 -3
- staticdash/dashboard.py +23 -6
- {staticdash-0.1.1.dist-info → staticdash-0.1.3.dist-info}/METADATA +1 -1
- staticdash-0.1.3.dist-info/RECORD +8 -0
- staticdash-0.1.1.dist-info/RECORD +0 -8
- {staticdash-0.1.1.dist-info → staticdash-0.1.3.dist-info}/WHEEL +0 -0
- {staticdash-0.1.1.dist-info → staticdash-0.1.3.dist-info}/top_level.txt +0 -0
staticdash/assets/css/style.css
CHANGED
staticdash/assets/js/script.js
CHANGED
@@ -2,10 +2,26 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
2
2
|
const links = document.querySelectorAll(".nav-link");
|
3
3
|
const sections = document.querySelectorAll(".page-section");
|
4
4
|
|
5
|
+
function resizePlotsIn(section) {
|
6
|
+
const plots = section.querySelectorAll(".plotly-graph-div");
|
7
|
+
plots.forEach(plot => {
|
8
|
+
if (typeof Plotly !== "undefined" && plot.data) {
|
9
|
+
Plotly.Plots.resize(plot);
|
10
|
+
}
|
11
|
+
});
|
12
|
+
}
|
13
|
+
|
5
14
|
function showPage(id) {
|
6
15
|
sections.forEach(section => section.style.display = "none");
|
7
16
|
const page = document.getElementById(id);
|
8
|
-
if (page)
|
17
|
+
if (page) {
|
18
|
+
page.style.display = "block";
|
19
|
+
|
20
|
+
// Resize Plotly charts within the newly visible section
|
21
|
+
requestAnimationFrame(() => {
|
22
|
+
resizePlotsIn(page);
|
23
|
+
});
|
24
|
+
}
|
9
25
|
|
10
26
|
links.forEach(link => link.classList.remove("active"));
|
11
27
|
const activeLink = Array.from(links).find(link => link.dataset.target === id);
|
@@ -20,8 +36,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
20
36
|
});
|
21
37
|
});
|
22
38
|
|
23
|
-
//
|
39
|
+
// Initial page load
|
24
40
|
if (sections.length > 0) {
|
25
41
|
showPage(sections[0].id);
|
26
42
|
}
|
27
|
-
});
|
43
|
+
});
|
staticdash/dashboard.py
CHANGED
@@ -18,7 +18,7 @@ class Page:
|
|
18
18
|
self.elements.append(("text", text))
|
19
19
|
|
20
20
|
def add_plot(self, plot):
|
21
|
-
html = raw_util(plot.to_html(full_html=False, include_plotlyjs='cdn'))
|
21
|
+
html = raw_util(plot.to_html(full_html=False, include_plotlyjs='cdn', config={'responsive': True}))
|
22
22
|
self.elements.append(("plot", html))
|
23
23
|
|
24
24
|
def add_table(self, df, table_id=None):
|
@@ -26,6 +26,11 @@ class Page:
|
|
26
26
|
table_id = f"table-{len(self.elements)}"
|
27
27
|
html = df.to_html(classes="table-hover table-striped", index=False, border=0, table_id=table_id)
|
28
28
|
self.elements.append(("table", (html, table_id)))
|
29
|
+
|
30
|
+
def add_download(self, file_path, label=None):
|
31
|
+
if not os.path.isfile(file_path):
|
32
|
+
raise FileNotFoundError(f"File not found: {file_path}")
|
33
|
+
self.elements.append(("download", (file_path, label)))
|
29
34
|
|
30
35
|
def add(self, element):
|
31
36
|
if isinstance(element, str):
|
@@ -59,15 +64,18 @@ class Dashboard:
|
|
59
64
|
self.pages.append(page)
|
60
65
|
|
61
66
|
def publish(self, output_dir="output"):
|
62
|
-
os.
|
67
|
+
output_dir = os.path.abspath(output_dir)
|
63
68
|
pages_dir = os.path.join(output_dir, "pages")
|
64
|
-
os.
|
65
|
-
|
66
|
-
# Copy assets
|
69
|
+
downloads_dir = os.path.join(output_dir, "downloads")
|
67
70
|
assets_src = os.path.join(os.path.dirname(__file__), "assets")
|
68
71
|
assets_dst = os.path.join(output_dir, "assets")
|
72
|
+
|
73
|
+
# Ensure directories exist
|
74
|
+
os.makedirs(pages_dir, exist_ok=True)
|
75
|
+
os.makedirs(downloads_dir, exist_ok=True)
|
69
76
|
shutil.copytree(assets_src, assets_dst, dirs_exist_ok=True)
|
70
77
|
|
78
|
+
|
71
79
|
# Generate each page
|
72
80
|
for page in self.pages:
|
73
81
|
doc = document(title=page.title)
|
@@ -113,7 +121,16 @@ class Dashboard:
|
|
113
121
|
elif kind == "table":
|
114
122
|
table_html, _ = content
|
115
123
|
div(raw_util(table_html))
|
124
|
+
elif kind == "download":
|
125
|
+
src_path, label = content
|
126
|
+
file_uuid = f"{uuid.uuid4().hex}_{os.path.basename(src_path)}"
|
127
|
+
dst_path = os.path.join(downloads_dir, file_uuid)
|
128
|
+
shutil.copy2(src_path, dst_path)
|
129
|
+
a(label or os.path.basename(src_path),
|
130
|
+
href=f"{downloads_dir}/{file_uuid}",
|
131
|
+
cls="download-button",
|
132
|
+
download=True)
|
116
133
|
|
117
134
|
|
118
135
|
with open(os.path.join(output_dir, "index.html"), "w") as f:
|
119
|
-
f.write(str(index_doc))
|
136
|
+
f.write(str(index_doc))
|
@@ -0,0 +1,8 @@
|
|
1
|
+
staticdash/__init__.py,sha256=KqViaDkiQnhBI8-j3hr14umLDmPgddvdB_G1nJeC5Xs,38
|
2
|
+
staticdash/dashboard.py,sha256=0A-1soi7ECzTeCQTjZqzFuT2Ef8a9YAPSLI2T7f66EY,5595
|
3
|
+
staticdash/assets/css/style.css,sha256=zcwUaOtGenWwGlWvWc5i9jnz_M1Jq2iGKGKizSGvBRo,1314
|
4
|
+
staticdash/assets/js/script.js,sha256=rAGEB9sgv8LGdpA1JLQwYAZVRimpEfFSELKb0fFeATI,1222
|
5
|
+
staticdash-0.1.3.dist-info/METADATA,sha256=0qjiyqbS0kGN78m6C8f5CNBIlRudnZ5xoBuV6JcK_48,2157
|
6
|
+
staticdash-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
staticdash-0.1.3.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
|
8
|
+
staticdash-0.1.3.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
staticdash/__init__.py,sha256=KqViaDkiQnhBI8-j3hr14umLDmPgddvdB_G1nJeC5Xs,38
|
2
|
-
staticdash/dashboard.py,sha256=7kLyd2UBKJNTi5HwepG9ivEcxhaSq9t3jqjSFujS5xg,4615
|
3
|
-
staticdash/assets/css/style.css,sha256=mc4j24VPIMB9pVWqH_ndyCrnLIJXUC0Tp3qn3lTOnJA,1186
|
4
|
-
staticdash/assets/js/script.js,sha256=L9HxPRlKMrvSwtLftxA_9WIEDLjMCi7axJNfeQQNRfM,842
|
5
|
-
staticdash-0.1.1.dist-info/METADATA,sha256=r55fdjdvi4aEJQ-6w8lhW9vD2vCXjjcLNQWTQO_6qRQ,2157
|
6
|
-
staticdash-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
-
staticdash-0.1.1.dist-info/top_level.txt,sha256=3MzZU6SptkUkjcHV1cvPji0H4aRzPphLHnpStgGEcxM,11
|
8
|
-
staticdash-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|