doc(Project Data) Document on using data in project
This commit is contained in:
Binary file not shown.
@@ -1,26 +1,24 @@
|
|||||||
@implements IDisposable;
|
@implements IDisposable;
|
||||||
@inject IAgileService AgileService;
|
@inject IAgileService agileService;
|
||||||
|
|
||||||
@layout PageLayout
|
@layout PageLayout
|
||||||
|
|
||||||
@page "/agile"
|
@page "/agile"
|
||||||
|
|
||||||
@if (!AgileService.IsLoaded())
|
@if (!agileService.IsLoaded())
|
||||||
{
|
{
|
||||||
<LoadingComponent/>
|
<LoadingComponent/>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
<LayoutMediumContentComponent>
|
<LayoutMediumContentComponent>
|
||||||
|
|
||||||
<WebsiteTitleComponent>Agile</WebsiteTitleComponent>
|
<WebsiteTitleComponent>Agile</WebsiteTitleComponent>
|
||||||
|
|
||||||
<div class="agileViewContainer">
|
<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">
|
<summary class="sprintSummary">
|
||||||
<div class="sprintTitle">@sprint.Name</div>
|
<div class="sprintTitle">@sprint.Name</div>
|
||||||
<div style="flex: 1; flex-grow: 1;"></div>
|
<div style="flex: 1; flex-grow: 1;"></div>
|
||||||
@@ -78,37 +76,23 @@ else
|
|||||||
|
|
||||||
|
|
||||||
@code {
|
@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();
|
private readonly List<AgileTaskModel> backlog = new();
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
AgileService.Subscribe(HasChanged);
|
agileService.Subscribe(HasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDisposable.Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
AgileService.Unsubscribe(HasChanged);
|
agileService.Unsubscribe(HasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HasChanged()
|
void HasChanged()
|
||||||
{
|
{
|
||||||
backlog.Clear();
|
backlog.Clear();
|
||||||
|
|
||||||
foreach (var task in AgileService.AgileTaskModels!)
|
foreach (var task in agileService.AgileTaskModels!)
|
||||||
{
|
{
|
||||||
if (task.AgileSprintModelId == null)
|
if (task.AgileSprintModelId == null)
|
||||||
{
|
{
|
||||||
@@ -121,11 +105,7 @@ else
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
#if NO_SQL
|
await agileService.Load();
|
||||||
await AgileService.Load();
|
|
||||||
#else
|
|
||||||
await AgileService.Load(Database);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,20 +1,18 @@
|
|||||||
|
using System.Net.Http.Json;
|
||||||
|
|
||||||
using System.Net.Http.Json;
|
|
||||||
using Contexts;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Model.Work.Tasks;
|
using Model.Work.Tasks;
|
||||||
|
|
||||||
namespace Services.Development;
|
namespace Services.Development;
|
||||||
|
|
||||||
public class AgileService : IAgileService {
|
public class AgileService : IAgileService
|
||||||
|
{
|
||||||
private readonly HttpClient httpClient;
|
private readonly HttpClient httpClient;
|
||||||
|
|
||||||
private bool isLoaded;
|
private bool isLoaded;
|
||||||
|
|
||||||
private event Action OnChange = default!;
|
private event Action OnChange = default!;
|
||||||
|
|
||||||
public AgileService(HttpClient httpClient) {
|
public AgileService(HttpClient httpClient)
|
||||||
|
{
|
||||||
this.httpClient = httpClient;
|
this.httpClient = httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,47 +21,53 @@ public class AgileService : IAgileService {
|
|||||||
public List<AgileSprintModel>? AgileSprintModels { get; set; }
|
public List<AgileSprintModel>? AgileSprintModels { get; set; }
|
||||||
public List<AgileTaskModel>? AgileTaskModels { get; set; }
|
public List<AgileTaskModel>? AgileTaskModels { get; set; }
|
||||||
#else
|
#else
|
||||||
|
|
||||||
private DatabaseContext Database { get; set; }
|
private DatabaseContext Database { get; set; }
|
||||||
public DbSet<SprintModel> SprintModels => Database.SprintModels;
|
public DbSet<SprintModel> SprintModels => Database.SprintModels;
|
||||||
public DbSet<TaskModel> TaskModels => Database.TaskModels;
|
public DbSet<TaskModel> TaskModels => Database.TaskModels;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
public void Subscribe(Action? action) {
|
public void Subscribe(Action? action)
|
||||||
|
{
|
||||||
OnChange += action;
|
OnChange += action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unsubscribe(Action? action) {
|
public void Unsubscribe(Action? action)
|
||||||
|
{
|
||||||
OnChange -= action;
|
OnChange -= action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsLoaded() {
|
public bool IsLoaded()
|
||||||
|
{
|
||||||
return isLoaded;
|
return isLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NO_SQL
|
#if NO_SQL
|
||||||
public async Task Load() {
|
public async Task Load()
|
||||||
if (isLoaded) {
|
{
|
||||||
return;
|
if (isLoaded) return;
|
||||||
}
|
|
||||||
|
|
||||||
AgileSprintModels = (await httpClient.GetFromJsonAsync<AgileSprintModel[]>("generated/AgileSprintModels.json")?? Array.Empty<AgileSprintModel>() ).ToList();
|
AgileSprintModels =
|
||||||
AgileTaskModels = (await httpClient.GetFromJsonAsync<AgileTaskModel[]>("generated/AgileTaskModels.json") ?? Array.Empty<AgileTaskModel>()).ToList();
|
(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)
|
SortSql();
|
||||||
{
|
|
||||||
if (agileTask.AgileSprintModelId != null)
|
|
||||||
{
|
|
||||||
SprintById(agileTask.AgileSprintModelId.Value)?.AgileTaskModels.Add(agileTask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
|
|
||||||
NotifyDataChanged();
|
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)
|
private AgileSprintModel? SprintById(int id)
|
||||||
{
|
{
|
||||||
foreach (var data in AgileSprintModels!)
|
foreach (var data in AgileSprintModels!)
|
||||||
@@ -101,11 +105,13 @@ public class AgileService : IAgileService {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public void Update() {
|
public void Update()
|
||||||
|
{
|
||||||
NotifyDataChanged();
|
NotifyDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NotifyDataChanged() {
|
private void NotifyDataChanged()
|
||||||
|
{
|
||||||
OnChange?.Invoke();
|
OnChange?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ public class DocumentationService : IDocumentationService
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//TODO Until SQL work in production. Or, why even add SQL?
|
//TODO Until SQL work in production. Or, why even add SQL?
|
||||||
SortSQL();
|
SortSql();
|
||||||
|
|
||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public class DocumentationService : IDocumentationService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SortSQL()
|
private void SortSql()
|
||||||
{
|
{
|
||||||
foreach (var connection in DocConnectionModels)
|
foreach (var connection in DocConnectionModels)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,11 +88,7 @@ public interface IAgileService {
|
|||||||
public void Unsubscribe(Action? action);
|
public void Unsubscribe(Action? action);
|
||||||
public void Update();
|
public void Update();
|
||||||
|
|
||||||
#if NO_SQL
|
|
||||||
public Task Load();
|
public Task Load();
|
||||||
#else
|
|
||||||
public Task Load(DatabaseContext database);
|
|
||||||
#endif
|
|
||||||
public bool IsLoaded();
|
public bool IsLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user