Browse Source

doc(Project Data) Document on using data in project

main
Jonathan McCaffrey 4 years ago
parent
commit
4285c0e1ed
  1. BIN
      IGP/Database.db
  2. 40
      IGP/Pages/Agile/AgilePage.razor
  3. 2
      IGP/wwwroot/generated/DocContentModels.json
  4. 58
      Services/Development/AgileService.cs
  5. 4
      Services/Development/DocumentationService.cs
  6. 4
      Services/IServices.cs

BIN
IGP/Database.db

Binary file not shown.

40
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())
{
<LoadingComponent/>
}
else
{
<LayoutMediumContentComponent>
<WebsiteTitleComponent>Agile</WebsiteTitleComponent>
<div class="agileViewContainer">
@foreach (var sprint in AgileService.AgileSprintModels!.OrderBy(e => e.EndDate).Reverse())
@foreach (var sprint in agileService.AgileSprintModels!
.OrderBy(e => e.EndDate).Reverse())
{
<details class="sprintDisplayContainer @sprint.GetSprintType().ToLower()" open="@(sprint.GetSprintType() == SprintType.Current)">
<details class="sprintDisplayContainer @sprint.GetSprintType().ToLower()"
open="@(sprint.GetSprintType() == SprintType.Current)">
<summary class="sprintSummary">
<div class="sprintTitle">@sprint.Name</div>
<div style="flex: 1; flex-grow: 1;"></div>
@ -78,37 +76,23 @@ else
@code {
#if NO_SQL
#else
[Inject]
DatabaseContext Database { get; set; }
[Parameter]
public DbSet<TaskModel> Tasks { get; set; }
[Parameter]
public DbSet<SprintModel> Sprints { get; set; }
#endif
private readonly List<AgileTaskModel> 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();
}
}

2
IGP/wwwroot/generated/DocContentModels.json

File diff suppressed because one or more lines are too long

58
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<AgileSprintModel>? AgileSprintModels { get; set; }
public List<AgileTaskModel>? AgileTaskModels { get; set; }
#else
private DatabaseContext Database { get; set; }
public DbSet<SprintModel> SprintModels => Database.SprintModels;
public DbSet<TaskModel> 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<AgileSprintModel[]>("generated/AgileSprintModels.json")?? Array.Empty<AgileSprintModel>() ).ToList();
AgileTaskModels = (await httpClient.GetFromJsonAsync<AgileTaskModel[]>("generated/AgileTaskModels.json") ?? Array.Empty<AgileTaskModel>()).ToList();
AgileSprintModels =
(await httpClient.GetFromJsonAsync<AgileSprintModel[]>("generated/AgileSprintModels.json")
?? Array.Empty<AgileSprintModel>()).ToList();
AgileTaskModels =
(await httpClient.GetFromJsonAsync<AgileTaskModel[]>("generated/AgileTaskModels.json")
?? Array.Empty<AgileTaskModel>()).ToList();
foreach (var agileTask in AgileTaskModels)
{
if (agileTask.AgileSprintModelId != null)
{
SprintById(agileTask.AgileSprintModelId.Value)?.AgileTaskModels.Add(agileTask);
}
}
SortSql();
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!)
@ -101,11 +105,13 @@ public class AgileService : IAgileService {
}
#endif
public void Update() {
public void Update()
{
NotifyDataChanged();
}
private void NotifyDataChanged() {
private void NotifyDataChanged()
{
OnChange?.Invoke();
}
}

4
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)
{

4
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();
}

Loading…
Cancel
Save