Skip to content

Commit

Permalink
refactor the URL building, so it becomes more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
klaernie committed Apr 2, 2023
1 parent d6fc20d commit ec5adc9
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions MMM-GrafanaChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,35 @@ Module.register("MMM-GrafanaChart", {
Log.info("Starting module: " + this.name);
this.scheduleUpdate();
},

buildUrl: function() {
var URL = "";
URL += this.config.protocol + "://";
URL += this.config.host + ":" + this.config.port;
if (this.config.version == "6") {
URL += "/d-solo/" + this.config.id;
} else{
URL += "/dashboard-solo/db";
}
URL += "/" + this.config.dashboardname;
URL += "?orgId=" + this.config.orgId;
URL += "&panelId=" + this.config.panelId;
URL += "&from=" + this.config.from;
URL += "&to=" + this.config.to
if (this.config.version == "6") {
URL += "&fullscreen&kiosk";
}
return URL;
},

// Override dom generator.
getDom: function() {
var iframe = document.createElement("IFRAME");
iframe.style = "border:0"
iframe.width = this.config.width;
iframe.height = this.config.height;
iframe.scrolling = this.config.scrolling;
if (this.config.version == "6") {
iframe.src = this.config.protocol + "://" + this.config.host + ":" + this.config.port + "/d-solo/" + this.config.id + "/" + this.config.dashboardname + "?orgId=" + this.config.orgId + "&panelId=" + this.config.panelId + "&from=" + this.config.from + "&to=" + this.config.to + "&fullscreen&kiosk";
} else{
iframe.src = this.config.protocol + "://" + this.config.host + ":" + this.config.port + "/dashboard-solo/db/" + this.config.dashboardname+ "?orgId=" + this.config.orgId + "&panelId=" + this.config.panelId + "&from=" + this.config.from + "&to=" + this.config.to;;
}
iframe.setAttribute("timestamp", new Date().getTime());
iframe.setAttribute("scrolling", "no");
return iframe;
},
scheduleUpdate: function() {
Expand Down

0 comments on commit ec5adc9

Please sign in to comment.