diff --git a/IGP/Database.db b/IGP/Database.db index 044f344..8e5f517 100644 Binary files a/IGP/Database.db and b/IGP/Database.db differ diff --git a/IGP/Pages/Agile/AgilePage.razor b/IGP/Pages/Agile/AgilePage.razor index ae354c1..22a9e28 100644 --- a/IGP/Pages/Agile/AgilePage.razor +++ b/IGP/Pages/Agile/AgilePage.razor @@ -1,26 +1,24 @@ @implements IDisposable; -@inject IAgileService AgileService; +@inject IAgileService agileService; @layout PageLayout @page "/agile" -@if (!AgileService.IsLoaded()) +@if (!agileService.IsLoaded()) { } else - - { - Agile -
- @foreach (var sprint in AgileService.AgileSprintModels!.OrderBy(e => e.EndDate).Reverse()) + @foreach (var sprint in agileService.AgileSprintModels! + .OrderBy(e => e.EndDate).Reverse()) { -
+
@sprint.Name
@@ -78,37 +76,23 @@ else @code { - -#if NO_SQL - -#else - [Inject] - DatabaseContext Database { get; set; } - - [Parameter] - public DbSet Tasks { get; set; } - - [Parameter] - public DbSet Sprints { get; set; } -#endif - private readonly List backlog = new(); protected override void OnInitialized() { - AgileService.Subscribe(HasChanged); + agileService.Subscribe(HasChanged); } void IDisposable.Dispose() { - AgileService.Unsubscribe(HasChanged); + agileService.Unsubscribe(HasChanged); } void HasChanged() { backlog.Clear(); - foreach (var task in AgileService.AgileTaskModels!) + foreach (var task in agileService.AgileTaskModels!) { if (task.AgileSprintModelId == null) { @@ -121,11 +105,7 @@ else protected override async Task OnInitializedAsync() { -#if NO_SQL - await AgileService.Load(); -#else - await AgileService.Load(Database); -#endif + await agileService.Load(); } } \ No newline at end of file diff --git a/IGP/wwwroot/generated/DocContentModels.json b/IGP/wwwroot/generated/DocContentModels.json index d860ca6..41e945c 100644 --- a/IGP/wwwroot/generated/DocContentModels.json +++ b/IGP/wwwroot/generated/DocContentModels.json @@ -1 +1 @@ -[{"Id":1,"ParentId":1,"DocSectionModelId":1,"Href":"setup","DocumentationModels":[],"Parent":null,"PageOrder":0,"CreatedDate":"2022-03-30T00:00:00","UpdatedDate":"2022-04-07T00:00:00","Name":"Development Setup","Description":"Get set up on developing this web project.","Content":"# Overview\n\nThis document will contain general setup notes for the project.\n\n## Prerequisite\n\nTo understand content in this document, it is recommended to have some software development experience. Particularly using GitHub and Visual Studio.\n\n- [GitHub Documentation](https://docs.github.com/en/get-started)\n\n- [Visual Studio Documentation](https://visualstudio.microsoft.com/vs/getting-started/)\n\nTo make updates to this website, it is recommended to understand HTML/CSS and C#.\n\n- [C# Documentation](https://docs.microsoft.com/en-us/dotnet/csharp/)\n- [Mozilla\u0027s HTML Documentation](https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started)\n- [W3SCHOOLS\u0027 HTML Documentation](https://www.w3schools.com/html/)\n\nFurther, you should understand the product and clients this website is for. So it is recommended to play \u0022Immortal: Gates of Pyre\u0022.\n\n- [IGP Website](https://gatesofpyre.com/)\n - **Please Note:** This product currently has restricted access with it is in a pre-alpha state. If you are not aware or interested in IGP, I recommend to wait for product release. Otherwise, check out their discord for steps of getting access.\n\n## Installation\n\nDownload and install Visual Studio preview.\n\n**Note:** Visual Studio Preview currently doesn\u0027t work on Mac for this project. Use a PC, or Rider.\n\n[https://visualstudio.microsoft.com/vs/preview/](https://visualstudio.microsoft.com/vs/preview/)\n\nWhen installing, ensure you have selected \u0022Workloads | **ASP.NET and web development**\u0022 and \u0022Individual components | **.NET WebAssembly build tools**\u0022.\n\n## Download Project\n\nGet this project from GitHub.\n\n\u0060\u0060\u0060bash\ngit clone https://github.com/JonathanMcCaffrey/IGP-Fan-Reference.git\n\u0060\u0060\u0060\n\n## Project Tree\n\n\u0060\u0060\u0060\nC:.\n\u251C\u2500\u2500\u2500.github\n\u2502 \u2514\u2500\u2500\u2500workflows # Workflows to deploy website\n\u251C\u2500\u2500\u2500Components # Components used be website\n\u251C\u2500\u2500\u2500Contexts\n\u251C\u2500\u2500\u2500IGP\n\u2502 \u251C\u2500\u2500\u2500Pages # Website pages\n\u2502 \u2514\u2500\u2500\u2500wwwroot\n\u2502 \u251C\u2500\u2500\u2500css\n\u2502 \u251C\u2500\u2500\u2500generated # Files generated by IGP_Convert. Do not edit\n\u2502 \u251C\u2500\u2500\u2500image\n\u2502 \u2514\u2500\u2500\u2500javascript\n\u251C\u2500\u2500\u2500IGP_Convert # Converts SQL into JSON for Blazor Wasm\n\u251C\u2500\u2500\u2500Model # Data models\n\u2514\u2500\u2500\u2500Services # Web services\n\u0060\u0060\u0060\n\n## Running\n\n- Open \u0060IGP/IGP.sln\u0060.\n- Click the green RUN button in Visual Studio.\n- A local copy of the IGP Website should have launched on your machine.\n\n## Publishing\n\nCode committed to the \u0060main\u0060 branch will automatically be deployed to [production](https://www.igpfanreference.com/).\n\nCode committed to the \u0060develop\u0060 branch will automatically be deployed to [development](https://calm-mud-04916b210.1.azurestaticapps.net/).\n\n_This is handle via the files in \u0060.github/workflow\u0060. Look into these [GitHub Actions Documents](https://docs.github.com/en/actions) if curious about how this CI system works._\n\n## Troubleshooting\n\n\nNothing that some good internet searches cannot resolved. But you can also contact the project maintainer on [Discord](https://discord.gg/uMq8bMGeeN)."}] \ No newline at end of file +[{"Id":1,"ParentId":null,"DocSectionModelId":1,"Href":"setup","DocumentationModels":[],"Parent":null,"PageOrder":0,"CreatedDate":"2022-03-30T00:00:00","UpdatedDate":"2022-04-07T00:00:00","Name":"Development Setup","Description":"Get set up on developing this web project.","Content":"# Overview\n\nThis document will contain general setup notes for the project.\n\n## Prerequisite\n\nTo understand content in this document, it is recommended to have some software development experience. Particularly using GitHub and Visual Studio.\n\n- [GitHub Documentation](https://docs.github.com/en/get-started)\n\n- [Visual Studio Documentation](https://visualstudio.microsoft.com/vs/getting-started/)\n\nTo make updates to this website, it is recommended to understand HTML/CSS and C#.\n\n- [C# Documentation](https://docs.microsoft.com/en-us/dotnet/csharp/)\n- [Mozilla\u0027s HTML Documentation](https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started)\n- [W3SCHOOLS\u0027 HTML Documentation](https://www.w3schools.com/html/)\n\nFurther, you should understand the product and clients this website is for. So it is recommended to play \u0022Immortal: Gates of Pyre\u0022.\n\n- [IGP Website](https://gatesofpyre.com/)\n - **Please Note:** This product currently has restricted access with it is in a pre-alpha state. If you are not aware or interested in IGP, I recommend to wait for product release. Otherwise, check out their discord for steps of getting access.\n\n## Installation\n\nDownload and install Visual Studio preview.\n\n**Note:** Visual Studio Preview currently doesn\u0027t work on Mac for this project. Use a PC, or Rider.\n\n[https://visualstudio.microsoft.com/vs/preview/](https://visualstudio.microsoft.com/vs/preview/)\n\nWhen installing, ensure you have selected \u0022Workloads | **ASP.NET and web development**\u0022 and \u0022Individual components | **.NET WebAssembly build tools**\u0022.\n\n## Download Project\n\nGet this project from GitHub.\n\n\u0060\u0060\u0060bash\ngit clone https://github.com/JonathanMcCaffrey/IGP-Fan-Reference.git\n\u0060\u0060\u0060\n\n## Project Tree\n\n\u0060\u0060\u0060\nC:.\n\u251C\u2500\u2500\u2500.github\n\u2502 \u2514\u2500\u2500\u2500workflows # Workflows to deploy website\n\u251C\u2500\u2500\u2500Components # Components used be website\n\u251C\u2500\u2500\u2500Contexts\n\u251C\u2500\u2500\u2500IGP\n\u2502 \u251C\u2500\u2500\u2500Pages # Website pages\n\u2502 \u2514\u2500\u2500\u2500wwwroot\n\u2502 \u251C\u2500\u2500\u2500css\n\u2502 \u251C\u2500\u2500\u2500generated # Files generated by IGP_Convert. Do not edit\n\u2502 \u251C\u2500\u2500\u2500image\n\u2502 \u2514\u2500\u2500\u2500javascript\n\u251C\u2500\u2500\u2500IGP_Convert # Converts SQL into JSON for Blazor Wasm\n\u251C\u2500\u2500\u2500Model # Data models\n\u2514\u2500\u2500\u2500Services # Web services\n\u0060\u0060\u0060\n\n## Running\n\n- Open \u0060IGP/IGP.sln\u0060.\n- Click the green RUN button in Visual Studio.\n- A local copy of the IGP Website should have launched on your machine.\n\n## Publishing\n\nCode committed to the \u0060main\u0060 branch will automatically be deployed to [production](https://www.igpfanreference.com/).\n\nCode committed to the \u0060develop\u0060 branch will automatically be deployed to [development](https://calm-mud-04916b210.1.azurestaticapps.net/).\n\n_This is handle via the files in \u0060.github/workflow\u0060. Look into these [GitHub Actions Documents](https://docs.github.com/en/actions) if curious about how this CI system works._\n\n## Troubleshooting\n\n\nNothing that some good internet searches cannot resolved. But you can also contact the project maintainer on [Discord](https://discord.gg/uMq8bMGeeN)."},{"Id":2,"ParentId":null,"DocSectionModelId":1,"Href":"data","DocumentationModels":[],"Parent":null,"PageOrder":0,"CreatedDate":"2022-04-11T00:00:00","UpdatedDate":"2022-04-11T00:00:00","Name":"Project Data","Description":"Using data in this project.","Content":"# Overview\n\nThis document will contain general information on data in this project.\n\n## General Note\n\nThis project is a work in progress. As such, most of the data in the website doesn\u0027t follow the document. Ideally, this will be fixed over time.\n\n## SQL\n\nRelational data is stored in a local SQL database.\n\nThis data is converted into JSON so it can be handled by Blazor WASM.\n\n\u003Ci\u003ECurrently, Blazor WASM has a bug that prevents SQL from being used in production. Although, given SQL doesn\u0027t seem to provide much, aside from increased build times and load times, it might just be best to use the design principals of SQL, and it\u0027s interface, without using the actual technology in production.\u003C/i\u003E\n\nThe data is then loaded in by a Service, via it\u0027s load method.\n\n\u0060\u0060\u0060csharp\n// Using Component\nprotected override async Task OnInitializedAsync()\n{\n await AgileService.Load();\n}\n\u0060\u0060\u0060\n\n\u0060\u0060\u0060csharp\n// Loading Service\npublic async Task Load()\n{\n if (isLoaded) return;\n AgileSprintModels =\n (await httpClient.GetFromJsonAsync\u003CAgileSprintModel[]\u003E(\u0022generated/AgileSprintModels.json\u0022)\n ?? Array.Empty\u003CAgileSprintModel\u003E()).ToList();\n AgileTaskModels =\n (await httpClient.GetFromJsonAsync\u003CAgileTaskModel[]\u003E(\u0022generated/AgileTaskModels.json\u0022)\n ?? Array.Empty\u003CAgileTaskModel\u003E()).ToList();\n SortSql();\n isLoaded = true;\n NotifyDataChanged();\n}\n\u0060\u0060\u0060\n\nWe create a \u0060SortSql()\u0060 method to handle adjusting the data to match what SQL would of given us.\n\n\u0060\u0060\u0060csharp\nprivate void SortSql()\n{\n foreach (var agileTask in AgileTaskModels!)\n {\n if (agileTask.AgileSprintModelId != null)\n {\n SprintById(agileTask.AgileSprintModelId.Value)?.AgileTaskModels.Add(agileTask);\n }\n }\n}\n\u0060\u0060\u0060\n\nWe could also create indexes, or whatever other functionality we lose by SQL not working in production.\n\nThen it\u0027s only a matter of using said data.\n\n\u0060\u0060\u0060csharp\n@if (!agileService.IsLoaded())\n{\n \u003CLoadingComponent/\u003E\n}\nelse\n{\n \u003CLayoutMediumContentComponent\u003E\n \u003CWebsiteTitleComponent\u003EAgile\u003C/WebsiteTitleComponent\u003E\n \u003Cdiv class=\u0022agileViewContainer\u0022\u003E\n @foreach (var sprint in agileService.AgileSprintModels!\n .OrderBy(e =\u003E e.EndDate).Reverse())\n {\n \u003Cdetails class=\u0022sprintDisplayContainer @sprint.GetSprintType().ToLower()\u0022\n open=\u0022@(sprint.GetSprintType() == SprintType.Current)\u0022\u003E\n \u003Csummary class=\u0022sprintSummary\u0022\u003E\n \u003Cdiv class=\u0022sprintTitle\u0022\u003E@sprint.Name\u003C/div\u003E\n\u0060\u0060\u0060\n\n## Localized Strings\n\nLocalized strings are handled in the Localizations.resx file.\n\nMost text isn\u0027t using localized strings yet. And English is the only plan of support in the short term, and probably in the long term as well.\n\n## Markdown Files\n\nDocuments are currently handled in the SQL database. But ideally, they will be markdown documents intead, with links to GitHub.\n\nBasically long term, this website will perhaps also act as a public wiki. Who knows? With GitHub as the public CMS.\n\nSo if Blazor WASM doesn\u0027t support some markdown generation that is not cumbersome, then the \u0060IGP_Convert\u0060 tool will need to be extended to convert Markup files to files Blazor WASM can use.\n\nAnd ideally, any generation systems we write will use any Frontmatter in the markdown documents.\n\nEach of these pages will have one of those \u0060edit on github\u0060 buttons.\n"}] \ No newline at end of file diff --git a/Services/Development/AgileService.cs b/Services/Development/AgileService.cs index fb22786..2d191af 100644 --- a/Services/Development/AgileService.cs +++ b/Services/Development/AgileService.cs @@ -1,20 +1,18 @@ - - -using System.Net.Http.Json; -using Contexts; -using Microsoft.EntityFrameworkCore; +using System.Net.Http.Json; using Model.Work.Tasks; namespace Services.Development; -public class AgileService : IAgileService { +public class AgileService : IAgileService +{ private readonly HttpClient httpClient; private bool isLoaded; - + private event Action OnChange = default!; - public AgileService(HttpClient httpClient) { + public AgileService(HttpClient httpClient) + { this.httpClient = httpClient; } @@ -23,47 +21,53 @@ public class AgileService : IAgileService { public List? AgileSprintModels { get; set; } public List? AgileTaskModels { get; set; } #else - private DatabaseContext Database { get; set; } public DbSet SprintModels => Database.SprintModels; public DbSet TaskModels => Database.TaskModels; #endif - public void Subscribe(Action? action) { + public void Subscribe(Action? action) + { OnChange += action; } - public void Unsubscribe(Action? action) { + public void Unsubscribe(Action? action) + { OnChange -= action; } - public bool IsLoaded() { + public bool IsLoaded() + { return isLoaded; } #if NO_SQL - public async Task Load() { - if (isLoaded) { - return; - } + public async Task Load() + { + if (isLoaded) return; + + AgileSprintModels = + (await httpClient.GetFromJsonAsync("generated/AgileSprintModels.json") + ?? Array.Empty()).ToList(); + AgileTaskModels = + (await httpClient.GetFromJsonAsync("generated/AgileTaskModels.json") + ?? Array.Empty()).ToList(); + + SortSql(); - AgileSprintModels = (await httpClient.GetFromJsonAsync("generated/AgileSprintModels.json")?? Array.Empty() ).ToList(); - AgileTaskModels = (await httpClient.GetFromJsonAsync("generated/AgileTaskModels.json") ?? Array.Empty()).ToList(); - - foreach (var agileTask in AgileTaskModels) - { - if (agileTask.AgileSprintModelId != null) - { - SprintById(agileTask.AgileSprintModelId.Value)?.AgileTaskModels.Add(agileTask); - } - } - isLoaded = true; NotifyDataChanged(); } - + + private void SortSql() + { + foreach (var agileTask in AgileTaskModels!) + if (agileTask.AgileSprintModelId != null) + SprintById(agileTask.AgileSprintModelId.Value)?.AgileTaskModels.Add(agileTask); + } + private AgileSprintModel? SprintById(int id) { foreach (var data in AgileSprintModels!) @@ -72,7 +76,7 @@ public class AgileService : IAgileService { return null; } - + private AgileTaskModel? TaskById(int id) { foreach (var data in AgileTaskModels!) @@ -81,7 +85,7 @@ public class AgileService : IAgileService { return null; } - + #else public async Task Load(DatabaseContext database) { Database = database; @@ -101,11 +105,13 @@ public class AgileService : IAgileService { } #endif - public void Update() { + public void Update() + { NotifyDataChanged(); } - private void NotifyDataChanged() { + private void NotifyDataChanged() + { OnChange?.Invoke(); } } \ No newline at end of file diff --git a/Services/Development/DocumentationService.cs b/Services/Development/DocumentationService.cs index be4085d..a8a5d04 100644 --- a/Services/Development/DocumentationService.cs +++ b/Services/Development/DocumentationService.cs @@ -68,7 +68,7 @@ public class DocumentationService : IDocumentationService #endif //TODO Until SQL work in production. Or, why even add SQL? - SortSQL(); + SortSql(); isLoaded = true; @@ -92,7 +92,7 @@ public class DocumentationService : IDocumentationService return null; } - private void SortSQL() + private void SortSql() { foreach (var connection in DocConnectionModels) { diff --git a/Services/IServices.cs b/Services/IServices.cs index ba6bd89..3d68215 100644 --- a/Services/IServices.cs +++ b/Services/IServices.cs @@ -88,11 +88,7 @@ public interface IAgileService { public void Unsubscribe(Action? action); public void Update(); -#if NO_SQL public Task Load(); -#else - public Task Load(DatabaseContext database); -#endif public bool IsLoaded(); }