Added port filter to main screen and allowed port filtering

This commit is contained in:
Daniel Schick 2024-09-16 09:17:52 +02:00
parent 775fa3a7e2
commit 0e7493366c
10 changed files with 377 additions and 1734 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1858,6 +1858,22 @@ components:
maxLength: 5 maxLength: 5
minLength: 5 minLength: 5
example: DEHAM example: DEHAM
created:
description: Readonly field set by the database when port was created
type: string
format: date-time
example: '2023-08-21T08:23:35Z'
modified:
description: Readonly field set by the database when port was last modified
type: string
format: date-time
nullable: true
example: '2023-08-21T08:23:35Z'
deleted:
description: marks the port as logically deleted
type: boolean
default: false
example: false
example: example:
id: 2 id: 2
name: Hamburg name: Hamburg

View File

@ -25,16 +25,19 @@ namespace BreCalClient
private static List<Participant> _participants = new(); private static List<Participant> _participants = new();
private static readonly List<ShipModel> _ships = new(); private static readonly List<ShipModel> _ships = new();
private static readonly List<ShipModel> _allShips = new(); private static readonly List<ShipModel> _allShips = new();
private static readonly List<Port> _ports = new();
private static readonly List<Port> _allPorts = new();
private readonly static ConcurrentDictionary<int, ShipModel> _shipLookupDict = new(); private readonly static ConcurrentDictionary<int, ShipModel> _shipLookupDict = new();
private readonly static ConcurrentDictionary<int, Berth> _berthLookupDict = new(); private readonly static ConcurrentDictionary<int, Berth> _berthLookupDict = new();
private readonly static Dictionary<int, Participant> _participantLookupDict = new(); private readonly static Dictionary<int, Participant> _participantLookupDict = new();
private readonly static ConcurrentDictionary<int, Port> _portLookupDict = new();
/// <summary> /// <summary>
/// List of TimeRef points /// List of TimeRef points
/// </summary> /// </summary>
// TODO: To make this portable the list of texts should come from a configuration file // TODO: To make this portable the list of texts should come from a configuration file
private readonly static List<string> _timeRefs = new List<string> private readonly static List<string> _timeRefs = new()
{ {
"ETB", "ETB",
"Geeste", "Geeste",
@ -45,12 +48,26 @@ namespace BreCalClient
#region Properties #region Properties
/// <summary>
/// fast ship lookup
/// </summary>
public static ConcurrentDictionary<int, ShipModel> ShipLookupDict { get { return _shipLookupDict; } } public static ConcurrentDictionary<int, ShipModel> ShipLookupDict { get { return _shipLookupDict; } }
/// <summary>
/// fast port lookup
/// </summary>
public static ConcurrentDictionary<int, Berth> BerthLookupDict { get { return _berthLookupDict; } } public static ConcurrentDictionary<int, Berth> BerthLookupDict { get { return _berthLookupDict; } }
/// <summary>
/// fast participant lookup
/// </summary>
public static Dictionary<int, Participant> ParticipantLookupDict { get { return _participantLookupDict; } } public static Dictionary<int, Participant> ParticipantLookupDict { get { return _participantLookupDict; } }
/// <summary>
/// fast port lookup
/// </summary>
public static ConcurrentDictionary<int, Port> PortLookupDict { get { return _portLookupDict; } }
/// <summary> /// <summary>
/// Participants that are agents /// Participants that are agents
/// </summary> /// </summary>
@ -91,6 +108,16 @@ namespace BreCalClient
/// </summary> /// </summary>
public static List<Berth> AllBerths { get { return _allBerths; } } public static List<Berth> AllBerths { get { return _allBerths; } }
/// <summary>
/// All active ports
/// </summary>
public static List<Port> Ports { get { return _ports; } }
/// <summary>
/// All ports including deleted ports
/// </summary>
public static List<Port> AllPorts { get { return _allPorts; } }
/// <summary> /// <summary>
/// All active ships /// All active ships
/// </summary> /// </summary>
@ -157,6 +184,17 @@ namespace BreCalClient
} }
} }
internal static void InitializePorts(List<Port> ports)
{
foreach(var port in ports)
{
_portLookupDict[port.Id] = port;
if(!port.Deleted)
_ports.Add(port);
_allPorts.Add(port);
}
}
#endregion #endregion
} }

