From 70a9255d1e6732bd3f43f633b32dfb20fea66aba Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 25 Mar 2025 10:52:15 -0400 Subject: [PATCH] handle different types of OMS from SUV status page --- .../src/mocha-php/include/mochacommon.inc.php | 8 +++---- .../src/mocha-php/lib/mocha/core/Oms.inc.php | 2 ++ .../lib/mocha/oms/HttpOmsClient.inc.php | 6 +++-- .../lib/mocha/oms/MySQLDatabaseOms.inc.php | 2 ++ .../src/mocha-php/ui/pages/SUVPage.phpx.php | 23 ++++++++++++------- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/mocha-php/src/mocha-php/include/mochacommon.inc.php b/mocha-php/src/mocha-php/include/mochacommon.inc.php index 0798d8d..887840c 100644 --- a/mocha-php/src/mocha-php/include/mochacommon.inc.php +++ b/mocha-php/src/mocha-php/include/mochacommon.inc.php @@ -96,7 +96,9 @@ function mocha_get_current_user() : ?InstanceReference { $currentTenant = $oms->getTenantByName($path[0]); } - $oms->setTenant($currentTenant); + if ($currentTenant != null) { + $oms->setTenant($currentTenant); + } } if ($currentTenant !== null) @@ -142,10 +144,6 @@ function mocha_get_current_user() : ?InstanceReference // echo ("user_token is NOT set"); die(); } } - else - { - echo ("currentTenant is null"); die(); - } return null; } /** diff --git a/mocha-php/src/mocha-php/lib/mocha/core/Oms.inc.php b/mocha-php/src/mocha-php/lib/mocha/core/Oms.inc.php index 6717580..6657c90 100644 --- a/mocha-php/src/mocha-php/lib/mocha/core/Oms.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/core/Oms.inc.php @@ -20,6 +20,8 @@ abstract class Oms { + public abstract function getBackendName() : string; + public ?array $MethodImplementations; public function __construct() diff --git a/mocha-php/src/mocha-php/lib/mocha/oms/HttpOmsClient.inc.php b/mocha-php/src/mocha-php/lib/mocha/oms/HttpOmsClient.inc.php index 0f673ca..6b20322 100644 --- a/mocha-php/src/mocha-php/lib/mocha/oms/HttpOmsClient.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/oms/HttpOmsClient.inc.php @@ -32,6 +32,8 @@ class HttpOmsClient extends Oms { + public function getBackendName() : string { return "dotnet"; } + public string $ServerName; public int $PortNumber; @@ -340,9 +342,9 @@ { foreach ($json["tenants"] as $tenant) { - if ($tenant == $tenantName) + if ($tenant["name"] == $tenantName) { - return new TenantReference($i, $tenant, null); + return new TenantReference($i, $tenant["name"], null); } $i++; } diff --git a/mocha-php/src/mocha-php/lib/mocha/oms/MySQLDatabaseOms.inc.php b/mocha-php/src/mocha-php/lib/mocha/oms/MySQLDatabaseOms.inc.php index 221e0a8..47800e1 100644 --- a/mocha-php/src/mocha-php/lib/mocha/oms/MySQLDatabaseOms.inc.php +++ b/mocha-php/src/mocha-php/lib/mocha/oms/MySQLDatabaseOms.inc.php @@ -11,6 +11,8 @@ class MySQLDatabaseOms extends DatabaseOms { private \PDO $PDO; + + public function getBackendName() : string { return "mysql"; } public function query($query, array $parms) { diff --git a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php index 33d27fa..9340f0c 100644 --- a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php +++ b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php @@ -56,7 +56,7 @@ { $tenants[] = array ( - "name" => $tenant, + "name" => $tenant["name"], "status" => "Active", "tenantType" => "Development", "dataCenter" => "Local", @@ -122,6 +122,7 @@ protected function OnPreRender(CancelEventArgs $e) { global $basepath; + $oms = mocha_get_oms(); $e->Cancel = true; @@ -194,10 +195,11 @@ ), "database" => array ( - "backend" => "mysql", - "userName" => System::GetConfigurationValue("Database.UserName"), - "hostName" => System::GetConfigurationValue("Database.ServerName"), - "portNumber" => intval(System::GetConfigurationValue("Database.PortNumber")), + "backend" => $oms->getBackendName(), + // "userName" => System::GetConfigurationValue("Database.UserName"), + "hostName" => $oms->ServerName, // System::GetConfigurationValue("Database.ServerName"), + "portNumber" => $oms->PortNumber, + // "portNumber" => intval(System::GetConfigurationValue("Database.PortNumber")), "status" => "running" ) ); @@ -482,6 +484,7 @@ EOF $page->Title = "Database"; $page->Content = function() { + $oms = mocha_get_oms(); ?> @@ -493,11 +496,15 @@ EOF - + - + @@ -505,7 +512,7 @@ EOF - +
BackendmysqlgetBackendName()); ?>
UsergetBackendName() == "mysql") { + echo (System::GetConfigurationValue("Database.UserName")); + } + ?>
Host
PortPortNumber); ?>
Status