diff --git a/Components/Components.csproj b/Components/Components.csproj index 1d20ee0..b068a9d 100644 --- a/Components/Components.csproj +++ b/Components/Components.csproj @@ -6,6 +6,14 @@ enable + + TRACE;NO_SQL + + + + TRACE;NO_SQL + + diff --git a/Components/Navigation/DesktopNavComponent.razor b/Components/Navigation/DesktopNavComponent.razor index 8de2df5..2d89e74 100644 --- a/Components/Navigation/DesktopNavComponent.razor +++ b/Components/Navigation/DesktopNavComponent.razor @@ -6,6 +6,8 @@ @using Microsoft.EntityFrameworkCore @implements IDisposable + +
- -
} @@ -84,11 +81,22 @@ else { @code { +#if NO_SQL + [Parameter] + public List Patches { get; set; } + + [Parameter] + public List Changes { get; set; } +#else + [Inject] + DatabaseContext Database { get; set; } + [Parameter] public DbSet Patches { get; set; } [Parameter] public DbSet Changes { get; set; } +#endif private bool isViewImportant = true; @@ -113,7 +121,11 @@ else { } protected override async Task OnInitializedAsync() { +#if NO_SQL + GitService.Load(); +#else GitService.Load(Database); +#endif } } \ No newline at end of file diff --git a/IGP/Pages/ChangeLogPage.razor.css b/IGP/Pages/ChangeLogPage.razor.css new file mode 100644 index 0000000..7ba378a --- /dev/null +++ b/IGP/Pages/ChangeLogPage.razor.css @@ -0,0 +1,13 @@ +.patchContainer { + padding: 16px; +} + +@media only screen and (max-width: 1025px) { + .patchContainer { + border: none; + padding-left: 8px; + padding-right: 8px; + padding-top: 16px; + padding-bottom: 16px; + } +} diff --git a/IGP/Program.cs b/IGP/Program.cs index b84af3a..da79622 100644 --- a/IGP/Program.cs +++ b/IGP/Program.cs @@ -1,7 +1,14 @@ -using Contexts; + using IGP; using Microsoft.AspNetCore.Components.Web; + +#if NO_SQL + +#else +using Contexts; using Microsoft.EntityFrameworkCore; +#endif + using Services; using Services.Immortal; using Services.Website; @@ -31,7 +38,11 @@ builder.Services.AddSingleton(new HttpClient { }); -builder.Services.AddDbContext(options => { options.UseSqlite("Data Source=./Database.db"); }); +#if NO_SQL + +#else +//builder.Services.AddDbContext(options => { options.UseSqlite("Data Source=./Database.db"); }); +#endif builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/IGP/_Imports.razor b/IGP/_Imports.razor index cb61a10..8ead7b6 100644 --- a/IGP/_Imports.razor +++ b/IGP/_Imports.razor @@ -1,4 +1,6 @@ -@using Components.Display + + +@using Components.Display @using Components.Feedback @using Components.Form @using Components.Info @@ -7,7 +9,6 @@ @using Components.Navigation @using Components.Shared @using Components.Utils -@using Contexts @using IGP.Pages @using IGP.Pages.Agile.Parts @using IGP.Pages.BuildCalculator.Parts diff --git a/Services/Work/AgileService.cs b/Services/Development/AgileService.cs similarity index 67% rename from Services/Work/AgileService.cs rename to Services/Development/AgileService.cs index d29a551..ca62d13 100644 --- a/Services/Work/AgileService.cs +++ b/Services/Development/AgileService.cs @@ -1,4 +1,6 @@ -using System.Net.Http.Json; + + +using System.Net.Http.Json; using Contexts; using Microsoft.EntityFrameworkCore; using Model.Work.Tasks; @@ -14,9 +16,17 @@ public class AgileService : IAgileService { this.httpClient = httpClient; } + +#if NO_SQL + public List SprintModels { get; set; } + public List TaskModels { get; set; } +#else + private DatabaseContext Database { get; set; } public DbSet SprintModels => Database.SprintModels; public DbSet TaskModels => Database.TaskModels; +#endif + public void Subscribe(Action action) { _onChange += action; @@ -30,10 +40,26 @@ public class AgileService : IAgileService { return isLoaded; } +#if NO_SQL + public async Task Load() { + if (isLoaded) { + return; + } + + SprintModels = (await httpClient.GetFromJsonAsync("generated/SprintModels.json")).ToList(); + TaskModels =(await httpClient.GetFromJsonAsync("generated/TaskModels.json")).ToList(); + + isLoaded = true; + + NotifyDataChanged(); + } +#else public async Task Load(DatabaseContext database) { Database = database; - if (isLoaded) return; + if (isLoaded) { + return; + } Database.SprintModels.AddRange(await httpClient.GetFromJsonAsync("generated/SprintModels.json")); Database.TaskModels.AddRange(await httpClient.GetFromJsonAsync("generated/TaskModels.json")); @@ -44,6 +70,7 @@ public class AgileService : IAgileService { NotifyDataChanged(); } +#endif public void Update() { NotifyDataChanged(); diff --git a/Services/Work/GitService.cs b/Services/Development/GitService.cs similarity index 65% rename from Services/Work/GitService.cs rename to Services/Development/GitService.cs index 48bd6db..8fccf17 100644 --- a/Services/Work/GitService.cs +++ b/Services/Development/GitService.cs @@ -1,7 +1,14 @@ -using System.Net.Http.Json; + + +using System.Net.Http.Json; +using Model.Work.Git; + +#if NO_SQL + +#else using Contexts; using Microsoft.EntityFrameworkCore; -using Model.Work.Git; +#endif namespace Services.Work; @@ -14,9 +21,16 @@ public class GitService : IGitService { this.httpClient = httpClient; } - public DatabaseContext Database { get; set; } +#if NO_SQL + public List ChangeModels { get; set; } + public List PatchModels { get; set; } +#else public DbSet ChangeModels => Database.ChangeModels; public DbSet PatchModels => Database.PatchModels; + public DatabaseContext Database { get; set; } +#endif + + public void Subscribe(Action action) { _onChange += action; @@ -30,20 +44,46 @@ public class GitService : IGitService { return isLoaded; } + +#if NO_SQL + + public async Task Load() { + + if (isLoaded) { + return; + } + + ChangeModels = (await httpClient.GetFromJsonAsync("generated/ChangeModels.json")).ToList(); + PatchModels = (await httpClient.GetFromJsonAsync("generated/PatchModels.json")).ToList(); + + + isLoaded = true; + + NotifyDataChanged(); + } + +#else + public async Task Load(DatabaseContext database) { Database = database; - if (isLoaded) return; - + if (isLoaded) { + return; + } + Database.ChangeModels.AddRange(await httpClient.GetFromJsonAsync("generated/ChangeModels.json")); Database.PatchModels.AddRange(await httpClient.GetFromJsonAsync("generated/PatchModels.json")); Database.SaveChanges(); + isLoaded = true; NotifyDataChanged(); } +#endif + + public void Update() { NotifyDataChanged(); } diff --git a/Services/IServices.cs b/Services/IServices.cs index 1534ecf..f212f58 100644 --- a/Services/IServices.cs +++ b/Services/IServices.cs @@ -1,4 +1,6 @@ -using Contexts; + + +using Contexts; using Microsoft.EntityFrameworkCore; using Model.Immortal.BuildOrders; using Model.Immortal.Economy; @@ -12,34 +14,72 @@ using Services.Immortal; namespace Services; -public interface IAgileService { - public DbSet SprintModels { get; } - public DbSet TaskModels { get; } +public interface IWebsiteService { +#if NO_SQL + public List WebPageModels { get; set; } + public List WebSectionModels { get; set; } +#else + public DbSet WebPageModels { get; } + public DbSet WebSectionModels { get; } +#endif + public void Subscribe(Action action); public void Unsubscribe(Action action); public void Update(); + + +#if NO_SQL + public Task Load(); +#else + public Task Load(DatabaseContext database); +#endif + + public bool IsLoaded(); } -public interface IWebsiteService { - public DbSet WebPageModels { get; } - public DbSet WebSectionModels { get; } +public interface IAgileService { + +#if NO_SQL + public List SprintModels { get; set; } + public List TaskModels { get; set; } +#else + public DbSet SprintModels { get; } + public DbSet TaskModels { get; } +#endif + public void Subscribe(Action action); public void Unsubscribe(Action action); public void Update(); + +#if NO_SQL + public Task Load(); +#else public Task Load(DatabaseContext database); +#endif public bool IsLoaded(); } public interface IGitService { + +#if NO_SQL + public List ChangeModels { get; set; } + public List PatchModels { get; set; } +#else public DbSet ChangeModels { get; } public DbSet PatchModels { get; } +#endif + public void Subscribe(Action action); public void Unsubscribe(Action action); public void Update(); +#if NO_SQL + public Task Load(); +#else public Task Load(DatabaseContext database); +#endif public bool IsLoaded(); } diff --git a/Services/Services.csproj b/Services/Services.csproj index cb7cd01..23969a9 100644 --- a/Services/Services.csproj +++ b/Services/Services.csproj @@ -6,13 +6,21 @@ enable + + TRACE;NO_SQL + + + + TRACE;NO_SQL; + + - + - - + + diff --git a/Services/Website/WebsiteService.cs b/Services/Website/WebsiteService.cs index 65d177b..50d182a 100644 --- a/Services/Website/WebsiteService.cs +++ b/Services/Website/WebsiteService.cs @@ -14,9 +14,20 @@ public class WebsiteService : IWebsiteService { this.httpClient = httpClient; } + + +#if NO_SQL + public List WebSectionModels { get; set; } + public List WebPageModels { get; set; } +#else + private DatabaseContext Database { get; set; } + + public DbSet WebSectionModels => Database.WebSectionModels; public DbSet WebPageModels => Database.WebPageModels; +#endif + public void Subscribe(Action action) { _onChange += action; @@ -29,11 +40,24 @@ public class WebsiteService : IWebsiteService { public bool IsLoaded() { return isLoaded; } + +#if NO_SQL + + public async Task Load() { + if (isLoaded) {return;} + + WebPageModels = (await httpClient.GetFromJsonAsync("generated/WebPageModels.json")).ToList(); + WebSectionModels =(await httpClient.GetFromJsonAsync("generated/WebSectionModels.json")).ToList(); + isLoaded = true; + + NotifyDataChanged(); + } +#else public async Task Load(DatabaseContext database) { Database = database; - if (isLoaded) return; + if (isLoaded) {return;} Database.WebPageModels.AddRange(await httpClient.GetFromJsonAsync("generated/WebPageModels.json")); Database.WebSectionModels.AddRange( @@ -44,7 +68,9 @@ public class WebsiteService : IWebsiteService { isLoaded = true; NotifyDataChanged(); - } + } +#endif + public void Update() { NotifyDataChanged();