Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
iCity
EnergyDashboard
Commits
fcb749b0
Commit
fcb749b0
authored
3 years ago
by
Pithon Kabiro
Browse files
Options
Download
Email Patches
Plain Diff
Attempt at generalizing the url requests
parent
a828b374
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/js/appChart.js
+38
-21
public/js/appChart.js
with
38 additions
and
21 deletions
+38
-21
public/js/appChart.js
+
38
-
21
View file @
fcb749b0
"
use strict
"
;
"
use strict
"
;
// Request parameters
// DEBUG:
// Observations WITHOUT data gap - Bau 225 / Datastream ID = 80
// Observations WITH data gap - Bau 112 / Datastream ID = 78
// Observations WITHOUT data gap - Bau 225
const
BASE_URL
=
"
http://193.196.39.91:8080/frost-icity-tp31/v1.1
"
;
const
BASE_URL
=
"
http://193.196.39.91:8080/frost-icity-tp31/v1.1/Datastreams(80)/Observations
"
;
/**
* Create URL to fetch the Observations corresponding to a provided Datastream
* @param {*} datastreamID - integer representing the Datastream ID
* @returns {String}
*/
const
getObservationsUrl
=
function
(
datastreamID
)
{
if
(
!
datastreamID
)
return
;
const
fullDatastreamURL
=
`
${
BASE_URL
}
/Datastreams(
${
datastreamID
}
)/Observations`
;
return
fullDatastreamURL
;
};
/**
* Create a temporal filter string for the fetched Observations
* @param {*} dateStart - start date in YYYY-MM-DD format
* @param {*} dateStop - stop date in YYYY-MM-DD format
* @returns {String}
*/
const
createTemporalFilterString
=
function
(
dateStart
,
dateStop
)
{
if
(
!
dateStart
||
!
dateStop
)
return
;
const
filterString
=
`resultTime ge
${
dateStart
}
T00:00:00.000Z and resultTime le
${
dateStop
}
T00:00:00.000Z`
;
return
filterString
;
};
const
BASE_URL_OBSERVATIONS
=
getObservationsUrl
(
80
);
const
PARAM_RESULT_FORMAT
=
"
dataArray
"
;
const
PARAM_RESULT_FORMAT
=
"
dataArray
"
;
const
PARAM_ORDER_BY
=
"
phenomenonTime asc
"
;
const
PARAM_ORDER_BY
=
"
phenomenonTime asc
"
;
const
PARAM_FILTER
=
const
PARAM_FILTER
=
createTemporalFilterString
(
"
2020-01-01
"
,
"
2021-01-01
"
);
"
resultTime ge 2020-01-01T00:00:00.000Z and resultTime le 2021-01-01T00:00:00.000Z
"
;
const
PARAM_SELECT
=
"
result,phenomenonTime
"
;
const
PARAM_SELECT
=
"
result,phenomenonTime
"
;
// Observations WITH data gap - Bau 112
const
axiosGetRequest
=
axios
.
get
(
BASE_URL_OBSERVATIONS
,
{
const
BASE_URL2
=
params
:
{
"
http://193.196.39.91:8080/frost-icity-tp31-v2/v1.1/Datastreams(78)/Observations
"
;
"
$resultFormat
"
:
PARAM_RESULT_FORMAT
,
const
PARAM_FILTER2
=
"
$orderBy
"
:
PARAM_ORDER_BY
,
"
resultTime ge 2020-06-01T00:00:00.000Z and resultTime le 2021-01-01T00:00:00.000Z
"
;
"
$filter
"
:
PARAM_FILTER
,
"
$select
"
:
PARAM_SELECT
,
},
});
/**
/**
* Format the response from SensorThings API to make it suitable for heatmap
* Format the response from SensorThings API to make it suitable for heatmap
...
@@ -216,16 +242,7 @@ const followNextLink = function (responsePromise) {
...
@@ -216,16 +242,7 @@ const followNextLink = function (responsePromise) {
};
};
// Get "ALL" the Observations that satisfy our query
// Get "ALL" the Observations that satisfy our query
followNextLink
(
followNextLink
(
axiosGetRequest
)
axios
.
get
(
BASE_URL
,
{
params
:
{
"
$resultFormat
"
:
PARAM_RESULT_FORMAT
,
"
$orderBy
"
:
PARAM_ORDER_BY
,
"
$filter
"
:
PARAM_FILTER
,
"
$select
"
:
PARAM_SELECT
,
},
})
)
.
then
((
success
)
=>
{
.
then
((
success
)
=>
{
const
successValue
=
success
.
data
.
value
;
const
successValue
=
success
.
data
.
value
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets