コード例 #1
0
def model_run_buttons():
    return html.Div([
        dbc.Button("Run Model",
                   id="run_model_button",
                   color="primary",
                   className="mr-1",
                   disabled=True),
        dbc.Button("See Results",
                   id="model_results_button",
                   color="success",
                   className="mr-1",
                   target="_blank",
                   disabled=True),
        dbc.Toast(
            [html.P("Model execution succeeded", className="mb-0")],
            id="run_model_toast",
            header="Notification",
            duration=3000,
            icon="primary",
            dismissable=True,
        ),
        dbc.Toast(
            [
                html.P("No cached results, please run model first",
                       className="mb-0")
            ],
            id="no_results_toast",
            header="Notification",
            duration=3000,
            icon="primary",
            dismissable=True,
        ),
    ])
コード例 #2
0
ファイル: login.py プロジェクト: epwalsh/allennlp-manager
 def try_log_in(n_clicks, username, password):
     if current_user.is_authenticated:
         return dbc.Toast(
             "You are already logged in",
             id="login-state-notification",
             header="Success",
             icon="success",
         )
     if not n_clicks or not username or not password:
         raise PreventUpdate
     user = UserService().find(username, password)
     if user:
         login_user(user)
         return dbc.Toast(
             f"Welcome, {user.username}!",
             id="login-state-notification",
             header="Success",
             icon="success",
         )
     return dbc.Toast(
         "Invalid username or password",
         id="login-state-notification",
         header="Error",
         dismissable=True,
         duration=4000,
         icon="danger",
     )
コード例 #3
0
    def render_page(pathname: str, param_string: str, current_path_data):
        if pathname is None:
            raise PreventUpdate
        logger.debug("Attempting to render page %s", pathname)
        if pathname != "/" and pathname.endswith("/") or pathname.endswith(
                "#"):
            pathname = pathname[:-1]
        if current_path_data:
            # If nothing in the path / param_string has changed, don't actually do anything.
            # NOTE: this is kind of a hack, since sometimes we have buttons w/ href='#',
            # and we don't want to actually re-render the pages content when clicked.
            if (current_path_data["pathname"] == pathname
                    and current_path_data["param_string"] == param_string):
                raise PreventUpdate
        updated_data = {"pathname": pathname, "param_string": param_string}
        try:
            PageClass = Page.by_name(pathname)
            if PageClass.permissions:
                if not current_user.is_authenticated:
                    PageClass = Page.by_name("/login")
                    params = PageClass.Params(next_pathname=pathname,
                                              next_params=param_string)
                    return PageClass.from_params(params).render() + (
                        None, updated_data)
                if PageClass.permissions > current_user.permissions:
                    raise NotPermittedError(
                        "You do not have adequate permissions to view this page"
                    )

            params = from_url(PageClass.Params, param_string)
            return PageClass.from_params(params).render() + (None,
                                                             updated_data)
        except RegistrationError:
            return (
                [],
                [],
                [],
                dbc.Toast(f"Page {pathname} not found",
                          header="404",
                          icon="danger"),
                updated_data,
            )
        except InvalidPageParametersError as e:
            return (
                [],
                [],
                [],
                dbc.Toast(str(e), header="Bad page parameters", icon="danger"),
                updated_data,
            )
        except Exception as e:
            logger.exception(e)
            return (
                [],
                [],
                [],
                dbc.Toast(str(e), header=e.__class__.__name__, icon="danger"),
                updated_data,
            )
コード例 #4
0
ファイル: layouts.py プロジェクト: rlcjj/fitly
def main_layout_header():
    """Dash layout with a top-header"""
    return html.Div(
        [
            make_header(),
            dbc.Container(
                dbc.Row(dbc.Col(id=server.config["CONTENT_CONTAINER_ID"])), fluid=True
            ),
            dcc.Location(id=server.config["LOCATION_COMPONENT_ID"], refresh=False),

            dbc.Toast(
                id="db-refresh-toast",
                header="Fit.ly",
                is_open=False,
                dismissable=False,
                icon="danger",
                # top: 66 positions the toast below the navbar
                style={"position": "fixed", "top": 66, "right": 10, "width": 350},
                children=[
                    dbc.Row(className='align-items-center text-center', children=[
                        dbc.Col(className='col-2', children=[dbc.Spinner(size='md', color="danger")]),
                        dbc.Col(className='col-8 text-center', children=['Database Refresh in Progress'])
                    ])
                ],
            ),
            dcc.Interval(id='db-refresh-toast-interval', interval=3 * 1000, n_intervals=0),
        ]
    )
