async def initialize(q: Q): # Initialize H2O-3 model and tests data set churn_predictor.build_model(config.training_data_url, config.default_model) churn_predictor.set_testing_data_frame(config.testing_data_url) churn_predictor.predict() q.app.header_png = await q.site.upload([config.image_path]) q.app.training_file_url = await q.site.upload([config.working_data]) q.page["title"] = ui.header_card( box=config.boxes["banner"], title=config.title, subtitle=config.subtitle, icon=config.icon, icon_color=config.color, ) q.page["nav_bar"] = ui.tab_card( box=config.boxes["navbar"], value=f'#{q.args["#"]}', items=[ ui.tab(name="#profile", label="Customer Profiles"), ui.tab(name="#tour", label="Application Code"), ], ) q.page['meta'] = ui.meta_card(box='', title='Telcom Churn Analytics') q.client.app_initialized = True
async def serve(q: Q): hash = q.args['#'] if hash: blurb = q.page['blurb'] if hash == 'menu/spam': blurb.content = "Sorry, we're out of spam!" elif hash == 'menu/ham': blurb.content = "Sorry, we're out of ham!" elif hash == 'menu/eggs': blurb.content = "Sorry, we're out of eggs!" elif hash == 'about': blurb.content = 'Everything here is gluten-free!' else: q.page['nav'] = ui.tab_card( box='1 1 4 1', items=[ ui.tab(name='#menu/spam', label='Spam'), ui.tab(name='#menu/ham', label='Ham'), ui.tab(name='#menu/eggs', label='Eggs'), ui.tab(name='#about', label='About'), ], ) q.page['blurb'] = ui.markdown_card( box='1 2 4 2', title='Store', content='Welcome to our store!', ) await q.page.save()
def card_navbar() -> ui.TabCard: """ Card for top navigation bar. """ card = ui.tab_card(box=box_nav_bar, items=[ ui.tab(name='#home', label='Home'), ui.tab(name='#data', label='People') ]) return card
async def serve(q: Q): if not q.client.initialized: q.client.tab = 'a' q.page['tabs'] = ui.tab_card( # Initialize once box='1 1 4 1', items=[ui.tab(name=f'#{t}', label=t.upper()) for t in TABS]) q.client.initialized = True if q.args['#']: q.client.tab = str(q.args['#']) await remove_cards(q) await display_tab(q) await q.page.save()
async def serve(q: Q): if '#' in q.args: hash_ = q.args['#'] q.page['tabs'] = ui.form_card(box='1 1 2 5', items=[ ui.text(f'#={hash_}'), ui.button(name='show_tabs', label='Back', primary=True), ]) else: q.page['tabs'] = ui.tab_card( box='1 1 4 1', items=[ ui.tab(name='#menu/spam', label='Spam'), ui.tab(name='#menu/ham', label='Ham'), ui.tab(name='#menu/eggs', label='Eggs'), ui.tab(name='#about', label='About'), ], ) await q.page.save()
async def serve(q: Q): content = 'Welcome to our store!' location = q.args['#'] if location: if location == 'menu/spam': content = "Sorry, we're out of spam!" elif location == 'menu/ham': content = "Sorry, we're out of ham!" elif location == 'menu/eggs': content = "Sorry, we're out of eggs!" elif location == 'about': content = 'Everything here is gluten-free!' if not q.client.initialized: q.page['nav'] = ui.tab_card( box='1 1 4 1', items=[ ui.tab(name='#menu/spam', label='Spam'), ui.tab(name='#menu/ham', label='Ham'), ui.tab(name='#menu/eggs', label='Eggs'), ui.tab(name='#about', label='About'), ], value=f'#{location}' if location else None, ) q.page['blurb'] = ui.markdown_card( box='1 2 4 2', title='Store', content=content, ) q.client.initialized = True elif location: blurb = q.page['blurb'] blurb.content = content await q.page.save()
async def serve(q: Q): hash = q.args['#'] if hash == 'form': q.page['navigation'] = ui.form_card(box='1 1 -1 11', items=[ ui.table( name='issues', columns=columns, rows=[ui.table_row( name=issue.id, cells=[issue.to_sid, issue.from_sid, issue.quote, issue.author, issue.quote_category, issue.vote, str(issue.quote_length), str(issue.num_unique_words)] ) for issue in issues], groupable=True, downloadable=False, resettable=True, height='800px' ), ui.button(name='show_tabs', label='Back', primary=True), ]) elif hash == 'home': q.page['navigation'] = ui.form_card(box='1 1 4 -1', items=[ ui.text(sample_markdown), ui.button(name='show_tabs', label='Back', primary=True), ]) else: q.page['navigation'] = ui.tab_card( box='1 1 4 1', items=[ ui.tab(name='#home', label='Home'), ui.tab(name='#form', label='Quote Table') ], link = True, ) await q.page.save()