50
50
<div class =" demo-mat-card-content" >
51
51
<MatHeadline6 class =" clear-margin" >
52
52
<MatChipSet Style =" align-items: center" >
53
- @if (portfolioEntryName != null )
53
+ @if (PortfolioEntryName != null )
54
54
{
55
- <MatH5 Class =" clear-margin-vertical" >@portfolioEntryName </MatH5 >
55
+ <MatH5 Class =" clear-margin-vertical" >@PortfolioEntryName </MatH5 >
56
56
}
57
57
else
58
58
{
114
114
}
115
115
</MatCardContent >
116
116
</MatCard >
117
- @if (tableRowsItems == null )
117
+ @if (TableRowsItems == null )
118
118
{
119
119
<MatProgressBar Indeterminate =" true" ></MatProgressBar >
120
120
}
121
- else if (tableRowsItems .Count == 0 )
121
+ else if (TableRowsItems .Count == 0 )
122
122
{
123
123
<MatH6 >No entries found .. .</MatH6 >
124
124
}
125
125
else
126
126
{
127
- <MatTable Items =" @tableRowsItems" Striped =" true" AllowSelection =" true" RowClass =" tester" class =" mat-elevation-z5" ShowPaging =" false" PageSize =" 9999" >
128
- <MatTableHeader >
129
- <th >Date </th >
130
- <th >Size </th >
131
- <th >Market Value </th >
132
- <th >Change </th >
133
- <th >Cost </th >
134
- <th >Fee </th >
135
- <th >Actions </th >
136
- </MatTableHeader >
137
- <MatTableRow >
138
- <td >
139
- <div style =" min-width : 9rem " >@( String .Format (" {0:d.M.yyyy HH:mm:ss}" , context .Item1 .Date )) </div >
140
- </td >
141
- <td >
142
- <div style =" min-width : 9rem " >@context.Item1.Size @ActivePortfolioEntry.Symbol.ToUpper() </div >
143
- </td >
144
- <td >@CurrencyUtils.Format(context.Item2.MarketValue , ActivePortfolio .Currency )</td >
145
- <td style =' color : @(context.Item2.RelativeChange >= 0 ? " #17a104" : " #FF0000" )' >
146
- <div style =" min-width : 9rem " >@CurrencyUtils.Format(context.Item2.AbsoluteChange , ActivePortfolio .Currency ) (@(DecimalUtils .FormatTwoDecimalPlaces (context .Item2 .RelativeChange * 100 ))% )</div >
147
- </td >
148
- <td >@CurrencyUtils.Format(context.Item2.Cost , ActivePortfolio .Currency )</td >
149
- <td >@CurrencyUtils.Format(context.Item1.Fee , ActivePortfolio .Currency )</td >
150
- <td >
151
- <MatIconButton Icon =" edit" OnClick =" EditMarketOrder" ></MatIconButton >
152
- <MatIconButton Icon =" delete" OnClick =" () => DeletePortfolio(context.Item1)" ></MatIconButton >
153
- </td >
154
- </MatTableRow >
155
- </MatTable >
127
+ <MatTable Items =" @TableRowsItems" Striped =" true" AllowSelection =" true" RowClass =" tester" class =" mat-elevation-z5" ShowPaging =" false" PageSize =" 9999" SelectionChanged =" SelectionChangedEvent" >
128
+ <MatTableHeader >
129
+ <th >Date </th >
130
+ <th >Size </th >
131
+ <th >Price </th >
132
+ <th >Market Value </th >
133
+ <th >Change </th >
134
+ <th >Actions </th >
135
+ </MatTableHeader >
136
+ <MatTableRow >
137
+ <td >
138
+ <div style =" min-width : 9rem " >@( String .Format (" {0:d.M.yyyy HH:mm:ss}" , context .Item1 .Date )) </div >
139
+ </td >
140
+ <td >
141
+ <div style =" min-width : 8rem " >@context.Item1.Size @ActivePortfolioEntry.Symbol.ToUpper() </div >
142
+ </td >
143
+ <td >
144
+ <div style =" min-width : 8rem " >@( CurrencyUtils .Format (context .Item1 .FilledPrice , ActivePortfolio .Currency )) </div >
145
+ </td >
146
+ <td >
147
+ <div style =" min-width : 9.2rem " >@CurrencyUtils.Format(context.Item2.MarketValue , ActivePortfolio .Currency )</div >
148
+ </td >
149
+ <td style =' color : @(context.Item2.RelativeChange >= 0 ? " #17a104" : " #FF0000" )' >
150
+ <div style =" min-width : 9rem " >@CurrencyUtils.Format(context.Item2.AbsoluteChange , ActivePortfolio .Currency ) (@(DecimalUtils .FormatTwoDecimalPlaces (context .Item2 .RelativeChange * 100 ))% )</div >
151
+ </td >
152
+ <td >
153
+ <MatIconButton Icon =" edit" OnClick =" EditMarketOrder" ></MatIconButton >
154
+ <MatIconButton Icon =" delete" OnClick =" () => DeletePortfolio(context.Item1)" ></MatIconButton >
155
+ </td >
156
+ </MatTableRow >
157
+ </MatTable >
156
158
}
157
159
</div >
158
160
<div class =" mat-layout-grid-cell mat-layout-grid-cell-span-2" ></div >
159
161
</div >
160
162
</div >
161
163
<MatFAB Class =" app-fab--absolute" Icon =" @MatIconNames.Add" Label =" Add a new order" OnClick =' () => { NavigationManager.NavigateTo($"newmarketorder/{ActivePortfolioEntry.Id}");}' ></MatFAB >
162
164
165
+ <MatDialog @bind-IsOpen =" @OrderDetailDialogIsOpen" >
166
+ <MatDialogTitle >Market Order Detail</MatDialogTitle >
167
+ <MatDialogContent >
168
+ @if (OrderToBeShown != null )
169
+ {
170
+ <div class =" mat-layout-grid" >
171
+ <div class =" mat-layout-grid-inner" style =" align-items : center " >
172
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" >
173
+ <LabelDecimalValue Smaller =" true" Value =" @($" {ActivePortfolioEntry.Symbol.ToUpper()} /{CurrencyUtils.GetCurrencyLabel(ActivePortfolio.Currency)} " )" Label =" Trading Pair" ></LabelDecimalValue >
174
+ </div >
175
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" style =" text-align : right " >
176
+ <LabelDecimalValue Smaller =" true" Value =" @(CurrencyUtils.Format(OrderToBeShown.Item1.FilledPrice, ActivePortfolio.Currency))" Label =" Price" ></LabelDecimalValue >
177
+ </div >
178
+ </div >
179
+ <div class =" mat-layout-grid-inner" style =" align-items : center ; margin-top : 2rem ;" >
180
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" >
181
+ <LabelDecimalValue Smaller =" true" Value =" @(CurrencyUtils.Format(OrderToBeShown.Item1.Fee, ActivePortfolio.Currency))" Label =" Fee" ></LabelDecimalValue >
182
+ </div >
183
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" style =" text-align : right " >
184
+ <LabelDecimalValue Smaller =" true" Value =" @(CurrencyUtils.Format(OrderToBeShown.Item2.Cost + OrderToBeShown.Item1.Fee, ActivePortfolio.Currency))" Label =" Cost (fees included)" ></LabelDecimalValue >
185
+ </div >
186
+ </div >
187
+ <div class =" mat-layout-grid-inner" style =" align-items : center ;margin-top : 2rem ; " >
188
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" >
189
+ <LabelDecimalValue Smaller =" true" ValueColorBasedOnValue =" true" Positive =" @(OrderToBeShown.Item2.RelativeChange >= 0)" Value =" @(DecimalUtils.FormatTwoDecimalPlaces(OrderToBeShown.Item2.RelativeChange * 100) + " % " )" Label =" Change" ></LabelDecimalValue >
190
+ </div >
191
+ <div class =" mat-layout-grid-cell mat-layout-grid-cell-span-6" style =" text-align : right " >
192
+ <LabelDecimalValue Smaller =" true" Value =" @(CurrencyUtils.Format(OrderToBeShown.Item1.Size * CurrentEntryAssetMarketEntry.CurrentPrice, ActivePortfolio.Currency))" Label =" Current Value" ></LabelDecimalValue >
193
+ </div >
194
+ </div >
195
+ </div >
196
+ }
197
+ </MatDialogContent >
198
+ <MatDialogActions >
199
+ <MatButton OnClick =" @HideOrderDetail" >Close</MatButton >
200
+ </MatDialogActions >
201
+ </MatDialog >
163
202
164
203
@code
165
204
{
205
+ // SummaryService.GetMarketOrderSummary(OrderToBeShown, CurrentEntryAssetMarketEntry.CurrentPrice).RelativeChange, ActivePortfolio.Currency)
166
206
[Parameter ]
167
207
public int EntryId { get ; set ; }
168
208
169
209
protected Portfolio ActivePortfolio ;
170
210
protected PortfolioEntry ActivePortfolioEntry ;
171
211
protected MarketEntry CurrentEntryAssetMarketEntry ;
172
- protected string portfolioEntryName = " Bitcoin" ;
173
- protected ISummaryService .Summary EntrySummary = new ( 523 m , 0 . 719 m , 1268 . 89 m , 745 . 58 m ) ;
212
+ protected string PortfolioEntryName = " Bitcoin" ;
213
+ protected ISummaryService .Summary EntrySummary ;
174
214
protected decimal TotalHoldings = 0 ;
215
+
216
+
217
+ protected bool OrderDetailDialogIsOpen ;
218
+ protected Tuple <MarketOrder , ISummaryService.Summary > OrderToBeShown ;
219
+
220
+
175
221
176
- protected List <Tuple <MarketOrder, ISummaryService.Summary >> tableRowsItems = new ()
177
- {
178
- new Tuple <MarketOrder , ISummaryService .Summary >(new (18300 m , 0 . 1 m , 0 . 003266 m , DateTime .Now .AddMonths (- 6 ), false ), new (120 m , 2 m , 183 . 00 m , 60 m )),
179
- new Tuple <MarketOrder , ISummaryService .Summary >(new (21200 , 0 . 3 m , 0 . 002866 m , DateTime .Now .AddDays (91 ), false ), new (101 m , 2 m , 123 . 00 m , 45 m )),
180
- new Tuple <MarketOrder , ISummaryService .Summary >(new (18300 m , 0 . 1 m , 0 . 003266 m , DateTime .Now .AddMonths (- 6 ), false ), new (180 m - 30 m , 2 . 3 m , 113 . 00 m , 23 m )),
181
- new Tuple <MarketOrder , ISummaryService .Summary >(new (18300 m , 0 . 1 m , 0 . 003266 m , DateTime .Now .AddMonths (- 6 ), false ), new (- 60 m , - 0 . 6 m , 40 . 00 m , 100 m )),
182
- };
183
-
222
+ protected List <Tuple <MarketOrder, ISummaryService.Summary >> TableRowsItems ;
184
223
185
224
protected override void OnInitialized ()
186
225
{
194
233
protected override async Task OnInitializedAsync ()
195
234
{
196
235
// resolve the name of the cryptocurrency (using the symbol)
197
- portfolioEntryName = await CryptoNameResolver .Resolve (ActivePortfolioEntry .Symbol );
236
+ PortfolioEntryName = await CryptoNameResolver .Resolve (ActivePortfolioEntry .Symbol );
198
237
199
238
await UpdateEntrySummary ();
200
239
}
201
240
202
241
private void SetEntryLoading ()
203
242
{
204
243
CurrentEntryAssetMarketEntry = null ;
205
- tableRowsItems = null ;
244
+ TableRowsItems = null ;
206
245
EntrySummary = null ;
207
246
StateHasChanged ();
208
247
}
214
253
// TODO null?
215
254
CurrentEntryAssetMarketEntry = (await CryptoStatsSource .GetMarketEntries (
216
255
CurrencyUtils .GetCurrencyLabel (ActivePortfolio .Currency ).ToLower (),
217
- portfolioEntryName .ToLower ()
256
+ PortfolioEntryName .ToLower ()
218
257
))[0 ];
219
258
220
259
// get all orders of the portfolio entry
227
266
TotalHoldings = entryOrders .Sum (order => order .Size * (order .Buy ? 1 : - 1 ));
228
267
229
268
// zip entry orders and summaries into a table rows
230
- tableRowsItems = entryOrders .Zip (entrySummaries )
269
+ TableRowsItems = entryOrders .Zip (entrySummaries )
231
270
.Select (tuple => new Tuple <MarketOrder , ISummaryService .Summary >(tuple .First , tuple .Second )).ToList ();
232
271
233
272
// compute suummary of this entry
251
290
Toaster .Add (" Order successfully deleted" , MatToastType .Success , " " , " " );
252
291
}
253
292
}
293
+
294
+ void ShowOrderDetail (Tuple < MarketOrder , ISummaryService .Summary > order )
295
+ {
296
+ Console .WriteLine (" here" );
297
+ OrderToBeShown = order ;
298
+ OrderDetailDialogIsOpen = true ;
299
+ StateHasChanged ();
300
+ }
301
+
302
+ void HideOrderDetail ()
303
+ {
304
+ OrderToBeShown = null ;
305
+ OrderDetailDialogIsOpen = false ;
306
+ StateHasChanged ();
307
+ }
308
+
309
+ private void SelectionChangedEvent (object obj )
310
+ {
311
+ Console .WriteLine (" show dialog" );
312
+ if (obj != null )
313
+ {
314
+ Console .WriteLine (" showing dialog" );
315
+ ShowOrderDetail ((Tuple <MarketOrder , ISummaryService .Summary >) obj ) ;
316
+ }
317
+ }
254
318
}
0 commit comments