mkdir TypeProviderKata
cd TypeProviderKata
yo fsharp
> Create standalone project
> WebSharper.UI.Next Suave
name: ReportingDashboard
Paket: yes
Fake: yes
- Visual Studio run
- http://localhost:8080/
(mono) .paket/paket.exe add -i SQLProvider
(voir si il faut migrer en .Net 4.6 pour avoir le package)
- Créer
Script1.fsx
. - copier le contenu du script fourni.
- essayer pendant 5 min de jouer avec l'autocompletion pour découvrir la base
(mono) .paket/paket.exe add -i FsLab
Executer :
#load "packages/FsLab/Themes/AtomChester.fsx"
#load "packages/FsLab/FsLab.fsx"
open FSharp.Charting
open XPlot
open XPlot.Plotly
let chart1 =
report1
|> Chart.Line
|> Chart.WithLayout (Layout(title = "Products by category"))
|> Chart.WithLegend true
|> Chart.WithHeight 500
|> Chart.WithWidth 700
chart1.GetInlineHtml()
Créer le module Reporting
contenant la fonction getProductsCountByCategory : unit -> string
.
Son role est de renvoyer le HTML du rapport.
Créer la page web qui permettra d'afficher le rapport.
let ProductsCategory ctx =
Templating.Main ctx EndPoint.ProductsCategory "ProductsCategory" [
h1 [text "Products count by category"]
div [
html [
Doc.Verbatim (Reporting.getProductsCountByCategory())
]
]
]