From 1e46acdfcc5d3d2daa310869d76ea841c296fdce Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 19 May 2021 12:26:57 +0200 Subject: [PATCH 1/4] Aggiunta Blazorise components --- MP.Stats/MP.Stats.csproj | 7 +++++++ MP.Stats/Pages/_Host.cshtml | 20 +++++++++++++++++++- MP.Stats/Startup.cs | 11 ++++++++++- MP.Stats/_Imports.razor | 2 ++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index 794cdd30..51f424aa 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -29,6 +29,13 @@ + + + + + + + PreserveNewest diff --git a/MP.Stats/Pages/_Host.cshtml b/MP.Stats/Pages/_Host.cshtml index 65bfed2c..c7466b07 100644 --- a/MP.Stats/Pages/_Host.cshtml +++ b/MP.Stats/Pages/_Host.cshtml @@ -14,7 +14,15 @@ MP.STATS - + @**@ + + + + + + + + @@ -32,6 +40,16 @@ 🗙 + + + + + + + + + + \ No newline at end of file diff --git a/MP.Stats/Startup.cs b/MP.Stats/Startup.cs index 5604ce52..57542753 100644 --- a/MP.Stats/Startup.cs +++ b/MP.Stats/Startup.cs @@ -10,9 +10,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; - using Microsoft.AspNetCore.Localization; using System.Globalization; +using Blazorise; +using Blazorise.Bootstrap; +using Blazorise.Icons.FontAwesome; namespace MP.Stats { @@ -76,6 +78,13 @@ namespace MP.Stats // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { + services.AddBlazorise(options => + { + options.ChangeTextOnKeyPress = true; // optional + }) + .AddBootstrapProviders() + .AddFontAwesomeIcons(); + services.AddLocalization(); services.AddRazorPages(); diff --git a/MP.Stats/_Imports.razor b/MP.Stats/_Imports.razor index b335524c..1dc55d9a 100644 --- a/MP.Stats/_Imports.razor +++ b/MP.Stats/_Imports.razor @@ -8,3 +8,5 @@ @using Microsoft.JSInterop @using MP.Stats @using MP.Stats.Shared +@using Blazorise +@using Blazorise.Charts \ No newline at end of file From 5c1ce470a793379cfbe1f668079aa2f9403b17d3 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 19 May 2021 12:27:09 +0200 Subject: [PATCH 2/4] Test page x chats --- MP.Stats/Pages/Test.razor | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 MP.Stats/Pages/Test.razor diff --git a/MP.Stats/Pages/Test.razor b/MP.Stats/Pages/Test.razor new file mode 100644 index 00000000..03d01f64 --- /dev/null +++ b/MP.Stats/Pages/Test.razor @@ -0,0 +1,51 @@ +@page "/test" + +Test + + + + + +@code { + LineChart lineChart; + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await HandleRedraw(); + } + } + + async Task HandleRedraw() + { + await lineChart.Clear(); + + await lineChart.AddLabelsDatasetsAndUpdate(Labels, GetLineChartDataset()); + } + + LineChartDataset GetLineChartDataset() + { + return new LineChartDataset + { + Label = "# of randoms", + Data = RandomizeData(), + BackgroundColor = backgroundColors, + BorderColor = borderColors, + Fill = true, + PointRadius = 2, + BorderDash = new List { } + }; + } + + string[] Labels = { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" }; + List backgroundColors = new List { ChartColor.FromRgba(255, 99, 132, 0.2f), ChartColor.FromRgba(54, 162, 235, 0.2f), ChartColor.FromRgba(255, 206, 86, 0.2f), ChartColor.FromRgba(75, 192, 192, 0.2f), ChartColor.FromRgba(153, 102, 255, 0.2f), ChartColor.FromRgba(255, 159, 64, 0.2f) }; + List borderColors = new List { ChartColor.FromRgba(255, 99, 132, 1f), ChartColor.FromRgba(54, 162, 235, 1f), ChartColor.FromRgba(255, 206, 86, 1f), ChartColor.FromRgba(75, 192, 192, 1f), ChartColor.FromRgba(153, 102, 255, 1f), ChartColor.FromRgba(255, 159, 64, 1f) }; + + List RandomizeData() + { + var r = new Random(DateTime.Now.Millisecond); + + return new List { r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble() }; + } +} \ No newline at end of file From f1c5d18d15c9bdfa0b55ca109eef4a39f48042fa Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 19 May 2021 17:48:09 +0200 Subject: [PATCH 3/4] Completato pagina Test x grafici (da rivedere) --- MP.Stats/Pages/Test.razor | 102 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 4 deletions(-) diff --git a/MP.Stats/Pages/Test.razor b/MP.Stats/Pages/Test.razor index 03d01f64..1cdce18e 100644 --- a/MP.Stats/Pages/Test.razor +++ b/MP.Stats/Pages/Test.razor @@ -2,12 +2,28 @@ Test - + - +
+
+ +
+
+ +
+
+ +
+
+ +
+
@code { + PieChart pieChart; LineChart lineChart; + HorizontalBarChart barChartHoriz; + BarChart barChart; protected override async Task OnAfterRenderAsync(bool firstRender) { @@ -17,11 +33,66 @@ } } + object horizontalLineChartOptions = new + { + //Title = new + //{ + // Display = true, + // Text = "Line chart sample" + //}, + //Scales = new + //{ + // XAxes = new object[] + // { + // new { + // //ScaleLabel = new { + // //Display = true, LabelString = "value" }, + // Stacked = true + // } + // } + //}, + Tooltips = new + { + Mode = "nearest", + Intersect = false + }, + Hover = new + { + Mode = "nearest", + Intersect = false + }, + Legend = new + { + Display = true, + FullWidth = true + }, + AspectRatio = 2.5 + }; + async Task HandleRedraw() { - await lineChart.Clear(); + await pieChart.Clear(); + await pieChart.AddLabelsDatasetsAndUpdate(Labels, GetPieChartDataset()); + await lineChart.Clear(); await lineChart.AddLabelsDatasetsAndUpdate(Labels, GetLineChartDataset()); + + await barChart.Clear(); + await barChart.AddLabelsDatasetsAndUpdate(Labels, GetBarChartDataset()); + + await barChartHoriz.Clear(); + await barChartHoriz.AddLabelsDatasetsAndUpdate(Labels, GetHorizBarChartDataset()); + } + + PieChartDataset GetPieChartDataset() + { + return new PieChartDataset + { + Label = "# of randoms", + Data = RandomizeData(), + BackgroundColor = backgroundColors, + BorderColor = borderColors + }; } LineChartDataset GetLineChartDataset() @@ -38,6 +109,29 @@ }; } + BarChartDataset GetBarChartDataset() + { + return new BarChartDataset + { + Label = "# of randoms", + Data = RandomizeData(), + BackgroundColor = backgroundColors, + BorderColor = borderColors, + HoverBorderWidth = 5 + }; + } + BarChartDataset GetHorizBarChartDataset() + { + return new BarChartDataset + { + Label = "# of randoms", + Data = RandomizeData(), + BackgroundColor = backgroundColors, + BorderColor = borderColors, + HoverBorderWidth = 5 + }; + } + string[] Labels = { "Red", "Blue", "Yellow", "Green", "Purple", "Orange" }; List backgroundColors = new List { ChartColor.FromRgba(255, 99, 132, 0.2f), ChartColor.FromRgba(54, 162, 235, 0.2f), ChartColor.FromRgba(255, 206, 86, 0.2f), ChartColor.FromRgba(75, 192, 192, 0.2f), ChartColor.FromRgba(153, 102, 255, 0.2f), ChartColor.FromRgba(255, 159, 64, 0.2f) }; List borderColors = new List { ChartColor.FromRgba(255, 99, 132, 1f), ChartColor.FromRgba(54, 162, 235, 1f), ChartColor.FromRgba(255, 206, 86, 1f), ChartColor.FromRgba(75, 192, 192, 1f), ChartColor.FromRgba(153, 102, 255, 1f), ChartColor.FromRgba(255, 159, 64, 1f) }; @@ -46,6 +140,6 @@ { var r = new Random(DateTime.Now.Millisecond); - return new List { r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble(), r.Next(3, 50) * r.NextDouble() }; + return new List { r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble(), r.Next(3, 30) * r.NextDouble() }; } } \ No newline at end of file From 7487efb7240c306d2fabfbd25f34da20de4d8446 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 19 May 2021 17:49:19 +0200 Subject: [PATCH 4/4] Inizio review paginazione --- MP.Stats/Components/DataPager.razor | 34 +++++++--- MP.Stats/Data/MpStatsService.cs | 4 +- MP.Stats/Pages/Scarti.razor | 100 ++++++++++++++-------------- MP.Stats/Pages/Scarti.razor.cs | 7 +- 4 files changed, 83 insertions(+), 62 deletions(-) diff --git a/MP.Stats/Components/DataPager.razor b/MP.Stats/Components/DataPager.razor index 527b8e78..fe4f3439 100644 --- a/MP.Stats/Components/DataPager.razor +++ b/MP.Stats/Components/DataPager.razor @@ -1,15 +1,31 @@ -
- row/pag:  - +
+
+
+
+ paginazione +
+
+ @totalCount records +
+
+
+
+
+ row/pag:  + +
+
@code { + [Parameter] + public int totalCount { get; set; } = 0; protected int _numRecord { get; set; } = 10; diff --git a/MP.Stats/Data/MpStatsService.cs b/MP.Stats/Data/MpStatsService.cs index 7f7eff2f..60e542c8 100644 --- a/MP.Stats/Data/MpStatsService.cs +++ b/MP.Stats/Data/MpStatsService.cs @@ -99,10 +99,10 @@ namespace MP.Stats.Data return Task.FromResult(dbController.StatOdlGetAll(numRecord, searchVal).ToArray()); } - public Task StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, int numRecord, string searchVal = "") + public Task StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, string searchVal = "") { // filtra e restituisce SOLO i primi record... - return Task.FromResult(dbController.StatScartiGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).Take(numRecord).ToArray()); + return Task.FromResult(dbController.StatScartiGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); } public Task StatUserLogGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, int numRecord, string searchVal = "") diff --git a/MP.Stats/Pages/Scarti.razor b/MP.Stats/Pages/Scarti.razor index 343d6c22..b2a7ee96 100644 --- a/MP.Stats/Pages/Scarti.razor +++ b/MP.Stats/Pages/Scarti.razor @@ -5,13 +5,12 @@
-
Registro Scarti
-
- +
Registro Scarti
+
-
+
@if (currRecord != null) { @**@ @@ -22,54 +21,55 @@ } else { - - - - - - - - - - - - - - @foreach (var record in ListRecords) - { - - - - - - - - - - } - -
MacchinaDataODL/CommessaArticoloDescrizioneQtaOperatore
-
@record.CodMacchina
-
@record.IdxMacchina
-
-
@record.DataOraRif.ToString("yyyy.MM.dd")
-
@record.DataOraRif.ToString("ddd HH:mm.ss")
-
@record.IdxOdl | @record.KeyRichiesta@record.CodArticolo -
-
[@record.Causale]
-
@record.Descrizione
-
-
@record.Note
-
@record.Qta@record.Cognome @record.Nome (@record.MatrOpr)
+
+
+ +
+
+ + + + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + + + + } + +
MacchinaDataODL/CommessaArticoloDescrizioneQtaOperatore
+
@record.CodMacchina
+
@record.IdxMacchina
+
+
@record.DataOraRif.ToString("yyyy.MM.dd")
+
@record.DataOraRif.ToString("ddd HH:mm.ss")
+
@record.IdxOdl | @record.KeyRichiesta@record.CodArticolo +
+
[@record.Causale]
+
@record.Descrizione
+
+
@record.Note
+
@record.Qta@record.Cognome @record.Nome (@record.MatrOpr)
+
+
}
\ No newline at end of file diff --git a/MP.Stats/Pages/Scarti.razor.cs b/MP.Stats/Pages/Scarti.razor.cs index 871d963c..9baea5ad 100644 --- a/MP.Stats/Pages/Scarti.razor.cs +++ b/MP.Stats/Pages/Scarti.razor.cs @@ -2,6 +2,8 @@ using Microsoft.JSInterop; using MP.Stats.Data; using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; namespace MP.Stats.Pages @@ -14,6 +16,8 @@ namespace MP.Stats.Pages private MP.Data.DatabaseModels.ResScarti[] ListRecords; + private MP.Data.DatabaseModels.ResScarti[] SearchRecords; + #endregion Private Fields #region Private Properties @@ -43,7 +47,8 @@ namespace MP.Stats.Pages private async Task reloadData() { - ListRecords = await StatService.StatScartiGetAll(currFilter.DateStart, currFilter.DateEnd, currFilter.IdxMacchina, currFilter.IdxOdl, currFilter.KeyRichiesta, currFilter.CodArticolo, numRecord, MessageService.SearchVal); + SearchRecords = await StatService.StatScartiGetAll(currFilter.DateStart, currFilter.DateEnd, currFilter.IdxMacchina, currFilter.IdxOdl, currFilter.KeyRichiesta, currFilter.CodArticolo, MessageService.SearchVal); + ListRecords = SearchRecords.Take(numRecord).ToArray(); } #endregion Private Methods