Skip to content

Commit

Permalink
Merge pull request #12 from rdymade/main
Browse files Browse the repository at this point in the history
Merge main into lupus
  • Loading branch information
rdymade authored Aug 27, 2024
2 parents c54729c + be539ad commit 089c22a
Show file tree
Hide file tree
Showing 45 changed files with 751 additions and 398 deletions.
2 changes: 1 addition & 1 deletion src/WHMapper.Tests/Models/Graph/GraphModelsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void Eve_System_Link_Model()
{
var node = new EveSystemNodeModel(new WHSystem(DEFAULT_MAP_ID,SOLAR_SYSTEM_JITA_ID, SOLAR_SYSTEM_JITA_NAME, SOLAR_SYSTEM_JITA_SECURITY), null, REGION_JITA_NAME, CONSTELLATION_JITA_NAME);
Assert.Equal(WHSystemStatus.Unknown,node.SystemStatus);
var node2 = new EveSystemNodeModel(new WHSystem(DEFAULT_MAP_ID, SOLAR_SYSTEM_WH_ID, SOLAR_SYSTEM_WH_NAME, -1.0F), null, REGION_WH_NAME, CONSTELLATION_WH_NAME,SOLAR_SYSTEM_WH_CLASS, SOLAR_SYSTEM_WH_EFFECT,null, new List<WHStatic>() { new WHStatic(SOLAR_SYSTEM_WH_STATICS,EveSystemType.C3) }) ;
var node2 = new EveSystemNodeModel(new WHSystem(DEFAULT_MAP_ID, SOLAR_SYSTEM_WH_ID, SOLAR_SYSTEM_WH_NAME, -1.0F), null, REGION_WH_NAME, CONSTELLATION_WH_NAME,SOLAR_SYSTEM_WH_CLASS, SOLAR_SYSTEM_WH_EFFECT,null, new List<WormholeType>() { new WormholeType(SOLAR_SYSTEM_WH_STATICS,EveSystemType.C3) }) ;


var link = new EveSystemLinkModel(new WHSystemLink(1, 2), node, node2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ public async Task Get_Route()
var route = await _routeServices.GetRoute(SOLAR_SYSTEM_JITA_ID, SOLAR_SYSTEM_AMARR_ID);
Assert.NotNull(route);
Assert.NotEmpty(route);
Assert.Equal(24, route.Length);
Assert.Equal(12, route.Length);
Assert.Equal(SOLAR_SYSTEM_JITA_ID, route[0]);
Assert.Equal(SOLAR_SYSTEM_AMARR_ID, route[23]);
Assert.Equal(SOLAR_SYSTEM_AMARR_ID, route[11]);

//WH route to Jita without connections
route = await _routeServices.GetRoute(SOLAR_SYSTEM_WH_ID, SOLAR_SYSTEM_JITA_ID);
Expand All @@ -292,10 +292,10 @@ public async Task Get_Route()
route = await _routeServices.GetRoute(SOLAR_SYSTEM_WH_ID, SOLAR_SYSTEM_JITA_ID, connections);
Assert.NotNull(route);
Assert.NotEmpty(route);
Assert.Equal(25, route.Length);
Assert.Equal(13, route.Length);
Assert.Equal(SOLAR_SYSTEM_WH_ID, route[0]);
Assert.Equal(SOLAR_SYSTEM_AMARR_ID, route[1]);
Assert.Equal(SOLAR_SYSTEM_JITA_ID, route[24]);
Assert.Equal(SOLAR_SYSTEM_JITA_ID, route[12]);

//wh route from jita to amarr with avoid Ahbazon
var avoid = new int[] { SOLAR_SYSTEM_AHBAZON_ID };
Expand Down
4 changes: 2 additions & 2 deletions src/WHMapper.Tests/WHHelper/EveWHMapperEntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class EveWHMapperEntityTest
private const int WH_TYPE_ID1 = 30583;
private const int WH_TYPE_ID2 = 30584;

private readonly IEveMapperService _eveMapperService;
private readonly IEveMapperCacheService _eveMapperCacheService;
private readonly IEveMapperService _eveMapperService = null!;
private readonly IEveMapperCacheService _eveMapperCacheService = null!;

public EveWHMapperEntityTest()
{
Expand Down
14 changes: 14 additions & 0 deletions src/WHMapper.Tests/WHHelper/WHColorHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public class WHColorHelperTest
private const string NODE_STATUS_HOSTILE_COLOR = "#be0000";
private const string NODE_STATUS_UNKNOWN_COLOR = IWHColorHelper.DEFAULT_COLOR;


private const string WH_SIGNATURE_ADD_COLOR = "#5cb85c";
private const string WH_SIGNATURE_UPDATE_COLOR = IWHColorHelper.DEFAULT_COLOR;
private const string WH_SIGNATURE_DELETE_COLOR = "#a52521";

private IWHColorHelper _whHelper;

public WHColorHelperTest()
Expand Down Expand Up @@ -174,6 +179,15 @@ public void Get_Node_Status_Color()
Assert.Equal(NODE_STATUS_UNKNOWN_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatus.Unknown));
Assert.Equal(IWHColorHelper.DEFAULT_COLOR, _whHelper.GetNodeStatusColor((WHSystemStatus)28));
}

[Fact]
public void Get_Analyzed_Signature_Color()
{
Assert.Equal(WH_SIGNATURE_ADD_COLOR, _whHelper.GetWHAnalyzedSignatureColor(WHAnalizedSignatureEnums.toAdd));
Assert.Equal(WH_SIGNATURE_DELETE_COLOR, _whHelper.GetWHAnalyzedSignatureColor(WHAnalizedSignatureEnums.toDelete));
Assert.Equal(WH_SIGNATURE_UPDATE_COLOR, _whHelper.GetWHAnalyzedSignatureColor(WHAnalizedSignatureEnums.toUpdate));
Assert.Equal(IWHColorHelper.DEFAULT_COLOR, _whHelper.GetWHAnalyzedSignatureColor((WHAnalizedSignatureEnums)28));
}
}


