Skip to content

Commit

Permalink
Bumping version to 0.16.24
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Dec 18, 2018
1 parent b9871a1 commit f8a2b03
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 41 deletions.
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release Notes

## 0.16.23 - 2018-12-15
## 0.16.24 - 2018-12-18
* Update to ASP.NET 2.2

## 0.15.11 - 2018-11-05
Expand All @@ -18,7 +18,7 @@
## 0.11.21 - 2018-10-23
* Next/Previous buttons

## 0.10.37 - 2018-10-23<>
## 0.10.37 - 2018-10-23
* Use better UI

## 0.9.7 - 2018-10-18
Expand Down
6 changes: 3 additions & 3 deletions src/Client/ReleaseNotes.fs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module internal ReleaseNotes

let Version = "0.16.23"
let Version = "0.16.24"

let IsPrerelease = false

let Notes = """
# Release Notes
## 0.16.23 - 2018-12-15
## 0.16.24 - 2018-12-18
* Update to ASP.NET 2.2
## 0.15.11 - 2018-11-05
Expand All @@ -25,7 +25,7 @@ let Notes = """
## 0.11.21 - 2018-10-23
* Next/Previous buttons
## 0.10.37 - 2018-10-23<>
## 0.10.37 - 2018-10-23
* Use better UI
## 0.9.7 - 2018-10-18
Expand Down
50 changes: 20 additions & 30 deletions src/PiServer/PiServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ type Msg =
| NewRFID of string
| CheckFirmware
| FirmwareUpToDate of unit
| ExecuteActions of TagAction list
| ExecuteAction of TagActionForBox
| RFIDRemoved
| DiscoverStartup
| NewTag of Tag
| NewTag of TagForBox
| Play of PlayList
| NextMediaFile
| PreviousMediaFile
Expand Down Expand Up @@ -116,7 +116,7 @@ let resolveRFID (model:Model,token:string) = task {
let url = sprintf @"%s/api/tags/%s/%s" model.TagServer model.UserID token
let! result = webClient.DownloadStringTaskAsync(System.Uri url)

match Decode.fromString Tag.Decoder result with
match Decode.fromString TagForBox.Decoder result with
| Error msg -> return failwith msg
| Ok tag -> return tag
}
Expand Down Expand Up @@ -181,12 +181,12 @@ let checkFirmware (model:Model) = task {
log.ErrorFormat("Upgrade error: {0}", exn.Message)
}

let getStartupActions (model:Model) = task {
let getStartupAction (model:Model) = task {
use webClient = new System.Net.WebClient()
let url = sprintf @"%s/api/startup" model.TagServer
let! result = webClient.DownloadStringTaskAsync(System.Uri url)

match Decode.fromString (Decode.list TagAction.Decoder) result with
match Decode.fromString (TagActionForBox.Decoder) result with
| Error msg -> return failwith msg
| Ok actions -> return actions
}
Expand All @@ -209,7 +209,7 @@ let update (msg:Msg) (model:Model) =

| NewTag tag ->
log.InfoFormat("Got new tag from server: {0}", tag)
model, Cmd.ofMsg (ExecuteActions [tag.Action])
model, Cmd.ofMsg (ExecuteAction tag.Action)

| Play playList ->
let model = { model with PlayList = Some playList }
Expand Down Expand Up @@ -253,7 +253,7 @@ let update (msg:Msg) (model:Model) =
model, Cmd.none

| DiscoverStartup ->
model, Cmd.ofTask getStartupActions model ExecuteActions Err
model, Cmd.ofTask getStartupAction model ExecuteAction Err

| FirmwareUpToDate _ ->
log.InfoFormat("Firmware {0} is uptodate.", ReleaseNotes.Version)
Expand All @@ -264,29 +264,19 @@ let update (msg:Msg) (model:Model) =
[fun dispatch -> rfidLoop (dispatch,model.NodeServices) |> Async.AwaitTask |> Async.StartImmediate ]
]

| ExecuteActions actions ->
match actions with
| action::rest ->
match action with
| TagAction.UnknownTag ->
log.Warn "Unknown Tag"
model, Cmd.ofMsg (ExecuteActions rest)
| TagAction.StopMusik ->
model, Cmd.batch [Cmd.ofMsg (FinishPlaylist()); Cmd.ofMsg (ExecuteActions rest) ]
| TagAction.PlayMusik urls ->
let playList : PlayList = {
MediaFiles = urls
Position = 0
}
model, Cmd.batch [Cmd.ofMsg (Play playList); Cmd.ofMsg (ExecuteActions rest) ]
| TagAction.PlayYoutube _ ->
log.Error "Youtube links need to be converted to direct links by the tag server"
model, Cmd.ofMsg (ExecuteActions rest)
| TagAction.PlayBlobMusik _ ->
log.Error "Blobs links need to be converted to direct links by the tag server"
model, Cmd.ofMsg (ExecuteActions rest)
| _ -> model, Cmd.none

