plugins + global_config fix

- fix query for plugin pages
- fix delete modal behavior and add input value (external)
- fix global_config duplicate general title
This commit is contained in:
BlasenhauerJ 2022-12-28 17:39:12 +01:00
parent 1aaac2dcf3
commit d2a634e7f7
5 changed files with 47 additions and 27 deletions

View File

@ -406,21 +406,25 @@ class Modal {
this.container = document.querySelector(`[${this.prefix}-list]`);
this.modal = document.querySelector(`[${this.prefix}-modal]`);
this.modalNameInp = this.modal.querySelector("input#name");
this.modalExtInp = this.modal.querySelector("input#external");
this.modalTitle = this.modal.querySelector(`[${this.prefix}-modal-title]`);
this.modalTxt = this.modal.querySelector(`[${this.prefix}-modal-text]`);
this.init();
}
init() {
console.log("init modal");
this.container.addEventListener("click", (e) => {
//DELETE HANDLER
console.log("click");
try {
if (
e.target.closest("button").getAttribute(`${this.prefix}`) === "delete"
e.target.closest("button").getAttribute(`${this.prefix}-action`) ===
"delete"
) {
const btnEl = e.target.closest("button");
const name = btnEl.getAttribute("name");
this.setModal(name);
this.setModal(btnEl);
this.showModal();
}
} catch (err) {}
@ -438,10 +442,21 @@ class Modal {
});
}
setModal(name) {
this.modalNameInp.value = name;
this.modalTitle.textContent = `DELETE ${name}`;
this.modalTxt.textContent = `Are you sure you want to delete ${name}`;
setModal(el) {
//name
const elName = el.getAttribute("name");
this.modalNameInp.value = elName;
this.modalTitle.textContent = `DELETE ${elName}`;
this.modalTxt.textContent = `Are you sure you want to delete ${elName} ?`;
//external
const isExternal = el
.closest("[plugins-external]")
.getAttribute("plugins-external")
.trim()
.includes("external")
? "True"
: "False";
this.modalExtInp.value = isExternal;
}
showModal() {

View File

@ -336,7 +336,7 @@
<a
target="_blank"
class="{% if current_endpoint == 'logs' %}font-semibold text-slate-700 dark:bg-primary/50 rounded-lg dark:hover:bg-primary/60 bg-primary/20 hover:bg-primary/30{% else %}dark:hover:bg-primary/20 hover:bg-primary/5 {% endif %} hover:rounded-lg dark:text-white dark:opacity-80 py-1 text-sm ease-nav-brand my-0 mx-2 flex items-center whitespace-nowrap px-4 transition"
href="{{request.url_root}}/plugins?{{plugin['id']}}"
href="{{request.url_root}}plugins?plugin_id={{plugin['id']}}"
>
<div
class="mr-2 flex items-center justify-center rounded-lg bg-center stroke-0 text-center p-1 xl:p-1.5"

View File

@ -33,13 +33,14 @@
id="form-delete-plugin"
method="POST"
>
<input type="hidden" name="external" id="external" />
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="hidden" value="name" name="name" id="name" />
<input type="hidden" value="delete" name="operation" id="operation" />
<div>
<p
plugins-modal-text
class="mx-2 mb-2 mt-8 font-semibold font-sans leading-normal uppercase text-sm"
class="text-center mx-2 mb-2 mt-8 font-semibold font-sans leading-normal uppercase text-sm"
></p>
</div>
<!-- action button -->

View File

@ -232,7 +232,7 @@ include "plugins-modal.html" %}
{% if plugin['page']%}
<a
class="hover:-translate-y-px"
href="{{request.url_root}}/plugins?{{plugin['id']}}"
href="{{request.url_root}}plugins?plugin_id={{plugin['id']}}"
>
<svg
class="h-6 w-6 fill-sky-500 dark dark:brightness-90"

View File

@ -1,24 +1,28 @@
{% set current_endpoint = url_for(request.endpoint)[1:].split("/")[-1].strip().replace('_', '-')
%}
{% set global_config = config["CONFIG"].get_config() %}
{% set plugins = [{
"id": "general",
"order": 999,
"name": "General",
"description": "The general settings for the server",
"version": "0.1",
"settings": {
"SERVER_NAME": {
"context": "multisite",
"default": "",
"help": "List of the virtual hosts served by bunkerweb.",
"id": "SERVER_NAME",
"label": "Server name",
"regex": ".*",
"type": "text",
{% if current_endpoint == "services"%}
{% set plugins = [{
"id": "general",
"order": 999,
"name": "General",
"description": "The general settings for the server",
"version": "0.1",
"settings": {
"SERVER_NAME": {
"context": "multisite",
"default": "",
"help": "List of the virtual hosts served by bunkerweb.",
"id": "SERVER_NAME",
"label": "Server name",
"regex": ".*",
"type": "text",
}
}
}
}] + config["CONFIG"].get_plugins() %}
}] + config["CONFIG"].get_plugins() %}
{% else %}
{% set plugins = config["CONFIG"].get_plugins() %}
{%endif%}
<!-- plugin item -->
{% for plugin in plugins %}