Skip to content

Commit 635e82e

Browse files
committed
Improved GUI, change Index.razor page, added CurrencyUtils.cs
1 parent 0988c41 commit 635e82e

File tree

6 files changed

+153
-4
lines changed

6 files changed

+153
-4
lines changed

Model/Model.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ public enum Currency : int
2727
Eur = 978,
2828
Usd = 849
2929
}
30+
3031
}

Utils/CurrencyUtils.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Model;
5+
6+
namespace Utils
7+
{
8+
public class CurrencyUtils
9+
{
10+
public static string GetCurrencyLabel(Currency currency)
11+
{
12+
switch (currency)
13+
{
14+
case Currency.Czk:
15+
return "CZK";
16+
case Currency.Eur:
17+
return "EUR";
18+
case Currency.Usd:
19+
return "USD";
20+
}
21+
22+
return "UNDEFINED";
23+
}
24+
25+
public static string Format(decimal value, Currency currency)
26+
{
27+
var valueStr = String.Format("{0:.00}", value);
28+
switch (currency)
29+
{
30+
case Currency.Czk:
31+
return $"{valueStr},- Kč";
32+
case Currency.Eur:
33+
return $"{valueStr} €";
34+
case Currency.Usd:
35+
return $"${valueStr}";
36+
}
37+
38+
return "UNDEFINED";
39+
}
40+
}
41+
}

Utils/Utils.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
<TargetFramework>net5.0</TargetFramework>
55
</PropertyGroup>
66

7+
<ItemGroup>
8+
<ProjectReference Include="..\Model\Model.csproj" />
9+
</ItemGroup>
10+
711
</Project>

WebFrontend/Pages/Index.razor

Lines changed: 105 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,108 @@
11
@page "/"
2+
@using Model
3+
@using Services
4+
@using Utils
5+
<style>
6+
.demo-mat-card {
7+
margin-bottom: 2em;
8+
}
29
3-
<h1>Hello, world!</h1>
10+
.demo-mat-card-content {
11+
padding: 1rem;
12+
}
413
5-
Welcome to KIV/NET app.
14+
.clear-margin {
15+
margin: 0px;
16+
}
17+
</style>
18+
<div class="mat-layout-grid mat-layout-grid-align-center">
19+
<div class="mat-layout-grid-inner center">
20+
21+
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-3"></div>
22+
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-6">
23+
<MatCard class="demo-mat-card">
24+
<MatCardContent>
25+
<div class="demo-mat-card-content">
26+
<MatHeadline6 class="clear-margin">
27+
<MatChipSet Style="align-items: center">
28+
<MatH5 Class="clear-margin">@activePortfolio.Name</MatH5>
29+
<MatChip Style="vertical-align: center" Label="@CurrencyUtils.GetCurrencyLabel(activePortfolio.Currency)"/>
30+
</MatChipSet>
31+
</MatHeadline6>
32+
</div>
33+
34+
<MatBody2 class="demo-mat-card-content clear-margin">
35+
<div class="mat-layout-grid">
36+
<div class="mat-layout-grid-inner" style="align-items: center">
37+
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-6">
38+
<MatH4 Class="clear-margin">@(CurrencyUtils.Format(portfolioSummary.MarketValue, activePortfolio.Currency))</MatH4>
39+
</div>
40+
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-6" style="text-align: end">
41+
@(portfolioSummary.RelativeChange * 100m) %
42+
</div>
43+
</div>
44+
</div>
45+
</MatBody2>
46+
</MatCardContent>
47+
</MatCard>
48+
<MatTable Items="@portfolioEntryRows" Striped="true" AllowSelection="true" RowClass="tester" class="mat-elevation-z5" ShowPaging="false" PageSize="9999">
49+
<MatTableHeader>
50+
<th>Coin</th>
51+
<th>Price</th>
52+
<th>Change (1h)</th>
53+
<th>Holdings</th>
54+
</MatTableHeader>
55+
<MatTableRow>
56+
<td>@context.symbol.ToUpper()</td>
57+
<td>@(CurrencyUtils.Format(context.currentPrice, activePortfolio.Currency))</td>
58+
<td style='color: @(context.relativeChange >= 0 ? "#17a104" : "#FF0000")'>@context.relativeChange%</td>
59+
<td>@context.percentage%</td>
60+
</MatTableRow>
61+
</MatTable>
62+
</div>
63+
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-3"></div>
64+
</div>
65+
</div>
66+
67+
68+
@code
69+
{
70+
protected Portfolio activePortfolio = new Portfolio("Main Portfolio", "My main portfolio to be used", Currency.Usd);
71+
72+
protected ISummaryService.Summary portfolioSummary = new(1341m, 1.8m, 9982.489m, 1000m);
73+
74+
protected List<PortfolioEntry> activePortfolioEntries = new List<PortfolioEntry>()
75+
{
76+
new("btc", 1, 1),
77+
new("ada", 1, 2),
78+
new("eth", 1, 3),
79+
new("ltc", 1, 4),
80+
new("link", 1, 5),
81+
};
82+
83+
protected List<decimal> portfolioHoldings = new()
84+
{
85+
44.8886m,
86+
28.18m,
87+
10.116m,
88+
9.38m,
89+
2.70m,
90+
};
91+
92+
protected List<PortfolioEntryRow> portfolioEntryRows = new()
93+
{
94+
new("btc", 57644.42m, 1.35m, 44.76m),
95+
new("ada", 1.36m, 0.58m, 28.18m),
96+
new("eth", 3279.64m, 10.95m, 27.11m),
97+
new("ltc", 291.55m, 7.20m, 9.38m),
98+
new("link", 42.20m, -5.19m, 2.70m)
99+
};
100+
101+
protected record PortfolioEntryRow(string symbol, decimal currentPrice, decimal relativeChange, decimal percentage);
102+
103+
protected override async Task OnInitializedAsync()
104+
{
105+
//_existingPortfolios = PortfolioService.GetPortfolios();
106+
}
107+
108+
}

WebFrontend/Pages/NewPortfolio.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
padding: 1rem;
2020
}
2121
22-
.demo-mat-card-clean-margin {
22+
.clear-margin {
2323
margin: 0px;
2424
}
2525
</style>

WebFrontend/Pages/NewPortfolioEntry.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
padding: 1rem;
2323
}
2424
25-
.demo-mat-card-clean-margin {
25+
.clear-margin {
2626
margin: 0px;
2727
}
2828
</style>

0 commit comments

Comments
 (0)