diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php index 90e7c7a93..3870d8bb2 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php @@ -48,6 +48,7 @@ class ServerState private $caseModel = ''; private $keyfileBase64UrlSafe = ''; private $updateOsResponse; + private $updateOsIgnoredReleases = []; public $myServersFlashCfg = []; public $myServersMemoryCfg = []; @@ -168,6 +169,11 @@ class ServerState * updateOsResponse is provided by the dynamix.plugin.manager/scripts/unraidcheck script saving to /tmp/unraidcheck/result.json */ $this->updateOsResponse = @json_decode(@file_get_contents('/tmp/unraidcheck/result.json'), true); + + /** + * updateOsIgnoredReleases is set by the dynamix.plugin.manager/inclue/UnraidIgnore.php script saving to /tmp/unraidcheck/ignored.json + */ + $this->updateOsIgnoredReleases = @json_decode(@file_get_contents('/tmp/unraidcheck/ignored.json'), true) ?? []; } /** @@ -253,6 +259,10 @@ class ServerState $serverState['updateOsResponse'] = $this->updateOsResponse; } + if ($this->updateOsIgnoredReleases) { + $serverState['updateOsIgnoredReleases'] = $this->updateOsIgnoredReleases; + } + return $serverState; } diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/includes/UnraidCheck.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/includes/UnraidCheck.php index a8897951b..24ad49ee7 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/includes/UnraidCheck.php +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/includes/UnraidCheck.php @@ -88,10 +88,23 @@ if (array_key_exists('json',$_GET) && $_GET['json']) { exit(0); } +// before sending a notification, check to see if the user requested to ignore the version +$ignoredReleasesFile = '/tmp/unraidcheck/ignored.json'; +$ignoredReleasesResult = []; +if (file_exists($ignoredReleasesFile)) { + $ignoredData = json_decode(file_get_contents($ignoredReleasesFile), true); + if (is_array($ignoredData) && array_key_exists('updateOsIgnoredReleases', $ignoredData)) { + $ignoredReleasesResult = $ignoredData['updateOsIgnoredReleases']; + } +} + // send notification if a newer version is available -if ($json && array_key_exists('isNewer',$json) && $json['isNewer']) { +$isNewerVersion = array_key_exists('isNewer',$json) ? $json['isNewer'] : false; +$isReleaseIgnored = in_array($json['version'], $ignoredReleasesResult); + +if ($json && $isNewerVersion && !$isReleaseIgnored) { $newver = (array_key_exists('version',$json) && $json['version']) ? $json['version'] : 'unknown'; exec("$script -e ".escapeshellarg("System - Unraid [$newver]")." -s ".escapeshellarg("Notice [$server] - Version update $newver")." -d ".escapeshellarg("A new version of Unraid is available")." -i ".escapeshellarg("normal $output")." -l '/Tools/Update' -x"); } exit(0); -?> \ No newline at end of file +?> diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/includes/UnraidIgnore.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/includes/UnraidIgnore.php new file mode 100644 index 000000000..055bd118d --- /dev/null +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.plugin.manager/includes/UnraidIgnore.php @@ -0,0 +1,143 @@ + + []], JSON_PRETTY_PRINT); + } else { + http_response_code(400); // Bad Request + echo "No JSON file found"; + } + } + // Check if the "removeVersion" key exists in the $data array + else if (isset($data['removeVersion'])) { + // Check if the "removeVersion" value is a valid PHP-standardized version number string + $remove_version = $data['removeVersion']; + if (isValidSemVerFormat($remove_version)) { + // Check if the JSON file exists + if (file_exists($json_file)) { + // If the file exists, read its content + $existing_data = json_decode(file_get_contents($json_file), true); + + // Check if key exists + if (isset($existing_data[$json_file_key])) { + // Remove the specified version from the array + $existing_data[$json_file_key] = array_diff($existing_data[$json_file_key], [$remove_version]); + + // Save the updated data to the JSON file + file_put_contents($json_file, json_encode($existing_data, JSON_PRETTY_PRINT)); + + http_response_code(200); // OK + header('Content-Type: application/json'); + echo json_encode($existing_data, JSON_PRETTY_PRINT); + } else { + http_response_code(400); // Bad Request + echo "No versions to remove in the JSON file"; + } + } else { + http_response_code(400); // Bad Request + echo "No JSON file found"; + } + } else { + http_response_code(400); // Bad Request + echo "Invalid removeVersion format"; + } + } + // Check if the "version" key exists in the $data array + else if (isset($data['version'])) { + + // Check if the "version" value is a valid PHP-standardized version number string + $version = $data['version']; + if (isValidSemVerFormat($version)) { + // Prepare the new data structure + $new_data = [$json_file_key => [$version]]; + + // Check if the JSON file already exists + if (file_exists($json_file)) { + // If the file exists, read its content + $existing_data = json_decode(file_get_contents($json_file), true); + + // Check if key already exists + if (isset($existing_data[$json_file_key])) { + // Append the new version to the existing array + $existing_data[$json_file_key][] = $version; + } else { + // If key doesn't exist, create it + $existing_data[$json_file_key] = [$version]; + } + + // Update the data to be saved + $new_data = $existing_data; + } + + // Save the data to the JSON file + file_put_contents($json_file, json_encode($new_data, JSON_PRETTY_PRINT)); + + http_response_code(200); // OK + header('Content-Type: application/json'); + echo json_encode($new_data, JSON_PRETTY_PRINT); + } else { + http_response_code(400); // Bad Request + echo "Invalid version format"; + } + + } else { + http_response_code(400); // Bad Request + echo "Invalid param data"; + } + + } else { + http_response_code(400); // Bad Request + echo "Error decoding JSON data"; + } + +} else { + // Handle non-GET requests + http_response_code(405); // Method Not Allowed + echo "Only GET requests are allowed"; +} diff --git a/web/components/Ui/Switch.vue b/web/components/Ui/Switch.vue new file mode 100644 index 000000000..0c2137bfd --- /dev/null +++ b/web/components/Ui/Switch.vue @@ -0,0 +1,34 @@ + + + diff --git a/web/components/UpdateOs/CheckUpdateResponseModal.vue b/web/components/UpdateOs/CheckUpdateResponseModal.vue index 5dd6018da..9545ace86 100644 --- a/web/components/UpdateOs/CheckUpdateResponseModal.vue +++ b/web/components/UpdateOs/CheckUpdateResponseModal.vue @@ -7,7 +7,6 @@ import { useAccountStore } from '~/store/account'; import { usePurchaseStore } from '~/store/purchase'; import { useServerStore } from '~/store/server'; import { useUpdateOsStore } from '~/store/updateOs'; -// import { useUpdateOsActionsStore } from '~/store/updateOsActions'; import { useUpdateOsChangelogStore } from '~/store/updateOsChangelog'; import type { ButtonProps } from '~/types/ui/button'; @@ -24,10 +23,9 @@ const accountStore = useAccountStore(); const purchaseStore = usePurchaseStore(); const serverStore = useServerStore(); const updateOsStore = useUpdateOsStore(); -// const updateOsActionsStore = useUpdateOsActionsStore(); const updateOsChangelogStore = useUpdateOsChangelogStore(); -const { osVersionBranch, updateOsResponse } = storeToRefs(serverStore); +const { osVersionBranch, updateOsResponse, updateOsIgnoredReleases } = storeToRefs(serverStore); const { available, availableWithRenewal, checkForUpdatesLoading } = storeToRefs(updateOsStore); interface ModalCopy { @@ -109,13 +107,13 @@ const close = () => { // then ignore the release if applicable if (ignoreThisRelease.value && (availableWithRenewal.value || available.value)) { setTimeout(() => { - updateOsStore.ignoreRelease(availableWithRenewal.value ?? available.value ?? ''); + serverStore.updateOsIgnoreRelease(availableWithRenewal.value ?? available.value ?? ''); }, 500); } }; const renderMainSlot = computed(() => { - return checkForUpdatesLoading.value || available.value || availableWithRenewal.value; + return checkForUpdatesLoading.value || available.value || availableWithRenewal.value || updateOsIgnoredReleases.value.length > 0; }); @@ -145,10 +143,21 @@ const renderMainSlot = computed(() => { class="inline-block h-20px w-20px transform rounded-full bg-white transition" /> - Ignore this release + {{ t('Ignore this release') }} +
+

+ {{ t('Ignored Releases') }} +

+ +