diff --git a/src/WHMapper.Tests/Models/Graph/GraphModelsTest.cs b/src/WHMapper.Tests/Models/Graph/GraphModelsTest.cs index 83ba2541..e1df2e1e 100644 --- a/src/WHMapper.Tests/Models/Graph/GraphModelsTest.cs +++ b/src/WHMapper.Tests/Models/Graph/GraphModelsTest.cs @@ -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() { 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() { new WormholeType(SOLAR_SYSTEM_WH_STATICS,EveSystemType.C3) }) ; var link = new EveSystemLinkModel(new WHSystemLink(1, 2), node, node2); diff --git a/src/WHMapper.Tests/Services/EveOnlineAPI/PublicEveOnlineAPITest.cs b/src/WHMapper.Tests/Services/EveOnlineAPI/PublicEveOnlineAPITest.cs index acdd9f74..aa81c89e 100644 --- a/src/WHMapper.Tests/Services/EveOnlineAPI/PublicEveOnlineAPITest.cs +++ b/src/WHMapper.Tests/Services/EveOnlineAPI/PublicEveOnlineAPITest.cs @@ -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); @@ -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 }; diff --git a/src/WHMapper.Tests/WHHelper/EveWHMapperEntityTest.cs b/src/WHMapper.Tests/WHHelper/EveWHMapperEntityTest.cs index 11a97ba5..be54bc41 100644 --- a/src/WHMapper.Tests/WHHelper/EveWHMapperEntityTest.cs +++ b/src/WHMapper.Tests/WHHelper/EveWHMapperEntityTest.cs @@ -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() { diff --git a/src/WHMapper.Tests/WHHelper/WHColorHelperTest.cs b/src/WHMapper.Tests/WHHelper/WHColorHelperTest.cs index cd098937..7cd84ab4 100644 --- a/src/WHMapper.Tests/WHHelper/WHColorHelperTest.cs +++ b/src/WHMapper.Tests/WHHelper/WHColorHelperTest.cs @@ -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() @@ -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)); + } } diff --git a/src/WHMapper.Tests/WHHelper/WHSignatureHelperTest.cs b/src/WHMapper.Tests/WHHelper/WHSignatureHelperTest.cs index ab99ff60..115b7278 100644 --- a/src/WHMapper.Tests/WHHelper/WHSignatureHelperTest.cs +++ b/src/WHMapper.Tests/WHHelper/WHSignatureHelperTest.cs @@ -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; @@ -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(() => _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 + { + 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 + { + 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); + } + } diff --git a/src/WHMapper/App.razor b/src/WHMapper/App.razor index 032f5016..3dc1943c 100644 --- a/src/WHMapper/App.razor +++ b/src/WHMapper/App.razor @@ -30,7 +30,6 @@ { TokenProvider.AccessToken = InitialState?.AccessToken; TokenProvider.RefreshToken = InitialState?.RefreshToken; - TokenProvider.XsrfToken = InitialState?.XsrfToken; return base.OnInitializedAsync(); } diff --git a/src/WHMapper/Models/Custom/Node/EveSystemNodeModel.cs b/src/WHMapper/Models/Custom/Node/EveSystemNodeModel.cs index 4a14c4e4..1e6f0c1e 100644 --- a/src/WHMapper/Models/Custom/Node/EveSystemNodeModel.cs +++ b/src/WHMapper/Models/Custom/Node/EveSystemNodeModel.cs @@ -115,13 +115,13 @@ public WHSystemStatus SystemStatus public EveSystemType SystemType { get; private set; } public WHEffect Effect { get; private set; } = WHEffect.None; public IList? EffectDetails { get; private set; } = null!; - public IList? Statics { get; private set; } = null!; + public IList? Statics { get; private set; } = null!; public BlockingCollection ConnectedUsers { get; private set; } = new BlockingCollection(); public bool IsRouteWaypoint{get;set;} = false; - public EveSystemNodeModel(WHSystem wh, WHNote? note, string regionName, string constellationName, EveSystemType systemType, WHEffect whEffect, IList? effectDetails, IList? whStatics) + public EveSystemNodeModel(WHSystem wh, WHNote? note, string regionName, string constellationName, EveSystemType systemType, WHEffect whEffect, IList? effectDetails, IList? whStatics) { this._wh = wh; if(note != null) diff --git a/src/WHMapper/Models/DTO/EveMapper/Enums/WHAnalizedSignatureEnums.cs b/src/WHMapper/Models/DTO/EveMapper/Enums/WHAnalizedSignatureEnums.cs new file mode 100644 index 00000000..2ad2c4f5 --- /dev/null +++ b/src/WHMapper/Models/DTO/EveMapper/Enums/WHAnalizedSignatureEnums.cs @@ -0,0 +1,10 @@ +namespace WHMapper.Models.DTO.EveMapper.Enums +{ + + public enum WHAnalizedSignatureEnums + { + toAdd, + toUpdate, + toDelete + } +} \ No newline at end of file diff --git a/src/WHMapper/Models/DTO/EveMapper/EveEntity/WHEntity.cs b/src/WHMapper/Models/DTO/EveMapper/EveEntity/WHEntity.cs index 60043f1a..4ace4681 100644 --- a/src/WHMapper/Models/DTO/EveMapper/EveEntity/WHEntity.cs +++ b/src/WHMapper/Models/DTO/EveMapper/EveEntity/WHEntity.cs @@ -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;} + + /// + /// Time in minutes + /// 24h = 1440 + /// 18h = 1080 + /// + 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; } + } diff --git a/src/WHMapper/Models/DTO/EveMapper/WHAnalizedSignature.cs b/src/WHMapper/Models/DTO/EveMapper/WHAnalizedSignature.cs new file mode 100644 index 00000000..6a58af17 --- /dev/null +++ b/src/WHMapper/Models/DTO/EveMapper/WHAnalizedSignature.cs @@ -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; + } + } +} + diff --git a/src/WHMapper/Models/DTO/EveMapper/WHStatic.cs b/src/WHMapper/Models/DTO/EveMapper/WHStatic.cs deleted file mode 100644 index 91111938..00000000 --- a/src/WHMapper/Models/DTO/EveMapper/WHStatic.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.ComponentModel; -using WHMapper.Models.DTO.EveMapper.Enums; - -namespace WHMapper.Models.DTO.EveMapper -{ - public class WHStatic - { - public string WHName { get; private set; } - public EveSystemType EveSystemDestinationType { get; private set; } - - public WHStatic(string whName, EveSystemType destType) - { - WHName = whName; - EveSystemDestinationType = destType; - } - } -} - - diff --git a/src/WHMapper/Models/DTO/EveMapper/WormholeType.cs b/src/WHMapper/Models/DTO/EveMapper/WormholeType.cs index 3546c7e2..137982b3 100644 --- a/src/WHMapper/Models/DTO/EveMapper/WormholeType.cs +++ b/src/WHMapper/Models/DTO/EveMapper/WormholeType.cs @@ -1,5 +1,6 @@ using System; using WHMapper.Models.DTO.EveMapper.Enums; +using WHMapper.Models.DTO.EveMapper.EveEntity; namespace WHMapper.Models.DTO.EveMapper { @@ -7,15 +8,33 @@ 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;} + + /// + /// Time in minutes + /// 24h = 1440 + /// 18h = 1080 + /// + 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())) diff --git a/src/WHMapper/Models/DTO/InitialApplicationState.cs b/src/WHMapper/Models/DTO/InitialApplicationState.cs index d7814356..aacb7169 100644 --- a/src/WHMapper/Models/DTO/InitialApplicationState.cs +++ b/src/WHMapper/Models/DTO/InitialApplicationState.cs @@ -5,7 +5,6 @@ public class InitialApplicationState { public string? AccessToken { get; set; } public string? RefreshToken { get; set; } - public string? XsrfToken { get; set; } } } diff --git a/src/WHMapper/Models/DTO/TokenProvider.cs b/src/WHMapper/Models/DTO/TokenProvider.cs index e5a27bf8..79da1919 100644 --- a/src/WHMapper/Models/DTO/TokenProvider.cs +++ b/src/WHMapper/Models/DTO/TokenProvider.cs @@ -7,7 +7,6 @@ public class TokenProvider { public string? AccessToken { get; set; } public string? RefreshToken { get; set; } - public string? XsrfToken { get; set; } } } diff --git a/src/WHMapper/Pages/Mapper/Add.cs b/src/WHMapper/Pages/Mapper/Add.cs index 36c4b718..83e88b10 100644 --- a/src/WHMapper/Pages/Mapper/Add.cs +++ b/src/WHMapper/Pages/Mapper/Add.cs @@ -163,7 +163,6 @@ private async Task Submit() } } - private void Cancel() { MudDialog.Cancel(); diff --git a/src/WHMapper/Pages/Mapper/Add.razor b/src/WHMapper/Pages/Mapper/Add.razor index 32af71f8..2958159c 100644 --- a/src/WHMapper/Pages/Mapper/Add.razor +++ b/src/WHMapper/Pages/Mapper/Add.razor @@ -3,7 +3,7 @@ - @if (AccessId > 0) { - @MSG_ACCESS_DELETE + @MSG_ACCESS_DELETE } @if (AdminId > 0) { - @MSG_ADMIN_DELETE + @MSG_ADMIN_DELETE } diff --git a/src/WHMapper/Pages/Mapper/Administration/Overview.cs b/src/WHMapper/Pages/Mapper/Administration/Overview.cs index 3a00ef52..602c02a8 100644 --- a/src/WHMapper/Pages/Mapper/Administration/Overview.cs +++ b/src/WHMapper/Pages/Mapper/Administration/Overview.cs @@ -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 WHMapper Access", parameters, options); - DialogResult result = await dialog.Result; + DialogResult? result = await dialog.Result; if (result!=null && !result.Canceled) await Restore(); @@ -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 WHMapper Admin", parameters, options); - DialogResult result = await dialog.Result; + DialogResult? result = await dialog.Result; if (result != null && !result.Canceled) await Restore(); diff --git a/src/WHMapper/Pages/Mapper/Administration/Overview.razor b/src/WHMapper/Pages/Mapper/Administration/Overview.razor index 9c7245d5..844cc01a 100644 --- a/src/WHMapper/Pages/Mapper/Administration/Overview.razor +++ b/src/WHMapper/Pages/Mapper/Administration/Overview.razor @@ -36,38 +36,39 @@ - - - - - @if (item.EntityType == EveEntityEnums.Alliance) - { - - } - else if (item.EntityType == EveEntityEnums.Corporation) - { - - } - else - { - - } - @item.Name - - - - + +
+ + + + @if (item.EntityType == EveEntityEnums.Alliance) + { + + } + else if (item.EntityType == EveEntityEnums.Corporation) + { + + } + else + { + + } + @item.Name + + + + +
- @@ -98,23 +99,25 @@ - - - - - - @item?.Name - - - - + +
+ + + + + @item?.Name + + + + +
diff --git a/src/WHMapper/Pages/Mapper/CustomNode/EveSystemNode.razor b/src/WHMapper/Pages/Mapper/CustomNode/EveSystemNode.razor index d60c63b1..2f24bbdf 100644 --- a/src/WHMapper/Pages/Mapper/CustomNode/EveSystemNode.razor +++ b/src/WHMapper/Pages/Mapper/CustomNode/EveSystemNode.razor @@ -69,7 +69,7 @@ { @foreach (var item in Node.Statics) { - @item.EveSystemDestinationType.ToString() + @item.Destination.ToString() } } diff --git a/src/WHMapper/Pages/Mapper/LinkInfos/Overview.razor b/src/WHMapper/Pages/Mapper/LinkInfos/Overview.razor index a4319bb6..c7070cc3 100644 --- a/src/WHMapper/Pages/Mapper/LinkInfos/Overview.razor +++ b/src/WHMapper/Pages/Mapper/LinkInfos/Overview.razor @@ -1,50 +1,51 @@ @using WHMapper.Models.Db.Enums @using WHMapper.Services.WHColor -