View File

@ -73,9 +73,19 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Margin="2" Grid.Column="0" Content="{x:Static p:Resources.textNewDots}" x:Name="buttonNew" Visibility="Hidden" Click="buttonNew_Click" Background="Transparent"/> <Button Margin="2" Grid.Column="0" Content="{x:Static p:Resources.textNewDots}" x:Name="buttonNew" Visibility="Hidden" Click="buttonNew_Click" Background="Transparent"/>
<Label Content="{x:Static p:Resources.textSortOrder}" Grid.Column="1" HorizontalContentAlignment="Right"/> <Label Content="{x:Static p:Resources.textSortOrder}" Grid.Column="1" HorizontalContentAlignment="Right"/>
<ComboBox x:Name="comboBoxSortOrder" Margin="2" Grid.Column="2" SelectionChanged="comboBoxSortOrder_SelectionChanged" /> <Grid Grid.Column="2" Grid.Row="1">
<CheckBox x:Name="checkboxShowCancelledCalls" Grid.Column="3" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2" Checked="checkboxShowCancelledCalls_Checked" Unchecked="checkboxShowCancelledCalls_Checked" /> <Grid.ColumnDefinitions>
<Label Content="{x:Static p:Resources.textShowCancelledShipcalls}" Grid.Column="4" /> <ColumnDefinition Width=".5*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width=".5*" />
</Grid.ColumnDefinitions>
<ComboBox x:Name="comboBoxSortOrder" Margin="2" Grid.Column="0" SelectionChanged="comboBoxSortOrder_SelectionChanged" />
<CheckBox x:Name="checkboxShowCancelledCalls" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2" Checked="checkboxShowCancelledCalls_Checked" Unchecked="checkboxShowCancelledCalls_Checked" />
<Label Content="{x:Static p:Resources.textShowCancelledShipcalls}" Grid.Column="2" />
</Grid>
<Label Content="{x:Static p:Resources.textHarbour}" Grid.Column="3" HorizontalAlignment="Right" />
<xctk:CheckComboBox x:Name="comboBoxPorts" Margin="2" Grid.Column="4" ItemSelectionChanged="comboBoxPorts_ItemSelectionChanged" DisplayMemberPath="Name" />
<Button Margin="2" Grid.Column="6" Content="{x:Static p:Resources.textClearFilters}" x:Name="buttonClearFilter" Click="buttonClearFilter_Click" Background="Transparent" /> <Button Margin="2" Grid.Column="6" Content="{x:Static p:Resources.textClearFilters}" x:Name="buttonClearFilter" Click="buttonClearFilter_Click" Background="Transparent" />
</Grid> </Grid>
<Grid Grid.Row="2"> <Grid Grid.Row="2">

View File

