perf(centralui): load template stubs/analysis projections instead of the full tracked graph (review 2026-10-21 07/P-1, 08/P1)
This commit is contained in:
@@ -107,7 +107,7 @@
|
||||
{
|
||||
_siteCount = (await SiteRepository.GetAllSitesAsync()).Count;
|
||||
_dataConnectionCount = (await SiteRepository.GetAllDataConnectionsAsync()).Count;
|
||||
_templateCount = (await TemplateEngineRepository.GetAllTemplatesAsync()).Count;
|
||||
_templateCount = (await TemplateEngineRepository.GetTemplateStubsAsync()).Count;
|
||||
_apiKeyCount = (await ApiKeyAdmin.ListAsync()).Count;
|
||||
}
|
||||
catch
|
||||
|
||||
+1
-1
@@ -267,7 +267,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
_templates = (await TemplateEngineRepository.GetAllTemplatesAsync()).ToList();
|
||||
_templates = (await TemplateEngineRepository.GetTemplateStubsAsync()).ToShellTemplates();
|
||||
_folders = (await TemplateEngineRepository.GetAllFoldersAsync()).ToList();
|
||||
_foldersById = _folders.ToDictionary(f => f.Id);
|
||||
if (TemplateId is int tid)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@page "/design/templates/create"
|
||||
@using ZB.MOM.WW.ScadaBridge.CentralUI.Services
|
||||
@using ZB.MOM.WW.ScadaBridge.Security
|
||||
@using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates
|
||||
@using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories
|
||||
@@ -73,7 +74,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
_templates = (await TemplateEngineRepository.GetAllTemplatesAsync()).ToList();
|
||||
_templates = (await TemplateEngineRepository.GetTemplateStubsAsync()).ToShellTemplates();
|
||||
if (ParentId is int pid && _templates.Any(t => t.Id == pid))
|
||||
{
|
||||
_createParentId = pid;
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
_loadError = null;
|
||||
try
|
||||
{
|
||||
_templates = (await TemplateEngineRepository.GetAllTemplatesAsync()).ToList();
|
||||
_templates = (await TemplateEngineRepository.GetAllTemplatesForAnalysisAsync()).ToList();
|
||||
|
||||
_selectedTemplate = await TemplateEngineRepository.GetTemplateWithChildrenAsync(Id)
|
||||
?? _templates.FirstOrDefault(t => t.Id == Id);
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
_loading = true;
|
||||
try
|
||||
{
|
||||
_templates = (await TemplateEngineRepository.GetAllTemplatesAsync()).ToList();
|
||||
_templates = (await TemplateEngineRepository.GetAllTemplatesForAnalysisAsync()).ToList();
|
||||
_folders = (await TemplateEngineRepository.GetAllFoldersAsync()).ToList();
|
||||
_templatesById = _templates.ToDictionary(t => t.Id);
|
||||
_compositionsById = _templates
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
using ZB.MOM.WW.ScadaBridge.CentralUI.Services;
|
||||
using System.Security.Cryptography;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
@@ -136,7 +137,7 @@ public partial class TransportExport : ComponentBase
|
||||
_errorMessage = null;
|
||||
try
|
||||
{
|
||||
_templates = (await TemplateRepo.GetAllTemplatesAsync()).ToList();
|
||||
_templates = (await TemplateRepo.GetTemplateStubsAsync()).ToShellTemplates();
|
||||
_folders = (await TemplateRepo.GetAllFoldersAsync()).ToList();
|
||||
_sharedScripts = (await TemplateRepo.GetAllSharedScriptsAsync()).ToList();
|
||||
_externalSystems = (await ExternalRepo.GetAllExternalSystemsAsync()).ToList();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Templates;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Adapts the untracked, body-free <see cref="TemplateStub"/> projection to childless
|
||||
/// <see cref="Template"/> shells for pickers and trees that only read identity/edge fields
|
||||
/// (id, name, parent, folder, derived flag) — review 2026-10-21 07/P-1.
|
||||
/// </summary>
|
||||
internal static class TemplateStubExtensions
|
||||
{
|
||||
/// <summary>Builds childless <see cref="Template"/> shells carrying only the stub's identity and edges.</summary>
|
||||
/// <param name="stubs">The stubs to adapt.</param>
|
||||
/// <returns>One shell template per stub, in input order.</returns>
|
||||
public static List<Template> ToShellTemplates(this IEnumerable<TemplateStub> stubs) =>
|
||||
stubs.Select(s => new Template(s.Name)
|
||||
{
|
||||
Id = s.Id,
|
||||
ParentTemplateId = s.ParentTemplateId,
|
||||
FolderId = s.FolderId,
|
||||
IsDerived = s.IsDerived,
|
||||
OwnerCompositionId = s.OwnerCompositionId,
|
||||
}).ToList();
|
||||
}
|
||||
Reference in New Issue
Block a user