Skip to content

Commit 7234810

Browse files
committed
use assetregistry to serve files
1 parent 6e6706a commit 7234810

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ JSON
66
TableTraits
77
IteratorInterfaceExtensions
88
Observables
9+
AssetRegistry

deps/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ag-grid

deps/build.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
isdir(joinpath(@__DIR__, "ag-grid")) || mkdir(joinpath(@__DIR__, "ag-grid"))
4+
5+
ag_grid_base = joinpath(@__DIR__, "ag-grid", "ag-grid.js")
6+
isfile(ag_grid_base) || download("https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.noStyle.js", ag_grid_base)
7+
8+
ag_grid_base_style = joinpath(@__DIR__, "ag-grid", "ag-grid.css")
9+
isfile(ag_grid_base_style) || download("https://unpkg.com/ag-grid-community/dist/styles/ag-grid.css", ag_grid_base_style)
10+
11+
ag_grid_light = joinpath(@__DIR__, "ag-grid", "ag-grid-light.css")
12+
isfile(ag_grid_light) || download("https://unpkg.com/ag-grid-community/dist/styles/ag-theme-balham.css", ag_grid_light)
13+
14+
ag_grid_dark = joinpath(@__DIR__, "ag-grid", "ag-grid-dark.css")
15+
isfile(ag_grid_dark) || download("https://unpkg.com/ag-grid-community/dist/styles/ag-theme-balham-dark.css", ag_grid_dark)

deps/build.log

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
% Total % Received % Xferd Average Speed Time Time Time Current
2+
Dload Upload Total Spent Left Speed
3+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 85 100 85 0 0 464 0 --:--:-- --:--:-- --:--:-- 461
4+
100 794k 100 794k 0 0 3933k 0 --:--:-- --:--:-- --:--:-- 3933k
5+
% Total % Received % Xferd Average Speed Time Time Time Current
6+
Dload Upload Total Spent Left Speed
7+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 71 100 71 0 0 353 0 --:--:-- --:--:-- --:--:-- 353
8+
100 55483 100 55483 0 0 255k 0 --:--:-- --:--:-- --:--:-- 255k
9+
% Total % Received % Xferd Average Speed Time Time Time Current
10+
Dload Upload Total Spent Left Speed
11+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 79 100 79 0 0 387 0 --:--:-- --:--:-- --:--:-- 389
12+
100 88197 100 88197 0 0 377k 0 --:--:-- --:--:-- --:--:-- 377k
13+
% Total % Received % Xferd Average Speed Time Time Time Current
14+
Dload Upload Total Spent Left Speed
15+
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 84 100 84 0 0 497 0 --:--:-- --:--:-- --:--:-- 497
16+
100 91448 100 91448 0 0 493k 0 --:--:-- --:--:-- --:--:-- 493k

src/TableView.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ module TableView
22
using Tables, TableTraits, IteratorInterfaceExtensions
33
using WebIO, JSExpr, JSON, Dates
44
using Observables: @map
5+
using AssetRegistry
6+
7+
const ag_grid_imports = []
8+
9+
function __init__()
10+
empty!(ag_grid_imports)
11+
for f in ["ag-grid.js", "ag-grid.css", "ag-grid-light.css", "ag-grid-dark.css"]
12+
path = normpath(joinpath(@__DIR__, "..", "deps", "ag-grid", f))
13+
AssetRegistry.register(path)
14+
push!(ag_grid_imports, path)
15+
end
16+
end
517

618
function showtable(x; dark = false)
719
iit = TableTraits.isiterabletable(x)
@@ -29,9 +41,7 @@ function _showtable(table, dark)
2941
names = schema.names
3042
types = schema.types
3143
end
32-
w = Scope(imports=["https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.noStyle.js",
33-
"https://unpkg.com/ag-grid-community/dist/styles/ag-grid.css",
34-
"https://unpkg.com/ag-grid-community/dist/styles/ag-theme-balham$(dark ? "-dark" : "").css",])
44+
w = Scope(imports=ag_grid_imports)
3545

3646
coldefs = [(
3747
headerName = n,
@@ -47,8 +57,8 @@ function _showtable(table, dark)
4757

4858
w.dom = dom"div#grid"(className = "ag-theme-balham$(dark ? "-dark" : "")",
4959
style = Dict("width" => "100%",
50-
"min-width" => "400px",
51-
"height" => "800px"))
60+
"min-width" => "400px",
61+
"height" => "800px"))
5262
w
5363
end
5464

0 commit comments

Comments
 (0)