diff options
author | 2017-05-09 14:24:20 -0400 | |
---|---|---|
committer | 2017-05-09 14:44:09 -0400 | |
commit | e2aefda183de4f1c1256d97f7ce09f8bee5477db (patch) | |
tree | 4b0eaf3f153df90591711daf081e63a8b20ace74 /dcae_dmaapbc_webapp/dbca-overlay/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js | |
parent | 472635713b7471b300a988db7e907bab0119eaee (diff) |
[ONAP-rebase] Rebase as 1.1.0-SNAPSHOT
Consolidate into a single maven project; no more separate model and client jars.
Change-Id: Ibbba982250b74c0dfd09ee1c65c0fb6c158dd632
Signed-off-by: Christopher Lott <cl778h@att.com>
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'dcae_dmaapbc_webapp/dbca-overlay/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js')
-rw-r--r-- | dcae_dmaapbc_webapp/dbca-overlay/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/dcae_dmaapbc_webapp/dbca-overlay/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js b/dcae_dmaapbc_webapp/dbca-overlay/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js new file mode 100644 index 0000000..8f777e6 --- /dev/null +++ b/dcae_dmaapbc_webapp/dbca-overlay/src/main/webapp/app/dbcapp/messagerouter/mr-topic-service.js @@ -0,0 +1,86 @@ +appDS2.factory('MRTopicService', function ($http, $q, $log) { + return { + /** + * Gets one page of message router topic objects. + * @param {Number} pageNum - page number; e.g., 1 + * @param {Number} viewPerPage - number of items per page; e.g., 25 + * @return {JSON} Response object from remote side + */ + getTopicsByPage: function(pageNum,viewPerPage) { + // cache control for IE + var cc = "&cc=" + new Date().getTime().toString(); + return $http({ + method: 'GET', + url: 'mr_topic?pageNum=' + pageNum + '&viewPerPage=' + viewPerPage + cc, + cache: false, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRTopicService.getTopicsByPage: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRTopicService.getTopicsByPage failed: ' + JSON.stringify(error)); + return $q.reject(error.statusText); + }); + }, + + // Creates a new topic. + addTopic: function(topic) { + return $http({ + method: 'POST', + url: 'mr_topic', + data: topic, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRTopicService.addTopic: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRTopicService.addTopic failed: ' + JSON.stringify(error)); + return $q.reject(error.statusText); + }); + }, + + // Updates an existing topic. + updateTopic: function(topic) { + return $http({ + method: 'PUT', + url: 'mr_topic/' + topic.fqtn, + data: topic, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRTopicService.updateTopic: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRTopicService.updateTopic failed: ' + JSON.stringify(error)); + return $q.reject(error.statusText); + }); + }, + + // Deletes the topic with the specified FQTN. + deleteTopic: function(fqtn) { + return $http({ + method: 'DELETE', + url: 'mr_topic/' + fqtn, + responseType: 'json' }) + .then(function(response) { + if (response.data == null || typeof response.data != 'object') + return $q.reject('MRTopicService.deleteTopic: response.data null or not object'); + else + return response.data; + }, + function(error) { + $log.error('MRTopicService.deleteTopic failed: ' + JSON.stringify(error)); + return $q.reject(error.statusText); + }); + }, + + }; +}); |