+ if parsed_url:
+ new_url = url_encode({
+ "scheme": parsed_url["scheme"],
+ "netloc": parsed_url["netloc"],
+ "path": parsed_url["path"],
+ "params": {
+ "store_sel": store_sel,
+ "start": start,
+ "end": end
+ }
+ })
+ else:
+ new_url = str()
+ return new_url
+
+
+ ctrl_panel = self.ControlPanel(cp_data)
+
+ d_start = self._get_date(d_start)
+ d_end = self._get_date(d_end)
+
+ # Parse the url:
+ parsed_url = url_decode(href)
+
+ row_fig_tput = no_update
+ row_fig_lat = no_update
+ row_btn_dwnld = no_update
+ row_card_sel_tests = no_update
+ row_btns_sel_tests = no_update
+
+ trigger_id = callback_context.triggered[0]["prop_id"].split(".")[0]
+
+ if trigger_id == "dd-ctrl-dut":
+ try:
+ dut = self.spec_tbs[dd_dut]
+ options = sorted(
+ [{"label": v, "value": v}for v in dut.keys()],
+ key=lambda d: d["label"]
+ )
+ disabled = False
+ except KeyError:
+ options = list()
+ disabled = True
+ ctrl_panel.set({
+ "dd-ctrl-dut-value": dd_dut,
+ "dd-ctrl-phy-value": str(),
+ "dd-ctrl-phy-options": options,
+ "dd-ctrl-phy-disabled": disabled,
+ "dd-ctrl-area-value": str(),
+ "dd-ctrl-area-options": list(),
+ "dd-ctrl-area-disabled": True,
+ "dd-ctrl-test-value": str(),
+ "dd-ctrl-test-options": list(),
+ "dd-ctrl-test-disabled": True,
+ "cl-ctrl-core-options": list(),
+ "cl-ctrl-core-value": list(),
+ "cl-ctrl-core-all-value": list(),
+ "cl-ctrl-core-all-options": self.CL_ALL_DISABLED,
+ "cl-ctrl-framesize-options": list(),
+ "cl-ctrl-framesize-value": list(),
+ "cl-ctrl-framesize-all-value": list(),
+ "cl-ctrl-framesize-all-options": self.CL_ALL_DISABLED,
+ "cl-ctrl-testtype-options": list(),
+ "cl-ctrl-testtype-value": list(),
+ "cl-ctrl-testtype-all-value": list(),
+ "cl-ctrl-testtype-all-options": self.CL_ALL_DISABLED,
+ })
+ elif trigger_id == "dd-ctrl-phy":
+ try:
+ dut = ctrl_panel.get("dd-ctrl-dut-value")
+ phy = self.spec_tbs[dut][dd_phy]
+ options = sorted(
+ [{"label": self.label(v), "value": v}
+ for v in phy.keys()],
+ key=lambda d: d["label"]
+ )
+ disabled = False
+ except KeyError:
+ options = list()
+ disabled = True
+ ctrl_panel.set({
+ "dd-ctrl-phy-value": dd_phy,
+ "dd-ctrl-area-value": str(),
+ "dd-ctrl-area-options": options,
+ "dd-ctrl-area-disabled": disabled,
+ "dd-ctrl-test-value": str(),
+ "dd-ctrl-test-options": list(),
+ "dd-ctrl-test-disabled": True,
+ "cl-ctrl-core-options": list(),
+ "cl-ctrl-core-value": list(),
+ "cl-ctrl-core-all-value": list(),
+ "cl-ctrl-core-all-options": self.CL_ALL_DISABLED,
+ "cl-ctrl-framesize-options": list(),
+ "cl-ctrl-framesize-value": list(),
+ "cl-ctrl-framesize-all-value": list(),
+ "cl-ctrl-framesize-all-options": self.CL_ALL_DISABLED,
+ "cl-ctrl-testtype-options": list(),
+ "cl-ctrl-testtype-value": list(),
+ "cl-ctrl-testtype-all-value": list(),
+ "cl-ctrl-testtype-all-options": self.CL_ALL_DISABLED,
+ })
+ elif trigger_id == "dd-ctrl-area":
+ try:
+ dut = ctrl_panel.get("dd-ctrl-dut-value")
+ phy = ctrl_panel.get("dd-ctrl-phy-value")
+ area = self.spec_tbs[dut][phy][dd_area]
+ options = sorted(
+ [{"label": v, "value": v} for v in area.keys()],
+ key=lambda d: d["label"]
+ )
+ disabled = False
+ except KeyError:
+ options = list()
+ disabled = True
+ ctrl_panel.set({
+ "dd-ctrl-area-value": dd_area,
+ "dd-ctrl-test-value": str(),
+ "dd-ctrl-test-options": options,
+ "dd-ctrl-test-disabled": disabled,
+ "cl-ctrl-core-options": list(),
+ "cl-ctrl-core-value": list(),
+ "cl-ctrl-core-all-value": list(),
+ "cl-ctrl-core-all-options": self.CL_ALL_DISABLED,
+ "cl-ctrl-framesize-options": list(),
+ "cl-ctrl-framesize-value": list(),
+ "cl-ctrl-framesize-all-value": list(),
+ "cl-ctrl-framesize-all-options": self.CL_ALL_DISABLED,
+ "cl-ctrl-testtype-options": list(),
+ "cl-ctrl-testtype-value": list(),
+ "cl-ctrl-testtype-all-value": list(),
+ "cl-ctrl-testtype-all-options": self.CL_ALL_DISABLED,
+ })
+ elif trigger_id == "dd-ctrl-test":
+ core_opts = list()
+ framesize_opts = list()
+ testtype_opts = list()
+ dut = ctrl_panel.get("dd-ctrl-dut-value")
+ phy = ctrl_panel.get("dd-ctrl-phy-value")
+ area = ctrl_panel.get("dd-ctrl-area-value")
+ test = self.spec_tbs[dut][phy][area][dd_test]
+ cores = test["core"]
+ fsizes = test["frame-size"]
+ ttypes = test["test-type"]
+ if dut and phy and area and dd_test:
+ core_opts = [{"label": v, "value": v}
+ for v in sorted(cores)]
+ framesize_opts = [{"label": v, "value": v}
+ for v in sorted(fsizes)]
+ testtype_opts = [{"label": v, "value": v}
+ for v in sorted(ttypes)]
+ ctrl_panel.set({
+ "dd-ctrl-test-value": dd_test,
+ "cl-ctrl-core-options": core_opts,
+ "cl-ctrl-core-value": list(),
+ "cl-ctrl-core-all-value": list(),
+ "cl-ctrl-core-all-options": self.CL_ALL_ENABLED,
+ "cl-ctrl-framesize-options": framesize_opts,
+ "cl-ctrl-framesize-value": list(),
+ "cl-ctrl-framesize-all-value": list(),
+ "cl-ctrl-framesize-all-options": self.CL_ALL_ENABLED,
+ "cl-ctrl-testtype-options": testtype_opts,
+ "cl-ctrl-testtype-value": list(),
+ "cl-ctrl-testtype-all-value": list(),
+ "cl-ctrl-testtype-all-options": self.CL_ALL_ENABLED,
+ })
+ elif trigger_id == "cl-ctrl-core":
+ val_sel, val_all = self._sync_checklists(
+ opt=ctrl_panel.get("cl-ctrl-core-options"),
+ sel=cl_core,
+ all=list(),
+ id=""
+ )
+ ctrl_panel.set({
+ "cl-ctrl-core-value": val_sel,
+ "cl-ctrl-core-all-value": val_all,
+ })
+ elif trigger_id == "cl-ctrl-core-all":
+ val_sel, val_all = self._sync_checklists(
+ opt = ctrl_panel.get("cl-ctrl-core-options"),
+ sel=list(),
+ all=cl_core_all,
+ id="all"
+ )
+ ctrl_panel.set({
+ "cl-ctrl-core-value": val_sel,
+ "cl-ctrl-core-all-value": val_all,
+ })
+ elif trigger_id == "cl-ctrl-framesize":
+ val_sel, val_all = self._sync_checklists(
+ opt = ctrl_panel.get("cl-ctrl-framesize-options"),
+ sel=cl_framesize,
+ all=list(),
+ id=""
+ )
+ ctrl_panel.set({
+ "cl-ctrl-framesize-value": val_sel,
+ "cl-ctrl-framesize-all-value": val_all,
+ })
+ elif trigger_id == "cl-ctrl-framesize-all":
+ val_sel, val_all = self._sync_checklists(
+ opt = ctrl_panel.get("cl-ctrl-framesize-options"),
+ sel=list(),
+ all=cl_framesize_all,
+ id="all"
+ )
+ ctrl_panel.set({
+ "cl-ctrl-framesize-value": val_sel,
+ "cl-ctrl-framesize-all-value": val_all,
+ })
+ elif trigger_id == "cl-ctrl-testtype":
+ val_sel, val_all = self._sync_checklists(
+ opt = ctrl_panel.get("cl-ctrl-testtype-options"),
+ sel=cl_testtype,
+ all=list(),
+ id=""
+ )
+ ctrl_panel.set({
+ "cl-ctrl-testtype-value": val_sel,
+ "cl-ctrl-testtype-all-value": val_all,
+ })
+ elif trigger_id == "cl-ctrl-testtype-all":
+ val_sel, val_all = self._sync_checklists(
+ opt = ctrl_panel.get("cl-ctrl-testtype-options"),
+ sel=list(),
+ all=cl_testtype_all,
+ id="all"
+ )
+ ctrl_panel.set({
+ "cl-ctrl-testtype-value": val_sel,
+ "cl-ctrl-testtype-all-value": val_all,
+ })
+ elif trigger_id == "btn-ctrl-add":
+ _ = btn_add
+ dut = ctrl_panel.get("dd-ctrl-dut-value")
+ phy = ctrl_panel.get("dd-ctrl-phy-value")
+ area = ctrl_panel.get("dd-ctrl-area-value")
+ test = ctrl_panel.get("dd-ctrl-test-value")
+ cores = ctrl_panel.get("cl-ctrl-core-value")
+ framesizes = ctrl_panel.get("cl-ctrl-framesize-value")
+ testtypes = ctrl_panel.get("cl-ctrl-testtype-value")
+ # Add selected test to the list of tests in store:
+ if all((dut, phy, area, test, cores, framesizes, testtypes)):
+ if store_sel is None:
+ store_sel = list()
+ for core in cores:
+ for framesize in framesizes:
+ for ttype in testtypes:
+ if dut == "trex":
+ core = str()
+ tid = "-".join((
+ dut, phy.replace('af_xdp', 'af-xdp'), area,
+ framesize.lower(), core.lower(), test,
+ ttype.lower()
+ ))
+ if tid not in [itm["id"] for itm in store_sel]:
+ store_sel.append({
+ "id": tid,
+ "dut": dut,
+ "phy": phy,
+ "area": area,
+ "test": test,
+ "framesize": framesize.lower(),
+ "core": core.lower(),
+ "testtype": ttype.lower()
+ })
+ store_sel = sorted(store_sel, key=lambda d: d["id"])
+ row_card_sel_tests = self.STYLE_ENABLED
+ row_btns_sel_tests = self.STYLE_ENABLED
+ if self.CLEAR_ALL_INPUTS:
+ ctrl_panel.set(ctrl_panel.defaults)
+ ctrl_panel.set({
+ "cl-selected-options": self._list_tests(store_sel)
+ })
+ row_fig_tput, row_fig_lat, row_btn_dwnld = \
+ _generate_plotting_area(
+ graph_trending(self.data, store_sel, self.layout,
+ d_start, d_end),
+ _gen_new_url(parsed_url, store_sel, d_start, d_end)
+ )
+ elif trigger_id == "dpr-period":
+ row_fig_tput, row_fig_lat, row_btn_dwnld = \
+ _generate_plotting_area(
+ graph_trending(self.data, store_sel, self.layout,
+ d_start, d_end),
+ _gen_new_url(parsed_url, store_sel, d_start, d_end)
+ )
+ elif trigger_id == "btn-sel-remove-all":
+ _ = btn_remove_all
+ row_fig_tput = self.PLACEHOLDER
+ row_fig_lat = self.PLACEHOLDER
+ row_btn_dwnld = self.PLACEHOLDER
+ row_card_sel_tests = self.STYLE_DISABLED
+ row_btns_sel_tests = self.STYLE_DISABLED
+ store_sel = list()
+ ctrl_panel.set({"cl-selected-options": list()})
+ elif trigger_id == "btn-sel-remove":
+ _ = btn_remove
+ if list_sel:
+ new_store_sel = list()
+ for item in store_sel:
+ if item["id"] not in list_sel:
+ new_store_sel.append(item)
+ store_sel = new_store_sel
+ if store_sel:
+ row_fig_tput, row_fig_lat, row_btn_dwnld = \
+ _generate_plotting_area(
+ graph_trending(self.data, store_sel, self.layout,
+ d_start, d_end),
+ _gen_new_url(parsed_url, store_sel, d_start, d_end)
+ )
+ ctrl_panel.set({
+ "cl-selected-options": self._list_tests(store_sel)
+ })
+ else:
+ row_fig_tput = self.PLACEHOLDER
+ row_fig_lat = self.PLACEHOLDER
+ row_btn_dwnld = self.PLACEHOLDER
+ row_card_sel_tests = self.STYLE_DISABLED
+ row_btns_sel_tests = self.STYLE_DISABLED
+ store_sel = list()
+ ctrl_panel.set({"cl-selected-options": list()})
+ elif trigger_id == "url":
+ # TODO: Add verification
+ url_params = parsed_url["params"]
+ if url_params:
+ store_sel = literal_eval(
+ url_params.get("store_sel", list())[0])
+ d_start = self._get_date(url_params.get("start", list())[0])
+ d_end = self._get_date(url_params.get("end", list())[0])
+ if store_sel:
+ row_fig_tput, row_fig_lat, row_btn_dwnld = \
+ _generate_plotting_area(
+ graph_trending(
+ self.data, store_sel, self.layout, d_start,
+ d_end
+ ),
+ _gen_new_url(
+ parsed_url, store_sel, d_start, d_end
+ )
+ )
+ row_card_sel_tests = self.STYLE_ENABLED
+ row_btns_sel_tests = self.STYLE_ENABLED
+ ctrl_panel.set({
+ "cl-selected-options": self._list_tests(store_sel)
+ })
+ else:
+ row_fig_tput = self.PLACEHOLDER
+ row_fig_lat = self.PLACEHOLDER
+ row_btn_dwnld = self.PLACEHOLDER
+ row_card_sel_tests = self.STYLE_DISABLED
+ row_btns_sel_tests = self.STYLE_DISABLED
+ store_sel = list()
+ ctrl_panel.set({
+ "cl-selected-options": list()
+ })
+
+ if ctrl_panel.get("cl-ctrl-core-value") and \
+ ctrl_panel.get("cl-ctrl-framesize-value") and \
+ ctrl_panel.get("cl-ctrl-testtype-value"):
+ disabled = False
+ else:
+ disabled = True
+ ctrl_panel.set({"btn-ctrl-add-disabled": disabled})