Expand Down
57 changes: 57 additions & 0 deletions src/WHMapper.Tests/WHHelper/WHSignatureHelperTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.ObjectModel;
using WHMapper.Models.Db;
using WHMapper.Models.Db.Enums;
using WHMapper.Models.DTO.EveMapper.Enums;
using WHMapper.Services.WHColor;
using WHMapper.Services.WHSignature;
using WHMapper.Services.WHSignatures;
Expand Down Expand Up @@ -66,6 +68,61 @@ public async Task Parse_Scan_Result_Test()
Assert.Equal(UNSTABLE_WORMHOLE, lastSig.Type);
}

[Fact]
public async Task Import_Scan_Result_Test()
{
var ex = await Assert.ThrowsAsync<Exception>(() => _whHelper.ImportScanResult(SCAN_USER, WH_ID, string.Empty, false));
Assert.Equal("Bad signatures format", ex.Message);

/*
bool valideScan = await _whHelper.ImportScanResult(SCAN_USER, WH_ID, DSCAN, false);
Assert.True(valideScan);
bool invalidateScan = await _whHelper.ImportScanResult(SCAN_USER, WH_ID, SCAN_USER, false);
Assert.False(invalidateScan);
bool valideScan2 = await _whHelper.ImportScanResult(SCAN_USER, WH_ID, DSCAN, true);
Assert.True(valideScan2);*/
}

[Fact]
public async Task Analyzed_Signature_Test()
{
var currentSystemSigs = new Collection<WHMapper.Models.Db.WHSignature>
{
new WHSignature(0, FIRST_SIG_NAME,WHSignatureGroup.Unknow,string.Empty,SCAN_USER),
new WHSignature(0, LAST_SIG_NAME,WHSignatureGroup.Wormhole,UNSTABLE_WORMHOLE,SCAN_USER)
};

var parsedSigs = new Collection<WHMapper.Models.Db.WHSignature>
{
new WHSignature(0, FIRST_SIG_NAME, WHSignatureGroup.Unknow,string.Empty,SCAN_USER),
new WHMapper.Models.Db.WHSignature(0, LAST_SIG_NAME, WHSignatureGroup.Wormhole,UNSTABLE_WORMHOLE,SCAN_USER)
};

var analyzedSigs = await _whHelper.AnalyzedSignatures(parsedSigs, currentSystemSigs, false);
Assert.NotNull(analyzedSigs);
Assert.NotEmpty(analyzedSigs);
Assert.Equal(2, analyzedSigs.Count());

var firstSig = analyzedSigs.First();
Assert.Equal(FIRST_SIG_NAME, firstSig.Name);
Assert.Equal(WHAnalizedSignatureEnums.toUpdate, firstSig.Status);
Assert.Equal(WHSignatureGroup.Unknow.ToString(), firstSig.Group);
Assert.Equal(string.Empty, firstSig.Type);

parsedSigs.RemoveAt(0);
parsedSigs.Add(new WHSignature(0, "NEW_SIG", WHSignatureGroup.Unknow, string.Empty, SCAN_USER));

analyzedSigs = await _whHelper.AnalyzedSignatures(parsedSigs, currentSystemSigs, true);
Assert.NotNull(analyzedSigs);
Assert.NotEmpty(analyzedSigs);
Assert.Equal(3, analyzedSigs.Count());
Assert.Equal(WHAnalizedSignatureEnums.toAdd, analyzedSigs.First().Status);
Assert.Equal(WHAnalizedSignatureEnums.toUpdate, analyzedSigs.ElementAt(1).Status);
Assert.Equal(WHAnalizedSignatureEnums.toDelete, analyzedSigs.Last().Status);
}

}


