From 412d78f89509d05f969a18aae8cc836171892ba3 Mon Sep 17 00:00:00 2001 From: Tim Forkmann Date: Fri, 21 Jun 2024 06:08:08 -0400 Subject: [PATCH] work on more docs --- src/docs/Docs.fsproj | 3 +- src/docs/Pages/Execute.fs | 60 ++++++++++ src/docs/Pages/Install.fs | 35 +++--- src/docs/Pages/QueryTable.fs | 50 -------- src/docs/Pages/Upsert.fs | 60 ++++++++++ src/docs/Pages/Use.fs | 13 +- src/docs/Router.fs | 24 ++-- src/docs/View.fs | 113 +++++++----------- src/docs/views/AzureTackle/AzureTackle.fs | 31 ----- .../views/AzureTackle/HandleNullValues.fs | 30 ----- src/docs/views/AzureTackle/InsertData.fs | 36 ------ .../views/AzureTackle/ParameterizedQuery.fs | 29 ----- .../AzureTackle/ProvidingDefaultValues.fs | 29 ----- src/docs/views/AzureTackle/QueryTable.fs | 56 --------- 14 files changed, 194 insertions(+), 375 deletions(-) create mode 100755 src/docs/Pages/Execute.fs delete mode 100755 src/docs/Pages/QueryTable.fs create mode 100755 src/docs/Pages/Upsert.fs delete mode 100644 src/docs/views/AzureTackle/AzureTackle.fs delete mode 100644 src/docs/views/AzureTackle/HandleNullValues.fs delete mode 100644 src/docs/views/AzureTackle/InsertData.fs delete mode 100644 src/docs/views/AzureTackle/ParameterizedQuery.fs delete mode 100644 src/docs/views/AzureTackle/ProvidingDefaultValues.fs delete mode 100644 src/docs/views/AzureTackle/QueryTable.fs diff --git a/src/docs/Docs.fsproj b/src/docs/Docs.fsproj index 2c73aeb..ccd8d00 100755 --- a/src/docs/Docs.fsproj +++ b/src/docs/Docs.fsproj @@ -8,7 +8,8 @@ - + + diff --git a/src/docs/Pages/Execute.fs b/src/docs/Pages/Execute.fs new file mode 100755 index 0000000..8016f53 --- /dev/null +++ b/src/docs/Pages/Execute.fs @@ -0,0 +1,60 @@ +module Docs.Pages.Execute + +open Feliz +open Feliz.Bulma +open Docs.SharedView + +let ExecuteView = + Html.div [ + Bulma.title.h1 "AzureTackle - Execute" + Html.hr [] + Bulma.content [ + Bulma.title.h4 "Connect to your database" + Html.p [ prop.dangerouslySetInnerHTML "Get the connection from the environment" ] + linedMockupCode """ + open AzureTackle + let connectionString() = Env.getVar "app_db + """ + ] + ] + +let code = + """ + let tableProps = AzureTable.withConnectionString ("UseDevelopmentStorage=true", TestTable) + let mapper = fun (tableEntity :TableEntity) -> + { + PartKey = tableEntity.PartitionKey + RowKey = tableEntity.RowKey + ValidFrom = tableEntity.ReadDateTimeOffset("ValidFrom") + ValidTo = tableEntity.ReadOptionalDateTimeOffset("ValidTo") + Exists = tableEntity.ReadBoolean("Exists") + Value = tableEntity.GetDouble("Value").Value + ValueDecimal = tableEntity.ReadDecimal("ValueDecimal") + Text = tableEntity.GetString("Text") + } + + let! values = + tableProps + |> AzureTable.execute (fun read -> + { + PartKey = read.PartitionKey + RowKey = read.RowKey + ValidFrom = read.ReadDateTimeOffset("ValidFrom") + ValidTo = read.ReadOptionalDateTimeOffset "ValidTo" + Exists = read.ReadBoolean "Exists" + Value = read.ReadDouble "Value" + ValueDecimal = read.ReadDecimal "ValueDecimal" + Text = read.ReadString "Text" + }) + """ + +let title = Html.text "AzureTackle" + +[] +let Execute () = + Html.div [ + Bulma.content [ + codedView title code ExecuteView + ] + fixDocsView "Execute" false + ] diff --git a/src/docs/Pages/Install.fs b/src/docs/Pages/Install.fs index c48e7d5..cee08af 100755 --- a/src/docs/Pages/Install.fs +++ b/src/docs/Pages/Install.fs @@ -9,26 +9,19 @@ open Docs.SharedView let InstallView () = React.fragment [ Html.divClassed "description" [ Html.text "Using NuGet package command" ] - Html.divClassed - "max-w-xl" - [ Daisy.mockupCode [ - Html.pre [ - mockupCode.prefix "$" - prop.children [ - Html.code "Install-Package AzureTackle" - ] - ] - ] ] + Html.divClassed "max-w-xl" [ + Daisy.mockupCode [ + Html.pre [ + mockupCode.prefix "$" + prop.children [ Html.code "Install-Package AzureTackle" ] + ] + ] + ] Html.divClassed "description" [ Html.text "or Paket" ] - Html.divClassed - "max-w-xl" - [ Daisy.mockupCode [ - Html.pre [ - mockupCode.prefix "$" - prop.children [ - Html.code "paket add AzureTackle" - ] - ] - ] ] - + Html.divClassed "max-w-xl" [ + Daisy.mockupCode [ + Html.pre [ mockupCode.prefix "$"; prop.children [ Html.code "dotnet paket add AzureTackle" ] ] + ] ] + + ] diff --git a/src/docs/Pages/QueryTable.fs b/src/docs/Pages/QueryTable.fs deleted file mode 100755 index cec2a14..0000000 --- a/src/docs/Pages/QueryTable.fs +++ /dev/null @@ -1,50 +0,0 @@ -module Docs.Pages.QueryTable - -open Feliz -open Feliz.Bulma -open Docs.SharedView - -let QueryTableView = - Html.div [ - Bulma.title.h1 "AzureTackle - QueryTable" - Html.hr [] - Bulma.content [ - Bulma.title.h4 "Connect to your database" - Html.p [ prop.dangerouslySetInnerHTML "Get the connection from the environment" ] - linedMockupCode """ - open AzureTackle - let connectionString() = Env.getVar "app_db""" - ] - ] - -let code = - """ - let data = - connectionString() - |> AzureTackle.connect - |> AzureTackle.query - " - SELECT * FROM Trades - ORDER BY timestamp desc - " - |> AzureTackle.execute (fun read -> - { Symbol = read.string "Symbol" - Timestamp = read.dateTime "Timestamp" - Price = read.double "Price" - TradeSize = read.double "TradeSize" }) - |> function - | Ok x -> x - | otherwise -> - printfn "error %A" otherwise - fail () """ - -let title = Html.text "AzureTackle" - -[] -let QueryTable () = - Html.div [ - Bulma.content [ - codedView title code QueryTableView - ] - fixDocsView "QueryTable" false - ] diff --git a/src/docs/Pages/Upsert.fs b/src/docs/Pages/Upsert.fs new file mode 100755 index 0000000..b37fb90 --- /dev/null +++ b/src/docs/Pages/Upsert.fs @@ -0,0 +1,60 @@ +module Docs.Pages.Upsert + +open Feliz +open Feliz.Bulma +open Docs.SharedView + +let UpsertView = + Html.div [ + Bulma.title.h1 "AzureTackle - Upsert" + Html.hr [] + Bulma.content [ + Bulma.title.h4 "Connect to your database" + Html.p [ prop.dangerouslySetInnerHTML "Get the connection from the environment" ] + linedMockupCode """ + open AzureTackle + let connectionString() = Env.getVar "app_db + """ + ] + ] + +let code = + """ + let tableProps = AzureTable.withConnectionString ("UseDevelopmentStorage=true", TestTable) + let mapper = fun (tableEntity :TableEntity) -> + { + PartKey = tableEntity.PartitionKey + RowKey = tableEntity.RowKey + ValidFrom = tableEntity.ReadDateTimeOffset("ValidFrom") + ValidTo = tableEntity.ReadOptionalDateTimeOffset("ValidTo") + Exists = tableEntity.ReadBoolean("Exists") + Value = tableEntity.GetDouble("Value").Value + ValueDecimal = tableEntity.ReadDecimal("ValueDecimal") + Text = tableEntity.GetString("Text") + } + + let! values = + tableProps + |> AzureTable.execute (fun read -> + { + PartKey = read.PartitionKey + RowKey = read.RowKey + ValidFrom = read.ReadDateTimeOffset("ValidFrom") + ValidTo = read.ReadOptionalDateTimeOffset "ValidTo" + Exists = read.ReadBoolean "Exists" + Value = read.ReadDouble "Value" + ValueDecimal = read.ReadDecimal "ValueDecimal" + Text = read.ReadString "Text" + }) + """ + +let title = Html.text "AzureTackle" + +[] +let Upsert () = + Html.div [ + Bulma.content [ + codedView title code UpsertView + ] + fixDocsView "Upsert" false + ] diff --git a/src/docs/Pages/Use.fs b/src/docs/Pages/Use.fs index a78acac..fdbdfa5 100755 --- a/src/docs/Pages/Use.fs +++ b/src/docs/Pages/Use.fs @@ -9,12 +9,9 @@ let UseView () = React.fragment [ Html.divClassed "description" [ Html.text "After installation just open proper namespace:" ] Html.divClassed "max-w-xl" [ linedMockupCode "open AzureTackle" ] - Html.divClassed - "description" - [ Html.text "Now you can start using library. Everything important starts with " - Html.code [ - prop.className "code" - prop.text "ChartJS.*" - ] - Html.text " module." ] + Html.divClassed "description" [ + Html.text "Now you can start using library. Everything important starts with " + Html.code [ prop.className "code"; prop.text "AzureTable.*" ] + Html.text " module." + ] ] diff --git a/src/docs/Router.fs b/src/docs/Router.fs index 170d98e..cce604b 100755 --- a/src/docs/Router.fs +++ b/src/docs/Router.fs @@ -7,11 +7,9 @@ open Fable.Core.JsInterop type Page = | Install | Use - | QueryTable - | HandleNullValues - | ProvidingDefaultValues - | ParameterizedQuery - | InsertData + | Execute + | Upsert + | Filter [] module Page = @@ -20,11 +18,9 @@ module Page = let parseFromUrlSegments = function | [ "use" ] -> Use - | [ "querytable" ] -> QueryTable - | [ "handlenullvalues" ] -> HandleNullValues - | [ "providingdefaultvalues" ] -> ProvidingDefaultValues - | [ "parameterizedquery" ] -> ParameterizedQuery - | [ "insertdata" ] -> InsertData + | [ "execute" ] -> Execute + | [ "upsert" ] -> Upsert + | [ "filter" ] -> Filter | _ -> defaultPage let noQueryString segments : string list * (string * string) list = segments, [] @@ -33,11 +29,9 @@ module Page = function | Install -> [] |> noQueryString | Use -> ["use"] |> noQueryString - | QueryTable -> ["querytable"] |> noQueryString - | HandleNullValues -> ["handlenullvalues"] |> noQueryString - | ProvidingDefaultValues -> ["providingdefaultvalues"] |> noQueryString - | ParameterizedQuery -> ["parameterizedquery"] |> noQueryString - | InsertData -> [ "insertdata" ] |> noQueryString + | Execute -> ["execute"] |> noQueryString + | Upsert -> ["upsert"] |> noQueryString + | Filter -> ["filter"] |> noQueryString [] module Router = diff --git a/src/docs/View.fs b/src/docs/View.fs index e8506a9..cc74f08 100755 --- a/src/docs/View.fs +++ b/src/docs/View.fs @@ -28,37 +28,31 @@ let private rightSide state dispatch (title: string) (docLink: string) elm = Daisy.drawerContent [ Daisy.navbar [ Daisy.navbarStart [ - Html.divClassed - "lg:hidden" - [ Daisy.button.label [ - button.square - button.ghost - prop.htmlFor "main-menu" - prop.children [ - Svg.svg [ - svg.viewBox (0, 0, 24, 24) - svg.className "inline-block w-6 h-6 stroke-current" - svg.children [ - Svg.path [ - svg.d "M4 6h16M4 12h16M4 18h16" - svg.strokeWidth 2 - ] - ] - ] - ] - ] ] + Html.divClassed "lg:hidden" [ + Daisy.button.label [ + button.square + button.ghost + prop.htmlFor "main-menu" + prop.children [ + Svg.svg [ + svg.viewBox (0, 0, 24, 24) + svg.className "inline-block w-6 h-6 stroke-current" + svg.children [ Svg.path [ svg.d "M4 6h16M4 12h16M4 18h16"; svg.strokeWidth 2 ] ] + ] + ] + ] + ] ] ] - Html.divClassed - "px-5 py-5" - [ Html.h2 [ - color.textPrimary - ++ prop.className "my-6 text-5xl font-bold" - prop.text title - ] + Html.divClassed "px-5 py-5" [ + Html.h2 [ + color.textPrimary ++ prop.className "my-6 text-5xl font-bold" + prop.text title + ] - elm ] + elm + ] ] let private leftSide (p: Page) = @@ -68,24 +62,18 @@ let private leftSide (p: Page) = prop.href mp prop.onClick Router.goToUrl if p = mp then - (menuItem.active - ++ prop.className "justify-between") + (menuItem.active ++ prop.className "justify-between") else prop.className "justify-between" - prop.children [ - Html.span t - Html.span [ - prop.className "badge" - prop.text b - ] - ] + prop.children [ Html.span t; Html.span [ prop.className "badge"; prop.text b ] ] ] ] let mi (t: string) (mp: Page) = Html.li [ Html.a [ - if p = mp then menuItem.active + if p = mp then + menuItem.active prop.text t prop.href mp prop.onClick Router.goToUrl @@ -93,26 +81,19 @@ let private leftSide (p: Page) = ] Daisy.drawerSide [ - Daisy.drawerOverlay [ - prop.htmlFor "main-menu" - ] + Daisy.drawerOverlay [ prop.htmlFor "main-menu" ] Html.aside [ prop.className "flex flex-col border-r w-80 bg-base-100 text-base-content" prop.children [ - Html.divClassed - "inline-block text-3xl font-title px-5 py-5 font-bold" - [ Html.span [ - color.textPrimary - prop.text "AzureTackle" - ] - Html.a [ - prop.href "https://www.nuget.org/packages/AzureTackle" - prop.children [ - Html.img [ - prop.src "https://img.shields.io/nuget/v/AzureTackle.svg?style=flat-square" - ] - ] - ] ] + Html.divClassed "inline-block text-3xl font-title px-5 py-5 font-bold" [ + Html.span [ color.textPrimary; prop.text "AzureTackle" ] + Html.a [ + prop.href "https://www.nuget.org/packages/AzureTackle" + prop.children [ + Html.img [ prop.src "https://img.shields.io/nuget/v/AzureTackle.svg?style=flat-square" ] + ] + ] + ] Daisy.menu [ menu.md prop.className "flex flex-col p-4 pt-0" @@ -120,8 +101,10 @@ let private leftSide (p: Page) = Daisy.menuTitle [ Html.span "Docs" ] mi "Install" Install mi "Use" Use - mi "QueryTable" QueryTable - ] + mi "Execute" Execute + mi "Upsert" Upsert + mi "Filter" Filter + ] ] ] ] @@ -135,9 +118,7 @@ let private inLayout state dispatch (title: string) (docLink: string) (p: Page) Daisy.drawer [ prop.className "lg:drawer-open" prop.children [ - Daisy.drawerToggle [ - prop.id "main-menu" - ] + Daisy.drawerToggle [ prop.id "main-menu" ] rightSide state dispatch title docLink elm leftSide p ] @@ -152,18 +133,12 @@ let AppView (state: State) (dispatch: Msg -> unit) = match state.Page with | Install -> "Installation", "/docs/install", Pages.Install.InstallView() | Use -> "How to use", "/docs/use", Pages.Use.UseView() - | QueryTable -> "QueryTable", "/querytable", Pages.QueryTable.QueryTable() + | Execute -> "Execute", "/execute", Pages.Execute.Execute() + | Upsert -> "Upsert", "/upsert", Pages.Upsert.Upsert() | _ -> "Not found", "", Html.text "Not found" React.router [ router.hashMode - router.onUrlChanged ( - Page.parseFromUrlSegments - >> UrlChanged - >> dispatch - ) - router.children [ - content - |> inLayout state dispatch title docLink state.Page - ] + router.onUrlChanged (Page.parseFromUrlSegments >> UrlChanged >> dispatch) + router.children [ content |> inLayout state dispatch title docLink state.Page ] ] diff --git a/src/docs/views/AzureTackle/AzureTackle.fs b/src/docs/views/AzureTackle/AzureTackle.fs deleted file mode 100644 index bd09013..0000000 --- a/src/docs/views/AzureTackle/AzureTackle.fs +++ /dev/null @@ -1,31 +0,0 @@ -module AzureTackle - -open Feliz -open Feliz.Bulma -open Shared -let overview = - Html.div [ - Bulma.title.h1 [ - Html.text "AzureTackle - Overview" - Html.a [ - prop.href "https://www.nuget.org/packages/AzureTackle/" - prop.children [ - Html.img [ - prop.src "https://img.shields.io/nuget/v/AzureTackle.svg?style=flat" - ] - ] - ] - ] - Bulma.subtitle.h2 [ - Html.text "Thin F# API for AzureTackle for easy data access to AzureTackle database with functional seasoning on top" - ] - Html.hr [] - Bulma.title.h2 "Installation" - Html.hr [] - Bulma.content [ - code "dotnet add package AzureTackle" - code ".paket/paket.exe add AzureTackle --project path/to/project.fsproj" - ] - fixDocsView "AzureTackle" - ] - diff --git a/src/docs/views/AzureTackle/HandleNullValues.fs b/src/docs/views/AzureTackle/HandleNullValues.fs deleted file mode 100644 index 629dd60..0000000 --- a/src/docs/views/AzureTackle/HandleNullValues.fs +++ /dev/null @@ -1,30 +0,0 @@ -module HandleNullValues - -open Feliz -open Feliz.Bulma -open Shared -let overview = - Html.div [ - Bulma.title.h1 [ - Html.text "AzureTackle - HandleNullValues" - Html.a [ - prop.href "https://www.nuget.org/packages/AzureTackle/" - prop.children [ - Html.img [ - prop.src "https://img.shields.io/nuget/v/AzureTackle.svg?style=flat" - ] - ] - ] - ] - Bulma.subtitle.h2 [ - Html.text "Thin F# API for AzureTackle for easy data access to AzureTackle database with functional seasoning on top" - ] - Html.hr [] - Bulma.content [ - Html.p "dotnet add package AzureTackle" - Html.p ".paket/paket.exe add AzureTackle --project path/to/project.fsproj" - ] - fixDocsView "HandleNullValues" - - ] - diff --git a/src/docs/views/AzureTackle/InsertData.fs b/src/docs/views/AzureTackle/InsertData.fs deleted file mode 100644 index 4e65ffa..0000000 --- a/src/docs/views/AzureTackle/InsertData.fs +++ /dev/null @@ -1,36 +0,0 @@ -module InsertData - -open Feliz -open Feliz.Bulma -open Shared - -let overview = - Html.div [ - Bulma.title.h1 "AzureTackle - InsertData" - Bulma.content [ - Bulma.title.h4 "Connect to your database" - Html.p [ prop.dangerouslySetInnerHTML "Get the connection from the environment" ] - code """ - open AzureTackle - let connectionString() = Env.getVar "app_db""" - ] - Html.hr [] - Bulma.content [ - Bulma.title.h4 "Insert trade data into database with commandInsert" - code """ - connectionString() - |> AzureTackle.connect - |> AzureTackle.commandInsert("Trades,trades) - |> AzureTackle.insertData trades - |> function - | Ok x -> - printfn "rows affected %A" x.Length - pass () - | otherwise -> - printfn "error %A" otherwise - fail () """ - ] - fixDocsView "InsertData" - - ] - diff --git a/src/docs/views/AzureTackle/ParameterizedQuery.fs b/src/docs/views/AzureTackle/ParameterizedQuery.fs deleted file mode 100644 index 8acfa5c..0000000 --- a/src/docs/views/AzureTackle/ParameterizedQuery.fs +++ /dev/null @@ -1,29 +0,0 @@ -module ParameterizedQuery - -open Feliz -open Feliz.Bulma -open Shared -let overview = - Html.div [ - Bulma.title.h1 [ - Html.text "AzureTackle - Docs are WIP" - Html.a [ - prop.href "https://www.nuget.org/packages/AzureTackle/" - prop.children [ - Html.img [ - prop.src "https://img.shields.io/nuget/v/AzureTackle.svg?style=flat" - ] - ] - ] - ] - Bulma.subtitle.h2 [ - Html.text "Thin F# API for AzureTackle for easy data access to AzureTackle database with functional seasoning on top" - ] - Html.hr [] - Bulma.content [ - Html.p "dotnet add package AzureTackle" - Html.p ".paket/paket.exe add AzureTackle --project path/to/project.fsproj" - ] - fixDocsView "ParameterizedQuery" - - ] diff --git a/src/docs/views/AzureTackle/ProvidingDefaultValues.fs b/src/docs/views/AzureTackle/ProvidingDefaultValues.fs deleted file mode 100644 index 22e8b2e..0000000 --- a/src/docs/views/AzureTackle/ProvidingDefaultValues.fs +++ /dev/null @@ -1,29 +0,0 @@ -module ProvidingDefaultValues - -open Feliz -open Feliz.Bulma -open Shared -let overview = - Html.div [ - Bulma.title.h1 [ - Html.text "AzureTackle - ProvidingDefaultValues" - Html.a [ - prop.href "https://www.nuget.org/packages/AzureTackle/" - prop.children [ - Html.img [ - prop.src "https://img.shields.io/nuget/v/Chia.svg?style=flat" - ] - ] - ] - ] - Bulma.subtitle.h2 [ - Html.text "Thin F# API for AzureTackle for easy data access to AzureTackle database with functional seasoning on top" - ] - Html.hr [] - Bulma.content [ - Html.p "dotnet add package AzureTackle" - Html.p ".paket/paket.exe add AzureTackle --project path/to/project.fsproj" - ] - fixDocsView "ProvidingDefaultValues" - - ] diff --git a/src/docs/views/AzureTackle/QueryTable.fs b/src/docs/views/AzureTackle/QueryTable.fs deleted file mode 100644 index 4a0f520..0000000 --- a/src/docs/views/AzureTackle/QueryTable.fs +++ /dev/null @@ -1,56 +0,0 @@ -module QueryTable - -open Feliz -open Feliz.Bulma -open Shared -let overview = - Html.div [ - Bulma.title.h1 "AzureTackle - QueryTable" - Html.hr [] - Bulma.content [ - Bulma.title.h4 "Connect to your database" - Html.p [ prop.dangerouslySetInnerHTML "Get the connection from the environment" ] - code """ - open AzureTackle - let connectionString() = Env.getVar "app_db""" - ] - Html.hr [] - Bulma.content [ - Bulma.title.h4 "Query data from to your database" - code """ - let data = - connectionString() - |> AzureTackle.connect - |> AzureTackle.query - " - SELECT * FROM Trades - ORDER BY timestamp desc - " - |> AzureTackle.execute (fun read -> - { Symbol = read.string "Symbol" - Timestamp = read.dateTime "Timestamp" - Price = read.double "Price" - TradeSize = read.double "TradeSize" }) - |> function - | Ok x -> x - | otherwise -> - printfn "error %A" otherwise - fail () """ - ] - fixDocsView "QueryTable" - - ] - - -// type User = { Id: int; Username: string } - -// let getUsers() : Result = -// connectionString() -// |> AzureTackle.connect -// |> AzureTackle.query "SELECT * FROM dbo.[Users]" -// |> AzureTackle.execute (fun read -> -// { -// Id = read.int "user_id" -// Username = read.string "username" -// }) -// ```