diff --git a/src/rest/frontend/res/js/app.js b/src/rest/frontend/res/js/app.js
index a3e352c8004..3875af069cf 100644
--- a/src/rest/frontend/res/js/app.js
+++ b/src/rest/frontend/res/js/app.js
@@ -122,24 +122,24 @@
$scope.isLoading = false;
$scope.showScanAlert = function(ev,response) {
- var text;
+ var alertMessage;
if (response.status == 200)
{
- text = 'No available thread network now'
+ alertMessage = 'No available thread network now'
}
else
{
if ('ErrorDescription' in response.data)
{
- text = response.data.ErrorDescription;
+ alertMessage = response.data.ErrorDescription;
}
else if ('ErorMessage' in response.data)
{
- text= response.data.ErorMessage;
+ alertMessage= response.data.ErorMessage;
}
else
{
- text = 'Undefined response';
+ alertMessage = 'Undefined response';
}
}
@@ -148,31 +148,31 @@
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title('Information')
- .textContent(text)
+ .textContent(alertMessage)
.ariaLabel('Alert Dialog Demo')
.ok('Okay')
);
};
$scope.showStatusAlert = function(ev,response) {
- var text;
+ var alertMessage;
if ('ErrorDescription' in response.data)
{
- text = response.data.ErrorDescription;
+ alertMessage = response.data.ErrorDescription;
}
else if ('ErrorMessage' in response.data)
{
- text= response.data.ErrorMessage ;
+ alertMessage= response.data.ErrorMessage ;
}
else
{
- text = 'Undefined response';
+ alertMessage = 'Undefined response';
}
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title('Information')
- .textContent(text)
+ .textContent(alertMessage)
.ariaLabel('Alert Dialog Demo')
.ok('Okay')
);
@@ -180,7 +180,7 @@
$scope.showPanels = function(index) {
$scope.headerTitle = $scope.menu[index].title;
- for (var i = 0; i <= 6; i++) {
+ for (var i = 0; i < 7; i++) {
$scope.menu[i].show = false;
}
$scope.menu[index].show = true;
@@ -275,24 +275,24 @@
$scope.showAlert = function(ev, response) {
- var text;
+ var alertMessage;
if (response.status == 200)
{
- text = 'Successful'
+ alertMessage = 'Successful'
}
else
{
if ('ErrorDescription' in response.data)
{
- text = response.data.ErrorDescription;
+ alertMessage = response.data.ErrorDescription;
}
else if ('ErorMessage' in response.data)
{
- text= response.data.ErorMessage;
+ alertMessage= response.data.ErorMessage;
}
else
{
- text = 'Failed bacause of Undefined response';
+ alertMessage = 'Failed bacause of Undefined response';
}
}
@@ -301,7 +301,7 @@
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title('Information')
- .textContent('Join operation is ' + text)
+ .textContent('Join operation is ' + alertMessage)
.ariaLabel('Alert Dialog Demo')
.ok('Okay')
.targetEvent(ev)
@@ -411,24 +411,24 @@
};
$scope.showAlert = function(ev, operation, response) {
- var text;
+ var alertMessage;
if (response.status == 200)
{
- text = 'Successful';
+ alertMessage = 'Successful';
}
else
{
if ('ErrorDescription' in response.data)
{
- text = response.data.ErrorDescription;
+ alertMessage = response.data.ErrorDescription;
}
else if ('ErorMessage' in response.data)
{
- text= response.data.ErorMessage;
+ alertMessage= response.data.ErorMessage;
}
else
{
- text = 'Failed bacause of Undefined response';
+ alertMessage = 'Failed bacause of Undefined response';
}
}
@@ -437,7 +437,7 @@
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title('Information')
- .textContent(operation + ' operation is ' + text)
+ .textContent(operation + ' operation is ' + alertMessage)
.ariaLabel('Alert Dialog Demo')
.ok('Okay')
.targetEvent(ev)
@@ -524,16 +524,14 @@
httpRequest.then(function successCallback(response) {
$scope.showAlert(event, 'Commission', response);
-
ev.target.disabled = false;
+
}, function errorCallback(response){
$scope.showAlert(event, 'Commission', response);
});
};
-
-
// Basic information line
$scope.basicInfo = {
'NetworkName' : 'Unknown',
@@ -546,11 +544,8 @@
$scope.nodeDetailInfo = 'Unknown';
// For response of Diagnostic
$scope.networksDiagInfo = '';
-
- // 0 : not call topology
- // 1 : is loading
- // 2 : topology is ready
- $scope.graphState = 0;
+ $scope.topologyIsReady = false;
+ $scope.topologyIsLoading = false;
$scope.detailList = {
'ExtAddress': { 'title': false, 'content': true },
@@ -599,7 +594,7 @@
$scope.detailList[key]['content'] = !$scope.detailList[key]['content']
}
- $scope.intToHexString = function(num , len){
+ $scope.intToHexString = function(num, len){
var value;
value = num.toString(16);
@@ -610,24 +605,24 @@
}
$scope.showTopologyAlert = function(ev,response) {
- var text;
+ var alertMessage;
if (response.status == 200)
{
- text = 'Empty diagnostic information returned, please check and try again later'
+ alertMessage = 'Empty diagnostic information returned, please check and try again later'
}
else
{
if ('ErrorDescription' in response.data)
{
- text = response.data.ErrorDescription;
+ alertMessage = response.data.ErrorDescription;
}
else if ('ErorMessage' in response.data)
{
- text= response.data.ErorMessage;
+ alertMessage= response.data.ErorMessage;
}
else
{
- text = 'Undefined response';
+ alertMessage = 'Undefined response';
}
}
@@ -636,7 +631,7 @@
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title('Information')
- .textContent(text)
+ .textContent(alertMessage)
.ariaLabel('Alert Dialog Demo')
.ok('Okay')
);
@@ -645,7 +640,8 @@
$scope.showTopology = function(event) {
// Is loading
- $scope.graphState = 1;
+ $scope.topologyIsLoading = true;
+ $scope.topologyIsReady = false;
$scope.graphInfo = {
'nodes': [],
'links': []
@@ -655,18 +651,21 @@
{
$scope.topology(response);
// Loads successfully
- $scope.graphState = 2;
+ $scope.topologyIsLoading = false;
+ $scope.topologyIsReady = true;
}
else{
// Not show anything
- $scope.graphState = 0;
+ $scope.topologyIsReady = false;
+ $scope.topologyIsLoading = false;
$scope.showTopologyAlert(event,response);
}
},
function errorCallback(response){
$scope.showTopologyAlert(event,response);
// Not show anything
- $scope.graphState = 0;
+ $scope.topologyIsReady = false;
+ $scope.topologyIsLoading = false;
}
@@ -700,7 +699,7 @@
rloc = parseInt(diagOfNode['Rloc16'],16).toString(16);
nodeMap[rloc] = count;
- if ( diagOfNode['RouteId'] == diagOfNode['LeaderData']['LeaderRouterId']) {
+ if (diagOfNode['RouteId'] == diagOfNode['LeaderData']['LeaderRouterId']) {
diagOfNode['Role'] = 'Leader';
}
else {
@@ -722,7 +721,7 @@
src = 0;
// Construct links
- for (var diagOfNode of $scope.networksDiagInfo) {
+ for (diagOfNode of $scope.networksDiagInfo) {
if ('ChildTable' in diagOfNode) {
// Link bewtwen routers
for (linkNode of diagOfNode['Route']['RouteData']) {
@@ -733,8 +732,6 @@
$scope.graphInfo.links.push({
'source': src,
'target': dist,
- 'weight': 1,
- 'type': 0,
'linkInfo': {
'inQuality': linkNode['LinkQualityIn'],
'outQuality': linkNode['LinkQualityOut']
@@ -760,8 +757,6 @@
$scope.graphInfo.links.push({
'source': src,
'target': count,
- 'weight': 1,
- 'type': 1,
'linkInfo': {
'Timeout': childInfo['Timeout'],
'Mode': childInfo['Mode']
@@ -1028,7 +1023,7 @@
.style('stroke', '#f39191')
.style('stroke-width', '1px');
$scope.$apply(function() {
- $scope.nodeDetailInfo = item ;
+ $scope.nodeDetailInfo = item;
$scope.updateDetailLabel();
});
});
diff --git a/src/rest/json.cpp b/src/rest/json.cpp
index 12ed74c41ff..0c080842fc9 100644
--- a/src/rest/json.cpp
+++ b/src/rest/json.cpp
@@ -627,7 +627,7 @@ std::string Error2JsonString(HttpStatusCode aErrorCode, std::string aErrorMessag
return ret;
}
-bool JsonString2NetworkConfiguration(std::string aString, NetworkConfiguration &aNetwork)
+bool JsonString2NetworkConfiguration(std::string &aString, NetworkConfiguration &aNetwork)
{
cJSON *value;
cJSON *jsonOut;
@@ -672,6 +672,8 @@ bool JsonString2NetworkConfiguration(std::string aString, NetworkConfiguration &
exit:
+ cJSON_Delete(jsonOut);
+
return ret;
}
@@ -693,6 +695,8 @@ bool JsonString2String(std::string aString, std::string aKey, std::string &aValu
ret = false;
}
+ cJSON_Delete(jsonOut);
+
return ret;
}
bool JsonString2Bool(std::string aString, std::string aKey, bool &aValue)
@@ -715,6 +719,8 @@ bool JsonString2Bool(std::string aString, std::string aKey, bool &aValue)
exit:
+ cJSON_Delete(jsonOut);
+
return ret;
}
@@ -736,6 +742,8 @@ bool JsonString2Int(std::string aString, std::string aKey, int32_t &aValue)
ret = false;
}
+ cJSON_Delete(jsonOut);
+
return ret;
}
diff --git a/src/rest/json.hpp b/src/rest/json.hpp
index b13acdfe616..b80ef6ff7b2 100644
--- a/src/rest/json.hpp
+++ b/src/rest/json.hpp
@@ -104,7 +104,7 @@ std::string Node2JsonString(const NodeInfo &aNode);
/**
* This method formats a vector including serveral Diagnostic object to a Json array and serialize it to a string.
*
- * @param[in] aDiagSet A vector including serveral Diagnostic object.
+ * @param[in] aDiagSet A vector including serveral Diagnostic object.
*
* @returns A string serlialized by a Json array.
*
@@ -124,7 +124,7 @@ std::string IpAddr2JsonString(const otIp6Address &aAddress);
/**
* This method formats extracts prefixes from a list of config object and format them as Json Array.
*
- * @param[in] aConfig an array of config object.
+ * @param[in] aConfig An array of config object.
*
* @returns A string serlialized by a Json Array.
*
@@ -224,7 +224,7 @@ std::string Network2JsonString(const otOperationalDataset &aDataset);
/**
* This method formats an error code and an error message to a Json object and serialize it to a string.
*
- * @param[in] aErrorCode Error code such as '404'.
+ * @param[in] aErrorCode An enum HttpStatusCode such as '404'.
* @param[in] aErrorMessage Error message such as '404 Not Found'.
* @param[in] aDescription Detailed error information.
*
@@ -236,20 +236,20 @@ std::string Error2JsonString(HttpStatusCode aErrorCode, std::string aErrorMessag
/**
* This method decodes a json object to a NetworkConfiguration object .
*
- * @param[in] aString a string contains Json object.
+ * @param[in] aString A string contains Json object.
* @param[out] aNetwork A reference to a NetworkConfiguration instance that could be set within this method.
*
* @returns A bool value that indicates whether the string could be decoded to the NetworkConfiguration object
*
*/
-bool JsonString2NetworkConfiguration(std::string aString, NetworkConfiguration &aNetwork);
+bool JsonString2NetworkConfiguration(std::string &aString, NetworkConfiguration &aNetwork);
/**
* This method decodes a json object to a NetworkConfiguration object .
*
- * @param[in] aString a string contains Json object.
+ * @param[in] aString A string contains Json object.
* @param[in] aKey The key that may exist in the Json object.
- * @param[inout] aValue the string that is the value of the key in this Json object.
+ * @param[inout] aValue The string that is the value of the key in this Json object.
*
* @returns A bool value that indicates whether the key exist in this Json object.
*
@@ -259,9 +259,9 @@ bool JsonString2String(std::string aString, std::string aKey, std::string &aValu
/**
* This method decodes a json object to a bool value .
*
- * @param[in] aString a string contains Json object.
+ * @param[in] aString A string contains Json object.
* @param[in] aKey The key that may exist in the Json object.
- * @param[inout] aValue the bool value that is the value of the key in this Json object.
+ * @param[inout] aValue The bool value that is the value of the key in this Json object.
*
* @returns A bool value that indicates whether the key exist in this Json object.
*
@@ -271,11 +271,11 @@ bool JsonString2Bool(std::string aString, std::string aKey, bool &aValue);
/**
* This method decodes a json object to a bool value .
*
- * @param[in] aString a string contains Json object.
+ * @param[in] aString A string contains Json object.
* @param[in] aKey The key that may exist in the Json object.
- * @param[inout] aValue the integer value that is the value of the key in this Json object.
+ * @param[inout] aValue The integer value that is the value of the key in this Json object.
*
- * @returns An bool value that indicates whether the key exist in this Json object.
+ * @returns A bool value that indicates whether the key exist in this Json object.
*
*/
bool JsonString2Int(std::string aString, std::string aKey, int32_t &aValue);
diff --git a/src/rest/request.hpp b/src/rest/request.hpp
index 110539b683f..e95efef2dbf 100644
--- a/src/rest/request.hpp
+++ b/src/rest/request.hpp
@@ -105,7 +105,7 @@ class Request
/**
* This method returns the HTTP method of this request.
*
- * @returns A enum class representing HTTP method.
+ * @returns An enum class representing HTTP method.
*/
HttpMethod GetMethod() const;
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 829b11e4eb3..8e8aaf77a23 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -27,7 +27,7 @@
#
add_subdirectory(openthread)
-if(OTBR_WEB)
+if(OTBR_REST)
add_subdirectory(cJSON)
add_subdirectory(http-parser)
endif()