コード例 #5
0
def make_toast(message):
    """
    Helper function for making a toast. dict id for use in pattern matching
    callbacks.

    The messages in the message store take the form

    {"id": id, "number": number}

    but we could add any additional fields we like to control how the Toast
    renders. For example, perhaps we could add an `icon` field to control the
    color of the icon for different messages, or a `header` field.
    """
    id_ = message["id"]
    return dbc.Toast(
        f"A random number: {message['number']}",
        id={
            "type": "toast",
            "id": id_
        },
        key=id_,
        header="Positioned toast",
        is_open=True,
        dismissable=True,
        icon="danger",
    )
コード例 #6
0
def get_create_style_components():
    style_components = [
        html.H3("Styles"),
        html.A(
            children="Style Reference",
            href="https://js.cytoscape.org/#style",
            target="_blank",
        ),
        dbc.Input(
            id=id_constants.STYLE_NAME_INPUT,
            type="text",
            placeholder="Style Name",
        ),
        dbc.Textarea(id=id_constants.STYLE_TEXTAREA),
        dbc.Button(
            id=id_constants.LOAD_STYLE_TEXTAREA_BUTTON,
            children="Load Style",
        ),
        dbc.Button(
            id=id_constants.SAVE_STYLE_TEXTAREA_BUTTON,
            children="Save Style",
        ),
        dbc.Button(
            id=id_constants.DELETE_STYLE_BUTTON,
            children="Delete Style",
        ),
        dbc.Toast(
            id=id_constants.SAVE_STYLE_TOAST,
            duration=3000,
            dismissable=True,
            body_style={"display": "none"},
            is_open=False,
        ),
    ]
    return style_components
コード例 #7
0
ファイル: AppLayout.py プロジェクト: bp89/plotlyDashEx
 def app_layout():
     return html.Div(children=[
         html.Div(children=[
             html.Span(children=[
                 html.Img(src='static/assets/logo.png',
                          style={
                              'height': '50px',
                              'width': '85px'
                          }),
                 html.H2(className='ta-center', children='Easy Banking'),
             ],
                       className='d-inline-flex')
         ],
                  className=
                  'd-inline-flex mb-4 border-bottom container-fluid'),
         dbc.Toast(
             [en_US['realtime_data_warning']],
             header='Warning',
             icon="warning",
             duration=4000,
             dismissable=True,
             style={
                 "position": "fixed",
                 "top": 0,
                 "right": '0%',
                 "width": 550
             },
         ),
         get_header_tabs(
             dict(home=home_content(),
                  savings=savings_content(),
                  loan=loan_content()))
     ])
コード例 #8
0
    def create(self, nwb_files, notebook, c_file):
        self.notebook = notebook
        self.c_file = c_file

        file_list = []
        block_names = sorted(list(nwb_files.keys()))
        for index in range(len(nwb_files)):
            block_index = int(block_names[index].split()[1]) - 1
            file_list.append({'label': notebook['Runs']['StimulusSet'][block_index] + " - " + block_names[index],
                              'value': block_names[index], 'fullpath': nwb_files[block_names[index]]})
        self.nwb_files = file_list
        left_panel = LeftPanel(file_list, self.c_file)
        middle_panel = Panel(width=6, name="middle_panel")
        right_panel = Panel(width=4, name="right_panel")
        self.panels = [left_panel, middle_panel, right_panel]
        print("Load file")
        nwb_io = NWBHDF5IO(nwb_files[file_list[c_file]["value"]], 'r')
        nwb_file = nwb_io.read()
        print("Create experiment")
        self.experiment = ExperimentFactory.create_experiment(nwb_file.protocol, nwb_file, self.panels, self.electrode,
                                                              self.stimuli)
        print("Apply layout")
        app.layout = html.Div(id="dashboard", children=[dbc.Row(children=self.experiment.get_html(), className="m-1"),
                                                        dbc.Toast(
                                                            [html.P("This is the content of the toast",
                                                                    className="mb-0")],
                                                            id="warning-toast",
                                                            header="Warning",
                                                            icon="danger",
                                                            dismissable=True,
                                                            is_open=False,
                                                            style={"position": "fixed", "top": 10, "right": 10,
                                                                   "width": 350})
                                                        ])
