Skip to content

Commit

Permalink
Navmenu, login, dashboard; fixes #102 & #36 & #37
Browse files Browse the repository at this point in the history
  • Loading branch information
justineatrhea committed Jul 22, 2022
1 parent 5bbcb5c commit 1be0abb
Show file tree
Hide file tree
Showing 29 changed files with 839 additions and 353 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ public async Task Verify_that_when_the_server_returns_an_error_the_login_fails()
Assert.That(loginResult, Is.EqualTo(AuthenticationStateKind.Fail));
}

[Test]
public async Task Verify_that_when_the_server_cannot_be_reached_the_login_fails()
{
this.session.Setup(x => x.Open(It.IsAny<bool>())).Throws(new DalReadException());

var authenticationService = new AuthenticationService(this.sessionAnchor.Object, this.cometWebAuthStateProvider);
var authenticationDto = new AuthenticationDto
{
SourceAddress = "https://www.rheagroup",
UserName = "John Doe",
Password = "secret"
};
var loginResult = await authenticationService.Login(authenticationDto);

Assert.That(loginResult, Is.EqualTo(AuthenticationStateKind.Fail));
}

[Test]
public async Task Verify_that_a_nonauthorized_user_cannot_login()
{
Expand Down
14 changes: 13 additions & 1 deletion COMETwebapp.Tests/SessionManagement/SessionAnchorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ public void Setup()
new DomainFileStore(Guid.NewGuid(), this.assembler.Cache, this.uri) { Owner = this.domain }
}
};
this.engineeringSetup.IterationSetup.Add(this.iteration.IterationSetup);
this.openIteration = new ConcurrentDictionary<Iteration, Tuple<DomainOfExpertise, Participant>>(
new List<KeyValuePair<Iteration, Tuple<DomainOfExpertise, Participant>>>()
{
new KeyValuePair<Iteration, Tuple<DomainOfExpertise, Participant>>(this.iteration, new Tuple<DomainOfExpertise, Participant>(this.domain, this.participant))
});

this.siteDirectory = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
this.siteDirectory = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri)
{
Model = { this.engineeringSetup }
};
this.siteDirectory.Person.Add(this.person);
this.siteDirectory.Domain.Add(this.domain);

Expand Down Expand Up @@ -229,5 +233,13 @@ public void VerifyUpdateThings()
thingsToUpdate.Add(clone);
Assert.DoesNotThrow(() => this.sessionAnchor.UpdateThings(thingsToUpdate));
}

[Test]
public void VerifyGetParticipant()
{
this.sessionAnchor.IsSessionOpen = true;
this.sessionAnchor.ReadIteration(this.iteration.IterationSetup);
Assert.That(this.sessionAnchor.GetParticipant(), Is.EqualTo(this.participant));
}
}
}
30 changes: 21 additions & 9 deletions COMETwebapp/Components/Login.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
------------------------------------------------------------------------------->

<EditForm Model="AuthenticationDto" OnValidSubmit="ExecuteLogin">
<DataAnnotationsValidator />

<div class="form-group row">
<label for="ur" class="text-align-start">Source Address:</label>
<div class="col-md-15 m-top-3px">
Expand All @@ -40,6 +42,22 @@
</div>
</div>

<ValidationSummary />

@if (this.AuthenticationState == AuthenticationStateKind.Fail)
{
<div class="form-group row m-top-10px">
<label class="text-danger">Login Failed.</label>
</div>
}

@if (this.AuthenticationState == AuthenticationStateKind.ServerFail)
{
<div class="form-group row m-top-10px">
<label class="text-danger">The Server could not be reached.</label>
</div>
}

<div class="row">
<div class="col-md-12 text-center">

Expand All @@ -52,19 +70,13 @@
<button id="connectbtn" type="submit" class="btn btn-connect m-top-10px" disabled>Connecting</button>
break;
case AuthenticationStateKind.Fail:
case AuthenticationStateKind.ServerFail:
<button id="connectbtn" type="submit" class="btn btn-connect m-top-10px" >Retry</button>
break;
}
</div>
</div>

@if (this.AuthenticationState == AuthenticationStateKind.Fail)
{
<div class="form-group row m-top-5px">
<label>Login Failed</label>
</div>
}

