Skip to content

Commit

Permalink
Bumping version to 0.0.35
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 5, 2018
1 parent db6cc79 commit d9794cd
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Release Notes

## 0.0.34 - 2018-10-05
## 0.0.35 - 2018-10-05

* Initial release
4 changes: 3 additions & 1 deletion src/Client/Client.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ let runIn (timeSpan:System.TimeSpan) successMsg errorMsg =
Cmd.ofPromise p () (fun _ -> successMsg) errorMsg


let userID = "9bb2b109-bf08-4342-9e09-f4ce3fb01c0f"

let fetchData() = promise {
let! res = Fetch.fetch "api/alltags" []
let! res = Fetch.fetch (sprintf "api/usertags/%s" userID) []
let! txt = res.text()

match Decode.fromString TagList.Decoder txt with
Expand Down
4 changes: 2 additions & 2 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.0.34"
let Version = "0.0.35"

let IsPrerelease = false

let Notes = """
# Release Notes
## 0.0.34 - 2018-10-05
## 0.0.35 - 2018-10-05
* Initial release
"""
5 changes: 4 additions & 1 deletion src/PiServer/PiServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ open System.Threading.Tasks
let tagServer = "https://audio-hub.azurewebsites.net"
// let tagServer = "http://localhost:8085"

let userID = "9bb2b109-bf08-4342-9e09-f4ce3fb01c0f"


let port = 8086us

let isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
Expand Down Expand Up @@ -68,7 +71,7 @@ let executeAction (nodeServices : INodeServices) (action:TagAction) =

let executeTag (nodeServices : INodeServices) (tag:string) = task {
use webClient = new System.Net.WebClient()
let tagsUrl tag = sprintf @"%s/api/tags/%s" tagServer tag
let tagsUrl tag = sprintf @"%s/api/tags/%s/%s" tagServer userID tag
let! result = webClient.DownloadStringTaskAsync(System.Uri (tagsUrl tag))

match Decode.fromString Tag.Decoder result with
Expand Down
29 changes: 19 additions & 10 deletions src/Server/AzureTable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,24 @@ let saveTag (userID:string) (tag:Tag) =
tagsTable.ExecuteAsync operation


let getTag userID token = task {
#if DEBUG
let tags =
[| { Token = "celeb"; Action = TagAction.PlayMusik (sprintf @"%s/custom/%s" URLs.mp3Server "Celebrate") }
{ Token = "stop"; Action = TagAction.StopMusik } |]

let getTag (userID:string) token = task {
return
tags
|> Array.tryFind (fun x -> x.Token = token)
}


let getAllTagsForUser (userID:string) = task {
return tags
}

#else
let getTag (userID:string) token = task {
let query = TableOperation.Retrieve(userID, token)
let! r = tagsTable.ExecuteAsync(query)
if r.HttpStatusCode <> 200 then
Expand All @@ -162,15 +179,7 @@ let getTag userID token = task {
if isNull result then return None else return Some(mapTag result)
}


#if DEBUG
let getAllTagsForUser userID = task {
return
[| { Token = "celeb"; Action = TagAction.PlayMusik (sprintf @"%s/custom/%s" URLs.mp3Server "Celebrate") }
{ Token = "stop"; Action = TagAction.StopMusik } |]
}
#else
let getAllTagsForUser userID = task {
let getAllTagsForUser (userID:string) = task {
let rec getResults token = task {
let query = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, userID)
let! result = tagsTable.ExecuteQuerySegmentedAsync(TableQuery(FilterString = query), token)
Expand Down
15 changes: 6 additions & 9 deletions src/Server/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ let publicPath = Path.GetFullPath "client"
let audioPath = Path.GetFullPath "../../audio"


let xs = [for x in System.Environment.GetEnvironmentVariables().Keys -> string x ]


let allTagsEndpoint =
let allTagsEndpoint userID =
pipeline {
set_header "Content-Type" "application/json"
plug (fun next ctx -> task {
let! tags = AzureTable.getAllTagsForUser "[email protected]"
let! tags = AzureTable.getAllTagsForUser userID
let txt = TagList.Encoder { Tags = tags } |> Encode.toString 0
return! setBodyFromString txt next ctx
})
Expand All @@ -40,12 +37,12 @@ let mp3Endpoint fileName =
})
}

let tagEndpoint token =
let tagEndpoint (userID,token) =
pipeline {
set_header "Content-Type" "application/json"
plug (fun next ctx -> task {

let! tag = AzureTable.getTag "[email protected]" token
let! tag = AzureTable.getTag userID token
let tag =
match tag with
| Some t -> t
Expand Down Expand Up @@ -90,8 +87,8 @@ let firmwareEndpoint =
let webApp =
router {
getf "/api/audio/mp3/%s" mp3Endpoint
getf "/api/tags/%s" tagEndpoint
get "/api/alltags" allTagsEndpoint
getf "/api/tags/%s/%s" tagEndpoint
getf "/api/usertags/%s" allTagsEndpoint
get "/api/startup" startupEndpoint
get "/api/firmware" firmwareEndpoint
}
Expand Down

0 comments on commit d9794cd

Please sign in to comment.