コード例 #9
0
def get_layout(token):
    old_password = dcc.Input(id='old-password-input',
                             type='password',
                             placeholder='Password')
    new_password = dcc.Input(id='new-password-input',
                             type='password',
                             placeholder='New Password')
    email = token['username']
    userInfo = UserInfo(token['username'])
    settings = userInfo.get_settings()
    email = settings['email']

    email_input = dcc.Input(id='email-input',
                            value=email,
                            type='text',
                            placeholder='Email')
    layout = html.Div([
        html.Div(token['username']),
        # html.Div(token),
        html.Div("Old password:"******"New password:"******"Password has been changed")],
                      id='change-pass-toast',
                      header="Completed",
                      duration=4000,
                      style={'opacity': '0.5'})
        ]),
        html.Div("Email:"),
        html.Div(email_input),
        html.Div([
            html.Button(id='settings-save-button',
                        children='Change email',
                        style={'backround': 'white'}),
            dbc.Toast([html.P("Settings has been saved", className="mb-0")],
                      id='settings-toast',
                      header="Completed",
                      duration=4000,
                      style={'opacity': '0.5'})
        ])
    ])
    return layout
コード例 #10
0
def get_comment_components(initial_value=""):
    """Generates a list of components for use in comment related interactions.

    We let the id fields be dictionaries here, to prevent Dash errors
    when registering callbacks to dynamically created components.
    Although we can directly assign an id and register a callback,
    an error appears in the Dash app saying that no such ID exists.
    The callback still works despite the error.
    It can be supressed, but only at a global granularity (for all callbacks),
    which seems too heavy handed.

    Instead, we use the pattern matching callback feature to
    match the dictionary fields in the id.
    This is the same approach taken in update_graph_elements to
    register the callback from the client datatable.

    Notice that the value of the dictionary doesn't matter,
    since we keep the key unique and match the value with ALL.
    Unfortunately, we can't do something like id={"id": "component-unique-id"},
    and match with Output/Input/State({"id": "component-unique-id"})
    since the callback requires a wildcard (ALL/MATCH) to match.
    We have to add an unused field, such as
    id={"id": "component-unique-id", "index": 0} and match with
    Output/Input/State({"id": "component-unique-id", "index": ALL/MATCH})
    Neither solution is ideal, but have to work with it.

    Returns:
        A list of Dash components.
    """

    comment_components = [
        html.H3("Comments"),
        dbc.Textarea(
            id={id_constants.NODE_COMMENT_TEXTAREA: id_constants.NODE_COMMENT_TEXTAREA},
            value=initial_value,
        ),
        dbc.Button(
            id={
                id_constants.SAVE_COMMENT_TEXTAREA_BUTTON: id_constants.SAVE_COMMENT_TEXTAREA_BUTTON
            },
            children="Save Comment",
        ),
        dbc.Button(
            id={
                id_constants.DISCARD_COMMENT_TEXTAREA_BUTTON: id_constants.DISCARD_COMMENT_TEXTAREA_BUTTON
            },
            children="Discard Comment Changes",
        ),
        dbc.Toast(
            id={id_constants.SAVE_COMMENT_TOAST: id_constants.SAVE_COMMENT_TOAST},
            header="Successfully saved comment!",
            icon="success",
            duration=3000,
            dismissable=True,
            body_style={"display": "none"},
            is_open=False,
        ),
    ]
    return comment_components
コード例 #11
0
ファイル: analysis.py プロジェクト: jviteMx/AMDCapstone
def construct_integrity_fail_message(error):
    error_toast = dbc.Toast(
        [html.P(error, className="mb-0")],
        id="simple-toast",
        header="All not good \U0001F616",
        icon="danger",
        dismissable=True,
    )
    return error_toast
