Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions API/Model/SOEController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class SOEController : RedirectionController
public SOEController(IAPICredentialRetriever retriever) : base(retriever) { }
#endif

[Route("{eventID:int}/{timeWindow:int}"), HttpGet]
public async ServerResponse Get(int eventID, int timeWindow, CancellationToken token) =>
[Route("{eventID:int}/{timeWindow:int}/{widgetID:int}"), HttpGet]
public async ServerResponse Get(int eventID, int timeWindow, int widgetID, CancellationToken token) =>
await ForwardRequest(token).ConfigureAwait(false);
}
}
63 changes: 63 additions & 0 deletions TSX/Widget/DynamicSQLResultsTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//******************************************************************************************************
// DynamicSQLResultsTable.tsx - Gbtc
//
// Copyright (c) 2025, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
// file except in compliance with the License. You may obtain a copy of the License at:
//
// http://opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 08/07/2026 - Preston Crawford
// Generated original version of source code.
//
//******************************************************************************************************

import React from 'react';
import { Column, Table } from '@gpa-gemstone/react-table';

export type DynamicSQLRow = Record<string, string | number | boolean | null>;

interface IProps {
Data: DynamicSQLRow[];
MaxHeight?: number;
}

const DynamicSQLResultsTable = (props: IProps) => {
const fields = Object.keys(props.Data[0] ?? {});

return (
<Table<DynamicSQLRow>
Data={props.Data}
OnSort={() => { /*Do Nothing*/ }}
SortKey={''}
Ascending={true}
TableClass="table"
TableStyle={{ maxHeight: props.MaxHeight ?? 500 }}
KeySelector={(_data, index = 0) => index}
>
Comment thread
prestoncraw marked this conversation as resolved.
{fields.map(field =>
<Column<DynamicSQLRow>
key={field}
Key={field}
AllowSort={false}
Field={field}
HeaderStyle={{ width: 'auto' }}
RowStyle={{ width: 'auto' }}
>
{field}
</Column>
)}
</Table>
);
}

export default DynamicSQLResultsTable;
69 changes: 10 additions & 59 deletions TSX/Widget/ITOA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,14 @@
import React from 'react';
import { EventWidget } from '../global';
import { Input, Select, TextArea } from '@gpa-gemstone/react-forms';
import { Table, Column } from '@gpa-gemstone/react-table';
import { ReactIcons } from '@gpa-gemstone/gpa-symbols';
import { Application } from '@gpa-gemstone/application-typings';
import { Alert } from '@gpa-gemstone/react-interactive';
import DynamicSQLResultsTable, { DynamicSQLRow } from './DynamicSQLResultsTable';

interface IValue {
Value: string | number
}
interface ItoaInfo {
StartTime: string,
Cause: string,
Voltage: string
ID: number,
Station: string
}
interface ISetting {
SQLCommand: string,
TimeWindow: number[]
Expand Down Expand Up @@ -110,12 +103,14 @@ const ITOA: EventWidget.IWidget<ISetting> = {
);
},
Widget: (props: EventWidget.IWidgetProps<ISetting>) => {
const [data, setData] = React.useState<ItoaInfo[]>([]);
const [data, setData] = React.useState<DynamicSQLRow[]>([]);
const [timeWindow, setTimeWindow] = React.useState<number>(2);
const [status, setStatus] = React.useState<Application.Types.Status>('uninitiated');

const timeWindowOptions = React.useMemo(() => props.Settings.TimeWindow.map((t) => ({ Value: t.toString(), Label: t.toString() })), [props.Settings.TimeWindow]);
const resultsMaxHeight = Math.min(props.MaxHeight, 200);

Comment thread
prestoncraw marked this conversation as resolved.
//Effect to get ITOA data
React.useEffect(() => {
setStatus('loading');
const handle = getITOAData(props.HomePath, props.EventID, timeWindow, props.WidgetID);
Expand Down Expand Up @@ -147,7 +142,7 @@ const ITOA: EventWidget.IWidget<ISetting> = {
/>
</div>
</div>
<div style={{ maxHeight: 200, overflowY: 'auto' }}>
<div style={{ maxHeight: resultsMaxHeight, overflowY: 'hidden' }}>
{status === 'error' ?
<Alert Class='alert-danger'>
An error occurred while fetching ITOA data. Please check System Center for more details.
Expand All @@ -158,54 +153,10 @@ const ITOA: EventWidget.IWidget<ISetting> = {
<ReactIcons.SpiningIcon Size={'50%'} />
</div>
:
<Table<ItoaInfo>
<DynamicSQLResultsTable
Data={data}
OnSort={() => { /*Do Nothing*/ }}
SortKey={''}
Ascending={true}
TableClass="table"
KeySelector={data => data.ID}
TheadStyle={{ fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%', height: 50 }}
TbodyStyle={{ display: 'block', overflowY: 'auto', width: '100%', maxHeight: props.MaxHeight ?? 500 }}
RowStyle={{ fontSize: 'smaller', display: 'table', tableLayout: 'fixed', width: '100%' }}
>
<Column<ItoaInfo>
Key={'Time'}
AllowSort={false}
Field={'StartTime'}
HeaderStyle={{ width: 'auto' }}
RowStyle={{ width: 'auto' }}
>
Time
</Column>
<Column<ItoaInfo>
Key={'Cause'}
AllowSort={false}
Field={'Cause'}
HeaderStyle={{ width: 'auto' }}
RowStyle={{ width: 'auto' }}
>
Alarm
</Column>
<Column<ItoaInfo>
Key={'Station'}
AllowSort={false}
Field={'Station'}
HeaderStyle={{ width: 'auto' }}
RowStyle={{ width: 'auto' }}
>
Description
</Column>
<Column<ItoaInfo>
Key={'Voltage'}
AllowSort={false}
Field={'Voltage'}
HeaderStyle={{ width: 'auto' }}
RowStyle={{ width: 'auto' }}
>
Voltages
</Column>
</Table>
MaxHeight={resultsMaxHeight}
/>
}
</div>
</div>
Expand All @@ -222,7 +173,7 @@ const getITOAData = (homePath: string, eventID: number, timeWindow: number, widg
dataType: 'json',
cache: false,
async: true
}) as JQuery.jqXHR<ItoaInfo[]>;
}) as JQuery.jqXHR<DynamicSQLRow[]>;
};

export default ITOA;
export default ITOA;
Loading