def build_geojson_upload(loc_mode, geojson_key=None, featureidkey=None): curr_geojson = get_custom_geojson(geojson_key) featureidkey_options = [] featureidkey_value = featureidkey featureidkey_placeholder = "Select uploaded data" disabled = False if curr_geojson and not isinstance(curr_geojson, list): if curr_geojson.get("type") == "FeatureCollection": featureidkey_options = [ build_option(fik) for fik in curr_geojson["properties"] ] else: featureidkey_value = None disabled = True featureidkey_placeholder = "id" return [ html.Div( [ html.Div( [ dcc.Upload( html.Div( html.Span( html.Span( "Upload File", style=dict(whiteSpace="pre-line")), className= "input-group-addon d-block pt-1 pb-0 pointer", ), className="input-group mr-3", id="upload-geojson-btn", ), id="upload-geojson", ), ], className="col-auto", ), html.Div(id="output-geojson-upload", className="col mt-auto mb-auto"), ], className="row pb-5", ), html.Div( [ build_input( "geojson", dcc.Dropdown( id="geojson-dropdown", options=[ build_option(ct["key"]) for ct in CUSTOM_GEOJSON ], placeholder="Select uploaded data", style=dict(width="inherit"), value=geojson_key if loc_mode == "geojson-id" else None, ), className="col-md-6", id="geojson-input", ), build_input( "featureidkey", dcc.Dropdown( id="featureidkey-dropdown", options=featureidkey_options, placeholder=featureidkey_placeholder, style=dict(width="inherit"), disabled=disabled, value=featureidkey_value, ), className="col-md-6", id="featureidkey-input", ), ], className="row", ), ]
def build_body(ext_aggs): col_inputs = [html.Div(id="extended-agg-errors")] for i in INPUT_IDS: ext_agg = ext_aggs[i - 1] if len(ext_aggs) >= i else {} col_inputs.append( html.Div( [ html.Span( "{}.".format(i), className="col-auto pr-0 mt-auto mb-auto ext-agg-id", ), build_input( text("Col"), dcc.Dropdown( id="col-dropdown-{}".format(i), placeholder=text("Select"), style=dict(width="inherit"), value=ext_agg.get("col"), ), className="col-md-3", ), build_input( text("Agg"), dcc.Dropdown( id="agg-dropdown-{}".format(i), options=[ build_option(v, text(AGGS[v])) for v in [ "count", "nunique", "sum", "mean", "rolling", "corr", "first", "last", # "drop_duplicates", "median", "min", "max", "std", "var", "mad", "prod", "pctsum", "pctct", ] ], placeholder=text("Select"), style=dict(width="inherit"), value=ext_agg.get("agg"), ), className="col-md-3", ), html.Div( [ build_input( text("Window"), dcc.Input( id="window-input-{}".format(i), type="number", placeholder=text("Enter Days"), className="form-control text-center", style={"lineHeight": "inherit"}, value=ext_agg.get("window"), ), className="col-md-6", ), build_input( text("Computation"), dcc.Dropdown( id="rolling-comp-dropdown-{}".format(i), options=[ build_option("corr", text("Correlation")), build_option("count", text("Count")), build_option("cov", text("Covariance")), build_option("kurt", text("Kurtosis")), build_option("max", text("Maximum")), build_option("mean", text("Mean")), build_option("median", text("Median")), build_option("min", text("Minimum")), build_option("skew", text("Skew")), build_option( "std", text("Standard Deviation"), ), build_option("sum", text("Sum")), build_option("var", text("Variance")), ], placeholder=text("Select"), style=dict(width="inherit"), value=ext_agg.get("rolling_comp"), ), className="col-md-6 pl-0", ), ], id="rolling-inputs-{}".format(i), style=show_style(ext_agg.get("agg") == "rolling", display_style="inherit"), className="col-md-6 row p-0", ), ], className="row pb-3", )) return html.Div(col_inputs, id="extended-agg-body")