MarcSkovMadsen commited on
Commit
7390946
1 Parent(s): 7acae1b

add loading indicator

Browse files
Files changed (3) hide show
  1. app.py +51 -23
  2. download_datasets.py +1 -1
  3. utils.py +57 -0
app.py CHANGED
@@ -11,6 +11,7 @@ from utils import (
11
  DATASHADER_URL,
12
  DESCRIPTION,
13
  MAJOR_TOM_LOGO,
 
14
  MAJOR_TOM_PICTURE,
15
  MAJOR_TOM_REF_URL,
16
  PANEL_LOGO,
@@ -178,35 +179,62 @@ class ImageInput(pn.viewable.Viewer):
178
  self.plot = hv.RGB(image_array).opts(xaxis=None, yaxis=None)
179
 
180
 
181
- pn.extension("tabulator", design="fast")
 
 
182
 
183
- dataset = DatasetInput()
184
- app = MapInput(data=dataset.param.data)
185
- image_input = ImageInput(data=app.param.data_selected)
186
 
 
 
 
 
 
 
 
 
 
 
187
 
188
- main = pn.Column(
189
- pn.FlexBox(
190
- pn.Column(dataset, app),
191
- image_input,
192
- ),
193
- )
194
- sidebar = pn.Column(
195
- pn.pane.Image(
196
- MAJOR_TOM_LOGO, link_url=MAJOR_TOM_REF_URL, sizing_mode="stretch_width"
197
- ),
198
- pn.pane.Image(
199
- MAJOR_TOM_PICTURE, link_url=MAJOR_TOM_REF_URL, sizing_mode="stretch_width"
200
- ),
201
- DESCRIPTION,
202
- pn.pane.Image(PANEL_LOGO, link_url=PANEL_URL, width=200, margin=(10, 20)),
203
- pn.pane.Image(DATASHADER_LOGO, link_url=DATASHADER_URL, width=200, margin=(10, 20)),
204
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
 
206
  pn.template.FastListTemplate(
207
  title="Major TOM Explorer",
208
- main=[main],
209
- sidebar=[sidebar],
210
  main_layout=None,
211
  accent="#003247", # "#A01346"
212
  ).servable()
 
11
  DATASHADER_URL,
12
  DESCRIPTION,
13
  MAJOR_TOM_LOGO,
14
+ MAJOR_TOM_LYRICS,
15
  MAJOR_TOM_PICTURE,
16
  MAJOR_TOM_REF_URL,
17
  PANEL_LOGO,
 
179
  self.plot = hv.RGB(image_array).opts(xaxis=None, yaxis=None)
180
 
181
 
182
+ class App(param.Parameterized):
183
+ sidebar = param.Parameter()
184
+ main = param.Parameter()
185
 
186
+ def __init__(self, **params):
187
+ super().__init__(**params)
 
188
 
189
+ self.sidebar = self._create_sidebar()
190
+ self.main = pn.FlexBox(
191
+ pn.Column(
192
+ pn.Row(
193
+ pn.indicators.LoadingSpinner(value=True, size=50),
194
+ "**Loading data...**",
195
+ ),
196
+ MAJOR_TOM_LYRICS,
197
+ )
198
+ )
199
 
200
+ pn.state.onload(self._update_main)
201
+
202
+ def _create_sidebar(self):
203
+ return pn.Column(
204
+ pn.pane.Image(
205
+ MAJOR_TOM_LOGO, link_url=MAJOR_TOM_REF_URL, sizing_mode="stretch_width"
206
+ ),
207
+ pn.pane.Image(
208
+ MAJOR_TOM_PICTURE,
209
+ link_url=MAJOR_TOM_REF_URL,
210
+ sizing_mode="stretch_width",
211
+ ),
212
+ DESCRIPTION,
213
+ pn.pane.Image(PANEL_LOGO, link_url=PANEL_URL, width=200, margin=(10, 20)),
214
+ pn.pane.Image(
215
+ DATASHADER_LOGO, link_url=DATASHADER_URL, width=200, margin=(10, 20)
216
+ ),
217
+ )
218
+
219
+ def _create_main_content(self):
220
+ dataset = DatasetInput()
221
+ map_input = MapInput(data=dataset.param.data)
222
+ image_input = ImageInput(data=map_input.param.data_selected)
223
+
224
+ return pn.Column(dataset, map_input), image_input
225
+
226
+ def _update_main(self):
227
+ self.main[:] = list(self._create_main_content())
228
+
229
+
230
+ pn.extension("tabulator", design="fast")
231
+
232
+ app = App()
233
 
234
  pn.template.FastListTemplate(
235
  title="Major TOM Explorer",
236
+ main=[app.main],
237
+ sidebar=[app.sidebar],
238
  main_layout=None,
239
  accent="#003247", # "#A01346"
240
  ).servable()
download_datasets.py CHANGED
@@ -4,4 +4,4 @@ for dataset in DATASETS:
4
  print(f"downloading {dataset}")
5
  get_meta_data(dataset=dataset)
6
 
7
- print("finished downloading datasets")
 
4
  print(f"downloading {dataset}")
5
  get_meta_data(dataset=dataset)
6
 
7
+ print("finished downloading datasets")
utils.py CHANGED
@@ -36,6 +36,63 @@ To find a sample, navigate on the map to a place of interest. Click the map to f
36
 
37
  """
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  hv.extension("bokeh")
40
 
41
  opts.defaults(
 
36
 
37
  """
38
 
39
+ MAJOR_TOM_LYRICS = """
40
+ Standing there alone, the ship is waiting
41
+ All systems are go, are you sure?
42
+ Control is not convinced, but the computer
43
+ Has the evidence, no need to abort
44
+ The countdown starts
45
+
46
+ Watching in a trance, the crew is certain
47
+ Nothing left to chance, all is working
48
+ Trying to relax up in the capsule
49
+ "Send me up a drink, " jokes **Major Tom**
50
+ The count goes on
51
+
52
+ Four, three, two, one
53
+
54
+ Earth below us, drifting, falling
55
+ Floating weightless, calling, calling home
56
+
57
+ Second stage is cut, we're now in orbit
58
+ Stabilizers up, running perfect
59
+ Starting to collect requested data
60
+ "What will it affect when all is done?"
61
+ Thinks **Major Tom**
62
+
63
+ Back at ground control, there is a problem
64
+ Go to rockets full, not responding
65
+ "Hello **Major Tom**, are you receiving?
66
+ Turn the thrusters on, we're standing by"
67
+ There's no reply
68
+
69
+ Four, three, two, one
70
+
71
+ Earth below us, drifting, falling
72
+ Floating weightless, calling, calling home
73
+
74
+ Across the stratosphere a final message
75
+ "Give my wife my love, " then nothing more
76
+ Far beneath the ship, the world is mourning
77
+ They don't realize he's alive
78
+ No one understands, but **Major Tom** sees
79
+ "Now the light commands, this is my home
80
+ I'm coming home"
81
+
82
+ Earth below us, drifting, falling
83
+ Floating weightless, coming home
84
+ Earth below us, drifting, falling
85
+ Floating weightless, coming home
86
+ Earth below us, drifting, falling
87
+ Floating weightless, coming, coming home
88
+
89
+ Home
90
+ Home
91
+ Home
92
+ Home
93
+ Home
94
+ """
95
+
96
  hv.extension("bokeh")
97
 
98
  opts.defaults(