From 6a52dc0914bb874ee443a54741aa9070ab560330 Mon Sep 17 00:00:00 2001 From: Justine Veirier d'Aiguebonne Date: Mon, 1 Aug 2022 16:46:45 +0200 Subject: [PATCH] Finalize Model dashboard; fixes #136 --- .../IterationServiceTest.cs | 14 + .../ParameterValues/DefaultValues.razor | 14 +- .../ParameterValues/DonutDashboard.razor | 6 +- .../ParameterValues/ParameterDashboard.razor | 27 +- .../ParameterDomainProgress.razor | 14 +- .../ParameterValues/PublishedParameters.razor | 12 +- .../ParameterValues/ToDoTable.razor | 8 +- .../IterationServices/IIterationService.cs | 11 +- .../IterationServices/IterationService.cs | 71 +++- .../Pages/ModelDashboard/DataDetails.razor | 230 ------------ .../ModelDashboard/ElementsDetails.razor | 75 ++-- .../Pages/ModelDashboard/ModelDashboard.razor | 5 +- .../ModelDashboard/ParametersDetails.razor | 329 ++++++++++++++++++ COMETwebapp/wwwroot/css/app.css | 14 + 14 files changed, 508 insertions(+), 322 deletions(-) delete mode 100644 COMETwebapp/Pages/ModelDashboard/DataDetails.razor create mode 100644 COMETwebapp/Pages/ModelDashboard/ParametersDetails.razor diff --git a/COMETwebapp.Tests/IterationServiceTest/IterationServiceTest.cs b/COMETwebapp.Tests/IterationServiceTest/IterationServiceTest.cs index 395490db..4cb3adf8 100644 --- a/COMETwebapp.Tests/IterationServiceTest/IterationServiceTest.cs +++ b/COMETwebapp.Tests/IterationServiceTest/IterationServiceTest.cs @@ -42,6 +42,7 @@ public class IterationServiceTest private Iteration iteration; private IIterationService iterationService = new IterationService(); private List parameterValueSets; + private List parameterValueSetBase; private List parameterSubscriptions; private List unReferencedElements; private List unUsedElements; @@ -274,6 +275,12 @@ public void SetUp() parameterValueset_2 }; + this.parameterValueSetBase = new List() + { + parameterValueset_1, + parameterValueset_2 + }; + this.unReferencedElements = new List() { elementDefinition_3 @@ -310,6 +317,13 @@ public void VerifyGetParameterValueSets() Assert.That(iterationService.GetParameterValueSets(this.iteration), Is.EqualTo(this.parameterValueSets)); } + [Test] + public void VerifyGetParameterValueSetBase() + { + Assert.That(iterationService.GetParameterValueSetBase(this.iteration), Is.Not.Empty); + Assert.That(iterationService.GetParameterValueSetBase(this.iteration), Is.EqualTo(this.parameterValueSetBase)); + } + [Test] public void VerifyGetNestedElements() { diff --git a/COMETwebapp/Components/ModelDashboard/ParameterValues/DefaultValues.razor b/COMETwebapp/Components/ModelDashboard/ParameterValues/DefaultValues.razor index 9f96d9ee..39e7f477 100644 --- a/COMETwebapp/Components/ModelDashboard/ParameterValues/DefaultValues.razor +++ b/COMETwebapp/Components/ModelDashboard/ParameterValues/DefaultValues.razor @@ -36,12 +36,12 @@ Copyright (c) 2022 RHEA System S.A. @if(this.Data != null){ - - @@ -76,10 +76,10 @@ Copyright (c) 2022 RHEA System S.A. - - @@ -110,7 +110,7 @@ Copyright (c) 2022 RHEA System S.A. /// Data in the graph /// [Parameter] - public List? Data { get; set; } + public List? Data { get; set; } /// /// Set the point label on the graph @@ -125,11 +125,11 @@ Copyright (c) 2022 RHEA System S.A. } /// - /// Get the number of represented in the selected area depending on criteria and domain + /// Get the number of represented in the selected area depending on criteria and domain /// /// The criteria represented in the selected area /// The associated domain of the selected area - /// The number of represented in the selected area + /// The number of represented in the selected area public int NumberData(string criteria, object domain) { if(this.Data != null && criteria.Equals("Published Values as Default")) diff --git a/COMETwebapp/Components/ModelDashboard/ParameterValues/DonutDashboard.razor b/COMETwebapp/Components/ModelDashboard/ParameterValues/DonutDashboard.razor index 9e15ac28..9088c79f 100644 --- a/COMETwebapp/Components/ModelDashboard/ParameterValues/DonutDashboard.razor +++ b/COMETwebapp/Components/ModelDashboard/ParameterValues/DonutDashboard.razor @@ -45,7 +45,7 @@ Copyright (c) 2022 RHEA System S.A. /// Data in the graph /// [Parameter] - public List? Data { get; set; } + public List? Data { get; set; } /// /// Set the color appearence for the donut chart @@ -70,9 +70,9 @@ Copyright (c) 2022 RHEA System S.A. /// /// Initialize list from data to represent in the grpah /// - /// List of to represent in the graph + /// List of to represent in the graph /// List of used in the graph - private List GetChartData(List? data) + private List GetChartData(List? data) { List donutData = new List(); var iteration = this.ISessionAnchor.OpenIteration; diff --git a/COMETwebapp/Components/ModelDashboard/ParameterValues/ParameterDashboard.razor b/COMETwebapp/Components/ModelDashboard/ParameterValues/ParameterDashboard.razor index 3a7f991e..fd74702f 100644 --- a/COMETwebapp/Components/ModelDashboard/ParameterValues/ParameterDashboard.razor +++ b/COMETwebapp/Components/ModelDashboard/ParameterValues/ParameterDashboard.razor @@ -30,7 +30,7 @@ Copyright (c) 2022 RHEA System S.A. {
- +
@@ -71,7 +71,7 @@ Copyright (c) 2022 RHEA System S.A. /// /// ParameterValueSet represented in graphs /// - public List? Data { get; set; } + public List Data { get; set; } = new List(); /// /// Listeners for the components to update it with ISession @@ -82,23 +82,24 @@ Copyright (c) 2022 RHEA System S.A. /// Filter data to show in the graph /// /// List of all data in the project - /// The list of filtered - public List Filter(List? data) + /// The list of filtered + public List Filter(List? data) { - var result = new List(); - if(data != null) + if(data == null) { - result.AddRange(data); + return new List(); } + + var result = data.ToList(); + if (this.FilterOption != null) { var nestedParameters = this.IterationService.GetNestedParameters(this.ISessionAnchor.OpenIteration, this.FilterOption); if (nestedParameters.Count != 0) { - nestedParameters.ForEach(nestedParameter => - { - result.RemoveAll(p => nestedParameter.AssociatedParameter.ValueSets.Contains(p)); - }); + var valueSets = nestedParameters.Select(x => x.ValueSet).ToList(); + result = result.Where(x => valueSets.Contains(x)).ToList(); + } else { result.Clear(); @@ -125,7 +126,7 @@ Copyright (c) 2022 RHEA System S.A. ///
/// List of all data in the iteration /// The list of filtered - public List FilterDomain(List? data) + public List FilterDomain(List? data) { return this.Filter(data?.FindAll(d => d.Owner == this.ISessionAnchor.CurrentDomainOfExpertise)); } @@ -170,6 +171,6 @@ Copyright (c) 2022 RHEA System S.A. /// private void InitializeData() { - this.Data = this.IterationService.GetParameterValueSets(this.ISessionAnchor.OpenIteration); + this.Data = this.IterationService.GetParameterValueSetBase(this.ISessionAnchor.OpenIteration); } } diff --git a/COMETwebapp/Components/ModelDashboard/ParameterValues/ParameterDomainProgress.razor b/COMETwebapp/Components/ModelDashboard/ParameterValues/ParameterDomainProgress.razor index 34239b6e..dd4a3d2e 100644 --- a/COMETwebapp/Components/ModelDashboard/ParameterValues/ParameterDomainProgress.razor +++ b/COMETwebapp/Components/ModelDashboard/ParameterValues/ParameterDomainProgress.razor @@ -20,6 +20,8 @@ Copyright (c) 2022 RHEA System S.A. along with this program. If not, see http://www.gnu.org/licenses/. -------------------------------------------------------------------------------> +@inject NavigationManager NavigationManager +
@@ -27,7 +29,7 @@ Copyright (c) 2022 RHEA System S.A.

