From 816921e2e2105eb9be203e2d472114cd6edbc4a2 Mon Sep 17 00:00:00 2001 From: ernolf Date: Mon, 11 Nov 2024 21:35:24 +0100 Subject: [PATCH 1/3] refactor: extract 'optional containers' to separate twig include Signed-off-by: ernolf --- php/templates/containers.twig | 96 +------------------ .../includes/optional-containers.twig | 96 +++++++++++++++++++ 2 files changed, 97 insertions(+), 95 deletions(-) create mode 100644 php/templates/includes/optional-containers.twig diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 531ea0d7b62..cf3f3d62135 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -591,102 +591,8 @@ {% endif %} {% endif %} {% if is_backup_container_running == false %} -

Optional containers

-

In this section you can enable or disable optional containers. There are further community containers available that are not listed below. See this documentation how to add them.

- {% if isAnyRunning == true %} -

Please note: You can enable or disable the options below only when your containers are stopped.

- {% else %} -

Please note: Make sure to save your changes by clicking Save changes below the list of optional containers. The changes will not be auto-saved.

- {% endif %} -
- - - - {% if is_clamav_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_collabora_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_fulltextsearch_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_imaginary_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_talk_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_talk_recording_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_onlyoffice_enabled == true %} -

- {% else %} - {#

#} - {% endif %} - {% if is_docker_socket_proxy_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_whiteboard_enabled == true %} -

- {% else %} -

- {% endif %} - - -
-

Minimal system requirements: When any optional container is enabled, at least 2GB RAM, a dual-core CPU and 40GB system storage are required. When enabling ClamAV, Nextcloud Talk Recording-server or Fulltextsearch, at least 3GB RAM are required. For Talk Recording-server additional 2 vCPUs are required. When enabling everything, at least 5GB RAM and a quad-core CPU are required. Recommended are at least 1GB more RAM than the minimal requirement. For further advices and recommendations see this documentation

- {% if isAnyRunning == true or is_x64_platform == false %} - - {% endif %} - {% if isAnyRunning == true %} - - - - - - - - - {% endif %} - - {% if is_collabora_enabled == true and isAnyRunning == false and was_start_button_clicked == true %} -

Collabora dictionaries

- {% if collabora_dictionaries == "" %} -

In order to get the correct dictionaries in Collabora, you may configure the dictionaries below:

-
- - - - -
-

You need to make sure that the dictionaries that you enter are valid. An example is de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru.

- {% else %} -

The dictionaries for Collabora are currently set to {{ collabora_dictionaries }}. You can reset them again by clicking on the button below.

-
- - - - -
- {% endif %} - {% endif %} + {{ include('includes/optional-containers.twig') }}

Timezone change

{% if isAnyRunning == true %} diff --git a/php/templates/includes/optional-containers.twig b/php/templates/includes/optional-containers.twig new file mode 100644 index 00000000000..0188c13cc6d --- /dev/null +++ b/php/templates/includes/optional-containers.twig @@ -0,0 +1,96 @@ +

Optional containers

+

In this section you can enable or disable optional containers. There are further community containers available that are not listed below. See this documentation how to add them.

+{% if isAnyRunning == true %} +

Please note: You can enable or disable the options below only when your containers are stopped.

+{% else %} +

Please note: Make sure to save your changes by clicking Save changes below the list of optional containers. The changes will not be auto-saved.

+{% endif %} +
+ + + + {% if is_clamav_enabled == true %} +

+ {% else %} +

+ {% endif %} + {% if is_collabora_enabled == true %} +

+ {% else %} +

+ {% endif %} + {% if is_fulltextsearch_enabled == true %} +

+ {% else %} +

+ {% endif %} + {% if is_imaginary_enabled == true %} +

+ {% else %} +

+ {% endif %} + {% if is_talk_enabled == true %} +

+ {% else %} +

+ {% endif %} + {% if is_talk_recording_enabled == true %} +

+ {% else %} +

+ {% endif %} + {% if is_onlyoffice_enabled == true %} +

+ {% else %} + {#

#} + {% endif %} + {% if is_docker_socket_proxy_enabled == true %} +

+ {% else %} +

+ {% endif %} + {% if is_whiteboard_enabled == true %} +

+ {% else %} +

+ {% endif %} + + +
+

Minimal system requirements: When any optional container is enabled, at least 2GB RAM, a dual-core CPU and 40GB system storage are required. When enabling ClamAV, Nextcloud Talk Recording-server or Fulltextsearch, at least 3GB RAM are required. For Talk Recording-server additional 2 vCPUs are required. When enabling everything, at least 5GB RAM and a quad-core CPU are required. Recommended are at least 1GB more RAM than the minimal requirement. For further advices and recommendations see this documentation

+{% if isAnyRunning == true or is_x64_platform == false %} + +{% endif %} +{% if isAnyRunning == true %} + + + + + + + + +{% endif %} + +{% if is_collabora_enabled == true and isAnyRunning == false and was_start_button_clicked == true %} +

Collabora dictionaries

+ + {% if collabora_dictionaries == "" %} +

In order to get the correct dictionaries in Collabora, you may configure the dictionaries below:

+
+ + + + +
+

You need to make sure that the dictionaries that you enter are valid. An example is de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru.

+ {% else %} +

The dictionaries for Collabora are currently set to {{ collabora_dictionaries }}. You can reset them again by clicking on the button below.

+
+ + + + +
+ {% endif %} +{% endif %} From 41c29b90a2dfe77fd7f2f2775c09dc4787fe8b58 Mon Sep 17 00:00:00 2001 From: ernolf Date: Mon, 11 Nov 2024 22:28:57 +0100 Subject: [PATCH 2/3] feat: toggle submit button based on unsaved changes Signed-off-by: ernolf --- php/public/options-form-submit.js | 113 +++++------ .../includes/optional-containers.twig | 176 +++++++++++++----- 2 files changed, 181 insertions(+), 108 deletions(-) diff --git a/php/public/options-form-submit.js b/php/public/options-form-submit.js index 52f3ca748e8..35f6e87810f 100644 --- a/php/public/options-form-submit.js +++ b/php/public/options-form-submit.js @@ -1,73 +1,60 @@ -function makeOptionsFormSubmitVisible() { - let optionsFormSubmit = document.getElementById("options-form-submit"); - optionsFormSubmit.style.display = 'block'; -} - -function handleTalkVisibility() { - let talk = document.getElementById("talk"); - let talkRecording = document.getElementById("talk-recording") - if (talk.checked) { - talkRecording.disabled = false - } else { - talkRecording.checked = false - talkRecording.disabled = true - } -} - -function handleDockerSocketProxyWarning() { - let dockerSocketProxy = document.getElementById("docker-socket-proxy"); - if (dockerSocketProxy.checked) { - alert('⚠️ Warning! Enabling this container comes with possible Security problems since you are exposing the docker socket and all its privileges to the Nextcloud container. Enable this only if you are sure what you are doing!') - } -} - -document.addEventListener("DOMContentLoaded", function(event) { - // handle submit button for options form - let optionsFormSubmit = document.getElementById("options-form-submit"); +document.addEventListener("DOMContentLoaded", function () { + // Hide submit button initially + const optionsFormSubmit = document.getElementById("options-form-submit"); optionsFormSubmit.style.display = 'none'; - // Clamav - let clamav = document.getElementById("clamav"); - clamav.addEventListener('change', makeOptionsFormSubmitVisible); - - // OnlyOffice - let onlyoffice = document.getElementById("onlyoffice"); - if (onlyoffice) { - onlyoffice.addEventListener('change', makeOptionsFormSubmitVisible); + // Store initial states for all checkboxes + const initialState = {}; + const checkboxes = document.querySelectorAll("#options-form input[type='checkbox']"); + + checkboxes.forEach(checkbox => { + initialState[checkbox.id] = checkbox.checked; // Use checked property to capture actual initial state + }); + + // Function to compare current states to initial states + function checkForChanges() { + let hasChanges = false; + + checkboxes.forEach(checkbox => { + if (checkbox.checked !== initialState[checkbox.id]) { + hasChanges = true; + } + }); + + // Show or hide submit button based on changes + optionsFormSubmit.style.display = hasChanges ? 'block' : 'none'; } - // Collabora - let collabora = document.getElementById("collabora"); - collabora.addEventListener('change', makeOptionsFormSubmitVisible); - - // Talk - let talk = document.getElementById("talk"); - talk.addEventListener('change', makeOptionsFormSubmitVisible); - talk.addEventListener('change', handleTalkVisibility); - - // Talk-recording - let talkRecording = document.getElementById("talk-recording"); - talkRecording.addEventListener('change', makeOptionsFormSubmitVisible); - if (!talk.checked) { - talkRecording.disabled = true + // Event listener to trigger visibility check on each change + checkboxes.forEach(checkbox => { + checkbox.addEventListener("change", checkForChanges); + }); + + // Custom behaviors for specific options + function handleTalkVisibility() { + const talkRecording = document.getElementById("talk-recording"); + if (document.getElementById("talk").checked) { + talkRecording.disabled = false; + } else { + talkRecording.checked = false; + talkRecording.disabled = true; + } + checkForChanges(); // Check changes after toggling Talk Recording } - // Imaginary - let imaginary = document.getElementById("imaginary"); - imaginary.addEventListener('change', makeOptionsFormSubmitVisible); + function handleDockerSocketProxyWarning() { + if (document.getElementById("docker-socket-proxy").checked) { + alert('⚠️ Warning! Enabling this container comes with possible Security problems since you are exposing the docker socket and all its privileges to the Nextcloud container. Enable this only if you are sure what you are doing!'); + } + } - // Fulltextsearch - let fulltextsearch = document.getElementById("fulltextsearch"); - fulltextsearch.addEventListener('change', makeOptionsFormSubmitVisible); + // Initialize event listeners for specific behaviors + document.getElementById("talk").addEventListener('change', handleTalkVisibility); + document.getElementById("docker-socket-proxy").addEventListener('change', handleDockerSocketProxyWarning); - // Docker socket proxy - let dockerSocketProxy = document.getElementById("docker-socket-proxy"); - if (dockerSocketProxy) { - dockerSocketProxy.addEventListener('change', makeOptionsFormSubmitVisible); - // dockerSocketProxy.addEventListener('change', handleDockerSocketProxyWarning); - } + // Initialize talk-recording visibility on page load + handleTalkVisibility(); // Ensure talk-recording is correctly initialized - // Whiteboard - let whiteboard = document.getElementById("whiteboard"); - whiteboard.addEventListener('change', makeOptionsFormSubmitVisible); + // Initial call to check for changes + checkForChanges(); }); diff --git a/php/templates/includes/optional-containers.twig b/php/templates/includes/optional-containers.twig index 0188c13cc6d..07b12b966a0 100644 --- a/php/templates/includes/optional-containers.twig +++ b/php/templates/includes/optional-containers.twig @@ -9,51 +9,137 @@ - {% if is_clamav_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_collabora_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_fulltextsearch_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_imaginary_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_talk_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_talk_recording_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_onlyoffice_enabled == true %} -

- {% else %} - {#

#} - {% endif %} - {% if is_docker_socket_proxy_enabled == true %} -

- {% else %} -

- {% endif %} - {% if is_whiteboard_enabled == true %} -

- {% else %} -

- {% endif %} +

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

From 16e4f41ca78554300b85dda7fa1089bc282c3866 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Tue, 12 Nov 2024 15:08:05 +0100 Subject: [PATCH 3/3] increase to v3 Signed-off-by: Simon L. --- php/templates/includes/optional-containers.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/templates/includes/optional-containers.twig b/php/templates/includes/optional-containers.twig index 07b12b966a0..f44a87cc47a 100644 --- a/php/templates/includes/optional-containers.twig +++ b/php/templates/includes/optional-containers.twig @@ -141,7 +141,7 @@

- +

Minimal system requirements: When any optional container is enabled, at least 2GB RAM, a dual-core CPU and 40GB system storage are required. When enabling ClamAV, Nextcloud Talk Recording-server or Fulltextsearch, at least 3GB RAM are required. For Talk Recording-server additional 2 vCPUs are required. When enabling everything, at least 5GB RAM and a quad-core CPU are required. Recommended are at least 1GB more RAM than the minimal requirement. For further advices and recommendations see this documentation

{% if isAnyRunning == true or is_x64_platform == false %}