1 change: 0 additions & 1 deletion src/WHMapper/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
{
TokenProvider.AccessToken = InitialState?.AccessToken;
TokenProvider.RefreshToken = InitialState?.RefreshToken;
TokenProvider.XsrfToken = InitialState?.XsrfToken;

return base.OnInitializedAsync();
}
Expand Down
4 changes: 2 additions & 2 deletions src/WHMapper/Models/Custom/Node/EveSystemNodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public WHSystemStatus SystemStatus
public EveSystemType SystemType { get; private set; }
public WHEffect Effect { get; private set; } = WHEffect.None;
public IList<EveSystemEffect>? EffectDetails { get; private set; } = null!;
public IList<WHStatic>? Statics { get; private set; } = null!;
public IList<WormholeType>? Statics { get; private set; } = null!;
public BlockingCollection<string> ConnectedUsers { get; private set; } = new BlockingCollection<string>();

public bool IsRouteWaypoint{get;set;} = false;


public EveSystemNodeModel(WHSystem wh, WHNote? note, string regionName, string constellationName, EveSystemType systemType, WHEffect whEffect, IList<EveSystemEffect>? effectDetails, IList<WHStatic>? whStatics)
public EveSystemNodeModel(WHSystem wh, WHNote? note, string regionName, string constellationName, EveSystemType systemType, WHEffect whEffect, IList<EveSystemEffect>? effectDetails, IList<WormholeType>? whStatics)
{
this._wh = wh;
if(note != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace WHMapper.Models.DTO.EveMapper.Enums
{

public enum WHAnalizedSignatureEnums
{
toAdd,
toUpdate,
toDelete
}
}
30 changes: 27 additions & 3 deletions src/WHMapper/Models/DTO/EveMapper/EveEntity/WHEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,47 @@ namespace WHMapper.Models.DTO.EveMapper.EveEntity;

public class WHEntity : AEveEntity
{ private const int DOGMA_ATTR_TARGET_SYSTEM_CLASS_FOR_WORMHOLES_ID = 1381;
//private const int DOGMA_ATTR_DISTRIBUTION_ID_OF_TARGET_WORMHOLE_DISTRIBUTION_ID = 1457;

private const int DOGMA_ATTR_WORMHOLE_MAX_STABLE_MASS = 1383;
private const int DOGMA_ATTR_WORMHOLE_MAX_JUMP_MASS = 1385;
private const int DOGMA_ATTR_WORMHOLE_MAX_STABLE_TIME = 1382; //unit8id 3 value 1440 = 24h???


public float SystemTypeValue { get; private set; }
public float MassMax {get; private set;}
public float JumpMassMax {get; private set;}

/// <summary>
/// Time in minutes
/// 24h = 1440
/// 18h = 1080
/// </summary>
public float StableTime {get;private set;}

public WHEntity(int id, WHMapper.Models.DTO.EveAPI.Universe.Type type)
: base(id, type.Name[9..].Trim(), EveEntityEnums.Wormhole)
{
SystemTypeValue = 0;
MassMax = 0;
JumpMassMax = 0;
StableTime = 0;
if (type.DogmaAttributes != null)
{
SystemTypeValue = type.DogmaAttributes.Where(x => x.AttributeId == DOGMA_ATTR_TARGET_SYSTEM_CLASS_FOR_WORMHOLES_ID).Select(x => x.Value).FirstOrDefault(0);
MassMax = type.DogmaAttributes.Where(x => x.AttributeId == DOGMA_ATTR_WORMHOLE_MAX_STABLE_MASS).Select(x => x.Value).FirstOrDefault(0);
JumpMassMax = type.DogmaAttributes.Where(x => x.AttributeId == DOGMA_ATTR_WORMHOLE_MAX_JUMP_MASS).Select(x => x.Value).FirstOrDefault(0);
StableTime = type.DogmaAttributes.Where(x => x.AttributeId == DOGMA_ATTR_WORMHOLE_MAX_STABLE_TIME).Select(x => x.Value).FirstOrDefault(0);
}
}

[JsonConstructor]
public WHEntity(int id, string name,float systemTypeValue)
public WHEntity(int id, string name,float systemTypeValue, float massMax, float jumpMassMax, float stableTime)
: base(id, name, EveEntityEnums.Wormhole)
{
SystemTypeValue = systemTypeValue;
MassMax = massMax;
JumpMassMax = jumpMassMax;
StableTime = stableTime;
}


}
23 changes: 23 additions & 0 deletions src/WHMapper/Models/DTO/EveMapper/WHAnalizedSignature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using WHMapper.Models.DTO.EveMapper.Enums;

namespace WHMapper.Models.DTO.EveMapper
{


public class WHAnalizedSignature
{
private readonly WHMapper.Models.Db.WHSignature _signature;
public WHAnalizedSignatureEnums Status { get; private set;}

public string Name { get { return _signature.Name; } }
public string Group { get { return _signature.Group.ToString(); } }
public string? Type { get { return _signature.Type; } }

public WHAnalizedSignature(WHMapper.Models.Db.WHSignature whsig,WHAnalizedSignatureEnums status)
{
_signature= whsig;
Status = status;
}
}
}

20 changes: 0 additions & 20 deletions src/WHMapper/Models/DTO/EveMapper/WHStatic.cs

This file was deleted.

25 changes: 22 additions & 3 deletions src/WHMapper/Models/DTO/EveMapper/WormholeType.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
using System;
using WHMapper.Models.DTO.EveMapper.Enums;
using WHMapper.Models.DTO.EveMapper.EveEntity;

namespace WHMapper.Models.DTO.EveMapper
{
public class WormholeType
{
public string Name { private set; get; }
public EveSystemType Destination { private set; get; }
public EveSystemType[]? Sources { private set; get; }

public WormholeType(string name, EveSystemType dest, EveSystemType[]? srcs)
public float MassMax {get; private set;}
public float JumpMassMax {get; private set;}

/// <summary>
/// Time in minutes
/// 24h = 1440
/// 18h = 1080
/// </summary>
public float StableTime {get;private set;}

public WormholeType(string name, EveSystemType dest)
{
Name = name;
Destination = dest;
Sources = srcs;
}

public WormholeType(WHEntity entity)
{
Name = entity.Name;
Destination = (EveSystemType)entity.SystemTypeValue;
MassMax = entity.MassMax;
JumpMassMax = entity.JumpMassMax;
StableTime = entity.StableTime;
}


public override string ToString()
{
if (string.IsNullOrEmpty(Destination.ToString()))
Expand Down
1 change: 0 additions & 1 deletion src/WHMapper/Models/DTO/InitialApplicationState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ public class InitialApplicationState
{
public string? AccessToken { get; set; }
public string? RefreshToken { get; set; }
public string? XsrfToken { get; set; }
}
}

1 change: 0 additions & 1 deletion src/WHMapper/Models/DTO/TokenProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public class TokenProvider
{
public string? AccessToken { get; set; }
public string? RefreshToken { get; set; }
public string? XsrfToken { get; set; }
}
}

1 change: 0 additions & 1 deletion src/WHMapper/Pages/Mapper/Add.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ private async Task Submit()
}
}


private void Cancel()
{
MudDialog.Cancel();
Expand Down
2 changes: 1 addition & 1 deletion src/WHMapper/Pages/Mapper/Add.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<MudDialog>
<DialogContent>
<MudForm @bind-IsValid="@_success" @ref="@_form">
<MudAutocomplete T="SDESolarSystem" Label="System Name" @bind-Value="_searchResult" SearchFuncWithCancel="@EveMapperSearch.SearchSystem"
<MudAutocomplete T="SDESolarSystem" Label="System Name" @bind-Value="_searchResult" SearchFunc="@EveMapperSearch.SearchSystem"
Margin="Margin.Dense" Dense="true"
Required="true" ResetValueOnEmptyText="true" CoerceValue="true" CoerceText="true"
Validation="@(new Func<string, IEnumerable<string>>(EveMapperSearch.ValidateSearchType))"
Expand Down
4 changes: 2 additions & 2 deletions src/WHMapper/Pages/Mapper/Administration/Delete.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<DialogContent>
@if (AccessId > 0)
{
<MudText>@MSG_ACCESS_DELETE</MudText>
<MudText Class="pointer-events-none">@MSG_ACCESS_DELETE</MudText>
}

@if (AdminId > 0)
{
<MudText>@MSG_ADMIN_DELETE</MudText>
<MudText Class="pointer-events-none">@MSG_ADMIN_DELETE</MudText>
}
</DialogContent>
<DialogActions>
Expand Down
4 changes: 2 additions & 2 deletions src/WHMapper/Pages/Mapper/Administration/Overview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private async Task DeleteAccess(int id)
var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };

var dialog = await DialogService.ShowAsync<Delete>("Delete WHMapper Access", parameters, options);
DialogResult result = await dialog.Result;
DialogResult? result = await dialog.Result;

if (result!=null && !result.Canceled)
await Restore();
Expand All @@ -197,7 +197,7 @@ private async Task DeleteAdmin(int id)
var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };

var dialog = await DialogService.ShowAsync<Delete>("Delete WHMapper Admin", parameters, options);
DialogResult result = await dialog.Result;
DialogResult? result = await dialog.Result;

if (result != null && !result.Canceled)
await Restore();
Expand Down
Loading

0 comments on commit 089c22a

Please sign in to comment.