@ -349,6 +349,7 @@ namespace BreCalClient
{ {
this.searchFilterControl.ClearFilters(); this.searchFilterControl.ClearFilters();
this.checkboxShowCancelledCalls.IsChecked = false; this.checkboxShowCancelledCalls.IsChecked = false;
this.comboBoxPorts.UnSelectAll();
this.FilterShipcalls(); this.FilterShipcalls();
} }
@ -366,6 +367,14 @@ namespace BreCalClient
this.SearchFilterControl_SearchFilterChanged(); this.SearchFilterControl_SearchFilterChanged();
} }
private void comboBoxPorts_ItemSelectionChanged(object sender, Xceed.Wpf.Toolkit.Primitives.ItemSelectionChangedEventArgs e)
{
this.searchFilterControl.SearchFilter.Ports.Clear();
foreach (Port port in comboBoxPorts.SelectedItems)
this.searchFilterControl.SearchFilter.Ports.Add(port.Id);
this.SearchFilterControl_SearchFilterChanged();
}
private async void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) private async void comboBoxSortOrder_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{ {
_sortOrder = (Extensions.SortOrder) this.comboBoxSortOrder.SelectedIndex; _sortOrder = (Extensions.SortOrder) this.comboBoxSortOrder.SelectedIndex;
@ -409,11 +418,13 @@ namespace BreCalClient
{ {
if (_loginResult == null) return; if (_loginResult == null) return;
BreCalLists.InitializePorts(await _staticApi.GetPortsAsync());
BreCalLists.InitializeBerths(await _staticApi.BerthsGetAsync()); BreCalLists.InitializeBerths(await _staticApi.BerthsGetAsync());
BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync()); BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync());
BreCalLists.InitializeParticipants(await _staticApi.ParticipantsGetAsync()); BreCalLists.InitializeParticipants(await _staticApi.ParticipantsGetAsync());
this.searchFilterControl.SetBerths(BreCalLists.Berths); this.searchFilterControl.SetBerths(BreCalLists.Berths);
this.comboBoxPorts.ItemsSource = BreCalLists.AllPorts;
foreach (Participant participant in BreCalLists.Participants) foreach (Participant participant in BreCalLists.Participants)
{ {
@ -448,6 +459,14 @@ namespace BreCalClient
SearchFilterModel.filterMap[_loginResult.Id] = currentFilter; SearchFilterModel.filterMap[_loginResult.Id] = currentFilter;
} }
this.searchFilterControl.SetFilterFromModel(currentFilter); this.searchFilterControl.SetFilterFromModel(currentFilter);
if (currentFilter.Ports != null)
{
foreach (Port p in this.comboBoxPorts.ItemsSource)
{
if (currentFilter.Ports.Contains(p.Id)) this.comboBoxPorts.SelectedItems.Add(p);
}
}
} }
_ = Task.Run(() => RefreshShipcalls()); _ = Task.Run(() => RefreshShipcalls());
@ -700,6 +719,11 @@ namespace BreCalClient
_ = this._visibleControlModels.RemoveAll(x => { if (x.Shipcall == null) return false; else return !sfm.Categories.Contains(x.Shipcall.Type); }); _ = this._visibleControlModels.RemoveAll(x => { if (x.Shipcall == null) return false; else return !sfm.Categories.Contains(x.Shipcall.Type); });
} }
if(sfm.Ports.Count > 0 )
{
_ = this._visibleControlModels.RemoveAll(x => { if(x.Shipcall == null) return false; else return !sfm.Ports.Contains(x.Shipcall.PortId); });
}
if(!string.IsNullOrEmpty(sfm.SearchString)) if(!string.IsNullOrEmpty(sfm.SearchString))
{ {
_ = this._visibleControlModels.RemoveAll(x => !(x.ContainsRemarkText(sfm.SearchString) || (x.Ship?.Name.Contains(sfm.SearchString, StringComparison.InvariantCultureIgnoreCase) ?? false))); _ = this._visibleControlModels.RemoveAll(x => !(x.ContainsRemarkText(sfm.SearchString) || (x.Ship?.Name.Contains(sfm.SearchString, StringComparison.InvariantCultureIgnoreCase) ?? false)));
@ -1118,6 +1142,6 @@ namespace BreCalClient
} }
#endregion #endregion
} }
} }

View File

