From 5485b05e78b1d37d64cfd8e0052ab5b59647c2c3 Mon Sep 17 00:00:00 2001 From: seshukm Date: Thu, 20 Apr 2017 12:32:32 +0530 Subject: [PATCH] SDN controller issues IssueId : CLIENT-197 Change-Id: I047cd82c9c9fd2db3f63b52468e18810ec30b12a Signed-off-by: seshukm --- .../main/webapp/extsys/sdncontroller/index.html | 2 +- .../webapp/extsys/sdncontroller/js/DataService.js | 80 ++++++++++++++++++++++ .../extsys/sdncontroller/templates/controller.html | 2 +- .../src/main/webapp/resmgr/sdn-resmgr/ne/neRest.js | 2 +- 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 extsys/src/main/webapp/extsys/sdncontroller/js/DataService.js diff --git a/extsys/src/main/webapp/extsys/sdncontroller/index.html b/extsys/src/main/webapp/extsys/sdncontroller/index.html index 1a0d84f1..942a86bb 100644 --- a/extsys/src/main/webapp/extsys/sdncontroller/index.html +++ b/extsys/src/main/webapp/extsys/sdncontroller/index.html @@ -37,7 +37,7 @@ - + diff --git a/extsys/src/main/webapp/extsys/sdncontroller/js/DataService.js b/extsys/src/main/webapp/extsys/sdncontroller/js/DataService.js new file mode 100644 index 00000000..f374bbd8 --- /dev/null +++ b/extsys/src/main/webapp/extsys/sdncontroller/js/DataService.js @@ -0,0 +1,80 @@ +app.factory("DataService", function($http, $log) { + return { + /** + * + * @param url - url of the service + * @param data - data as an object (used as query string in url) + * @returns {*} + */ + get: function (url, data) { + if(data) { + url += "?"; + for(key in data){ + url += key+ "=" + data[key]; + } + } + return $http({ + url: url, + method: 'GET', + data: null, + headers: {'Content-Type': 'application/json'} + }).then(function (response) { + return response.data; + }); + }, + /** + * + * @param url - url of the service + * @param data - data as an object (used for post method) + * @returns {*} + */ + post: function (url, data) { + return $http({ + url: url, + method: 'POST', + data: data, + headers: {'Content-Type': 'application/json '} + }).then(function (response) { + console.log("Response : "); + $log.info(response.data); + return response.data; + }); + }, + /** + * TODO - To Check for Delete + * @param url + * @param data + * @returns {*} + */ + delete: function (url) { + return $http({ + url: url, + method: 'DELETE', + data: null, + headers: {'Content-Type': 'application/json '} + }).then(function (response) { + console.log("Response : "); + $log.info(response.data); + return response.data; + }); + }, + /** + * + * @param url + * @param data + */ + put: function (url, data) { + return $http({ + url: url, + method: 'PUT', + data: data, + headers: {'Content-Type': 'application/json '} + }).then(function (response) { + console.log("Response : "); + $log.info(response.data); + return response.data; + }); + } + + } +}) \ No newline at end of file diff --git a/extsys/src/main/webapp/extsys/sdncontroller/templates/controller.html b/extsys/src/main/webapp/extsys/sdncontroller/templates/controller.html index 3e914d0e..1aab2bdf 100644 --- a/extsys/src/main/webapp/extsys/sdncontroller/templates/controller.html +++ b/extsys/src/main/webapp/extsys/sdncontroller/templates/controller.html @@ -80,7 +80,7 @@