Skip to content

Commit 616b9b3

Browse files
committed
ENH: added dashboard api functions
1 parent 34bcd83 commit 616b9b3

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/Plotly.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Plotly
44

55
using URIParser
66
using Reexport
7+
using JSON
78
@reexport using PlotlyJS
89
export set_credentials_file, RemotePlot, download_plot, savefig_remote, post
910

@@ -64,6 +65,7 @@ Post a local Plotly plot to the Plotly cloud.
6465
Must be signed in first.
6566
"""
6667
function post(p::Plot; fileopt=get_config().fileopt, filename=nothing, kwargs...)
68+
JSON.lower(p)
6769
fileopt = Symbol(fileopt)
6870
grid_fn = string(filename, "_", "Grid")
6971
clean_p = srcify(p; fileopt=fileopt, grid_fn=grid_fn, kwargs...)
@@ -98,6 +100,8 @@ function post(p::Plot; fileopt=get_config().fileopt, filename=nothing, kwargs...
98100
end
99101

100102
function post_v1(p::Plot; kwargs...)
103+
# call JSON.lower to apply themes
104+
JSON.lower(p)
101105
config = get_config()
102106
default_kwargs = Dict{Symbol,Any}(:filename=>"Plot from Julia API",
103107
:world_readable=> config.world_readable)

src/utils.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using JSON
1+
struct PlotlyError
2+
msg::String
3+
end
24

35
struct PlotlyCredentials
46
username::String

src/v2.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ file_writeable_metadata = [
254254
:parent_path, :filename, :parent, :share_key_enabled, :world_readable
255255
]
256256
grid_writable_metadata = vcat(file_writeable_metadata, [:])
257+
dashboard_writeable_metadata = [
258+
:content, :filename, :parent, :parent_path, :world_readable
259+
]
257260
for _api in [
258261
# search
259262
ApiCall(:search_list, :get, :search, false, required=[:q])
@@ -328,6 +331,16 @@ for _api in [
328331
ApiCall(:comment_create, :post, :comments, false, required_json=[:fid, :comment])
329332
ApiCall(:comment_delete, :delete, :comments, true)
330333

334+
# dashboards
335+
ApiCall(:dashboard_create, :post, :dashboards, false, required_json=[:content])
336+
ApiCall(:dashboard_list, :get, :dashboards, false)
337+
ApiCall(:dashboard_retrieve, :get, :dashboards, true)
338+
ApiCall(:dashboard_update, :put, :dashboards, true, json=dashboard_writeable_metadata)
339+
ApiCall(:dashboard_partial_update, :patch, :dashboards, true, json=dashboard_writeable_metadata)
340+
ApiCall(:dashboard_trash, :post, :dashboards, true, :trash)
341+
ApiCall(:dashboard_permanent_delete, :delete, :dashboards, true, :permanent_delete, data_out=false)
342+
ApiCall(:dashboard_schema, :get, :dashboards, false, :schema)
343+
331344
# plot-schema
332345
ApiCall(:plot_schema_get, :get, Symbol("plot-schema"), required=[:sha1])
333346
]

0 commit comments

Comments
 (0)