Merge pull request #2099 from zackspear/feat/web-component-related-files-syned-to-latest

feat: align shared .page, php, scripts, & web components with api repo
This commit is contained in:
tom mortensen
2025-04-02 10:04:29 -07:00
committed by GitHub
16 changed files with 485 additions and 154 deletions

View File

@@ -20,4 +20,4 @@ $replaceKey->check(true);
?>
<unraid-i18n-host>
<unraid-registration></unraid-registration>
</unraid-i18n-host>
</unraid-i18n-host>

View File

@@ -1,19 +1,6 @@
<?php
/* Copyright 2005-2023, Lime Technology
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$var = (array)parse_ini_file('state/var.ini');
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/webGui/include/Helpers.php";
extract(parse_plugin_cfg('dynamix',true));
$var = (array)parse_ini_file('state/var.ini'); // required for state.php - don't remove unless you've refactored the code to work without it
require_once "$docroot/plugins/dynamix.my.servers/include/state.php";
$serverState = new ServerState();

View File

@@ -0,0 +1,166 @@
<?php
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
class ActivationCodeExtractor {
public const DIR = '/boot/config/activation';
public const FILE_PATTERN = '/activation_code_([A-Za-z0-9]+)\.activationcode/';
public const DOCROOT = '/usr/local/emhttp';
public const WEBGUI_IMAGES_BASE_DIR = '/webGui/images';
public const PARTNER_LOGO_FILE_NAME = 'partner-logo.svg';
public const DEFAULT_LOGO = self::DOCROOT . self::WEBGUI_IMAGES_BASE_DIR . '/UN-logotype-gradient.svg';
/** @var array{
* code: string,
* partnerName: string,
* partnerUrl?: string,
* sysModel?: string,
* comment?: string,
* caseIcon: string,
* partnerLogo?: boolean,
* header?: string,
* headermetacolor?: string,
* background?: string,
* showBannerGradient?: string,
* theme?: "azure" | "black" | "gray" | "white
* }
*/
private array $data = [];
private string $partnerName = '';
private string $partnerUrl = 'https://unraid.net';
private string $partnerLogoPath = '';
/**
* Constructor to automatically fetch JSON data from all matching files.
*/
public function __construct() {
$this->data = $this->fetchJsonData();
}
/**
* Fetch JSON data from all files matching the pattern.
*
* @return array Array of extracted JSON data.
*/
private function fetchJsonData(): array {
$data = [];
if (!is_dir(self::DIR)) {
return $data;
}
$files = scandir(self::DIR);
if ($files === false || count($files) === 0) {
return $data;
}
foreach ($files as $file) {
$filePath = self::DIR . DIRECTORY_SEPARATOR . $file;
if (preg_match(self::FILE_PATTERN, $file, $matches)) {
// $activationCode = $matches[1];
$fileContent = file_get_contents($filePath);
$jsonData = json_decode($fileContent, true);
if (json_last_error() === JSON_ERROR_NONE) {
$data = $jsonData;
} else {
$data = ['error' => 'Invalid JSON format'];
}
break; // Stop after the first match
}
}
if (isset($data['partnerName'])) {
$this->partnerName = $data['partnerName'];
}
if (isset($data['partnerUrl'])) {
$this->partnerUrl = $data['partnerUrl'];
}
/**
* During the plg install, the partner logo asset is copied to the webgui images dir.
*/
$logo = self::DOCROOT . self::WEBGUI_IMAGES_BASE_DIR . '/' . self::PARTNER_LOGO_FILE_NAME;
if (file_exists($logo)) {
$this->partnerLogoPath = $logo;
}
return $data;
}
/**
* Get the partner logo path.
*
* @return string
*/
public function getPartnerLogoPath(): string {
return $this->partnerLogoPath;
}
/**
* Get the extracted data.
*
* @return array
*/
public function getData(): array {
return $this->data;
}
/**
* Retrieve the activation code data as JSON string with converted special characters to HTML entities
*
* @return string
*/
public function getDataForHtmlAttr(): string {
$json = json_encode($this->getData());
return htmlspecialchars($json, ENT_QUOTES, 'UTF-8');
}
/**
* Get the partner logo render string.
*
* @return string
*/
public function getPartnerLogoRenderString(): string {
if (empty($this->partnerLogoPath)) { // default logo
return file_get_contents(self::DEFAULT_LOGO);
}
return file_get_contents($this->partnerLogoPath);
}
/**
* Get the partner name.
*
* @return string
*/
public function getPartnerName(): string {
return $this->partnerName;
}
/**
* Get the partner URL.
*
* @return string
*/
public function getPartnerUrl(): string {
return $this->partnerUrl;
}
/**
* Output for debugging
* @return void
*/
public function debug(): void {
echo "data: "; var_dump($this->data);
echo "partnerName: "; var_dump($this->partnerName);
echo "partnerUrl: "; var_dump($this->partnerUrl);
echo "partnerLogoPath: "; var_dump($this->partnerLogoPath);
echo $this->getPartnerLogoRenderString();
}
}

