handle different types of OMS from SUV status page

This commit is contained in:
Michael Becker 2025-03-25 10:52:15 -04:00
parent 2cc1a4f37c
commit 70a9255d1e
5 changed files with 26 additions and 15 deletions

View File

@ -96,7 +96,9 @@ function mocha_get_current_user() : ?InstanceReference
{ {
$currentTenant = $oms->getTenantByName($path[0]); $currentTenant = $oms->getTenantByName($path[0]);
} }
$oms->setTenant($currentTenant); if ($currentTenant != null) {
$oms->setTenant($currentTenant);
}
} }
if ($currentTenant !== null) if ($currentTenant !== null)
@ -142,10 +144,6 @@ function mocha_get_current_user() : ?InstanceReference
// echo ("user_token is NOT set"); die(); // echo ("user_token is NOT set"); die();
} }
} }
else
{
echo ("currentTenant is null"); die();
}
return null; return null;
} }
/** /**

View File

@ -20,6 +20,8 @@
abstract class Oms abstract class Oms
{ {
public abstract function getBackendName() : string;
public ?array $MethodImplementations; public ?array $MethodImplementations;
public function __construct() public function __construct()

View File

@ -32,6 +32,8 @@
class HttpOmsClient extends Oms class HttpOmsClient extends Oms
{ {
public function getBackendName() : string { return "dotnet"; }
public string $ServerName; public string $ServerName;
public int $PortNumber; public int $PortNumber;
@ -340,9 +342,9 @@
{ {
foreach ($json["tenants"] as $tenant) 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++; $i++;
} }

View File

@ -11,6 +11,8 @@
class MySQLDatabaseOms extends DatabaseOms class MySQLDatabaseOms extends DatabaseOms
{ {
private \PDO $PDO; private \PDO $PDO;
public function getBackendName() : string { return "mysql"; }
public function query($query, array $parms) public function query($query, array $parms)
{ {

View File

@ -56,7 +56,7 @@
{ {
$tenants[] = array $tenants[] = array
( (
"name" => $tenant, "name" => $tenant["name"],
"status" => "Active", "status" => "Active",
"tenantType" => "Development", "tenantType" => "Development",
"dataCenter" => "Local", "dataCenter" => "Local",
@ -122,6 +122,7 @@
protected function OnPreRender(CancelEventArgs $e) protected function OnPreRender(CancelEventArgs $e)
{ {
global $basepath; global $basepath;
$oms = mocha_get_oms();
$e->Cancel = true; $e->Cancel = true;
@ -194,10 +195,11 @@
), ),
"database" => array "database" => array
( (
"backend" => "mysql", "backend" => $oms->getBackendName(),
"userName" => System::GetConfigurationValue("Database.UserName"), // "userName" => System::GetConfigurationValue("Database.UserName"),
"hostName" => System::GetConfigurationValue("Database.ServerName"), "hostName" => $oms->ServerName, // System::GetConfigurationValue("Database.ServerName"),
"portNumber" => intval(System::GetConfigurationValue("Database.PortNumber")), "portNumber" => $oms->PortNumber,
// "portNumber" => intval(System::GetConfigurationValue("Database.PortNumber")),
"status" => "running" "status" => "running"
) )
); );
@ -482,6 +484,7 @@ EOF
$page->Title = "Database"; $page->Title = "Database";
$page->Content = function() $page->Content = function()
{ {
$oms = mocha_get_oms();
?> ?>
<table class="uwt-listview"> <table class="uwt-listview">
<thead> <thead>
@ -493,11 +496,15 @@ EOF
<tbody> <tbody>
<tr> <tr>
<td>Backend</td> <td>Backend</td>
<td>mysql</td> <td><?php echo($oms->getBackendName()); ?></td>
</tr> </tr>
<tr> <tr>
<td>User</td> <td>User</td>
<td><?php echo(System::GetConfigurationValue("Database.UserName")); ?></td> <td><?php
if ($oms->getBackendName() == "mysql") {
echo (System::GetConfigurationValue("Database.UserName"));
}
?></td>
</tr> </tr>
<tr> <tr>
<td>Host</td> <td>Host</td>
@ -505,7 +512,7 @@ EOF
</tr> </tr>
<tr> <tr>
<td>Port</td> <td>Port</td>
<td><?php echo(System::GetConfigurationValue("Database.PortNumber")); ?></td> <td><?php echo($oms->PortNumber); ?></td>
</tr> </tr>
<tr> <tr>
<td>Status</td> <td>Status</td>