Skip to content

Commit

Permalink
added a filter for channels with assets
Browse files Browse the repository at this point in the history
  • Loading branch information
collins-self committed Nov 4, 2024
1 parent 45f4505 commit a271187
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ export default function AssetPage(props: IProps) {
return <StationBatteryAttributes NewEdit={newEdit} Asset={newEditAsset} UpdateState={setNewEditAsset} />;
}

function filterChannels(chs: OpenXDA.Types.Channel[]) {
return chs.filter(ch =>
!(ch.Asset.length > 0)
);
}

return (
<div className="container-fluid d-flex h-100 flex-column" style={{ padding: 0 }}>
<div className="row" style={{ flex: 1, overflow: 'hidden' }}>
Expand Down Expand Up @@ -516,7 +522,7 @@ export default function AssetPage(props: IProps) {
<div className="col-12 d-flex flex-column">
<ChannelSelector
Label="Associated Channels"
Channels={props.Channels}
Channels={filterChannels(props.Channels)}
SelectedChannels={newEditAsset.Channels}
UpdateChannels={(c) => {
setNewEditAsset((prev) => ({ ...prev, Channels: c }));
Expand All @@ -533,7 +539,7 @@ export default function AssetPage(props: IProps) {
<div className="col-6 d-flex flex-column">
<ChannelSelector
Label="Associated Channels Bus Side"
Channels={props.Channels}
Channels={filterChannels(props.Channels)}
SelectedChannels={newEditAsset.Channels.filter(ch => ch.ConnectionPriority == 0)}
UpdateChannels={(c) => {
let asset = _.clone(newEditAsset as OpenXDA.Types.Asset);
Expand All @@ -551,7 +557,7 @@ export default function AssetPage(props: IProps) {
<div className="col-6 d-flex flex-column">
<ChannelSelector
Label="Associated Channels Line/XFR Side"
Channels={props.Channels}
Channels={filterChannels(props.Channels)}
SelectedChannels={newEditAsset.Channels.filter(ch => ch.ConnectionPriority == 1)}
UpdateChannels={(c) => {
let asset = _.clone(newEditAsset as OpenXDA.Types.Asset);
Expand All @@ -572,7 +578,7 @@ export default function AssetPage(props: IProps) {
<div className="col-4 d-flex flex-column">
<ChannelSelector
Label="Associated Channels Primary Side"
Channels={props.Channels}
Channels={filterChannels(props.Channels)}
SelectedChannels={newEditAsset.Channels.filter(ch => ch.ConnectionPriority == 0)}
UpdateChannels={(c) => {
let asset = _.clone(newEditAsset as OpenXDA.Types.Asset);
Expand All @@ -590,7 +596,7 @@ export default function AssetPage(props: IProps) {
<div className="col-4 d-flex flex-column">
<ChannelSelector
Label="Associated Channels Secondary Side"
Channels={props.Channels}
Channels={filterChannels(props.Channels)}
SelectedChannels={newEditAsset.Channels.filter(ch => ch.ConnectionPriority == 1)}
UpdateChannels={(c) => {
let asset = _.clone(newEditAsset as OpenXDA.Types.Asset);
Expand All @@ -608,7 +614,7 @@ export default function AssetPage(props: IProps) {
<div className="col-4 d-flex flex-column">
<ChannelSelector
Label="Associated Channels Tertiary Side"
Channels={props.Channels}
Channels={filterChannels(props.Channels)}
SelectedChannels={newEditAsset.Channels.filter(ch => ch.ConnectionPriority == 2)}
UpdateChannels={(c) => {
let asset = _.clone(newEditAsset as OpenXDA.Types.Asset);
Expand All @@ -632,5 +638,4 @@ export default function AssetPage(props: IProps) {
</Modal>
</div>
);

}

0 comments on commit a271187

Please sign in to comment.