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
57 changes: 57 additions & 0 deletions Libraries/openXDA.Model/TransmissionElements/AssetTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//******************************************************************************************************
// AssetTypes.cs - Gbtc
//
// Copyright © 2019, 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:
// ----------------------------------------------------------------------------------------------------
// 12/24/2019 - C. Lackner
// Generated original version of source code.
//
//******************************************************************************************************

using System.ComponentModel.DataAnnotations;
using Gemstone.Data.Model;

namespace openXDA.Model
{
public enum AssetType
{
Line = 1,
Bus = 2,
Breaker = 3,
CapacitorBank = 4,
LineSegement = 5,
Comment thread
prestoncraw marked this conversation as resolved.
Transformer = 6,
CapBankRelay = 7,
DER = 8,
StationAux = 9,
StationBattery = 10,
Generation = 11
}

[TableName("AssetType")]
public class AssetTypes
{
[PrimaryKey(true)]
public int ID { get; set; }

[StringLength(50)]
[DefaultSortOrder]
public string Name { get; set; }

[StringLength(250)]
public string Description { get; set; }
}
}
3 changes: 3 additions & 0 deletions SEBrowser/Controllers/OpenXDA/ModelControlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class EventTypeController : ReadOnlyModelController<SEbrowserEventType>;
[Route("api/openXDA/Asset")]
public class OpenXDAAssetController : ReadOnlyModelController<DetailedAsset>;

[Route("api/openXDA/AssetType")]
public class AssetTypeController : ReadOnlyModelController<AssetTypes>;

[Route("api/openXDA/Meter")]
public class OpenXDAMeterController : ReadOnlyModelController<DetailedMeter>;

Expand Down
2 changes: 1 addition & 1 deletion SEBrowser/Scripts/TSX/Components/Common/DefaultSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const defaultAssetSearchCols: Search.IField<SystemCenter.Types.DetailedAsset>[]
{ label: 'Key', key: 'AssetKey', type: 'string', isPivotField: false },
{ label: 'Name', key: 'AssetName', type: 'string', isPivotField: false },
{ label: 'Nominal Voltage (L-L kV)', key: 'VoltageKV', type: 'number', isPivotField: false },
{ label: 'Type', key: 'AssetType', type: 'enum', isPivotField: false },
{ label: 'Type', key: 'AssetType', type: 'enum', enum: [{ Label: 'AssetType', Value: 'AssetType' }], isPivotField: false },
{ label: 'Meter Key', key: 'Meter', type: 'string', isPivotField: false },
{ label: 'Substation Key', key: 'Location', type: 'string', isPivotField: false },
{ label: 'Number of Meters', key: 'Meters', type: 'integer', isPivotField: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ interface IProps<T> {
Searchbar: (children: React.ReactNode, SetFilter: (filters: Search.IFilter<T>[]) => void, SearchStatus: Application.Types.Status, ResultCount: number) => React.ReactNode,
Type?: 'single' | 'multiple',
Title: string,
AddlFilters?: Search.IFilter<T>[],
MinSelection?: number,
children?: React.ReactNode
}

const SelectPopup = <T,>(props: IProps<T>) => {
const controller = React.useMemo(() => new ReadOnlyControllerFunctions_Gemstone<T>(props.ControllerAPIPath), [props.ControllerAPIPath]);
const bulkHandle = React.useRef<JQuery.jqXHR<T[]> | null>(null);
const [filters, setFilters] = React.useState<Search.IFilter<T>[]>([]);
const [filters, setFilters] = React.useState<Search.IFilter<T>[]>(props.AddlFilters ?? []);
const [sortField, setSortField] = React.useState<keyof T>(props.DefaultSortField);
const [ascending, setAscending] = React.useState<boolean>(true);

Expand Down Expand Up @@ -248,4 +249,4 @@ const SelectPopup = <T,>(props: IProps<T>) => {
)
}

export default SelectPopup;
export default SelectPopup;
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { TimeFilter } from '@gpa-gemstone/common-pages';
import { useAppDispatch, useAppSelector } from '../../../hooks';
import { SelectAssetGroupList, SelectAssetList, SelectMeterList, SelectReset, SelectStationList, SelectTimeFilter, SetFilterLists } from '../../../Store/EventSearchSlice';
import { ResetFilters, SetFilters } from '../../../Store/EventSearchSlice';
import { AssetGroupControllerPath, AssetControllerPath, LocationControlerPath, MeterControllerPath } from '../../../Store/ControllerFunctions';
import { AssetGroupControllerPath, AssetControllerPath, AssetTypeController, LocationControlerPath, MeterControllerPath } from '../../../Store/ControllerFunctions';
import { DefaultSelects } from '../../Common/DefaultSelects';
import NavbarFilterButton from '../../Common/NavbarFilterButton';
import { SystemCenter, OpenXDA, Gemstone } from '@gpa-gemstone/application-typings';
Expand Down Expand Up @@ -249,6 +249,13 @@ const EventSearchNavbar = () => {
</DefaultSelects.Meter>
<DefaultSelects.Asset
ControllerAPIPath={AssetControllerPath}
AddlFilters={[{
FieldName: 'AssetType',
SearchText: 'LineSegment',
Operator: '<>',
Type: 'enum',
IsPivotColumn: false
}]}
Selection={assetList}
OnClose={(selected, conf) => {
setFilter('None');
Expand Down Expand Up @@ -463,10 +470,24 @@ const orderAdditionalFields = <T,>(fields: SystemCenter.Types.AdditionalField[])
);
}

const getEnum = (setOptions: (options: Gemstone.TSX.Interfaces.ILabelValue<string>[]) => void, field: Search.IField<SystemCenter.Types.DetailedMeter>) => {
export const getEnum = <T,>(setOptions: (options: Gemstone.TSX.Interfaces.ILabelValue<string>[]) => void, field: Search.IField<T>) => {
if (field.type != 'enum' || field.enum == undefined || field.enum.length != 1)
return () => {/*Do Nothing*/ };

if (field.key == 'AssetType') {
const handle = AssetTypeController.GetAll('Name', true, [{
FieldName: 'Name',
SearchParameter: 'LineSegment',
Operator: '<>'
}]);

handle.done(d => setOptions(d.map(item => ({ Value: item.Name, Label: item.Name }))));

return () => {
if (handle.abort != null) handle.abort();
}
}

const handle: JQuery.jqXHR<ValueListItemResponse[]> = getValueListGroup(field.enum[0].Value);

handle.done(d => setOptions(d.map(item => ({ Value: item.Value.toString(), Label: item.AltValue ?? item.Value }))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { FilterType, TrendChannelTableState } from './Types';
import TrendChannelFilters from './ChannelFilters';
import TrendDataNavbarButtons from './TrendDataNavbarButtons';
import { useTrendDataNavbar } from './useTrendDataNavbar';
import { getValueListGroup, ValueListItemResponse } from '../../EventSearch/Navbar/EventSearchNavbar';
import { getEnum } from '../../EventSearch/Navbar/EventSearchNavbar';
import { TrendChannelSelectorTutorialAlert } from '../TrendDataTutorials';

interface IProps {
Expand Down Expand Up @@ -108,19 +108,6 @@ const TrendSearchNavbar = React.memo((props: IProps) => {

const tableHeight = timeOffsetHeight > filtOffsetHeight ? timeOffsetHeight : filtOffsetHeight;

function getEnum(setOptions, field) {
if (field.type != 'enum' || field.enum == undefined || field.enum.length != 1)
return () => { /*noop */};

const handle: JQuery.jqXHR<ValueListItemResponse[]> = getValueListGroup(field.enum[0].Value);

handle.done(d => setOptions(d.map(item => ({ Value: item.Value.toString(), Label: item.AltValue ?? item.Value }))))
return () => {
if (handle?.abort != null)
handle.abort();
}
}

function getAdditionalMeterFields(setFields) {
const handle = getAdditionalMeterFieldNames();

Expand Down Expand Up @@ -326,6 +313,13 @@ const TrendSearchNavbar = React.memo((props: IProps) => {
</DefaultSelects.Meter>
<DefaultSelects.Asset
ControllerAPIPath={AssetControllerPath}
AddlFilters={[{
FieldName: 'AssetType',
SearchText: 'LineSegment',
Operator: '<>',
Type: 'enum',
IsPivotColumn: false
}]}
Selection={trendFilter?.AssetList ?? []}
OnClose={(selected, conf) => {
setShowFilter('None');
Expand Down
2 changes: 2 additions & 0 deletions SEBrowser/Scripts/TSX/Store/ControllerFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ declare let homePath: string;
// Controller API paths
export const MeterControllerPath = `${homePath}api/OpenXDA/Meter`;
export const AssetControllerPath = `${homePath}api/OpenXDA/Asset`;
export const AssetTypeControllerPath = `${homePath}api/OpenXDA/AssetType`;
export const EventTypeControllerPath = `${homePath}api/OpenXDA/EventType`;
export const LocationControlerPath = `${homePath}api/OpenXDA/Location`;
export const AssetGroupControllerPath = `${homePath}api/openXDA/AssetGroup`;
Expand All @@ -39,6 +40,7 @@ export const ChannelGroupControllerPath = `${homePath}api/openXDA/ChannelGroup`;
// Shared read-only controllers - instantiated once here and reused across the app
export const MeterController = new ReadOnlyControllerFunctions_Gemstone<SystemCenter.Types.DetailedMeter>(MeterControllerPath);
export const AssetController = new ReadOnlyControllerFunctions_Gemstone<SystemCenter.Types.DetailedAsset>(AssetControllerPath);
export const AssetTypeController = new ReadOnlyControllerFunctions_Gemstone<OpenXDA.Types.AssetType>(AssetTypeControllerPath);
export const LocationController = new ReadOnlyControllerFunctions_Gemstone<SystemCenter.Types.DetailedLocation>(LocationControlerPath);
export const AssetGroupController = new ReadOnlyControllerFunctions_Gemstone<OpenXDA.Types.AssetGroup>(AssetGroupControllerPath);
export const EventTypeController = new ReadOnlyControllerFunctions_Gemstone<OpenXDA.Types.EventType>(EventTypeControllerPath);
Expand Down