Skip to content

Commit 7524284

Browse files
committed
New widget: StaticIFrame
1 parent 73341d4 commit 7524284

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export default class StaticIFrame {
2+
static defaultConfig = {
3+
type: "StaticIFrame",
4+
title: "Inline Frame",
5+
src: "https://example.com/",
6+
options: {},
7+
icon: "bi bi-window",
8+
w: 8,
9+
h: 6,
10+
};
11+
static formConfig = {
12+
title: {
13+
type: "text",
14+
label: "Tooltip",
15+
},
16+
src: {
17+
type: "text",
18+
label: "URL",
19+
},
20+
};
21+
22+
constructor(root, config) {
23+
this.root = d3.select(root);
24+
this.config = config;
25+
26+
this.src = config.src || "";
27+
}
28+
29+
clear() {
30+
this.root.select("iframe").remove();
31+
}
32+
33+
init() {
34+
this.render(this.src);
35+
}
36+
37+
render(data) {
38+
this.clear();
39+
40+
this.root
41+
.append("iframe")
42+
.attr("src", data)
43+
.attr("width", "100%")
44+
.attr("height", "100%");
45+
46+
this.root.classed("overflow-hidden", true);
47+
}
48+
}

src/main/resources/static/js/widgets/widgets.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import StaticImage from "./static/StaticImage.js";
22
import StaticText from "./static/StaticText.js";
33
import StaticVideo from "./static/StaticVideo.js";
4+
import StaticIFrame from "./static/StaticIFrame.js";
45

56
import BarChart from "./charts/BarChart.js";
67
import LineChart from "./charts/LineChart.js";
@@ -16,6 +17,7 @@ export default {
1617
StaticText,
1718
StaticImage,
1819
StaticVideo,
20+
StaticIFrame,
1921

2022
BarChart,
2123
PieChart,

0 commit comments

Comments
 (0)