Skip to content

Commit

Permalink
Merge pull request #19 from tforkmann/extend-docs
Browse files Browse the repository at this point in the history
work on more docs
  • Loading branch information
tforkmann authored Jun 21, 2024
2 parents 06d2d90 + 412d78f commit 8b71d20
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 375 deletions.
3 changes: 2 additions & 1 deletion src/docs/Docs.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<Compile Include="SharedView.fs" />
<Compile Include="Pages/Install.fs" />
<Compile Include="Pages/Use.fs" />
<Compile Include="Pages/QueryTable.fs" />
<Compile Include="Pages/Execute.fs" />
<Compile Include="Pages/Upsert.fs" />
<Compile Include="View.fs" />
<Compile Include="App.fs" />
<Content Include="index.html" />
Expand Down
60 changes: 60 additions & 0 deletions src/docs/Pages/Execute.fs
Original file line number Diff line number Diff line change
@@ -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"

[<ReactComponent>]
let Execute () =
Html.div [
Bulma.content [
codedView title code ExecuteView
]
fixDocsView "Execute" false
]
35 changes: 14 additions & 21 deletions src/docs/Pages/Install.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] ]
]
]

]
50 changes: 0 additions & 50 deletions src/docs/Pages/QueryTable.fs

This file was deleted.

60 changes: 60 additions & 0 deletions src/docs/Pages/Upsert.fs
Original file line number Diff line number Diff line change
@@ -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"

[<ReactComponent>]
let Upsert () =
Html.div [
Bulma.content [
codedView title code UpsertView
]
fixDocsView "Upsert" false
]
13 changes: 5 additions & 8 deletions src/docs/Pages/Use.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
]
24 changes: 9 additions & 15 deletions src/docs/Router.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ open Fable.Core.JsInterop
type Page =
| Install
| Use
| QueryTable
| HandleNullValues
| ProvidingDefaultValues
| ParameterizedQuery
| InsertData
| Execute
| Upsert
| Filter

[<RequireQualifiedAccess>]
module Page =
Expand All @@ -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, []
Expand All @@ -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

[<RequireQualifiedAccess>]
module Router =
Expand Down
Loading

0 comments on commit 8b71d20

Please sign in to comment.