diff --git a/src/ui/builder/advanced_mode.py b/src/ui/builder/advanced_mode.py index c8945ecde..dfb402954 100644 --- a/src/ui/builder/advanced_mode.py +++ b/src/ui/builder/advanced_mode.py @@ -28,7 +28,7 @@ def advanced_mode_builder(templates: list[dict], plugins: list, global_config: d { "type": "Templates", "data": { - "templates": get_forms(templates, plugins, settings, ("advanced",), is_new), + "templates": get_forms(templates, plugins, settings, ("advanced",), is_new, True), "operation": "new" if is_new else "edit", "oldServerName": service_name if service_name else "", }, diff --git a/src/ui/builder/easy_mode.py b/src/ui/builder/easy_mode.py index ed6688367..9ef70842d 100644 --- a/src/ui/builder/easy_mode.py +++ b/src/ui/builder/easy_mode.py @@ -28,7 +28,7 @@ def easy_mode_builder(templates: list[dict], plugins: list, global_config: dict, { "type": "Templates", "data": { - "templates": get_forms(templates, plugins, settings, ("easy",), is_new), + "templates": get_forms(templates, plugins, settings, ("easy",), is_new, True), "operation": "new" if is_new else "edit", "oldServerName": service_name if service_name else "", }, diff --git a/src/ui/builder/raw_mode.py b/src/ui/builder/raw_mode.py index f6c0c6811..89a604ee4 100644 --- a/src/ui/builder/raw_mode.py +++ b/src/ui/builder/raw_mode.py @@ -37,7 +37,7 @@ def raw_mode_builder(templates: list[dict], plugins: list, global_config: dict, { "type": "Templates", "data": { - "templates": get_forms(templates, plugins, settings, ("raw",), is_new), + "templates": get_forms(templates, plugins, settings, ("raw",), is_new, True), "operation": "new" if is_new else "edit", "oldServerName": service_name if service_name else "", }, diff --git a/src/ui/builder/utils/form.py b/src/ui/builder/utils/form.py index c53301192..bbf5a7701 100644 --- a/src/ui/builder/utils/form.py +++ b/src/ui/builder/utils/form.py @@ -24,19 +24,51 @@ def get_service_settings(service_name: str, global_config: dict, total_config: d return global_config -def get_forms(templates: list = [], plugins: list = [], settings: dict = {}, render_forms: tuple = ("advanced", "easy", "raw"), is_new: bool = False) -> dict: +def get_plugins_multisite(plugins: list) -> list: + # loop on plugins with list index + plugins_multisite = [] + for index, plugin in enumerate(plugins): + multisite_settings = {} + # loop on settings + for setting, value in plugin.get("settings").items(): + # check if setting is multisite + if value.get("context") != "multisite": + continue + # add multisite key to plugin + multisite_settings[setting] = value + + # add multisite settings to plugin + if len(multisite_settings): + plugin_multisite = copy.deepcopy(plugin) + plugin_multisite["settings"] = multisite_settings + plugins_multisite.append(plugin_multisite) + + return plugins + + +def get_forms( + templates: list = [], + plugins: list = [], + settings: dict = {}, + render_forms: tuple = ("advanced", "easy", "raw"), + is_new: bool = False, + only_multisite: bool = False, +) -> dict: """ Will generate every needed form using templates, plugins and settings. We will run on each plugins, set template value if one, and override by the custom settings value if exists. We will format to fit each form type (easy, advanced, raw) in case """ + # Copy of the plugins, and get the plugins by context if needed + # In services page, we want only multisite settings, but in global config we want both + plugins_base = get_plugins_multisite(plugins) if only_multisite else copy.deepcopy(plugins) # Update SERVER_NAME to be empty if new if is_new and "SERVER_NAME" in settings: settings["SERVER_NAME"]["value"] = "" if is_new and not "SERVER_NAME" in settings: - settings["SERVER_NAME"] = {"value": "", "method": "ui", "global": True} + settings["SERVER_NAME"] = {"value": "", "method": "ui", "global": False} forms = {} for form in render_forms: @@ -44,13 +76,13 @@ def get_forms(templates: list = [], plugins: list = [], settings: dict = {}, ren for template in templates: if "advanced" in forms: - forms["advanced"][template.get("name")] = set_advanced(template, plugins, settings, is_new) + forms["advanced"][template.get("name")] = set_advanced(template, plugins_base, settings, is_new) if "raw" in forms: - forms["raw"][template.get("name")] = set_raw(template, plugins, settings, is_new) + forms["raw"][template.get("name")] = set_raw(template, plugins_base, settings, is_new) if "easy" in forms: - forms["easy"][template.get("name")] = set_easy(template, plugins, settings, is_new) + forms["easy"][template.get("name")] = set_easy(template, plugins_base, settings, is_new) return forms diff --git a/src/ui/client/dashboard/components/Dashboard/Menu.vue b/src/ui/client/dashboard/components/Dashboard/Menu.vue index ac80ca8c3..0bfd4cb5e 100644 --- a/src/ui/client/dashboard/components/Dashboard/Menu.vue +++ b/src/ui/client/dashboard/components/Dashboard/Menu.vue @@ -202,6 +202,7 @@ onBeforeMount(() => { ? JSON.parse(dataEl.getAttribute(dataAtt)) : {}; menu.username = data?.username || ""; + menu.pagePlugins = data?.plugins_page || []; }); @@ -365,13 +366,12 @@ onBeforeMount(() => { :tabindex=" menu.isDesktop ? menuIndex : menu.isActive ? menuIndex : '-1' " - target="_blank" class="menu-page-plugin-anchor" - :href="`/plugins?plugin_id=${plugin.id}`" + :href="`plugins/${plugin.id}`" > diff --git a/src/ui/client/dashboard/components/Widget/ButtonGroup.vue b/src/ui/client/dashboard/components/Widget/ButtonGroup.vue index 218c8a0d1..41250bc16 100644 --- a/src/ui/client/dashboard/components/Widget/ButtonGroup.vue +++ b/src/ui/client/dashboard/components/Widget/ButtonGroup.vue @@ -59,7 +59,7 @@ const groupEl = ref(null); onMounted(() => { group.class = - props.boutonGroupClass || groupEl.value.closest("[data-is]") + props.boutonGroupClass || groupEl?.value?.closest("[data-is]") ? `button-group-${groupEl.value .closest("[data-is]") .getAttribute("data-is")}` diff --git a/src/ui/client/dashboard/components/Widget/Instance.vue b/src/ui/client/dashboard/components/Widget/Instance.vue index a5a398273..87fc117bd 100644 --- a/src/ui/client/dashboard/components/Widget/Instance.vue +++ b/src/ui/client/dashboard/components/Widget/Instance.vue @@ -65,6 +65,6 @@ const props = defineProps({ <ListPairs :pairs="props.pairs" /> - <ButtonGroup :buttons="props.buttons" /> + <ButtonGroup v-if="props.buttons.length > 0" :buttons="props.buttons" /> </Container> </template> diff --git a/src/ui/client/dashboard/components/Widget/Text.vue b/src/ui/client/dashboard/components/Widget/Text.vue index 91e73ff76..c9442326a 100644 --- a/src/ui/client/dashboard/components/Widget/Text.vue +++ b/src/ui/client/dashboard/components/Widget/Text.vue @@ -74,7 +74,7 @@ const textIconEl = ref(null); onMounted(() => { // Check if next sibling is a const renderEl = textEl.value || textIconEl.value || null; - const isVoid = renderEl.closest('[data-is="void"]') ? "void" : ""; + const isVoid = renderEl?.closest('[data-is="void"]') ? "void" : ""; text.class = props.textClass || renderEl.closest("[data-is]") ? `text-${ diff --git a/src/ui/client/dashboard/pages/bans/index.html b/src/ui/client/dashboard/pages/bans/index.html index 74a845576..6ea4e2607 100644 --- a/src/ui/client/dashboard/pages/bans/index.html +++ b/src/ui/client/dashboard/pages/bans/index.html @@ -9,13 +9,18 @@ <title>BunkerWeb | Bans - - - + + +
diff --git a/src/ui/client/dashboard/pages/dashboard/index.html b/src/ui/client/dashboard/pages/dashboard/index.html index 4edaf9c9c..0a4f261e6 100644 --- a/src/ui/client/dashboard/pages/dashboard/index.html +++ b/src/ui/client/dashboard/pages/dashboard/index.html @@ -9,8 +9,14 @@ BunkerWeb | DASHBOARD - - + +
diff --git a/src/ui/client/dashboard/pages/global-config/index.html b/src/ui/client/dashboard/pages/global-config/index.html index 89f153ccc..8b4f4c25b 100644 --- a/src/ui/client/dashboard/pages/global-config/index.html +++ b/src/ui/client/dashboard/pages/global-config/index.html @@ -9,7 +9,10 @@ BunkerWeb | Global config - +