forked from equinor/webviz-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_example_data_download.py
32 lines (25 loc) · 956 Bytes
/
_example_data_download.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from typing import Optional
import dash_html_components as html
from dash import Dash
from .. import WebvizPluginABC, EncodedFile
class ExampleDataDownload(WebvizPluginABC):
def __init__(self, app: Dash, title: str):
super().__init__()
self.title = title
self.set_callbacks(app)
@property
def layout(self) -> html.H1:
return html.H1(self.title)
def set_callbacks(self, app: Dash) -> None:
@app.callback(self.plugin_data_output, self.plugin_data_requested)
def _user_download_data(data_requested: bool) -> Optional[EncodedFile]:
return (
WebvizPluginABC.plugin_compressed_data(
filename="webviz-data.zip",
content=[
{"filename": "some_file.txt", "content": "Some download data"}
],
)
if data_requested
else None
)