View File

@@ -36,27 +36,15 @@ a[href="/Tools/Downgrade"] .icon-update:before {
display: inline-block; /* required otherwise the rotation won't work */
rotate: 180deg;
}
/* overriding #header .logo svg */
#header .logo .partner-logo svg {
fill: var(--header-text-primary);
width: auto;
height: 28px;
}
</style>
<?php
// Set the path for the local manifest file
$localManifestFile = '/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/manifest.json';
require_once("$docroot/plugins/dynamix.my.servers/include/web-components-extractor.php");
// Load the local manifest
$localManifest = json_decode(file_get_contents($localManifestFile), true);
$searchText = 'unraid-components.client.mjs';
$fileValue = null;
foreach ($localManifest as $key => $value) {
if (strpos($key, $searchText) !== false && isset($value["file"])) {
$fileValue = $value["file"];
break;
}
}
if ($fileValue !== null) {
$prefixedPath = '/plugins/dynamix.my.servers/unraid-components/';
echo '<script src="' . $prefixedPath . $fileValue . '"></script>';
} else {
echo '<script>console.error("%cNo matching key containing \'' . $searchText . '\' found.", "font-weight: bold; color: white; background-color: red");</script>';
}
$wcExtractor = new WebComponentsExtractor();
echo $wcExtractor->getScriptTagHtml();

View File

@@ -165,4 +165,4 @@ class RebootDetails
$this->previousReleaseDate = $parseOutput['releaseDate'];
}
}
}
}

View File