コード例 #12
0
def get_toast_hint():
    return dbc.Toast([
        html.P([
            "The dots are at your service.",
            html.Br(), "Go ahead and click a dot to see more details."
        ],
               className="mb-0")
    ],
                     header="Interactive dots alert!",
                     dismissable=True)
コード例 #13
0
ファイル: settings.py プロジェクト: epwalsh/allennlp-manager
 def get_notifications(self):
     return [
         html.Div(id="settings-account-deleted"),
         html.Div(id="settings-user-permissions-updated"),
         html.Div(id="settings-user-account-deleted"),
         dbc.Toast(
             "Username successfully changed. You'll have to sign back in with your new username now.",
             header="Success",
             icon="success",
             duration=4000,
             id="settings-username-changed-success",
             is_open=False,
             dismissable=True,
         ),
         dbc.Toast(
             "Profile successfully updated",
             header="Success",
             icon="success",
             duration=4000,
             id="settings-profile-updated-success",
             is_open=False,
             dismissable=True,
         ),
         dbc.Toast(
             "Password successfully changed. Please log out and then log back in.",
             header="Success",
             icon="success",
             duration=4000,
             id="settings-pw-change-success",
             is_open=False,
             dismissable=True,
         ),
         dbc.Toast(
             "The current password you entered is wrong",
             header="Oops!",
             icon="danger",
             duration=4000,
             id="settings-pw-change-fail",
             is_open=False,
             dismissable=True,
         ),
     ]
コード例 #14
0
ファイル: settings.py プロジェクト: epwalsh/allennlp-manager
 def notify_delete_account(n_clicks):
     if not n_clicks:
         raise PreventUpdate
     return dbc.Toast(
         "Your account has been deleted. Sorry to see you go :(",
         header="Account deleted",
         icon="danger",
         duration=4000,
         id="settings-account-deleted-noti",
         is_open=True,
         dismissable=True,
     )
コード例 #15
0
 def get_notifications(self):
     return [
         dbc.Toast(
             "Tags successfully updated",
             id="experiment-edit-tags-noti",
             header="Success",
             dismissable=True,
             duration=4000,
             is_open=False,
             icon="success",
         )
     ]
コード例 #16
0
def model_run_buttons():
    return html.Div([
        dbc.Button("Run Model",
                   id="run_model_button",
                   color="primary",
                   className="mr-1",
                   disabled=True),
        dbc.Button("See Results",
                   id="model_results_button",
                   color="success",
                   className="mr-1",
                   target="_blank",
                   disabled=True,
                   external_link=True,
                   href='none',
                   key='model_results_button_key'),
        dbc.Button("See Report",
                   id="model_report_button",
                   color="success",
                   className="mr-1",
                   disabled=True,
                   key='model_report_button_key'),
        dbc.Toast([],
                  id="run_model_toast",
                  header="Notification",
                  duration=3000,
                  icon="primary",
                  dismissable=True,
                  is_open=False),
        html.Div([], id='model_run_tooltip_holder'),
        dbc.Modal([
            dbc.ModalHeader(id='show_report_header'),
            dbc.ModalBody([
                html.Div("Select intervention profiles to compare:"),
                dbc.Checklist(options=[],
                              value=[],
                              id="show_report_intervention_checklist")
            ]),
            dbc.ModalFooter([
                dbc.Button("OK",
                           id="do_show_report",
                           className="ml-auto",
                           target="_blank",
                           external_link=True,
                           href='none'),
                dbc.Button(
                    "Cancel", id="cancel_show_report", className="ml-auto")
            ]),
        ],
                  id="show_report_dialog",
                  centered=True)
    ],
                    id='run_buttons_div')
