diff --git a/Source/Applications/SystemCenter/Controllers/SystemCenter/AppHostController.cs b/Source/Applications/SystemCenter/Controllers/SystemCenter/AppHostController.cs index dd8f67867..765381061 100644 --- a/Source/Applications/SystemCenter/Controllers/SystemCenter/AppHostController.cs +++ b/Source/Applications/SystemCenter/Controllers/SystemCenter/AppHostController.cs @@ -26,8 +26,8 @@ using GSF.Data.Model; using GSF.Reflection; using Newtonsoft.Json; -using openXDA.APIMiddleware; using openXDA.APIAuthentication; +using openXDA.APIMiddleware; using openXDA.Model; using System; using System.Collections.Generic; @@ -88,6 +88,8 @@ public IHttpActionResult Get() // Add MiMD hosts.Add(GetMiMD()); + hosts.Add(GetOpenMIC()); + // Add XDA Nodes using (AdoDataConnection connection = CreateDbConnection()) { @@ -208,6 +210,28 @@ void ConfigureRequest(HttpRequestMessage request) return ResponseMessage(responseMessage); } + [Route("openMIC/Ping"), HttpGet] + public IHttpActionResult openMICPing() + { + using (AdoDataConnection connection = new AdoDataConnection("systemSettings")) + { + string url = new TableOperations(connection).QueryRecordWhere($"Name = 'OpenMIC.Url'")?.Value ?? ""; + string credential = new TableOperations(connection).QueryRecordWhere($"Name = 'OpenMIC.Credential'")?.Value ?? ""; + string password = new TableOperations(connection).QueryRecordWhere($"Name = 'OpenMIC.Password'")?.Value ?? ""; + + //string token = GenerateAntiForgeryToken(application); + //return Get(httpClient, url, requestURI, credential, password, token); + APIQuery query = new APIQuery(credential, password, url); + void ConfigureRequest(HttpRequestMessage request) + { + request.Method = HttpMethod.Get; + } + HttpResponseMessage response = query.SendWebRequestAsync(ConfigureRequest, $"api/health").Result; + if (response.IsSuccessStatusCode) return Ok(1); + return ResponseMessage(response); + } + } + [Route("MiMDConsole/Ping"), HttpGet] public IHttpActionResult MiMDPing() { @@ -299,6 +323,14 @@ private string GetMiMDBaseURL() } } + private string GetOpenMICBaseURL() + { + using (AdoDataConnection connection = CreateDbConnection()) + { + return connection.ExecuteScalar("", "SELECT Value FROM [SystemCenter.Setting] WHERE Name = {0}", "OpenMIC.Url"); + } + } + private AdoDataConnection CreateDbConnection() { AdoDataConnection connection = new AdoDataConnection("systemSettings"); @@ -344,6 +376,21 @@ private AppHost GetMiMD() }; } + private AppHost GetOpenMIC() + { + return new AppHost() + { + Name = "openMIC", + App = "openMIC", + PingURL = "./api/SystemCenter/AppHost/openMIC/Ping", + Properties = new AppProperty[] + { + new AppProperty() { Name= "Host", Value = GetOpenMICBaseURL() } + }, + Image = "../Images/NodeTiles/openMIC.png" + }; + } + private string DatabaseName { get diff --git a/Source/Applications/SystemCenter/SystemCenter.csproj b/Source/Applications/SystemCenter/SystemCenter.csproj index 532ac87a8..337b8ec91 100644 --- a/Source/Applications/SystemCenter/SystemCenter.csproj +++ b/Source/Applications/SystemCenter/SystemCenter.csproj @@ -492,6 +492,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -504,6 +507,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -547,7 +553,12 @@ - + + + + + + @@ -574,6 +585,7 @@ + diff --git a/Source/Applications/SystemCenter/wwwroot/Images/NodeTiles/openMIC.png b/Source/Applications/SystemCenter/wwwroot/Images/NodeTiles/openMIC.png new file mode 100644 index 000000000..acc388b0c Binary files /dev/null and b/Source/Applications/SystemCenter/wwwroot/Images/NodeTiles/openMIC.png differ diff --git a/Source/Applications/SystemCenter/wwwroot/Images/NodeTiles/openMICIcon.png b/Source/Applications/SystemCenter/wwwroot/Images/NodeTiles/openMICIcon.png new file mode 100644 index 000000000..2bccc6c7b Binary files /dev/null and b/Source/Applications/SystemCenter/wwwroot/Images/NodeTiles/openMICIcon.png differ diff --git a/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/AppHost.tsx b/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/AppHost.tsx index f6a36825f..7ed2ed541 100644 --- a/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/AppHost.tsx +++ b/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/AppHost.tsx @@ -25,8 +25,7 @@ import * as React from 'react'; import { Application } from '@gpa-gemstone/application-typings'; import { LoadingScreen, ServerErrorIcon, LayoutGrid } from '@gpa-gemstone/react-interactive'; import ApplicationCard, { IHost } from './ApplicationCard'; -import ConsoleWindow from './ConsoleWindow'; -import NodeStats from './NodeStats'; +import NodeDetails from './NodeDetails'; import { useMediaQuery } from '@gpa-gemstone/helper-functions'; @@ -34,7 +33,7 @@ const AppHost: Application.Types.iByComponent = (props) => { const [hosts, setHosts] = React.useState([]); const [status, setStatus] = React.useState('uninitiated'); const [console, setConsole] = React.useState(null); - const [stats, setStats] = React.useState(null); + const [details, setDetails] = React.useState(null); const shouldHaveTwoRowsHeight = useMediaQuery('(max-height: 1250px)'); const shouldBeSmall = useMediaQuery('(max-width: 1750px)'); @@ -68,23 +67,20 @@ const AppHost: Application.Types.iByComponent = (props) => { {hosts.map((h) => setConsole(h)} - OpenStats={() => setStats(h)} + OpenDetails={() => { setDetails(h); setConsole(h) }} key={h.PingURL} IsSmall={shouldBeSmall} />)} - setConsole(null)} - ConsoleURL={console?.ConsoleURL} - /> - setStats(null)} - StatsURL={stats?.StatsURL} - ApplicationType={stats?.App ?? null} - Properties={stats?.Properties} + ) } diff --git a/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/ApplicationCard.tsx b/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/ApplicationCard.tsx index 1abc07a1e..f4c29faf1 100644 --- a/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/ApplicationCard.tsx +++ b/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/ApplicationCard.tsx @@ -23,6 +23,7 @@ import * as React from 'react'; import { useAppDispatch } from '../hooks'; +import { SystemCenter as SC } from '../global' export interface IHostProperties { Name: string, Value: string } @@ -33,9 +34,9 @@ export interface IHost { StatsURL?: string, ConsoleURL: string, Name: string, - App: 'XDA' | 'MiMD' | 'SystemCenter', + App: SC.ApplicationType, OpenConsole: () => void, - OpenStats: () => void + OpenDetails: () => void } export interface IApplicationCard extends IHost { @@ -98,13 +99,8 @@ const ApplicationCard = (props: IApplicationCard) => {
-
- -
-
- {props.App === 'MiMD' ? null : - - } +
+
diff --git a/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/ConsoleWindow.tsx b/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/ConsoleWindow.tsx index b98fb0ffa..4c21befee 100644 --- a/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/ConsoleWindow.tsx +++ b/Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AppHost/ConsoleWindow.tsx @@ -22,8 +22,6 @@ //****************************************************************************************************** import * as React from 'react'; -import { Modal } from '@gpa-gemstone/react-interactive'; - export interface IMessage { Message: string, Type: number } export interface IProps { @@ -103,7 +101,7 @@ const ConsoleWindow = (props: IProps) => { React.useEffect(() => { - if (props.ConsoleURL != undefined && props.ConsoleURL.length > 0) + if (props.ConsoleURL != undefined && props.ConsoleURL.length > 0) document.addEventListener("keydown", handleKeyPress, false); return () => { @@ -113,19 +111,19 @@ const ConsoleWindow = (props: IProps) => { React.useEffect(() => { cmdRef.current = cmd; }, [cmd]); React.useEffect(() => { lastCmdRef.current = lastCmd; }, [lastCmd]); - + function handleKeyPress(event) { if (event.keyCode == 38 && cmd.length > 0) // arrow down key { event.preventDefault(); - setCMD(lastCmdRef.current); + setCMD(lastCmdRef.current); } else if (event.keyCode == 13) // enter key { event.preventDefault(); sendCmd(cmdRef.current); - setCMD(''); + setCMD(''); } } @@ -179,31 +177,24 @@ const ConsoleWindow = (props: IProps) => { }, [props.ConsoleURL]); return ( - <> - 0} - CallBack={(_conf, button) => { if (!button) { props.Close(); sessionIDRef.current = ''; } else { sendCmd(cmd); setCMD(''); } }} - ShowCancel={false} Size={'xlg'} - Title={'Console - ' + props.ApplicationName} - ShowX={true} - ConfirmText={'Send'} - > -
-
-
-