def common_bootstrap_payload() -> Dict[str, Any]: """Common data always sent to the client""" messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) # should not expose API TOKEN to frontend frontend_config = {k: conf.get(k) for k in FRONTEND_CONF_KEYS} if conf.get("SLACK_API_TOKEN"): frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [ ReportRecipientType.EMAIL, ReportRecipientType.SLACK, ] else: frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [ ReportRecipientType.EMAIL, ] bootstrap_data = { "flash_messages": messages, "conf": frontend_config, "locale": locale, "language_pack": get_language_pack(locale), "feature_flags": get_feature_flags(), "extra_sequential_color_schemes": conf["EXTRA_SEQUENTIAL_COLOR_SCHEMES"], "extra_categorical_color_schemes": conf["EXTRA_CATEGORICAL_COLOR_SCHEMES"], "theme_overrides": conf["THEME_OVERRIDES"], "menu_data": menu_data(), } bootstrap_data.update( conf["COMMON_BOOTSTRAP_OVERRIDES_FUNC"](bootstrap_data)) return bootstrap_data
def common_bootsrap_payload(self): """Common data always sent to the client""" messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) return { 'flash_messages': messages, 'conf': {k: conf.get(k) for k in FRONTEND_CONF_KEYS}, 'locale': locale, 'language_pack': get_language_pack(locale), 'feature_flags': get_feature_flags(), }
def test_get_feature_flags(self): feature_flags = get_feature_flags() self.assertEqual( feature_flags, { "True_Flag1": True, "True_Flag2": True, "Flag3": False, "Flag4": True }, )
def common_bootsrap_payload(self): """Common data always sent to the client""" messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) return { 'flash_messages': messages, 'conf': {k: conf.get(k) for k in FRONTEND_CONF_KEYS}, 'locale': locale, 'language_pack': get_language_pack(locale), 'feature_flags': get_feature_flags(), }
def common_bootstrap_payload(self): """Common data always sent to the client""" messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) return { "flash_messages": messages, "conf": {k: conf.get(k) for k in FRONTEND_CONF_KEYS}, "locale": locale, "language_pack": get_language_pack(locale), "feature_flags": get_feature_flags(), }
def common_bootstrap_payload() -> Dict[str, Any]: """Common data always sent to the client""" messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) return { "flash_messages": messages, "conf": {k: conf.get(k) for k in FRONTEND_CONF_KEYS}, "locale": locale, "language_pack": get_language_pack(locale), "feature_flags": get_feature_flags(), "extra_sequential_color_schemes": conf["EXTRA_SEQUENTIAL_COLOR_SCHEMES"], "extra_categorical_color_schemes": conf["EXTRA_CATEGORICAL_COLOR_SCHEMES"], "menu_data": menu_data(), }
def show(self, pk): pk = self._deserialize_pk_if_composite(pk) widgets = self._show(pk) query = self.datamodel.get(pk).to_json() query["extra_json"] = json.loads(query["extra_json"]) payload = {"common": {"feature_flags": get_feature_flags(), "query": query}} return self.render_template( self.show_template, pk=pk, title=self.show_title, widgets=widgets, related_views=self._related_views, bootstrap_data=json.dumps(payload, default=utils.json_iso_dttm_ser), )
def common_bootstrap_payload() -> Dict[str, Any]: """Common data always sent to the client""" messages = get_flashed_messages(with_categories=True) locale = str(get_locale()) # should not expose API TOKEN to frontend frontend_config = { k: (list(conf.get(k)) if isinstance(conf.get(k), set) else conf.get(k)) for k in FRONTEND_CONF_KEYS } if conf.get("SLACK_API_TOKEN"): frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [ ReportRecipientType.EMAIL, ReportRecipientType.SLACK, ] else: frontend_config["ALERT_REPORTS_NOTIFICATION_METHODS"] = [ ReportRecipientType.EMAIL, ] # verify client has google sheets installed available_specs = get_available_engine_specs() frontend_config["HAS_GSHEETS_INSTALLED"] = bool( available_specs[GSheetsEngineSpec]) bootstrap_data = { "flash_messages": messages, "conf": frontend_config, "locale": locale, "language_pack": get_language_pack(locale), "feature_flags": get_feature_flags(), "extra_sequential_color_schemes": conf["EXTRA_SEQUENTIAL_COLOR_SCHEMES"], "extra_categorical_color_schemes": conf["EXTRA_CATEGORICAL_COLOR_SCHEMES"], "theme_overrides": conf["THEME_OVERRIDES"], "menu_data": menu_data(), } bootstrap_data.update( conf["COMMON_BOOTSTRAP_OVERRIDES_FUNC"](bootstrap_data)) return bootstrap_data
def show(self, pk): pk = self._deserialize_pk_if_composite(pk) widgets = self._show(pk) extra_json = self.datamodel.get(pk).extra_json payload = { 'common': { 'feature_flags': get_feature_flags(), 'extra_json': json.loads(extra_json), }, } return self.render_template( self.show_template, pk=pk, title=self.show_title, widgets=widgets, related_views=self._related_views, bootstrap_data=json.dumps(payload, default=utils.json_iso_dttm_ser), )