def disp_hover_data(clickData): if clickData != None: return_specific_car = [ dbc.FormGroup([ dbc.Badge('Link', color="light", className='information-specific-car-label'), html.Label(html.A(str(clickData['points'][0]['customdata'][0]), href=str( clickData['points'][0]['customdata'][0]), target='_blank'), className='information-specific-car') ]) ] a_website = clickData['points'][0]['customdata'][0] webbrowser.open_new_tab(a_website) columns_for_car = ['Title', 'Year', 'Price', 'Location'] for index, value in enumerate(columns_for_car): return_specific_car.append( dbc.FormGroup([ dbc.Badge(value, color="light", className='information-specific-car-label'), dbc.Label(str(clickData['points'][0]['customdata'][index + 1]), className='information-specific-car') ])) return return_specific_car
def __reset_canvas(self, reset_click: int): ctx = dash.callback_context if not ctx.triggered: raise PreventUpdate upload_last_modified = [] upload_file_namne = [] upload_contents = [] new_badges = [ dbc.Badge(id="energy_badge", children="Energy", pill=True, color="light"), dbc.Badge(id="distance_badge", children="Distance", pill=True, color="light"), dbc.Badge(id="contact_badge", children="Contacts", pill=True, color="light") ] new_spinner = dbc.Spinner( html.Div(id="trace-spinner", className="option_log_text", style={"marginBottom": "10px"})) self.__initialize_empty_components() return upload_contents, upload_file_namne, upload_last_modified, new_spinner, new_badges, "localhost:8050"
def __init__(self, name, sess_id, data): self.sess_id = sess_id self.p_data = data self.name = name self.raceName = self.p_data["race"] self.className = self.p_data["class"] self.num = data["session_num"] self.img_src = data["img_src"] self.channel = -1 self.cards = [] index = [] i = 0 for c in g_cards_name: if c in data['cards']: index.append(i) if "channel" in g_cards_name[c].keys(): self.channel = g_cards_name[c]["channel"] i += 1 for i in index: self.cards.append(g_cards[i]) self.create_layout() self.create_gm_interface() self.xp_to_use = 0 # Keep the name of the items for the mg GUI self.inventory = dbc.Row( [dbc.Badge("none", color="primary", className="mr-1")]) self.attribute_badges = [ dbc.Badge(attr + ": " + str(value), color="primary", className="mr-1") for attr, value in self.p_data["attribute"].items() ] self.bonus = dict([(attr, 0) for attr in self.p_data["attribute"]])
def status_badge(code): if code == 200: return dbc.Row(dbc.Badge("200 sucesso", color="success"), justify="center") elif code == 404: return dbc.Row(dbc.Badge("404 não encontrado", color="danger"), justify="center")
def complete_alarm(n_clicks, _id, tab): if n_clicks == 0: return 'Complete Alarm?' elif n_clicks == 1: return 'Are you sure?' elif n_clicks == 2: try: with open(f'log/{tab}/alarms.xml', 'r', encoding='utf-8') as fp: content = fp.read() bs_alarms = BS(content, 'lxml-xml') bs_alarms_tag = bs_alarms.find('alarms') bs_ongoing = bs_alarms.find('ongoing') bs_completed = bs_alarms.find('completed') if bs_completed is None: bs_completed = bs_alarms_tag.new_tag('completed') bs_alarm_to_move = bs_ongoing.find('alarm', {'id': _id['id_alarm']}) bs_completed.append(bs_alarm_to_move) bs_alarms_tag.append(bs_completed) with open(f"log/{tab}/alarms.xml", 'w', encoding='utf-8') as fp: fp.write(bs_alarms.prettify()) except FileNotFoundError: print('No alarm file found in log.') pass return dbc.Badge('Alarm completed', color='success') else: return dbc.Badge('Alarm completed', color='success')
def get_collection_badges(self) -> List[html.Span]: return [ html.Span([ dbc.Badge(f'{collection_id}', className='badge-pill', color='primary'), ' ' ]) for collection_id in self._loaded_collection_ids ] if self._loaded_collection_ids else [ html.Span([dbc.Badge('None', className='badge-pill')]) ]
def get_adf_badge(data, mi): if mi == 0: p_value = adf_pvalue(data) if p_value <= 0.05: color = 'success' else: color = 'danger' return dbc.Badge(round(p_value, 4), color=color, className='mr-1') else: return dbc.Badge('Unk', color='warning', className='mr-1')
def update_tab_content(active_tab): if active_tab == 'tab-1': output = case_endpoit.get_case_data(state_code='TT') else: output = case_endpoit.get_case_data(state_code='TN') return dbc.Row([ dbc.Col(html.H4(dbc.Badge(f'Confirmed {output["confirmed"]}', color="danger")), width="auto"), dbc.Col(html.H4(dbc.Badge(f'Recovered {output["recovered"]}', color="success")), width="auto"), dbc.Col(html.H4(dbc.Badge(f'Active {output["active"]}', color="warning")), width="auto"), dbc.Col(html.H4(dbc.Badge(f'Deceased {output["deaths"]}', color="dark")), width="auto")], justify='center')
def display_tags(es: ExperimentService): tags = es.get_tags() tag_badges = [ dbc.Badge( [t, html.I(className="fas fa-times-circle", style={"margin-left": "5px"})], id=f"experiment-tag-{i}", key=t, color="info", className="mr-1", pill=True, href="#", ) for i, t in enumerate(tags[:MAX_TAG_BADGES]) ] tooltips = [ dbc.Tooltip(f"""Remove "{t}" tag""", target=f"experiment-tag-{i}") for i, t in enumerate(tags[:MAX_TAG_BADGES]) ] for i in range(len(tags), MAX_TAG_BADGES): tag_badges.append( dbc.Badge("", id=f"experiment-tag-{i}", href="#", style={"display": "none"}) ) if len(tags) > MAX_TAG_BADGES: tag_badges.append( dbc.Badge( html.I(className="fas fa-ellipsis-h"), id="experiment-edit-tags-modal-open", color="info", className="mr-1", pill=True, href="#", ) ) tooltips.append( dbc.Tooltip( "See all tags or edit", target="experiment-edit-tags-modal-open" ) ) else: tag_badges.append( dbc.Badge( html.I(className="fas fa-edit", style={"margin-left": "3px"}), id="experiment-edit-tags-modal-open", color="info", className="mr-1", pill=True, href="#", ) ) tooltips.append( dbc.Tooltip("Edit tags", target="experiment-edit-tags-modal-open") ) return [html.Span(tag_badges), html.Div(children=tooltips)]
def get_freqmap_card_ghsom(): return dbc.CardBody(children=[ html.Div( children=[ html.Div(id='grafo_ghsom_freq', children='', style=pu.get_css_style_center()), html.Div( id='div_freq_map_ghsom', children=None #,style={'margin': '0 auto','width': '100%', 'display': 'flex','align-items': 'center', 'justify-content': 'center','flex-wrap': 'wrap', 'flex-direction': 'column ' } ), ], style=pu.get_css_style_inline_flex()), html.Div(children=[ dbc.FormGroup([ dbc.RadioItems( options=[ { "label": "Linear Scale", "value": 0 }, { "label": "Logarithmic Scale", "value": 1 }, ], value=0, id="radioscale_freq_ghsom", inline=True, ), ], style=pu.get_css_style_center()) ]), html.Div(style=pu.get_css_style_inline_flex(), children=[ html.H6( dbc.Badge('Minimum hits to plot a neuron ', pill=True, color="light", className="mr-1")), html.H6( dbc.Badge('0', pill=True, color="warning", className="mr-1", id='badge_min_hits_slider_ghsom')), ]), dcc.Slider(id='min_hits_slider_ghsom', min=0, max=0, value=0, step=1), ])
def update_table(symbol): evaluations = get_stock_evaluation() if (any(evaluations)): # if any reason exists return html.Span( html.H5([ dbc.Badge(evaluation, pill=True, color="danger", className="mr-1") for evaluation in evaluations ])) else: return html.H5( dbc.Badge("GOOD", pill=True, color="success", className="mr-1"))
def Card(image, title, description, link, badge, git): card = dbc.Col(html.Div( [ html.A(html.Div(html.Img(src=image, alt=title), className="bottom16 portfolio_card_img"), href=link, target="_blank"), html.Div([ html.H4(title, className="font-sm bold uppercase"), html.P(description, className="font-xs"), ], className="portfolio_card_text bottom16"), html.Div([ html.Div([ html.Div(dbc.Badge( i, className="mr-1 self_center default_inverse primary_bg" ), className="inline-block") for i in badge ]), html.A(html.I(className="fab fa-github font-sm terciary"), href=git, target="_blank"), ], className="font-xs flex_row_btw portfolio_card_footer") ], className="second_bg padding16 radius8 portfolio_card"), className="padding16", lg=4, md=6, sm=6, xs=12) return card
def page_content(): projects = json.loads(open("projects.json").read()) columns = [] #iter over pojects for project in projects: #set color of badge if project["status"] == "ONLINE": color = "success" elif project["status"] == "OFFLINE": color = "danger" else: color = "warning" #create project cards columns.append( dbc.Col( children = [ dbc.Alert( children = [ html.H4(project["name"]), dbc.Badge(project["status"], color = color), html.Div( html.H1( emoji.emojize(project["icon"]), style = {"font-size": "50px"} ), style = flex_style ), html.Br(), html.Div( html.A( dbc.Button( "VIEW", color = "primary", block = True ), href = project["url"], target = "_blank", style = {"width": "200px"} ), style = flex_style ), html.Div(style = {"width": "300px"}) ], color = "primary", style = { "height": "90%" } ), html.Br(), ] ) ) #return row return dbc.Row( children = columns )
def store_questionaire_answer(data, n): if n: answer = json.loads(data) header = html.Div( [ html.Div([ html.H1("KCCQ Questionnaire", style={ "font-size": "1.6rem", "padding-right": "30px" }), dbc.Badge(answer["answer-date"] + " Completed", color="primary", className="mr-1", style={ "font-family": "NotoSans-SemiBold", "font-size": "1rem" }), ]), html. H6("Instructions: The following questions refer to your heart failure and how it may affect your life. Please read and complete the following questions. There are no right or wrong answers. Please mark the answer that best applies to you." ) ], style={ "width": "80%", "padding-left": "40px", "padding-right": "40px", "padding-top": "10px", "padding-bottom": "10px" }) return answer["q1a"], answer["q1b"], answer["q1c"], answer[ "q2"], answer["q3"], answer["q4"], answer["q5"], answer[ "q6"], answer["q7"], answer["q8a"], answer["q8b"], answer[ "q8c"], header return "", "", "", "", "", "", "", "", "", "", "", "", ""
def make_pill(token, tag, idx): return dbc.Badge(token, pill=True, color="primary", className="mr-1", style=tag_colors[tag], id=f"tooltip-target-tag-{idx}")
def downsample_counts_slider(): m = dbc.Card(children=[ dbc.CardHeader("Downsample UMI counts"), dbc.CardBody(children=[ html.Div(children=[ html. P("Take only a fraction of UMIs (unique mRNA molecules) for downstream analysis" ) ]), dcc.Slider(id="downsample_counts_slider", min=5, max=100, step=5, marks={ 10: "10%", 25: "25%", 50: "50%", 75: "75%", 100: "100% (default)" }, value=100) ]), dbc.CardFooter(children=[ html.H4([ dbc.Badge("% UMI counts = 100% ()", id="downsample_counts_output_container") ]) ]) ]) return m
def _make_nav_item(sector_name, emissions, indent, page, bold=False, active=False): attrs = {} if page is None: attrs['disabled'] = True else: attrs['disabled'] = False attrs['href'] = page.path style = {} if indent: style = {'marginLeft': '%drem' % 2 * indent} if bold: style = {'fontWeight': 'bold'} if active: attrs['active'] = True item = dbc.ListGroupItem([ html.Span(sector_name, style=style), dbc.Badge( "%.0f kt" % emissions, color="light", className="ml-1 float-right") ], action=True, **attrs) return item
def get_freqmap_card_gsom(): return dbc.CardBody(children=[ html.Div(id='div_freq_map_gsom', children='', style=pu.get_single_heatmap_css_style()), dbc.FormGroup([ dbc.RadioItems( options=[ { "label": "Linear Scale", "value": 0 }, { "label": "Logarithmic Scale", "value": 1 }, ], value=0, id="radioscale_freq_gsom", inline=True, ), ], style=pu.get_css_style_center()), html.Div(style=pu.get_css_style_inline_flex(), children=[ html.H6( dbc.Badge('Minimum hits to plot a neuron ', pill=True, color="light", className="mr-1")), html.H6( dbc.Badge('0', pill=True, color="warning", className="mr-1", id='badge_min_hits_slider_gsom')), ]), dcc.Slider(id='min_hits_slider_gsom', min=0, max=0, value=0, step=1), html.Div([ dbc.Button("Plot", id="ver_freq_map_gsom_button", className="mr-2", color="primary") ], style=pu.get_css_style_center()) ])
def generate_pos_subtitles(): return html.Div([html.H5("Label colors")] + [ dbc.Badge(pos, pill=True, color="primary", className="mr-1", style=tag_colors[pos]) for pos in tag_colors ])
def checklist_domain_measures_lv1(d): domain_focus = list(Domain_options.keys()) measures_lv1 = Domain_options[domain_focus[d]] key = list(measures_lv1.keys()) n = len(key) button_group = [] for i in range(n): if len(measures_lv1[key[i]]) == 0: hidden_status = True else: hidden_status = False default = [] for v in measures_lv1[key[i]]: if v in default_measure: default.append(v) button_measure_lv1 = html.Div([dbc.FormGroup( [ dbc.Row([ dbc.Button( u"{}".format(key[i]), id=u"optimizer-measures-lv1-{}-{}".format(d+1,i+1), color = "light", style={"background-color":"#ebebeb","border":"none", "border-radius":"10rem", "font-family":"NotoSans-Regular", "font-size":"0.8rem", "height":"2rem"} ), html.Div( [ dbc.Badge(id = u"optimizer-card-selected-{}-{}".format(d+1,i+1), color="primary", className="ml-1", #style={"padding":"0.8rem"} ), ], #style={"margin-top":"0.8rem","margin-bottom":"0.8rem"} ) ]), dbc.Collapse( dbc.FormGroup([ dbc.Checklist( options = [{"label" : k, "value": k, "disabled" : False} if k in undisabled_list else {"label" : k, "value": k, "disabled" : True} for k in measures_lv1[key[i]]], value=default, id=u"optimizer-checklist-domain-measures-lv2-{}-{}".format(d+1,i+1), inline=True, # persistence = True, # persistence_type = 'session', ), html.Hr(className="my-2") ]), id=u"optimizer-checklist-domain-measures-lv2-container-{}-{}".format(d+1,i+1), style={"margin-top":"1rem", "font-family":"NotoSans-Regular", "font-size":"0.8rem"} ) ] )], hidden = hidden_status, style={"padding-left":"2rem", "padding-right":"2rem"}) button_group.append(button_measure_lv1) return html.Div(button_group)
def ServerStatusList(cache): version = html.H4(dbc.Badge(conplot_version(), color='primary', pill=True)) if is_redis_available(cache): redis_badge = html.H4(dbc.Badge('OK', color='success', pill=True)) active_sessions = html.H4( dbc.Badge(get_active_sessions(cache), color='primary', pill=True)) else: redis_badge = html.H4(dbc.Badge('ERROR', color='danger', pill=True)) active_sessions = html.H4(dbc.Badge('ERROR', color='danger', pill=True)) if postgres_utils.is_postgres_available(): postgres_badge = html.H4(dbc.Badge('OK', color='success', pill=True)) else: postgres_badge = html.H4(dbc.Badge('ERROR', color='danger', pill=True)) return dbc.Row(dbc.ListGroup([ StatusItem(idx=1, name='Cache status', status_badge=redis_badge), StatusItem(idx=2, name='Database status', status_badge=postgres_badge), StatusItem(idx=3, name='Server load', status_badge=active_sessions), StatusItem(idx=4, name='App version', status_badge=version) ], style={'width': '75%'}), justify='center', align='center')
def generate_qm(item): id_hash = df_variables[df_variables["nom_variable"] == item].index.values[0] question_mark = dbc.Badge("?", pill=True, color="light", id="badge-" + str(id_hash)) return dbc.Col(question_mark, width=1, style={"padding": "5px"})
def update_search_results(results_store, country_filter, income_filter, category_filter, sector_filter, page_store, tags_store): """create search cards from tags selected""" # get search results if not results_store: return "Please search for a tag above" df = filter_results(results_store, country_filter, income_filter, category_filter, sector_filter) cards = [] # subset for pagination start = int(page_store.get('start', 0)) end = int(page_store.get('end', PAGE_LIMIT)) print(df.iloc[start:end, :]) for _, result in df.iloc[start:end, :].iterrows(): # get tags and build badge list tags = tags_store.get(result['Report_ID']) tag_pills = [] for tag in tags: pill = dbc.Badge(tag, pill=True, color='secondary', className='mr-1') tag_pills.append(pill) # build report card report_card = dbc.Card( dbc.CardBody([ html.H4(result['Report_Title'], className="card-title"), html.H6( html.A( result['Project'].upper(), # id='report_link', href=f"/apps/project?{result['Project']}"), className="card-subtitle"), html.P( result['Summary'], className="card-text", ), html.A("Report link", href=result['Link'], target="_blank"), html.Br(), html.Div(tag_pills) ]), style={"margin-top": "2rem"}) cards.append(report_card) if len(cards) > 0: return cards else: return "No results found"
def badge(num): float(num) if num < 0: return html.P( dbc.Badge('{}%'.format(num), color="danger", pill=True, className="mr-1")) elif num == 0: return html.P( dbc.Badge('{}%'.format(num), color="warning", pill=True, className="mr-1")) else: return html.P( dbc.Badge('{}%'.format(num), color="success", pill=True, className="mr-1"))
def show_document(match: dict): url = f"/pdf/{match['pdf']}" iframe = dbc.Row( dbc.Col(html.Iframe(src=url, style={ "width": "100%", "height": "100%" })), style={ "resize": "vertical", "overflow-y": "hidden", "height": "1000px", "min-height": "100px", }, ) title = match["title"].replace("_", " ") title = " ".join([w.capitalize() for w in title.split()]) title = dbc.Row(dbc.Col(html.H3(title))) date = html.A( match["date"], id={ "type": "link_date", "date": match["date"] }, href="#", n_clicks=0, style={ "text-decoration": "none", "color": "inherit" }, ) tags = html.P([ dbc.Badge( tag, id={ "type": "link_tag", "tag": tag }, href="#", n_clicks=0, color="primary", className="mr-1", ) for tag in match["tags"] ]) data = dbc.Table( [ html.Tbody([ html.Tr([html.Td("Date"), html.Td(date)]), html.Tr([html.Td("Tags"), html.Td(tags)]), ]) ], striped=True, ) return dbc.Row([dbc.Col([title, data], width=4), dbc.Col(iframe)])
def estimates(v1, v2, unit): return html.Div([ dbc.Button( [ "Annual potential (admin.ch)", dbc.Badge( "%.1f %s" % (v1, unit), color="light", className="ml-1") ], color="primary", ), html.Label(' - '), dbc.Button( [ "Annual potential (EPFL)", dbc.Badge("%.1f %s" % (v2, unit) if v2 is not None else 'N/A', color="light", className="ml-1") ], color="secondary", ) ])
def get_results_collection_badges(self) -> List[html.Span]: if self.results_collection_id: if self.results_file_ready: if self.job_id: color = 'success' else: color = 'primary' else: if self.job_id: color = 'warning' else: color = 'danger' return [ html.Span([ dbc.Badge(f'{self.results_collection_id}', className='badge-pill', color=color), ' ' ]) ] else: return [html.Span([dbc.Badge('None', className='badge-pill')])]
def get_status_badge(status: Status): if status == Status.FINISHED: status_badge_color = "success" elif status == Status.FAILED: status_badge_color = "danger" elif status == Status.IN_PROGRESS: status_badge_color = "primary" else: status_badge_color = "secondary" return dbc.Badge( status.value, color=status_badge_color, className="experiment-status-badge" )
def status(): return html.Div( html.Div( [ html.Div( html.H1("Overview", style={"font-size":"2rem","color":"#000"}), style={"text-align":"start","padding-bottom":"0rem"}, ), html.Div( [ html.Div( html.Div( [ html.H6("TOTAL PATIENT ASSIGNED", style={"color":"#fff","width":"7rem"}), dbc.Badge("", id = 'physician-badge-patientct',style={"font-family":"NotoSans-SemiBold","font-size":"1.2rem","border-radius":"10rem","width":"4.5rem","background":"#fff","color":"#1357dd"}), ], style={"border-radius":"0.8rem", "border":"1px solid #1357dd","background":"#1357dd","padding":"0.5rem","box-shadow":"0 4px 8px 0 rgba(19, 86, 221, 0.4), 0 6px 20px 0 rgba(19, 86, 221, 0.1)"} ), style={"padding":"1rem"} ), html.Div( html.Div( [ html.H6("TOTAL ACTIVE TASKS", style={"color":"#fff","width":"7rem"}), dbc.Badge("", id = 'physician-badge-activetasks', style={"font-family":"NotoSans-SemiBold","font-size":"1.2rem","border-radius":"10rem","width":"4.5rem","background":"#fff","color":"#dc3545"}), ], style={"border-radius":"0.8rem", "border":"1px solid #dc3545","background":"#dc3545","padding":"0.5rem","box-shadow":"0 4px 8px 0 rgba(220, 53, 70, 0.4), 0 6px 20px 0 rgba(220, 53, 70, 0.1)"} ), style={"padding":"1rem"} ), ], style={"display":"flex"} ), ], style={"padding-top":"3rem", "padding-left":"11rem", "padding-bottom":"2rem", "background":"#f5f5f5"} ) )
def _make_navbar(self): if flask.has_request_context(): custom_setting_count = len( [k for k in session.keys() if not k.startswith('_')]) else: custom_setting_count = 0 badge_el = None if custom_setting_count: badge_el = dbc.Badge(f'{custom_setting_count} ', className='badge-danger') els = [ dbc.DropdownMenu( [ dbc.DropdownMenuItem(_('Population'), href='/vaesto'), dbc.DropdownMenuItem(_('Buildings'), href='/rakennukset') ], nav=True, in_navbar=True, label=_("Defaults"), # id="dropdown-nav" ), dbc.NavItem( dbc.NavLink(href='/omat-asetukset', children=[ _("Own settings"), badge_el, ])), dbc.NavItem(html.Span(html.I(className='language-icon')), className='nav-link pr-0'), dbc.DropdownMenu( [ dbc.DropdownMenuItem( "Suomi", href='/language/fi', external_link=True), dbc.DropdownMenuItem( "English", href='/language/en', external_link=True) ], nav=True, in_navbar=True, label=get_active_locale().upper(), right=True, ), ] return dbc.NavbarSimple(brand=get_variable('site_name_%s' % get_active_locale()), brand_href="/", color="primary", dark=True, fluid=True, children=els)