I have already checked this and that is the same error message that I am getting but the solution for that problem does not help me with mine. Any help that you guys can provide would be greatly appreciated I have been struggling with it for the last day or so.
# Layout
app.layout = html.Div([
html.Div([
html.H2('Find Meraki Network ID'),
html.P('This page can be used to find a Meraki Network ID based on the name.', style={'fontSize':14})
], className='ten columns offset-by-one', style={'margin-top': 10}),
html.Div([
html.Div([
html.H2('General Search Term'),
dcc.Input(
id='input-box-1_find_meraki_network_id',
type='text',
placeholder='Search Term',
value='')
], style={'margin-top': 30}),
html.Div([
html.Button('Search', id='general_search_find_meraki_network_id')
], style={'margin-top': 30})
], className='ten columns offset-by-one'),
html.Div(id='table_find_meraki_network_id', className='six columns offset-by-three', style={'margin-top': 30}),
html.Div(id='intermediate-value_find_meraki_network_id', style={'display': 'none'})
])
# Callbacks
@app.callback(
output=Output('intermediate-value_find_meraki_network_id', 'children'),
inputs=[Input('general_search_find_meraki_network_id', "n_clicks")],
state=[State('input-box-1_find_meraki_network_id', "value")]
)
def get_combined_network_list(n_clicks, search_term):
full_network_list = list_all_networks_in_all_orgs()
if full_network_list == '':
return 'error'
else:
if n_clicks == None:
pass
else:
network_df = pd.DataFrame(full_network_list)
result_list = search_for_network(network_df,search_term)
if len(result_list) == 0:
return 'no results'
else:
network_search_df = pd.DataFrame(result_list)
network_search_df.columns = ['Network']
return [network_df.to_json(), network_search_df.to_json()]
@app.callback(Output('table_find_meraki_network_id', 'children'), [Input('intermediate-value_find_meraki_network_id', 'children')])
def networks_table(jsonified_cleaned_data):
if jsonified_cleaned_data == None:
pass
else:
if jsonified_cleaned_data == 'error':
return html.H2('There was an error, please refresh the page and try again.')
else:
if jsonified_cleaned_data == 'no results':
return html.H2('No Results were found. Please try a different search term.')
else:
networks = pd.read_json(jsonified_cleaned_data[1])
return html.Div([
html.Div([
dash_table.DataTable(
id='datatable-interactivity_find_meraki_network_id',
columns=[
{"name": i, "id": i} for i in networks.columns
],
data=networks.to_dict("rows"),
editable=False,
sort_action=True,
sort_mode="single",
row_selectable="single",
selected_rows=[],
style_table={'margin-top': 10, 'overflowX': 'scroll'},
style_cell={'text-align': 'center'}
),
]),
html.Div([
html.Div(id='display_selected_row_find_meraki_network_id', className='offset-by-one', style={'margin-top': 30})
]),
])
@app.callback(
output=Output('display_selected_row_find_meraki_network_id', "children"),
inputs=[Input('datatable-interactivity_find_meraki_network_id', "selected_rows")],
state=[State('intermediate-value_find_meraki_network_id', 'children'), State('datatable-interactivity_find_meraki_network_id', 'data')])
def update_table(selected_rows, jsonified_cleaned_data, rows):
if jsonified_cleaned_data == None:
pass
else:
networks = pd.read_json(jsonified_cleaned_data[1])
if selected_rows is None:
selected_rows = []
if rows is None:
dff = networks
else:
dff = pd.DataFrame(rows)
dff = dff.iloc[selected_rows]
if selected_rows == []:
return ''
else:
return html.Div([
html.Div(
dash_table.DataTable(
id='display_selected_row_data_table_find_meraki_network_id',
columns=[
{"name": i, "id": i} for i in networks.columns
],
# data should be a list of dictionaries. [ {'column-1': 4.5, 'column-2': 'montreal', 'column-3': 'canada'}, {'column-1': 8, 'column-2': 'boston', 'column-3': 'america'} ]
data=dff.to_dict("rows"),
editable=False,
style_table={'overflowX': 'scroll'},
style_cell={'text-align': 'center'}
)
),
html.Div(
html.Div([
html.H3('If this is the network ID that you would like, please press "Submit".'),
html.Div(
html.Button('Submit', id='specific_search_find_meraki_network_id')
),
html.Div(html.H4(id='output-container-button_find_meraki_network_id'), style={'margin-top': 15})
])
, className='twelve columns', style={'margin-top': 30})
])
@app.callback(
Output('output-container-button_find_meraki_network_id', 'children'),
[Input('specific_search_find_meraki_network_id', 'n_clicks')],
state=[State('datatable-interactivity_find_meraki_network_id', "selected_rows"), State('intermediate-value_find_meraki_network_id', 'children')])
def update_output(n_clicks, row, jsonified_cleaned_data):
if jsonified_cleaned_data == None:
pass
else:
networks = pd.read_json(jsonified_cleaned_data[0])
selected_network = pd.read_json(jsonified_cleaned_data[1])
if n_clicks == None:
app.logger.debug('not searching for specific network yet')
return ''
else:
app.logger.debug('searching for specific network')
selected_row = (selected_network.iloc[[row[0]]].to_dict("rows"))[0]
app.logger.debug('selected row: ' + str(selected_row))
specific_network_name = selected_row.get('Network', ' ')
app.logger.debug('network name: ' + str(specific_network_name))
network_id = get_specific_network(networks, specific_network_name)
app.logger.debug('network ID: ' + str(network_id))
app.logger.debug('##################################################')
app.logger.debug(('The network ID for the location "{}" is "{}"').format(specific_network_name, network_id))
app.logger.debug('##################################################')
return ('The network ID for the location "{}" is "{}"').format(specific_network_name, network_id)