@ -731,6 +731,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Harbour.
/// </summary>
public static string textHarbour {
get {
return ResourceManager.GetString("textHarbour", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Incoming. /// Looks up a localized string similar to Incoming.
/// </summary> /// </summary>

View File

@ -541,4 +541,7 @@
<data name="textZoneEntryInThePast" xml:space="preserve"> <data name="textZoneEntryInThePast" xml:space="preserve">
<value>Zeit Reviereintritt liegt in der Vergangenheit</value> <value>Zeit Reviereintritt liegt in der Vergangenheit</value>
</data> </data>
<data name="textHarbour" xml:space="preserve">
<value>Hafen</value>
</data>
</root> </root>

View File

@ -328,6 +328,9 @@
<data name="textFrom" xml:space="preserve"> <data name="textFrom" xml:space="preserve">
<value>from</value> <value>from</value>
</data> </data>
<data name="textHarbour" xml:space="preserve">
<value>Harbour</value>
</data>
<data name="textIncoming" xml:space="preserve"> <data name="textIncoming" xml:space="preserve">
<value>Incoming</value> <value>Incoming</value>
</data> </data>

View File

@ -25,6 +25,8 @@ namespace BreCalClient
public List<int> Berths { get; set; } = new(); public List<int> Berths { get; set; } = new();
public List<int> Ports { get; set; } = new();
public string? SearchString { get; set; } public string? SearchString { get; set; }
public double? ShipLengthFrom { get; set; } public double? ShipLengthFrom { get; set; }

View File

@ -72,7 +72,7 @@ namespace BreCalClient
string agentName = ""; string agentName = "";
string? name; string? name;
_agency = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.AGENCY); _agency = this.ShipcallControlModel?.GetParticipantForType(Extensions.ParticipantType.AGENCY);
name = _agency?.Name; name = _agency?.Name;
if (name != null) agentName = name; if (name != null) agentName = name;
this.labelAgent.Content = name ?? "- / -"; this.labelAgent.Content = name ?? "- / -";
@ -86,7 +86,7 @@ namespace BreCalClient
this.textBlockDraft.Text = ""; this.textBlockDraft.Text = "";
} }
_mooring = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.MOORING); _mooring = this.ShipcallControlModel?.GetParticipantForType(Extensions.ParticipantType.MOORING);
name = _mooring?.Name; name = _mooring?.Name;
this.labelMooring.Content = name ?? "- / -"; this.labelMooring.Content = name ?? "- / -";
if(_mooring == null) if(_mooring == null)
@ -95,7 +95,7 @@ namespace BreCalClient
this.textBlockMooringRemarks.Text = ""; this.textBlockMooringRemarks.Text = "";
} }
_pilot = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.PILOT); _pilot = this.ShipcallControlModel?.GetParticipantForType(Extensions.ParticipantType.PILOT);
name = _pilot?.Name; name = _pilot?.Name;
this.labelPilot.Content = name ?? "- / - "; this.labelPilot.Content = name ?? "- / - ";
if(_pilot == null) if(_pilot == null)
@ -104,7 +104,7 @@ namespace BreCalClient
this.textBlockPilotRemarks.Text = ""; this.textBlockPilotRemarks.Text = "";
} }
_tug = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.TUG); _tug = this.ShipcallControlModel?.GetParticipantForType(Extensions.ParticipantType.TUG);
name = _tug?.Name; name = _tug?.Name;
this.labelTug.Content = name ?? "- / - "; this.labelTug.Content = name ?? "- / - ";
if(_tug == null) if(_tug == null)
@ -113,7 +113,7 @@ namespace BreCalClient
this.textBlockTugRemarks.Text = ""; this.textBlockTugRemarks.Text = "";
} }
_port_administration = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.PORT_ADMINISTRATION); _port_administration = this.ShipcallControlModel?.GetParticipantForType(Extensions.ParticipantType.PORT_ADMINISTRATION);
name = _port_administration?.Name; name = _port_administration?.Name;
this.labelPortAuthority.Content = name ?? "- / - "; this.labelPortAuthority.Content = name ?? "- / - ";
if(_port_administration == null) if(_port_administration == null)
@ -122,7 +122,7 @@ namespace BreCalClient
this.textBlockPortAuthorityRemarks.Text = ""; this.textBlockPortAuthorityRemarks.Text = "";
} }
_terminal = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.TERMINAL); _terminal = this.ShipcallControlModel?.GetParticipantForType(Extensions.ParticipantType.TERMINAL);
name = _terminal?.Name; name = _terminal?.Name;
this.labelTerminal.Content = name ?? "- / - "; this.labelTerminal.Content = name ?? "- / - ";
if(_terminal == null) if(_terminal == null)