コード例 #17
0
ファイル: wdsm.py プロジェクト: kimthanin/wp
def graph(s):
    S = ympd[s].loc[ympd[s].Y == 'Year']
    fig1 = px.scatter(S,
                      x='MillWeight',
                      y='YP',
                      color='YC',
                      size='count_y',
                      symbol='Type',
                      color_continuous_scale='Blugrn',
                      facet_col_spacing=0.005,
                      facet_col='Month',
                      height=240)
    fig1.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
    fig1.for_each_yaxis(lambda a: a.update(dtick=1))
    fig1.for_each_yaxis(lambda a: a.update(title='', tickangle=90, dtick=1),
                        row=1,
                        col=1)
    fig1.for_each_xaxis(lambda a: a.update(title='', showticklabels=False)
                        )  # showgrid=True, visible=False, dtick=10000
    fig1.layout.update(coloraxis_showscale=False,
                       showlegend=False,
                       margin=dict(l=0, r=0, t=24,
                                   b=0))  # , title_font=dict(size=14))
    fig1.update_yaxes(autorange="reversed")  # matches=None

    S = ympd[s].loc[ympd[s].Y == 'Price']
    fig2 = px.scatter(S,
                      x='MillWeight',
                      y='YP',
                      color='YC',
                      size='mean_y',
                      symbol='Type',
                      color_continuous_scale='Blugrn',
                      facet_col_spacing=0.005,
                      facet_col='Month',
                      height=500,
                      labels={'Type': ''})  # , facet_row='Y'
    fig2.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
    fig2.for_each_yaxis(lambda a: a.update(title='', tickangle=90),
                        row=1,
                        col=1)
    fig2.for_each_xaxis(
        lambda a: a.update(title='', tickangle=90))  # , dtick=10000
    fig2.layout.update(coloraxis_showscale=False,
                       legend_orientation='h',
                       margin=dict(l=0, r=0, t=0, b=0))

    return [
        dcc.Graph(figure=fig1),
        dcc.Graph(figure=fig2), ry[s]['2020'], ry[s]['2021'],
        dbc.Button('Save', id=f'{s}-save_target', color="success"),
        dbc.Toast(duration=2000, id=f'{s}-toast')
    ]
コード例 #18
0
ファイル: index.py プロジェクト: epwalsh/allennlp-manager
 def get_notifications(self):
     return [
         dbc.Toast(
             "Tags successfully updated",
             id="index-edit-tags-noti",
             header="Success",
             dismissable=True,
             duration=4000,
             is_open=False,
             icon="success",
         ),
         html.Div(id="database-build-noti-container"),
         dbc.Toast(
             "Database successfully re-built",
             id="database-build-finish-noti",
             header="Success",
             dismissable=True,
             duration=4000,
             is_open=False,
             icon="success",
         ),
     ]
コード例 #19
0
ファイル: index.py プロジェクト: epwalsh/allennlp-manager
 def notify_re_build_database(n_clicks):
     if not n_clicks:
         raise PreventUpdate
     return dbc.Toast(
         [
             dbc.Spinner(color="info", size="sm", style={"margin-right": "5px"}),
             "Re-building database",
         ],
         id="database-build-noti",
         header="In progress",
         is_open=True,
         icon="info",
     )
コード例 #20
0
ファイル: settings.py プロジェクト: epwalsh/allennlp-manager
 def update_user_permissions(n_clicks, username, value):
     if not n_clicks or not username or not value:
         raise PreventUpdate
     permissions = getattr(Permissions, value)
     if UserService().set_permissions(username, permissions):
         return dbc.Toast(
             f"Successfully updated user permissions to {value.replace('_', ' + ')}.",
             header="Success",
             icon="success",
             duration=4000,
             id="settings-update-user-permissions-success",
             is_open=True,
             dismissable=True,
         )
     return dbc.Toast(
         "Failed to update user permissions",
         header="Failed",
         icon="danger",
         duration=4000,
         id="settings-update-user-permissions-fail",
         is_open=True,
         dismissable=True,
     )
コード例 #21
0
def toast():
    return html.Div([
        dbc.Toast(
                    "This file is in CSV format. To read it in Excel as a table, \
                    open a new Excel file, select the 'Data' Menu and then click on 'from text/CSV'.",
                    id="positioned-toast",
                    header="Downloading Data",
                    is_open=False,
                    dismissable=True,
                    icon="secondary",
                    # top: 66 positions the toast below the navbar
                    style={"position": "fixed", "top": 66, "right": 10, "width": 350},
                ),
            ])