| ExecuteAction action ->
match action with
| TagActionForBox.UnknownTag ->
log.Warn "Unknown Tag"
model, Cmd.none
| TagActionForBox.StopMusik ->
model, Cmd.ofMsg (FinishPlaylist())
| TagActionForBox.PlayMusik urls ->
let playList : PlayList = {
MediaFiles = urls
Position = 0
}
model, Cmd.batch [Cmd.ofMsg (Play playList) ]
| Err exn ->
log.ErrorFormat("Error: {0}", exn.Message)
model, Cmd.none
Expand Down
17 changes: 11 additions & 6 deletions src/Server/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ let uploadEndpoint (token:string) =
let file = form.Files.[0]
use stream = file.OpenReadStream()
let! tagAction = uploadMusik stream
let tag = { Token = System.Guid.NewGuid().ToString(); Action = tagAction; Description = ""; Object = "" }
let tag : Tag = { Token = System.Guid.NewGuid().ToString(); Action = tagAction; Description = ""; Object = "" }
let! _saved = AzureTable.saveTag token tag
let! tag = mapBlobMusikTag tag
let txt = Tag.Encoder tag |> Encode.toString 0
Expand All @@ -133,7 +133,13 @@ let tagEndpoint (userID,token) =
| _ -> task { return { Token = token; Action = TagAction.UnknownTag; Description = ""; Object = "" } }

let! tag = tag |> mapYoutube
let txt = Tag.Encoder tag |> Encode.toString 0
let tag : TagForBox = {
Token = tag.Token
Object = tag.Object
Description = tag.Description
Action = TagActionForBox.GetFromTagAction tag.Action }

let txt = TagForBox.Encoder tag |> Encode.toString 0
return! setBodyFromString txt next ctx
})
}
Expand All @@ -153,12 +159,11 @@ let startupEndpoint =
set_header "Content-Type" "application/json"
plug (fun next ctx -> task {
let! sas = getSASMediaLink "d97cdddb-8a19-4690-8ba5-b8ea43d3641f"
let actions = [ TagAction.PlayMusik [| sas |] ]
let action = TagActionForBox.PlayMusik [| sas |]

let txt =
actions
|> List.map TagAction.Encoder
|> Encode.list
action
|> TagActionForBox.Encoder
|> Encode.toString 0
return! setBodyFromString txt next ctx
})
Expand Down
59 changes: 59 additions & 0 deletions src/Shared/Shared.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,43 @@ type TagAction =
|> Decode.map TagAction.PlayBlobMusik
]


[<RequireQualifiedAccess>]
type TagActionForBox =
| UnknownTag
| StopMusik
| PlayMusik of string []

static member GetFromTagAction(action:TagAction) =
match action with
| TagAction.StopMusik -> TagActionForBox.StopMusik
| TagAction.UnknownTag -> TagActionForBox.UnknownTag
| TagAction.PlayMusik urls -> TagActionForBox.PlayMusik urls
| _ -> failwithf "Can't convert %A" action

static member Encoder (action : TagActionForBox) =
match action with
| TagActionForBox.UnknownTag ->
Encode.object [
"UnknownTag", Encode.nil
]
| TagActionForBox.StopMusik ->
Encode.object [
"StopMusik", Encode.nil
]
| TagActionForBox.PlayMusik urls ->
Encode.object [
"PlayMusik", Encode.array (Array.map Encode.string urls)
]

static member Decoder =
Decode.oneOf [
Decode.field "UnknownTag" (Decode.succeed TagActionForBox.UnknownTag)
Decode.field "StopMusik" (Decode.succeed TagActionForBox.StopMusik)
Decode.field "PlayMusik" (Decode.array Decode.string)
|> Decode.map TagActionForBox.PlayMusik
]

type Link = {
Token : string
Url : string
Expand Down Expand Up @@ -95,6 +132,28 @@ type Tag =
)


type TagForBox =
{ Token : string
Object : string
Description : string
Action : TagActionForBox }

static member Encoder (tag : TagForBox) =
Encode.object [
"Token", Encode.string tag.Token
"Description", Encode.string tag.Description
"Object", Encode.string tag.Object
"Action", TagActionForBox.Encoder tag.Action
]

static member Decoder =
Decode.object (fun get ->
{ Token = get.Required.Field "Token" Decode.string
Object = get.Required.Field "Object" Decode.string
Description = get.Required.Field "Description" Decode.string
Action = get.Required.Field "Action" TagActionForBox.Decoder }
)


type TagList =
{ Tags : Tag [] }
Expand Down

0 comments on commit f8a2b03

Please sign in to comment.