-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created observation view, date not yet included
continued modelling necessary types
- Loading branch information
1 parent
433edb8
commit d8ea62a
Showing
10 changed files
with
307 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
namespace PRo3D.Base | ||
|
||
open System | ||
open Adaptify | ||
open Aardvark.Base | ||
open FSharp.Data.Adaptive | ||
open Aardvark.UI | ||
open Aardvark.UI.Operators | ||
open Aardvark.UI.Generic | ||
open PRo3D.Base | ||
|
||
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | ||
module Calendar = | ||
[<ReferenceEquality; NoComparison>] | ||
type Thing<'a> = { value : 'a } | ||
let inline thing a = { value = a } | ||
|
||
type CalendarAction = | ||
| SetDateString of string | ||
| SetDate of DateTime | ||
| SetDateJs of list<string> | ||
|
||
let parseDate (dateString : string) = | ||
let sucess, date = DateTime.TryParse dateString | ||
if sucess then | ||
date | ||
else | ||
let dateString = String.trimc '"' dateString | ||
let sucess, date = DateTime.TryParse dateString | ||
if sucess then | ||
date | ||
else | ||
Log.error "[Calendar] Could not parse date %s" dateString | ||
DateTime.Now | ||
|
||
let update (m : Calendar) (msg : CalendarAction) = | ||
match msg with | ||
| SetDateString str -> | ||
let result = DateTime.TryParse str | ||
match result with | ||
| true, date -> | ||
Log.line "setting date %s" str | ||
{m with date = date} | ||
| _ -> | ||
Log.error "[Calendar] Could not parse date %s" str | ||
m | ||
| SetDate date -> | ||
{m with date = date} | ||
| SetDateJs lst -> | ||
match lst with | ||
| [] -> | ||
Log.warn "[Calendar] received empty list from js." | ||
m | ||
| date::tail -> | ||
{m with date = parseDate date} | ||
|
||
let view (m : AdaptiveCalendar) (centre : bool) (disabled : bool) = | ||
let bootCode = | ||
String.concat ";" [ | ||
yield | ||
sprintf "$('#__ID__').calendar({ | ||
type:'date', | ||
className: {table: 'ui inverted celled center aligned unstackable table'}, | ||
onChange: function(newDate){ | ||
console.log(newDate); | ||
var oldDate = $(this).calendar('get date'); | ||
if(!oldDate || oldDate != newDate) { | ||
aardvark.processEvent('__ID__', 'onDateChange', newDate.toLocaleDateString()); | ||
} | ||
} | ||
});" | ||
] | ||
|
||
let attributes = | ||
seq { | ||
yield clazz "ui inverted calendar" | ||
yield onEvent "onDateChange" [] (fun x -> SetDateJs x) | ||
if centre then | ||
yield style "display: flex;align-items: center;;justify-content: center" | ||
} |> Seq.toList | ||
|
||
let divClass = | ||
if disabled then | ||
"ui inverted disabled input left icon" | ||
else | ||
"ui inverted input left icon" | ||
|
||
require (Html.semui) ( | ||
onBoot bootCode ( | ||
div attributes [ | ||
div [clazz divClass; | ||
] [ | ||
i [clazz "inverted calendar icon"] [] | ||
input [attribute "placeholder" "Select date"] | ||
] | ||
] | ||
) | ||
) | ||
|
||
let init = | ||
{ | ||
date = DateTime.Now | ||
minDate = None | ||
maxDate = None | ||
label = None | ||
} | ||
|
||
let fromDate date = | ||
{ | ||
date = date | ||
minDate = None | ||
maxDate = None | ||
label = None | ||
} | ||
|
||
let withMinMax date minDate maxDate = | ||
{ | ||
date = date | ||
minDate = Some minDate | ||
maxDate = Some maxDate | ||
label = None | ||
} | ||
|
||
let withLabel date minDate maxDate label = | ||
{ | ||
date = date | ||
minDate = Some minDate | ||
maxDate = Some maxDate | ||
label = label | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace PRo3D.Base | ||
|
||
open System | ||
open Adaptify | ||
open Aardvark.Base | ||
open FSharp.Data.Adaptive | ||
|
||
[<ModelType>] | ||
type Calendar = { | ||
date : DateTime | ||
minDate : option<DateTime> | ||
maxDate : option<DateTime> | ||
label : option<string> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
namespace PRo3D.Core.Gis | ||
|
||
|
||
open Aardvark.Base | ||
open Aardvark.UI | ||
open PRo3D.Base | ||
open PRo3D.Core | ||
open FSharp.Data.Adaptive | ||
open PRo3D.Core.Surface | ||
open PRo3D.Base.GisModels | ||
open Aether | ||
|
||
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | ||
module ObservationInfo = | ||
let update (m : ObservationInfo) (msg : ObservationInfoAction) = | ||
match msg with | ||
| ObservationInfoAction.CalendarMessage msg -> | ||
{m with time = Calendar.update m.time msg} | ||
| ObservationInfoAction.SetTarget target -> | ||
{m with target = target} | ||
| ObservationInfoAction.SetObserver observer -> | ||
{m with observer = observer} | ||
| ObservationInfoAction.SetTime time -> | ||
{m with time = {m.time with date = time}} | ||
| ObservationInfoAction.SetReferenceFrame frame -> | ||
{m with referenceFrame = frame} | ||
|
||
let view (m : AdaptiveObservationInfo) | ||
(entities : amap<System.Guid, Entity>) | ||
(referenceFrames : amap<FrameSpiceName, ReferenceFrame>) = | ||
|
||
let entityDropdownText entity = | ||
match Entity.spiceName entity with | ||
| Some name -> name | ||
| None -> "---" | ||
|
||
let observerDropdown = | ||
UI.dropDownWithEmptyText | ||
(entities | ||
|> AMap.toASet | ||
|> ASet.toAList | ||
|> AList.map snd) | ||
m.observer | ||
(fun x -> SetObserver x) | ||
(fun x -> entityDropdownText x) | ||
"Select Observer" | ||
let targetDropdown = | ||
UI.dropDownWithEmptyText | ||
(entities | ||
|> AMap.toASet | ||
|> ASet.toAList | ||
|> AList.map snd) | ||
m.target | ||
(fun x -> SetTarget x) | ||
(fun x -> entityDropdownText x) | ||
"Select Target" | ||
|
||
let frameDropdown = | ||
UI.dropDownWithEmptyText | ||
(referenceFrames | ||
|> AMap.toASet | ||
|> ASet.toAList | ||
|> AList.map snd) | ||
m.referenceFrame | ||
(fun x -> SetReferenceFrame x) | ||
(fun x -> x.spiceName.Value) | ||
"Select Frame" | ||
|
||
require GuiEx.semui ( | ||
Html.table [ | ||
Html.row "Observer:" [observerDropdown] | ||
Html.row "Target:" [targetDropdown] | ||
//Html.row "Time:" [Calendar.view m.time false false] | ||
// |> UI.map CalendarMessage | ||
Html.row "Reference Frame:" [frameDropdown] | ||
] | ||
) | ||
|
||
let inital = | ||
{ | ||
target = None | ||
observer = None | ||
time = Calendar.init | ||
referenceFrame = None | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.