コード例 #22
0
def render():
    return (dbc.Toast(
        "Notifications will go here",
        id=TOAST_ACHIEVEMENT_ID,
        header="Achievements Earned!",
        is_open=False,
        dismissable=True,
        icon="success",
        fade=True,
        # top: 66 positions the toast below the navbar
        style={"position": "fixed", "top": 10, "right": 10, "width": 350},
    ),
        dbc.Toast(
        "Notifications will go here",
        id=TOAST_NEW_LOCATION_ID,
        header="New Locations!",
        is_open=False,
        dismissable=True,
        icon="info",
        fade=True,
        # top: 66 positions the toast below the navbar
        style={"position": "fixed", "top": 66, "right": 10, "width": 350},
    ))
コード例 #23
0
ファイル: toasts.py プロジェクト: rigdenlab/conplot
def SuccesfulLoginToast(username):
    return dbc.Toast(
        "Logged in as %s" % username,
        id="positioned-toast",
        header="Successful login",
        is_open=True,
        dismissable=True,
        icon="success",
        style={
            "position": "fixed",
            "top": 66,
            "right": 10,
            "width": 350
        },
    )
コード例 #24
0
ファイル: toasts.py プロジェクト: rigdenlab/conplot
def SuccesfulSessionShareToast(username):
    return dbc.Toast(
        "You are now sharing the session with %s" % username,
        id="positioned-toast",
        header="Session shared",
        is_open=True,
        dismissable=True,
        icon="success",
        style={
            "position": "fixed",
            "top": 66,
            "right": 10,
            "width": 350
        },
    )
コード例 #25
0
ファイル: toasts.py プロジェクト: rigdenlab/conplot
def SessionAlreadyShared(share_with):
    return dbc.Toast(
        "You are already sharing this session with %s" % share_with,
        id="positioned-toast",
        header="Invalid input",
        is_open=True,
        dismissable=True,
        icon="danger",
        style={
            "position": "fixed",
            "top": 66,
            "right": 10,
            "width": 350
        },
    )
コード例 #26
0
ファイル: toasts.py プロジェクト: rigdenlab/conplot
def SuccesfulSessionStopShareToast():
    return dbc.Toast(
        "You have stopped sharing the session",
        id="positioned-toast",
        header="Session no longer shared",
        is_open=True,
        dismissable=True,
        icon="danger",
        style={
            "position": "fixed",
            "top": 66,
            "right": 10,
            "width": 350
        },
    )
コード例 #27
0
ファイル: toasts.py プロジェクト: rigdenlab/conplot
def SuccesfulSessionDeleteToast(session_name):
    return dbc.Toast(
        "You have deleted session '%s'" % session_name,
        id="positioned-toast",
        header="Session removed",
        is_open=True,
        dismissable=True,
        icon="danger",
        style={
            "position": "fixed",
            "top": 66,
            "right": 10,
            "width": 350
        },
    )
コード例 #28
0
ファイル: toasts.py プロジェクト: rigdenlab/conplot
def SuccesfulLogoutToast():
    return dbc.Toast(
        "You have logged out!",
        id="positioned-toast",
        header="User log out",
        is_open=True,
        dismissable=True,
        icon="danger",
        style={
            "position": "fixed",
            "top": 66,
            "right": 10,
            "width": 350
        },
    )
コード例 #29
0
ファイル: toasts.py プロジェクト: rigdenlab/conplot
def InvalidUsernameToast():
    return dbc.Toast(
        "Please provide a valid username to share the session with",
        id="positioned-toast",
        header="Invalid input",
        is_open=True,
        dismissable=True,
        icon="danger",
        style={
            "position": "fixed",
            "top": 66,
            "right": 10,
            "width": 350
        },
    )
コード例 #30
0
ファイル: toasts.py プロジェクト: rigdenlab/conplot
def SessionTimedOutToast():
    return dbc.Toast(
        "Session has timed-out!",
        id="positioned-toast",
        header="Session timed-out",
        is_open=True,
        dismissable=True,
        icon="danger",
        style={
            "position": "fixed",
            "top": 66,
            "right": 10,
            "width": 350
        },
    )