@@ -8,12 +8,14 @@
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
/**
* @todo refactor globals currently if you try to use $GLOBALS the class will break.
*/
$webguiGlobals = $GLOBALS;
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/plugins/dynamix.my.servers/include/activation-code-extractor.php";
require_once "$docroot/plugins/dynamix.my.servers/include/reboot-details.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/UnraidCheck.php";
/**
@@ -52,6 +54,10 @@ class ServerState
"nokeyserver" => 'NO_KEY_SERVER',
"withdrawn" => 'WITHDRAWN',
];
/**
* SSO Sub IDs from the my servers config file.
*/
public $ssoEnabled = false;
private $osVersion;
private $osVersionBranch;
private $rebootDetails;
@@ -66,12 +72,14 @@ class ServerState
public $myServersMemoryCfg = [];
public $host = 'unknown';
public $combinedKnownOrigins = [];
public $nginxCfg = [];
public $flashbackupStatus = [];
public $registered = false;
public $myServersMiniGraphConnected = false;
public $keyfileBase64 = '';
public $activationCodeData = [];
public $state = 'UNKNOWN';
/**
* Constructor to initialize class properties and gather server information.
@@ -83,12 +91,27 @@ class ServerState
* @see - getWebguiGlobal() for usage
* */
global $webguiGlobals;
$this->webguiGlobals =& $webguiGlobals;
$this->webguiGlobals = &$webguiGlobals;
// echo "<pre>" . json_encode($this->webguiGlobals, JSON_PRETTY_PRINT) . "</pre>";
$this->var = (array)parse_ini_file('state/var.ini');
$this->var = $webguiGlobals['var'];
$patcherVersion = null;
if (file_exists('/tmp/Patcher/patches.json')) {
$patcherData = @json_decode(file_get_contents('/tmp/Patcher/patches.json'), true);
$unraidVersionInfo = parse_ini_file('/etc/unraid-version');
if ($patcherData['unraidVersion'] === $unraidVersionInfo['version']) {
$patcherVersion = $patcherData['combinedVersion'] ?? null;
}
}
// If we're on a patch, we need to use the combinedVersion to check for updates
if ($patcherVersion) {
$this->var['version'] = $patcherVersion;
}
$this->nginxCfg = @parse_ini_file('/var/local/emhttp/nginx.ini') ?? [];
$this->state = strtoupper(empty($this->var['regCheck']) ? $this->var['regTy'] : $this->var['regCheck']);
$this->osVersion = $this->var['version'];
$this->osVersionBranch = trim(@exec('plugin category /var/log/plugins/unRAIDServer.plg') ?? 'stable');
@@ -109,12 +132,14 @@ class ServerState
$this->updateOsResponse = $this->updateOsCheck->getUnraidOSCheckResult();
$this->setConnectValues();
$this->detectActivationCode();
}
/**
* Retrieve the value of a webgui global setting.
*/
public function getWebguiGlobal(string $key, ?string $subkey = null) {
public function getWebguiGlobal(string $key, ?string $subkey = null)
{
if (!$subkey) {
return _var($this->webguiGlobals, $key, '');
}
@@ -122,14 +147,15 @@ class ServerState
return _var($keyArray, $subkey, '');
}
private function setConnectValues() {
private function setConnectValues()
{
if (file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net')) {
$this->connectPluginInstalled = 'dynamix.unraid.net.plg';
}
if (file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net.staging')) {
$this->connectPluginInstalled = 'dynamix.unraid.net.staging.plg';
}
if ($this->connectPluginInstalled && !file_exists('/usr/local/sbin/unraid-api')) {
if ($this->connectPluginInstalled && !file_exists('/usr/bin/unraid-api')) {
$this->connectPluginInstalled .= '_installFailed';
}
@@ -149,13 +175,15 @@ class ServerState
$this->getFlashBackupStatus();
}
private function getFlashBackupStatus() {
private function getFlashBackupStatus()
{
$flashbackupCfg = '/var/local/emhttp/flashbackup.ini';
$this->flashbackupStatus = (file_exists($flashbackupCfg)) ? @parse_ini_file($flashbackupCfg) : [];
$this->flashBackupActivated = empty($this->flashbackupStatus['activated']) ? '' : 'true';
}
private function getMyServersCfgValues() {
private function getMyServersCfgValues()
{
/**
* @todo can we read this from somewhere other than the flash? Connect page uses this path and /boot/config/plugins/dynamix.my.servers/myservers.cfg…
* - $myservers_memory_cfg_path ='/var/local/emhttp/myservers.cfg';
@@ -188,9 +216,11 @@ class ServerState
$this->registered = !empty($this->myServersFlashCfg['remote']['apikey']) && $this->connectPluginInstalled;
$this->registeredTime = $this->myServersFlashCfg['remote']['regWizTime'] ?? '';
$this->username = $this->myServersFlashCfg['remote']['username'] ?? '';
$this->ssoEnabled = !empty($this->myServersFlashCfg['remote']['ssoSubIds'] ?? '');
}
private function getConnectKnownOrigins() {
private function getConnectKnownOrigins()
{
/**
* Allowed origins warning displayed when the current webGUI URL is NOT included in the known lists of allowed origins.
* Include localhost in the test, but only display HTTP(S) URLs that do not include localhost.
@@ -198,7 +228,7 @@ class ServerState
$this->host = $_SERVER['HTTP_HOST'] ?? "unknown";
$memoryCfgPath = '/var/local/emhttp/myservers.cfg';
$this->myServersMemoryCfg = (file_exists($memoryCfgPath)) ? @parse_ini_file($memoryCfgPath) : [];
$this->myServersMiniGraphConnected = (($this->myServersMemoryCfg['minigraph']??'') === 'CONNECTED');
$this->myServersMiniGraphConnected = (($this->myServersMemoryCfg['minigraph'] ?? '') === 'CONNECTED');
$allowedOrigins = $this->myServersMemoryCfg['allowedOrigins'] ?? "";
$extraOrigins = $this->myServersFlashCfg['api']['extraOrigins'] ?? "";
@@ -214,8 +244,8 @@ class ServerState
$this->combinedKnownOrigins = explode(",", $combinedOrigins);
if ($this->combinedKnownOrigins) {
foreach($this->combinedKnownOrigins as $key => $origin) {
if ( (strpos($origin, "http") === false) || (strpos($origin, "localhost") !== false) ) {
foreach ($this->combinedKnownOrigins as $key => $origin) {
if ((strpos($origin, "http") === false) || (strpos($origin, "localhost") !== false)) {
// clean up $this->combinedKnownOrigins, only display warning if origins still remain to display
unset($this->combinedKnownOrigins[$key]);
}
@@ -228,6 +258,23 @@ class ServerState
}
}
private function detectActivationCode()
{
// Fresh server and we're not loading with a callback param to install
if ($this->state !== 'ENOKEYFILE' || !empty($_GET['c'])) {
return;
}
$activationCodeData = new ActivationCodeExtractor();
$data = $activationCodeData->getData();
if (empty($data)) {
return;
}
$this->activationCodeData = $data;
}
/**
* Retrieve the server information as an associative array
*
@@ -286,7 +333,8 @@ class ServerState
"registered" => $this->registered,
"registeredTime" => $this->registeredTime,
"site" => _var($_SERVER, 'REQUEST_SCHEME') . "://" . _var($_SERVER, 'HTTP_HOST'),
"state" => strtoupper(empty($this->var['regCheck']) ? $this->var['regTy'] : $this->var['regCheck']),
"ssoEnabled" => $this->ssoEnabled,
"state" => $this->state,
"theme" => [
"banner" => !empty($this->getWebguiGlobal('display', 'banner')),
"bannerGradient" => $this->getWebguiGlobal('display', 'showBannerGradient') === 'yes' ?? false,
@@ -318,6 +366,10 @@ class ServerState
$serverState['updateOsResponse'] = $this->updateOsResponse;
}
if ($this->activationCodeData) {
$serverState['activationCodeData'] = $this->activationCodeData;
}
return $serverState;
}
@@ -326,7 +378,8 @@ class ServerState
*
* @return string
*/
public function getServerStateJson() {
public function getServerStateJson()
{
return json_encode($this->getServerState());
}
@@ -335,8 +388,9 @@ class ServerState
*
* @return string
*/
public function getServerStateJsonForHtmlAttr() {
public function getServerStateJsonForHtmlAttr()
{
$json = json_encode($this->getServerState());
return htmlspecialchars($json, ENT_QUOTES, 'UTF-8');
}
}
}

View File

@@ -80,6 +80,8 @@ class WebComponentTranslations
'<p>Your Unraid registration key is ineligible for replacement as it has been replaced within the last 12 months.</p>' => '<p>' . _('Your Unraid registration key is ineligible for replacement as it has been replaced within the last 12 months.') . '</p>',
'A Trial key provides all the functionality of an Unleashed Registration key' => _('A Trial key provides all the functionality of an Unleashed Registration key'),
'Acklowledge that you have made a Flash Backup to enable this action' => _('Acklowledge that you have made a Flash Backup to enable this action'),
'Activate License' => _('Activate License'),
'Activate Now' => _('Activate Now'),
'ago' => _('ago'),
'All you need is an active internet connection, an Unraid.net account, and the Connect plugin. Get started by installing the plugin.' => _('All you need is an active internet connection, an Unraid.net account, and the Connect plugin.') . ' ' . _('Get started by installing the plugin.'),
'Attached Storage Devices' => _('Attached Storage Devices'),
@@ -117,11 +119,15 @@ class WebComponentTranslations
'Copy Key URL' => _('Copy Key URL'),
'Copy your Key URL: {0}' => sprintf(_('Copy your Key URL: %s'), '{0}'),
'Create Flash Backup' => _('Create Flash Backup'),
'Create a password' => _('Create a password'),
'Create an Unraid.net account and activate your key' => _('Create an Unraid.net account and activate your key'),
'Create Device Password' => _('Create Device Password'),
'Current Version {0}' => sprintf(_('Current Version %s'), '{0}'),
'Current Version: Unraid {0}' => sprintf(_('Current Version: Unraid %s'), '{0}'),
'Customizable Dashboard Tiles' => _('Customizable Dashboard Tiles'),
'day' => sprintf(_('%s day'), '{n}') . ' | ' . sprintf(_('%s days'), '{n}'),
'Deep Linking' => _('Deep Linking'),
'Device is ready to configure' => _('Device is ready to configure'),
'DNS issue, unable to resolve wanip4.unraid.net' => _('DNS issue, unable to resolve wanip4.unraid.net'),
'Downgrade Unraid OS to {0}' => sprintf(_('Downgrade Unraid OS to %s'), '{0}'),
'Downgrade Unraid OS' => _('Downgrade Unraid OS'),
@@ -204,6 +210,7 @@ class WebComponentTranslations
'Learn more and link your key to your account' => _('Learn more and link your key to your account'),
'Learn More' => _('Learn More'),
'Learn more' => _('Learn more'),
'Let\'s activate your Unraid OS License' => _('Let\'s activate your Unraid OS License'),
'Let\'s Unleash your Hardware!' => _('Let\'s Unleash your Hardware!'),
'License key actions' => _('License key actions'),
'License key type' => _('License key type'),
@@ -218,6 +225,8 @@ class WebComponentTranslations
'minute' => sprintf(_('%s minute'), '{n}') . ' | ' . sprintf(_('%s minutes'), '{n}'),
'Missing key file' => _('Missing key file'),
'month' => sprintf(_('%s month'), '{n}') . ' | ' . sprintf(_('%s months'), '{n}'),
'More about Unraid.net Accounts' => _('More about Unraid.net Accounts'),
'More about Unraid.net' => _('More about Unraid.net'),
'More options' => _('More options'),
'Multiple License Keys Present' => _('Multiple License Keys Present'),
'Never ever be left without a backup of your config. If you need to change flash drives, generate a backup from Connect and be up and running in minutes.' => _('Never ever be left without a backup of your config.') . ' ' . _('If you need to change flash drives, generate a backup from Connect and be up and running in minutes.'),
@@ -281,6 +290,7 @@ class WebComponentTranslations
'Requires the local unraid-api to be running successfully' => _('Requires the local unraid-api to be running successfully'),
'Restarting unraid-api…' => _('Restarting unraid-api…'),
'second' => sprintf(_('%s second'), '{n}') . ' | ' . sprintf(_('%s seconds'), '{n}'),
'Secure your device' => _('Secure your device'),
'Server Up Since {0}' => sprintf(_('Server Up Since %s'), '{0}'),
'Servers equipped with a myunraid.net certificate can be managed directly from within the Connect web UI. Manage multiple servers from your phone, tablet, laptop, or PC in the same browser window.' => _('Servers equipped with a myunraid.net certificate can be managed directly from within the Connect web UI.') . ' ' . _('Manage multiple servers from your phone, tablet, laptop, or PC in the same browser window.'),
'Set custom server tiles how you like and automatically display your server\'s banner image on your Connect Dashboard.' => _('Set custom server tiles how you like and automatically display your server\'s banner image on your Connect Dashboard.'),
@@ -302,6 +312,7 @@ class WebComponentTranslations
'SSL certificates for unraid.net deprecated' => _('SSL certificates for unraid.net deprecated'),
'Stale Server' => _('Stale Server'),
'Stale' => _('Stale'),
'On the following screen, your license will be activated. You\'ll then create an Unraid.net Account to manage your license going forward.' => _('On the following screen, your license will be activated.') . ' ' . _('You\'ll then create an Unraid.net Account to manage your license going forward.'),
'Start Free 30 Day Trial' => _('Start Free 30 Day Trial'),
'Starting your free 30 day trial' => _('Starting your free 30 day trial'),
'Success!' => _('Success!'),
@@ -372,6 +383,8 @@ class WebComponentTranslations
'View on Docs' => _('View on Docs'),
'View release notes' => _('View release notes'),
'We recommend backing up your USB Flash Boot Device before starting the update.' => _('We recommend backing up your USB Flash Boot Device before starting the update.'),
'Welcome to your new ${0} system, powered by Unraid!' => _('Welcome to your new ${0} system, powered by Unraid!'),
'Welcome to Unraid!' => _('Welcome to Unraid!'),
'year' => sprintf(_('%s year'), '{n}') . ' | ' . sprintf(_('%s years'), '{n}'),
'You are still eligible to access OS updates that were published on or before {1}.' => sprintf(_('You are still eligible to access OS updates that were published on or before %s.'), '{1}'),
'You can also manually create a new backup by clicking the Create Flash Backup button.' => _('You can also manually create a new backup by clicking the Create Flash Backup button.'),
@@ -380,6 +393,7 @@ class WebComponentTranslations
'You have exceeded the number of devices allowed for your license. Please remove a device before adding another.' => _('You have exceeded the number of devices allowed for your license. Please remove a device before adding another.'),
'You have not activated the Flash Backup feature via the Unraid Connect plugin.' => _('You have not activated the Flash Backup feature via the Unraid Connect plugin.'),
'You may still update to releases dated prior to your update expiration date.' => _('You may still update to releases dated prior to your update expiration date.'),
'You\'re about to create a password to secure access to your system. This password is essential for managing and configuring your server. Youll use this password every time you access the Unraid web interface.' => _('You\'re about to create a password to secure access to your system.') . ' ' . _('This password is essential for managing and configuring your server.') . ' ' . _('Youll use this password every time you access the Unraid web interface.'),
'You\'re one step closer to enhancing your Unraid experience' => _('You\'re one step closer to enhancing your Unraid experience'),
'Your {0} Key has been replaced!' => sprintf(_('Your %s Key has been replaced!'), '{0}'),
'Your {0} license included one year of free updates at the time of purchase. You are now eligible to extend your license and access the latest OS updates. You are still eligible to access OS updates that were published on or before {1}.' => sprintf(_('Your %s license included one year of free updates at the time of purchase.'), '{0}') . ' ' . _('You are now eligible to extend your license and access the latest OS updates.') . ' ' . sprintf(_('You are still eligible to access OS updates that were published on or before %s.'), '{1}'),

View File

@@ -0,0 +1,103 @@
<?php
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
class WebComponentsExtractor
{
private const PREFIXED_PATH = '/plugins/dynamix.my.servers/unraid-components/';
private const RICH_COMPONENTS_ENTRY = 'unraid-components.client.mjs';
private const UI_ENTRY = 'src/register.ts';
private const UI_STYLES_ENTRY = 'style.css';
public function __construct() {}
private function findManifestFiles(string $manifestName): array
{
$basePath = '/usr/local/emhttp' . self::PREFIXED_PATH;
$escapedBasePath = escapeshellarg($basePath);
$escapedManifestName = escapeshellarg($manifestName);
$command = "find {$escapedBasePath} -name {$escapedManifestName}";
exec($command, $files);
return $files;
}
public function getAssetPath(string $asset, string $subfolder = ''): string
{
return self::PREFIXED_PATH . ($subfolder ? $subfolder . '/' : '') . $asset;
}
private function getRelativePath(string $fullPath): string
{
$basePath = '/usr/local/emhttp' . self::PREFIXED_PATH;
$relative = str_replace($basePath, '', $fullPath);
return dirname($relative);
}
public function getManifestContents(string $manifestPath): array
{
$contents = @file_get_contents($manifestPath);
return $contents ? json_decode($contents, true) : [];
}
private function getRichComponentsFile(): string
{
$manifestFiles = $this->findManifestFiles('manifest.json');
foreach ($manifestFiles as $manifestPath) {
$manifest = $this->getManifestContents($manifestPath);
$subfolder = $this->getRelativePath($manifestPath);
foreach ($manifest as $key => $value) {
if (strpos($key, self::RICH_COMPONENTS_ENTRY) !== false && isset($value["file"])) {
return ($subfolder ? $subfolder . '/' : '') . $value["file"];
}
}
}
return '';
}
private function getRichComponentsScript(): string
{
$jsFile = $this->getRichComponentsFile();
if (empty($jsFile)) {
return '<script>console.error("%cNo matching key containing \'' . self::RICH_COMPONENTS_ENTRY . '\' found.", "font-weight: bold; color: white; background-color: red");</script>';
}
return '<script src="' . $this->getAssetPath($jsFile) . '"></script>';
}
private function getUnraidUiScriptHtml(): string
{
$manifestFiles = $this->findManifestFiles('ui.manifest.json');
if (empty($manifestFiles)) {
error_log("No ui.manifest.json found");
return '';
}
$manifestPath = $manifestFiles[0]; // Use the first found manifest
$manifest = $this->getManifestContents($manifestPath);
$subfolder = $this->getRelativePath($manifestPath);
if (!isset($manifest[self::UI_ENTRY]) || !isset($manifest[self::UI_STYLES_ENTRY])) {
error_log("Required entries not found in ui.manifest.json");
return '';
}
$jsFile = ($subfolder ? $subfolder . '/' : '') . $manifest[self::UI_ENTRY]['file'];
$cssFile = ($subfolder ? $subfolder . '/' : '') . $manifest[self::UI_STYLES_ENTRY]['file'];
return '<script defer type="module">
import { registerAllComponents } from "' . $this->getAssetPath($jsFile) . '";
registerAllComponents({ pathToSharedCss: "' . $this->getAssetPath($cssFile) . '" });
</script>';
}
public function getScriptTagHtml(): string
{
try {
return $this->getRichComponentsScript() . $this->getUnraidUiScriptHtml();
} catch (\Exception $e) {
error_log("Error in WebComponentsExtractor::getScriptTagHtml: " . $e->getMessage());
return "";
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
{
".nuxt/nuxt-custom-elements/entries/unraid-components.client.mjs": {
"file": "_nuxt/unraid-components.client-BXUDi12i.js",
"name": "unraid-components.client",
"src": ".nuxt/nuxt-custom-elements/entries/unraid-components.client.mjs",
"isEntry": true,
"css": [
"_nuxt/unraid-components-BvEqdEb_.css"
]
},
"ts": 1743029655
}

View File

@@ -115,7 +115,17 @@ class UnraidOsCheck
$params = [];
$params['branch'] = plugin('category', self::PLG_PATH, 'stable');
$params['current_version'] = plugin('version', self::PLG_PATH) ?: _var($var,'version');
// Get current version from patches.json if it exists, otherwise fall back to plugin version or var.ini
$patcherVersion = null;
if (file_exists('/tmp/Patcher/patches.json')) {
$patcherData = @json_decode(file_get_contents('/tmp/Patcher/patches.json'), true);
$unraidVersionInfo = parse_ini_file('/etc/unraid-version');
if ($patcherData['unraidVersion'] === $unraidVersionInfo['version']) {
$patcherVersion = $patcherData['combinedVersion'] ?? null;
}
}
$params['current_version'] = $patcherVersion ?: plugin('version', self::PLG_PATH) ?: _var($var, 'version');
if (_var($var,'regExp')) $params['update_exp'] = date('Y-m-d', _var($var,'regExp')*1);
$defaultUrl = self::BASE_RELEASES_URL;
// pass a param of altUrl to use the provided url instead of the default
@@ -258,4 +268,4 @@ $isGetRequest = !empty($_SERVER) && isset($_SERVER['REQUEST_METHOD']) && $_SERVE
$getHasAction = $_GET !== null && !empty($_GET) && isset($_GET['action']);
if ($isGetRequest && $getHasAction) {
new UnraidOsCheck();
}
}

View File

@@ -13,6 +13,7 @@
?>
<?
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/plugins/dynamix/include/ReplaceKey.php";
$replaceKey = new ReplaceKey();
$replaceKey->check();
@@ -22,4 +23,4 @@ parse_str(getenv('QUERY_STRING') ?? '', $_GET);
require_once "$docroot/plugins/dynamix.plugin.manager/include/UnraidCheck.php";
$unraidOsCheck = new UnraidOsCheck();
$unraidOsCheck->checkForUpdate();
$unraidOsCheck->checkForUpdate();

View File

@@ -234,4 +234,4 @@ class ReplaceKey
$this->installNewKey($latestKey);
}
}
}

View File

@@ -11,11 +11,7 @@
*/
?>
<?
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Wrappers.php";
// This is a stub, does nothing but return success
my_logger("This is a stub and should not be called", "UpdateDNS");
$cli = php_sapi_name()=='cli';
if ($cli) {
exit("success".PHP_EOL);