Splitting cmds in services
Change-Id: I7caaf9807f28ada80b82df2bd8afa3d6ed3b0caa
diff --git a/views/ngXosViews/UITutorial/src/js/responseHandler.js b/views/ngXosViews/UITutorial/src/js/responseHandler.js
new file mode 100644
index 0000000..28146b5
--- /dev/null
+++ b/views/ngXosViews/UITutorial/src/js/responseHandler.js
@@ -0,0 +1,21 @@
+(function () {
+ 'use strict';
+ angular.module('xos.UITutorial')
+ .service('ResponseHandler', function(){
+ this.parse = (res, done) => {
+ // TODO @Arpit format res (it can be an array or an object),
+ // it is better if the output is a valid JSON (that we can copy and paste)
+ // TODO handle 204/No-Content response
+ if(angular.isArray(res)){
+ res = res.map(i => {
+ return JSON.stringify(i, ['id', 'name', 'max_instances'], 2) + '<br/>';
+ });
+ }
+ else {
+ res = JSON.stringify(res, ['id', 'name', 'max_instances'], 2);
+ }
+
+ done(res);
+ };
+ });
+})();
\ No newline at end of file