Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions hubigraph_time_graph.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,30 @@ preferences {


mappings {
path("/graph/") {
path("/graph/") { // retained for preview from parent app
action: [
GET: "getGraph"
]
}
path("/graph") {
action: [
GET: "getGraph"
]
}

path("/getData/") {
path("/getData") {
action: [
GET: "getData"
]
}

path("/getOptions/") {
path("/getOptions") {
action: [
GET: "getOptions"
]
}

path("/getSubscriptions/") {
path("/getSubscriptions") {
action: [
GET: "getSubscriptions"
]
Expand Down Expand Up @@ -816,11 +821,19 @@ def mainPage() {
}
parent.hubiForm_section(this, "Local Graph URL", 1, "link"){
container = [];
container << parent.hubiForm_text(this, "${fullLocalApiServerUrl("")}graph/?access_token=${state.endpointSecret}",
"${fullLocalApiServerUrl("")}graph/?access_token=${state.endpointSecret}");
container << parent.hubiForm_text(this, "${fullLocalApiServerUrl('graph')}?access_token=${state.endpointSecret}",
"${fullLocalApiServerUrl('graph')}?access_token=${state.endpointSecret}");

parent.hubiForm_container(this, container, 1);
}
parent.hubiForm_section(this, "Remote Graph URL", 1, "link"){
container = [];
container << parent.hubiForm_text(this, "${fullApiServerUrl('graph')}?access_token=${state.endpointSecret}",
"${fullApiServerUrl('graph')}?access_token=${state.endpointSecret}");

parent.hubiForm_container(this, container, 1);
}


if (graph_timespan!=null){
parent.hubiForm_section(this, "Preview", 10, "show_chart"){
Expand Down Expand Up @@ -1189,23 +1202,23 @@ class Loader {
}

function getOptions() {
return jQuery.get("${fullLocalApiServerUrl("")}getOptions/?access_token=${state.endpointSecret}", (data) => {
return jQuery.get("${request?.requestSource == 'local' ? fullLocalApiServerUrl('getOptions') : fullApiServerUrl('getOptions')}?access_token=${state.endpointSecret}", (data) => {
options = data;
console.log("Got Options");
console.log(options);
});
}

function getSubscriptions() {
return jQuery.get("${fullLocalApiServerUrl("")}getSubscriptions/?access_token=${state.endpointSecret}", (data) => {
return jQuery.get("${request?.requestSource == 'local' ? fullLocalApiServerUrl('getSubscriptions') : fullApiServerUrl('getSubscriptions')}?access_token=${state.endpointSecret}", (data) => {
console.log("Got Subscriptions");
subscriptions = data;

});
}

function getGraphData() {
return jQuery.get("${fullLocalApiServerUrl("")}getData/?access_token=${state.endpointSecret}", (data) => {
return jQuery.get("${request?.requestSource == 'local' ? fullLocalApiServerUrl('getData') : fullApiServerUrl('getData')}?access_token=${state.endpointSecret}", (data) => {
console.log("Got Graph Data");
graphData = data;
});
Expand Down Expand Up @@ -1688,12 +1701,12 @@ def getOverlay(){
def getDateStringEvent(date) {
def dateObj = date
def yyyy = dateObj.getYear() + 1900
def MM = String.format("%02d", dateObj.getMonth()+1);
def dd = String.format("%02d", dateObj.getDate());
def HH = String.format("%02d", dateObj.getHours());
def mm = String.format("%02d", dateObj.getMinutes());
def ss = String.format("%02d", dateObj.getSeconds());
def dateString = /$yyyy-$MM-$dd $HH:$mm:$ss.000/;
def MM = String.format("%02d", dateObj.getMonth()+1)
def dd = String.format("%02d", dateObj.getDate())
def HH = String.format("%02d", dateObj.getHours())
def mm = String.format("%02d", dateObj.getMinutes())
def ss = String.format("%02d", dateObj.getSeconds())
def dateString = /$yyyy-$MM-$dd $HH:$mm:$ss.000/
dateString
}

Expand All @@ -1703,8 +1716,8 @@ def initializeAppEndpoint() {
def accessToken = createAccessToken()
if (accessToken) {
state.endpoint = getApiServerUrl()
state.localEndpointURL = fullLocalApiServerUrl("")
state.remoteEndpointURL = fullApiServerUrl("/graph")
state.localEndpointURL = fullLocalApiServerUrl
state.remoteEndpointURL = fullApiServerUrl
state.endpointSecret = accessToken
}
}
Expand Down Expand Up @@ -1849,3 +1862,4 @@ def getColorCode(code){
}
return ret;
}