</EditForm>

@code{
Expand Down Expand Up @@ -101,12 +113,12 @@
this.AuthenticationState = AuthenticationStateKind.Authenticating;
StateHasChanged();

if (AuthenticationService != null)
if (this.AuthenticationService != null)
{
this.AuthenticationState = await AuthenticationService.Login(AuthenticationDto);
}

if (NavigationManager != null && this.AuthenticationState == AuthenticationStateKind.Success)
if (this.NavigationManager != null && this.AuthenticationState == AuthenticationStateKind.Success)
{
NavigationManager.NavigateTo("/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ Copyright (c) 2022 RHEA System S.A.
<UnreferencedElements Data="Data" />
</div>


@code {
/// <summary>
/// ElementDefinition represented in graphs
/// </summary>
public List<ElementDefinition> Data { get; set; }
public List<ElementDefinition>? Data { get; set; }

/// <summary>
/// Listeners for the components to update it with ISession
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!------------------------------------------------------------------------------
Copyright (c) 2022 RHEA System S.A.
Authors: Justine Veirier d'aiguebonne, Sam Gerené, Alex Vorobiev, Alexander van Delft
This file is part of COMET WEB Community Edition
The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
The COMET WEB Community Edition is free software; you can redistribute it and/or
modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The COMET WEB Community Edition is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
------------------------------------------------------------------------------->

@if (this.Data != null)
{
var identifiedElements = Math.Round((double)this.IdentifiedElements.Count * 100 / this.Data.Count);
var otherElements = 100 - identifiedElements;
<div class="container-fluid p-0">
<div class="row m-0">
<BSProgress Class="height-30px">
<BSProgressBar IsStriped="true" Class="taskdone" Value="otherElements">
@otherElements %
</BSProgressBar>
<BSProgressBar IsStriped="true" Color="BSColor.Danger" Value="identifiedElements">
@identifiedElements %
</BSProgressBar>
</BSProgress>
</div>

<ElementTable Elements="@IdentifiedElements"/>
</div>
}

@code {
/// <summary>
/// <see cref="ElementDefinition">s owned by the active domain
/// </summary>
[Parameter]
public List<ElementDefinition>? Data { get; set; }


/// <summary>
/// <see cref="ElementDefinition">s identified as unused or unreferenced
/// </summary>
[Parameter]
public List<ElementDefinition> IdentifiedElements { get; set; }

}
56 changes: 56 additions & 0 deletions COMETwebapp/Components/ModelDashboard/Elements/ElementTable.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!------------------------------------------------------------------------------
Copyright (c) 2022 RHEA System S.A.
Authors: Justine Veirier d'aiguebonne, Sam Gerené, Alex Vorobiev, Alexander van Delft
This file is part of COMET WEB Community Edition
The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
The COMET WEB Community Edition is free software; you can redistribute it and/or
modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The COMET WEB Community Edition is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
------------------------------------------------------------------------------->

@if(this.Elements != null && this.Elements.Count != 0)
{
<div class="m-top-20px" style="border: 1px solid #008bd2; border-radius: 10px;">
<BSTable IsBordered="false" IsStriped="true" Class="text-align-center">
<BSTHead>
<BSTR>
<BSTD>Element</BSTD>
</BSTR>
</BSTHead>
<BSTBody>
@foreach(var element in this.Elements)
{
<BSTR AlignRow="AlignRow.Middle">
<BSTD>@element.Name</BSTD>
</BSTR>
}
</BSTBody>
</BSTable>
</div>
} else
{
<div>
No Task to do.
</div>
}


@code {
/// <summary>
/// All <see cref="ParameterValueSet"> to complete
/// </summary>
[Parameter]
public List<ElementDefinition>? Elements { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,51 @@ Copyright (c) 2022 RHEA System S.A.
@inject IIterationService IterationService
@implements IDisposable

<div>
<div class="row">
<div class="col-9">
<h3 class="text-align-end">Unreferenced Elements</h3>
@if (this.Data != null && this.UnReferencedElements != null)
{
<div>
<div class="row">
<div class="col-9">
<h3 class="text-align-end">Unreferenced Elements</h3>
</div>
<div class="col text-align-start p-0">
<Tooltip MarginBottom="bottom-60" Text="Elements without associated element usage">
<button type="button" class="btn btn-secondary btn-tooltip"><span class="oi oi-info"></span></button>
</Tooltip>
</div>
</div>
<div class="col text-align-start p-0">
<Tooltip MarginBottom="bottom-60" Text="Elements without associated element usage">
<button type="button" class="btn btn-secondary btn-tooltip"><span class="oi oi-info"></span></button>
</Tooltip>
</div>
</div>
<DxChart Data="@Data" CustomizeSeriesPoint="@PreparePointLabel">
<DxChartFullStackedBarSeries Color="System.Drawing.Color.MediumPurple" Name="Referenced Elements" Filter="@((ElementDefinition e) => !this.UnReferencedElements.Contains(e))"
@{
var participantRole = this.ISessionAnchor.GetParticipant()?.Role;
}
@if (participantRole != null && participantRole.Name.Equals("Model Administrator"))
{
<DxChart Data="@Data" CustomizeSeriesPoint="@PreparePointLabel">
<DxChartFullStackedBarSeries Color="System.Drawing.Color.MediumPurple" Name="Referenced Elements" Filter="@((ElementDefinition e) => !this.UnReferencedElements.Contains(e))"
ArgumentField="@(e => e.Owner.ShortName)" ValueField="@(e => 1)"
AggregationMethod="Enumerable.Sum">
<DxChartSeriesLabel Position="RelativePosition.Inside"/>
</DxChartFullStackedBarSeries>
<DxChartFullStackedBarSeries Color="System.Drawing.Color.Orchid" Name="Unreferenced Elements" Filter="@((ElementDefinition e) => this.UnReferencedElements.Contains(e))"
ArgumentField="@(e => e.Owner.ShortName)" ValueField="@(e => 1)"
AggregationMethod="Enumerable.Sum">
<DxChartSeriesLabel Position="RelativePosition.Inside" />
</DxChartFullStackedBarSeries>
<DxChartTooltip Enabled="true" Position="RelativePosition.Inside">
<DxChartSeriesLabel Position="RelativePosition.Inside"/>
</DxChartFullStackedBarSeries>
<DxChartFullStackedBarSeries Color="System.Drawing.Color.Orchid" Name="Unreferenced Elements" Filter="@((ElementDefinition e) => this.UnReferencedElements.Contains(e))"
ArgumentField="@(e => e.Owner.ShortName)" ValueField="@(e => 1)"
AggregationMethod="Enumerable.Sum">
<DxChartSeriesLabel Position="RelativePosition.Inside" />
</DxChartFullStackedBarSeries>
<DxChartTooltip Enabled="true" Position="RelativePosition.Inside">
<div style="margin: 0.1rem">
<button class="card-btn" @onclick="@(() => AccessData(context.Point.SeriesName, context.Point.Argument))">
More
</button>
</div>
</DxChartTooltip>
<DxChartLegend Visible="true" Position="RelativePosition.Outside" VerticalAlignment="VerticalEdge.Bottom" />
</DxChart>
</div>
</DxChartTooltip>
<DxChartLegend Visible="true" Position="RelativePosition.Outside" VerticalAlignment="VerticalEdge.Bottom" />
</DxChart>
}
else if(participantRole != null && participantRole.Name.Equals("Domain Expert"))
{
<ElementDomainProgress Data="FilterDomain(this.Data)" IdentifiedElements="FilterDomain(this.UnReferencedElements)"/>
}
</div>
}

@code {
/// <summary>
Expand Down Expand Up @@ -130,4 +143,13 @@ Copyright (c) 2022 RHEA System S.A.
{
this.NavigationManager.NavigateTo($"ModelDashboard/ElementsDetails?criteria={criteria}&domain={domain}");
}

/// <summary>
/// Gets <see cref="ElementDefinition"> owned by the current domain
/// </summary>
/// <param name="elements"><see cref="ElementDefinition">s to filter</param>
public List<ElementDefinition>? FilterDomain(List<ElementDefinition>? elements)
{
return elements?.FindAll(e => e.Owner == this.ISessionAnchor.CurrentDomainOfExpertise);
}
}
Loading

0 comments on commit 1be0abb

Please sign in to comment.