Publishable Parameters

- +
@@ -54,7 +56,7 @@ Copyright (c) 2022 RHEA System S.A.
-

Actual Values as Default

+

Current Values as Default

@@ -78,16 +80,18 @@ Copyright (c) 2022 RHEA System S.A.
- + }
@code { /// - /// s owned by the active domain + /// s owned by the active domain /// [Parameter] - public List? Data { get; set; } + public List? Data { get; set; } } diff --git a/COMETwebapp/Components/ModelDashboard/ParameterValues/PublishedParameters.razor b/COMETwebapp/Components/ModelDashboard/ParameterValues/PublishedParameters.razor index de94b4ad..b55b09e0 100644 --- a/COMETwebapp/Components/ModelDashboard/ParameterValues/PublishedParameters.razor +++ b/COMETwebapp/Components/ModelDashboard/ParameterValues/PublishedParameters.razor @@ -37,12 +37,12 @@ Copyright (c) 2022 RHEA System S.A. @if(this.Data != null) { - - @@ -77,10 +77,10 @@ Copyright (c) 2022 RHEA System S.A.
- - @@ -108,10 +108,10 @@ Copyright (c) 2022 RHEA System S.A. public string? FilterParameterType { get; set; } /// - /// for the graph + /// for the graph /// [Parameter] - public List? Data { get; set; } + public List? Data { get; set; } /// /// Set the point label on the graph diff --git a/COMETwebapp/Components/ModelDashboard/ParameterValues/ToDoTable.razor b/COMETwebapp/Components/ModelDashboard/ParameterValues/ToDoTable.razor index 2fcc2a18..8ac17145 100644 --- a/COMETwebapp/Components/ModelDashboard/ParameterValues/ToDoTable.razor +++ b/COMETwebapp/Components/ModelDashboard/ParameterValues/ToDoTable.razor @@ -35,8 +35,8 @@ Copyright (c) 2022 RHEA System S.A. @foreach(var parameterValueSet in this.ParameterValueSets) { - var parameter = (Parameter)parameterValueSet.Container; - var element = (ElementDefinition)parameter.Container; + var parameter = (ParameterBase)parameterValueSet.Container; + var element = (ElementBase)parameter.Container; @element.Name @parameter.ParameterType.Name @@ -69,8 +69,8 @@ Copyright (c) 2022 RHEA System S.A. @code { /// - /// All to complete + /// All to complete /// [Parameter] - public List? ParameterValueSets { get; set; } + public List? ParameterValueSets { get; set; } } diff --git a/COMETwebapp/IterationServices/IIterationService.cs b/COMETwebapp/IterationServices/IIterationService.cs index f97f5eae..331bc895 100644 --- a/COMETwebapp/IterationServices/IIterationService.cs +++ b/COMETwebapp/IterationServices/IIterationService.cs @@ -54,6 +54,15 @@ public interface IIterationService /// All List GetParameterValueSets(Iteration? iteration); + /// + /// Get all of the given iteration + /// + /// + /// The for which the s list is created + /// + /// All + List GetParameterValueSetBase(Iteration? iteration); + /// /// Get all of the given iteration for all options /// @@ -146,6 +155,6 @@ public interface IIterationService /// The name of for which the s list is created /// /// All - List GetParameterValueSetsByParameterType(Iteration? iteration, string? parameterTypeName); + List GetParameterValueSetsByParameterType(Iteration? iteration, string? parameterTypeName); } } diff --git a/COMETwebapp/IterationServices/IterationService.cs b/COMETwebapp/IterationServices/IterationService.cs index 03d34683..f088b853 100644 --- a/COMETwebapp/IterationServices/IterationService.cs +++ b/COMETwebapp/IterationServices/IterationService.cs @@ -60,6 +60,43 @@ public List GetParameterValueSets(Iteration? iteration) return result; } + /// + /// Get all of the given iteration + /// + /// + /// The for which the s list is created + /// + /// All + public List GetParameterValueSetBase(Iteration? iteration) + { + var result = new List(); + if (iteration?.TopElement != null) + { + iteration?.TopElement.Parameter.ForEach(p => result.AddRange(p.ValueSet)); + } + iteration?.Element.ForEach(e => + { + e.ContainedElement.ForEach(containedElement => + { + if(containedElement.ParameterOverride.Count == 0) + { + containedElement.ElementDefinition.Parameter.ForEach(p => result.AddRange(p.ValueSet)); + } else + { + var associatedParameterValueSet = new List(); + containedElement.ParameterOverride.ForEach(p => { + result.AddRange(p.ValueSet); + p.ValueSet.ForEach(povs => associatedParameterValueSet.Add(povs.ParameterValueSet)); + }); + containedElement.ElementDefinition.Parameter.ForEach(p => { + result.AddRange(p.ValueSet.FindAll(pvs => !associatedParameterValueSet.Contains(pvs))); + }); + } + }); + }); + return result.DistinctBy(p => p.Iid).ToList(); + } + /// /// Get all of the given iteration for all options /// @@ -114,7 +151,8 @@ public List GetNestedParameters(Iteration? iteration, Guid? opt { var nestedElementTreeGenerator = new NestedElementTreeGenerator(); var nestedParameters = new List(); - var option = iteration?.Option.ToList().Find(o => o.Iid == optionIid); + var option = iteration?.Option.FirstOrDefault(x => x.Iid == optionIid); + if (option != null && iteration?.TopElement != null) { nestedParameters.AddRange(nestedElementTreeGenerator.GetNestedParameters(option)); @@ -316,14 +354,35 @@ public List GetParameterTypes(Iteration? iteration) /// The name of for which the s list is created /// /// All - public List GetParameterValueSetsByParameterType(Iteration? iteration, string? parameterTypeName) + public List GetParameterValueSetsByParameterType(Iteration? iteration, string? parameterTypeName) { - var result = new List(); - if (parameterTypeName != null && iteration != null) + var result = new List(); + if (iteration?.TopElement != null) { - iteration.Element.ForEach(e => e.Parameter.FindAll(p => p.ParameterType.Name.Equals(parameterTypeName)).ForEach(p => result.AddRange(p.ValueSet))); + iteration?.TopElement.Parameter.FindAll(p => p.ParameterType.Name.Equals(parameterTypeName)).ForEach(p => result.AddRange(p.ValueSet)); } - return result; + iteration?.Element.ForEach(e => + { + e.ContainedElement.ForEach(containedElement => + { + if (containedElement.ParameterOverride.Count == 0) + { + containedElement.ElementDefinition.Parameter.FindAll(p => p.ParameterType.Name.Equals(parameterTypeName)).ForEach(p => result.AddRange(p.ValueSet)); + } + else + { + var associatedParameterValueSet = new List(); + containedElement.ParameterOverride.FindAll(p => p.ParameterType.Name.Equals(parameterTypeName)).ForEach(p => { + result.AddRange(p.ValueSet); + p.ValueSet.ForEach(povs => associatedParameterValueSet.Add(povs.ParameterValueSet)); + }); + containedElement.ElementDefinition.Parameter.FindAll(p => p.ParameterType.Name.Equals(parameterTypeName)).ForEach(p => { + result.AddRange(p.ValueSet.FindAll(pvs => !associatedParameterValueSet.Contains(pvs))); + }); + } + }); + }); + return result.DistinctBy(p => p.Iid).ToList(); } } } diff --git a/COMETwebapp/Pages/ModelDashboard/DataDetails.razor b/COMETwebapp/Pages/ModelDashboard/DataDetails.razor deleted file mode 100644 index 46501942..00000000 --- a/COMETwebapp/Pages/ModelDashboard/DataDetails.razor +++ /dev/null @@ -1,230 +0,0 @@ - - -@page "/ModelDashboard/ParametersDetails" -@inject ISessionAnchor ISessionAnchor -@inject IIterationService IterationService -@implements IDisposable - -
-
Details
- - - - - - - - - @{ - var intvalue = (context as BuiltParameter)?.ActualValue; - } - @intvalue?.First() - - - - - @{ - var intvalue = (context as BuiltParameter)?.PublishedValue; - } - @intvalue?.First() - - - - -
- -@code { - /// - /// of the option to filter the data - /// - [Parameter] - [SupplyParameterFromQuery] - public Guid? FilterOption { get; set; } - - /// - /// of the state to filter the data - /// - [Parameter] - [SupplyParameterFromQuery] - public Guid? FilterState { get; set; } - - /// - /// Name of parameter type to filter the data - /// - [Parameter] - [SupplyParameterFromQuery] - public string? FilterParameterType { get; set; } - - /// - /// The criteria to filter ParameterValueSet list - /// - [Parameter] - [SupplyParameterFromQuery] - public string? Criteria { get; set; } - - /// - /// ShortName Domain to filter ParameterValueSet list - /// - [Parameter] - [SupplyParameterFromQuery] - public string? Domain { get; set; } - - /// - /// Get selected filter on url page - /// - protected override void OnParametersSet() - { - this.FilterOption = FilterOption ?? null; - this.FilterState = FilterState ?? null; - this.FilterParameterType = FilterParameterType ?? null; - this.Criteria = Criteria ?? null; - this.Domain = Domain ?? null; - } - - /// - /// List of in the table - /// - public ObservableCollection Parameters = new ObservableCollection(); - - /// - /// Listeners for the components to update it with ISession - /// - private Dictionary listeners = new Dictionary(); - - /// - /// Initialize component at first render and after session update - /// - protected override void OnInitialized() - { - this.InitializeParameters(); - - if (!this.listeners.TryGetValue("UpToDate", out var listener)) - { - this.listeners.Add("UpToDate", CDPMessageBus.Current.Listen().Where(x => x == SessionStateKind.UpToDate).Subscribe(x => - { - this.Parameters.Clear(); - this.InitializeParameters(); - this.StateHasChanged(); - })); - } - } - - /// - /// Stop and clear listeners of the component - /// - public void Dispose() - { - this.listeners.Values.ToList().ForEach(l => l.Dispose()); - this.listeners.Clear(); - } - - /// - /// Initialize the list showed in the table - /// - private void InitializeParameters() - { - var iteration = this.ISessionAnchor.OpenIteration; - if (this.Criteria is not null && this.Domain is not null && iteration != null) - { - List elements = iteration.Element; - - List parameters = new List(); - elements.ForEach(element => parameters.AddRange(element.Parameter)); - - List parameterValueSets = this.IterationService.GetParameterValueSets(iteration); - - this.FilterDomainCriteriaOptionStateParameterType(parameterValueSets).ForEach(valueSet => - { - var associatedParameter = parameters.Find(p => p.ValueSet.Contains(valueSet)); - Parameters.Add(new BuiltParameter() - { - Name = associatedParameter?.ParameterType?.Name, - ElementName = elements.Find(element => element.Parameter.Contains(associatedParameter))?.Name, - Domain = valueSet.Owner.ShortName, - Option = iteration.Option.ToList().Find(o => o.Iid == this.FilterOption)?.Name, - State = valueSet.ActualState?.Name, - Scale = associatedParameter?.Scale?.ShortName, - ActualValue = valueSet.ActualValue, - PublishedValue = valueSet.Published - }); - }); - } - } - - /// - /// Filter the given ParameterValueSet list with criteria, domain, option and state filters - /// - /// List of ParameterValueSet to filter - /// The filtered list - private List FilterDomainCriteriaOptionStateParameterType(List parameterValueSets) - { - parameterValueSets.RemoveAll(p => !p.Owner.ShortName.Equals(this.Domain)); - - if (this.Criteria is not null && this.Criteria.Equals("Published Parameters")) - { - parameterValueSets.RemoveAll(p => !p.Published.SequenceEqual(p.ActualValue)); - - } else if(this.Criteria is not null && this.Criteria.Equals("Publishable Parameters")) - { - parameterValueSets.RemoveAll(p => p.Published.SequenceEqual(p.ActualValue)); - - } else if (this.Criteria is not null && this.Criteria.Equals("Published Values as Default")) - { - parameterValueSets.RemoveAll(p => p.Published.Count(el => !el.Equals("-")) != 0); - - } else if (this.Criteria is not null && this.Criteria.Equals("Other Values")) - { - parameterValueSets.RemoveAll(p => p.Published.Count(el => !el.Equals("-")) == 0); - } - - if (this.FilterOption != null) - { - var nestedParameters = this.IterationService.GetNestedParameters(this.ISessionAnchor.OpenIteration, this.FilterOption); - - if (nestedParameters.Count != 0) - { - nestedParameters.ForEach(nestedParameter => - { - parameterValueSets.RemoveAll(p => nestedParameter.AssociatedParameter.ValueSets.Contains(p)); - }); - } else - { - parameterValueSets.Clear(); - } - } - - if (this.FilterState != null) - { - parameterValueSets.RemoveAll(d => d.ActualState == null || (d.ActualState != null && d.ActualState.Iid != this.FilterState)); - } - - Console.WriteLine(this.FilterParameterType); - if(this.FilterParameterType is not null && !this.FilterParameterType.Equals("")) - { - var parameterValueSetsByParameterType = this.IterationService.GetParameterValueSetsByParameterType(this.ISessionAnchor.OpenIteration, this.FilterParameterType); - parameterValueSets.RemoveAll(d => !parameterValueSetsByParameterType.Contains(d)); - } - - return parameterValueSets; - } -} diff --git a/COMETwebapp/Pages/ModelDashboard/ElementsDetails.razor b/COMETwebapp/Pages/ModelDashboard/ElementsDetails.razor index cf4d289d..015e240c 100644 --- a/COMETwebapp/Pages/ModelDashboard/ElementsDetails.razor +++ b/COMETwebapp/Pages/ModelDashboard/ElementsDetails.razor @@ -27,11 +27,26 @@ Copyright (c) 2022 RHEA System S.A.
Details
- - - - - + + + + + Element + Model Code + Owner + + + + @foreach(var element in this.Elements) + { + + @element.Name + @element.ModelCode() + @element.Owner.ShortName + + } + +
@code { @@ -59,19 +74,9 @@ Copyright (c) 2022 RHEA System S.A. } /// - /// The built element to show in the table - /// - public class BuildElement - { - public string Name { get; set; } - public string ShortName { get; set; } - public string Owner { get; set; } - } - - /// - /// List of in the table + /// List of in the table /// - public ObservableCollection Elements = new ObservableCollection(); + public List Elements = new List(); /// /// Listeners for the components to update it with ISession @@ -110,48 +115,30 @@ Copyright (c) 2022 RHEA System S.A. /// private void InitializeElements() { - List unusedElements = this.IterationService.GetUnusedElementDefinitions(this.ISessionAnchor.OpenIteration); - List unreferencedElements = this.IterationService.GetUnreferencedElements(this.ISessionAnchor.OpenIteration); + var unusedElements = this.IterationService.GetUnusedElementDefinitions(this.ISessionAnchor.OpenIteration); + var unreferencedElements = this.IterationService.GetUnreferencedElements(this.ISessionAnchor.OpenIteration); var iteration = this.ISessionAnchor.OpenIteration; if (Criteria is not null && Domain is not null && iteration != null) { - List elements = new List(); + var elements = new List(); elements.AddRange(iteration.Element.FindAll(e => e.Owner.ShortName.Equals(this.Domain))); if (this.Criteria.Equals("Unused Elements")) { - elements.FindAll(e => unusedElements.Contains(e)).ForEach(e => Elements.Add(new BuildElement() - { - Name = e.Name, - ShortName = e.ShortName, - Owner = e.Owner.Name - })); + this.Elements = elements.FindAll(e => unusedElements.Contains(e)).OrderBy(e => e.Name).ToList(); } else if (this.Criteria.Equals("Used Elements")) { - elements.FindAll(e => !unusedElements.Contains(e)).ForEach(e => Elements.Add(new BuildElement() - { - Name = e.Name, - ShortName = e.ShortName, - Owner = e.Owner.Name - })); + this.Elements = elements.FindAll(e => !unusedElements.Contains(e)).OrderBy(e => e.Name).ToList(); + } else if (this.Criteria.Equals("Unreferenced Elements")) { - elements.FindAll(e => unreferencedElements.Contains(e)).ForEach(e => Elements.Add(new BuildElement() - { - Name = e.Name, - ShortName = e.ShortName, - Owner = e.Owner.Name - })); + this.Elements = elements.FindAll(e => unreferencedElements.Contains(e)).OrderBy(e => e.Name).ToList(); + } else { - elements.FindAll(e => !unreferencedElements.Contains(e)).ForEach(e => Elements.Add(new BuildElement() - { - Name = e.Name, - ShortName = e.ShortName, - Owner = e.Owner.Name - })); + this.Elements = elements.FindAll(e => !unreferencedElements.Contains(e)).OrderBy(e => e.Name).ToList(); } } } diff --git a/COMETwebapp/Pages/ModelDashboard/ModelDashboard.razor b/COMETwebapp/Pages/ModelDashboard/ModelDashboard.razor index fd8e1a78..67c029d6 100644 --- a/COMETwebapp/Pages/ModelDashboard/ModelDashboard.razor +++ b/COMETwebapp/Pages/ModelDashboard/ModelDashboard.razor @@ -42,10 +42,8 @@ Copyright (c) 2022 RHEA System S.A.
Filter on Option:
} @@ -180,7 +178,8 @@ Copyright (c) 2022 RHEA System S.A. /// protected override void OnParametersSet() { - this.FilterOption = FilterOption ?? null; + var option = this.ISessionAnchor.OpenIteration?.Option.First(); + this.FilterOption = FilterOption ?? option?.Iid; this.FilterState = FilterState ?? null; this.FilterParameterType = FilterParameterType ?? null; diff --git a/COMETwebapp/Pages/ModelDashboard/ParametersDetails.razor b/COMETwebapp/Pages/ModelDashboard/ParametersDetails.razor new file mode 100644 index 00000000..f878f6ff --- /dev/null +++ b/COMETwebapp/Pages/ModelDashboard/ParametersDetails.razor @@ -0,0 +1,329 @@ + + +@page "/ModelDashboard/ParametersDetails" +@inject ISessionAnchor ISessionAnchor +@inject IIterationService IterationService +@implements IDisposable + +
+
Details
+ + + + + Element + Parameter + Model Code + Actual Value + Published Value + Owner + + + + @foreach(var parameterValueSet in this.ParameterValueSets) + { + var parameter = (ParameterBase)parameterValueSet.Container; + var element = (ElementBase)parameter.Container; + var modelCode = parameterValueSet.ModelCode().Split("\\"); + + @element.Name + @parameter.ParameterType.Name + @if(modelCode.Count() == 1) + { + @modelCode[0] + } else if(modelCode.Count() == 2) + { + if (parameter.IsOptionDependent) + { + +
+ @modelCode[0] +
+ Option: @modelCode[1] +
+
+
+ } else if (parameter.StateDependence != null) + { + +
+ @modelCode[0] +
+ State: @modelCode[1] +
+
+
+ } + + } else if(modelCode.Count() > 2) + { + +
+ @modelCode[0] +
+ Option: @modelCode[1] +
+
+ State: @modelCode[2] +
+
+
+ } + @if(parameter.ParameterType.NumberOfValues == 1) + { + + + + + + + } else if(parameter.ParameterType.GetType().Equals(typeof(ArrayParameterType))) + { + + + + + + + } else + { + var compoundParameterType = (CompoundParameterType)parameter.ParameterType; + var components = compoundParameterType?.Component.ToList(); + if (components != null && compoundParameterType != null) + { + +
+ @foreach (var component in components) + { + var indexStart = 0; + for (int i = 0; i < compoundParameterType.Component.IndexOf(component); i++) + { + indexStart += compoundParameterType.Component.ElementAt(i).ParameterType.NumberOfValues; + + } + + } +
+
+ +
+ @foreach (var component in components) + { + var indexStart = 0; + for (int i = 0; i < compoundParameterType.Component.IndexOf(component); i++) + { + indexStart += compoundParameterType.Component.ElementAt(i).ParameterType.NumberOfValues; + + } + + } +
+
+ } + } + @parameterValueSet.Owner.ShortName +
+ } +
+
+
+ +@code { + /// + /// of the option to filter the data + /// + [Parameter] + [SupplyParameterFromQuery] + public Guid? FilterOption { get; set; } + + /// + /// of the state to filter the data + /// + [Parameter] + [SupplyParameterFromQuery] + public Guid? FilterState { get; set; } + + /// + /// Name of parameter type to filter the data + /// + [Parameter] + [SupplyParameterFromQuery] + public string? FilterParameterType { get; set; } + + /// + /// The criteria to filter ParameterValueSet list + /// + [Parameter] + [SupplyParameterFromQuery] + public string? Criteria { get; set; } + + /// + /// ShortName Domain to filter ParameterValueSet list + /// + [Parameter] + [SupplyParameterFromQuery] + public string? Domain { get; set; } + + /// + /// List of in the table + /// + public List ParameterValueSets = new List(); + + /// + /// Get selected filter on url page + /// + protected override void OnParametersSet() + { + this.FilterOption = FilterOption ?? null; + this.FilterState = FilterState ?? null; + this.FilterParameterType = FilterParameterType ?? null; + this.Criteria = Criteria ?? null; + this.Domain = Domain ?? null; + } + + /// + /// Listeners for the components to update it with ISession + /// + private Dictionary listeners = new Dictionary(); + + /// + /// Initialize component at first render and after session update + /// + protected override void OnInitialized() + { + this.InitializeParameterValueSets(); + + if (!this.listeners.TryGetValue("UpToDate", out var listener)) + { + this.listeners.Add("UpToDate", CDPMessageBus.Current.Listen().Where(x => x == SessionStateKind.UpToDate).Subscribe(x => + { + this.ParameterValueSets.Clear(); + this.InitializeParameterValueSets(); + this.StateHasChanged(); + })); + } + } + + /// + /// Filter the given ParameterValueSet list with criteria, domain, option and state filters + /// + /// List of ParameterValueSet to filter + /// The filtered list + private List Filter(List parameterValueSets) + { + if(this.Domain != null) + { + parameterValueSets.RemoveAll(p => !p.Owner.ShortName.Equals(this.Domain)); + } + + if (this.Criteria is not null && this.Criteria.Equals("Published Parameters")) + { + parameterValueSets.RemoveAll(p => !p.Published.SequenceEqual(p.ActualValue)); + + } else if(this.Criteria is not null && this.Criteria.Equals("Publishable Parameters")) + { + parameterValueSets.RemoveAll(p => p.Published.SequenceEqual(p.ActualValue)); + + } else if (this.Criteria is not null && this.Criteria.Equals("Published Values as Default")) + { + parameterValueSets.RemoveAll(p => p.Published.Count(el => !el.Equals("-")) != 0); + + } else if (this.Criteria is not null && this.Criteria.Equals("Other Values")) + { + parameterValueSets.RemoveAll(p => p.Published.Count(el => !el.Equals("-")) == 0); + } + + if (this.FilterOption != null) + { + var nestedParameters = this.IterationService.GetNestedParameters(this.ISessionAnchor.OpenIteration, this.FilterOption); + if (nestedParameters.Count != 0) + { + var valueSets = nestedParameters.Select(x => x.ValueSet).ToList(); + parameterValueSets = parameterValueSets.Where(x => valueSets.Contains(x)).ToList(); + } else + { + parameterValueSets.Clear(); + } + } + + if (this.FilterState != null) + { + parameterValueSets.RemoveAll(d => d.ActualState == null || (d.ActualState != null && d.ActualState.Iid != this.FilterState)); + } + + if(this.FilterParameterType is not null && !this.FilterParameterType.Equals("")) + { + var parameterValueSetsByParameterType = this.IterationService.GetParameterValueSetsByParameterType(this.ISessionAnchor.OpenIteration, this.FilterParameterType); + parameterValueSets.RemoveAll(d => !parameterValueSetsByParameterType.Contains(d)); + } + + return parameterValueSets; + } + + /// + /// Initialize the list showed in the table + /// + private void InitializeParameterValueSets() + { + var iteration = this.ISessionAnchor.OpenIteration; + if (this.Criteria is not null && this.Domain is not null && iteration != null) + { + var parameterValueSets = this.IterationService.GetParameterValueSetBase(iteration); + + this.ParameterValueSets = this.Filter(parameterValueSets).OrderBy(p => this.GetElementBase(p).Name).ToList(); + } + } + + /// + /// Gets the containing the given parameterValueSetBase + /// + private ElementBase GetElementBase(ParameterValueSetBase parameterValueSetBase) + { + var parameter = (ParameterBase)parameterValueSetBase.Container; + var element = (ElementBase)parameter.Container; + return element; + } + + /// + /// Stop and clear listeners of the component + /// + public void Dispose() + { + this.listeners.Values.ToList().ForEach(l => l.Dispose()); + this.listeners.Clear(); + } +} diff --git a/COMETwebapp/wwwroot/css/app.css b/COMETwebapp/wwwroot/css/app.css index 1d05708c..51b1a26f 100644 --- a/COMETwebapp/wwwroot/css/app.css +++ b/COMETwebapp/wwwroot/css/app.css @@ -299,6 +299,14 @@ html, body, #app { width: 10%; } +.width-20 { + width: 20%; +} + +.width-40 { + width: 40%; +} + .width-15{ width: 15%; } @@ -330,4 +338,10 @@ html, body, #app { .m-bottom-20px{ margin-bottom: 20px; +} + +.todo-btn { + width: 100%; + background-color: transparent; + border: none; } \ No newline at end of file