Clean up to prepare new version of API
[src/app-framework-demo.git] / afm-client / app / Frontend / widgets / ActionButtons / AppliButton.js
index 269ee81..a10030c 100644 (file)
                     scope.runmode   = urlquery.runmode || "auto";
                     scope.clicked = function () {
 
-                        var notifyError = function(action, response) {
+                        var notifyError = function(action, jresp) {
                             Notification.error ({message: "Fail /api/afm-main" + action + "=" + scope.label + " RunID="+ scope.appID, delay: 5000});
                             elem.addClass ("fail");
                             elem.removeClass ("success");
-                            scope.callback (scope.appID, action, response);
+                            scope.callback (scope.appID, action, jresp);
                         };
                         
-                        var notifySuccess = function (action, response) {
+                        var notifySuccess = function (action, jresp) {
                             elem.removeClass ("fail");
-                            scope.runID = response.data.response.runid;
-                            scope.callback (scope.appID, action, response);
+                            scope.runID = jresp.response.runid;
+                            scope.callback (scope.appID, action, jresp);
                         };
                         
                         var closeModApp = function() {
                                 
                                 case "start":
                                     if (scope.runstatus !== "stop") return;
-                                    AppCall.get ("afm-main", "start", {id: scope.appID, mode: scope.runmode}, function(response) {
-                                        if (response.status !== 200 || response.data.jtype !== "afb-reply") {
-                                            notifyError ("start", response);
+                                    AppCall.get ("afm-main", "start", {id: scope.appID, mode: scope.runmode}, function(jresp, errcode) {
+                                        if (errcode !== 200 || jresp.jtype !== "afb-reply") {
+                                            notifyError ("start", jresp);
                                             return;
                                         }
                                         scope.runstatus="start";
-                                        notifySuccess (action, response);
+                                        notifySuccess (action, jresp);
                                        if(response.data.response.uri)
                                             scope.winapp= $window.open(response.data.response.uri.replace("%h", $location.host()));                                            
                                     });
                                 case "stop":
                                     if (scope.runstatus !== "start") return;
                                     
-                                    AppCall.get ("afm-main", "terminate", {runid: scope.runID}, function(response) {
-                                        if (response.status !== 200 || response.data.jtype !== "afb-reply") {
-                                            notifyError ("stop", response);
+                                    AppCall.get ("afm-main", "terminate", {runid: scope.runID}, function(jresp, errcode) {
+                                        if (errcode !== 200 || jresp.jtype !== "afb-reply") {
+                                            notifyError ("stop", jresp);
                                             return;
                                         }
                                         scope.runstatus="stop";
                                            scope.winapp.close();
                                            scope.winapp=false;
                                         }
-                                        notifySuccess (action, response);
+                                        notifySuccess (action, jresp);
                                     });
                                     break;
                                         
                                 case "info":
-                                    AppCall.get ("afm-main", "detail", {id: scope.appID}, function(response) {
-                                        if (response.status !== 200 || response.data.jtype !== "afb-reply") {
-                                            notifyError ("detail", response);
+                                    AppCall.get ("afm-main", "detail", {id: scope.appID}, function(jresp, errcode) {
+                                        if (errcode !== 200 || jresp.jtype !== "afb-reply") {
+                                            notifyError ("detail", jresp);
                                             return;
                                         }
                                                                                
 
                                 case "uninstall":
                                     if (scope.runstatus !== "stop") return;
-                                    AppCall.get ("afm-main", "uninstall", {id: scope.appID}, function(response) {
-                                        if (response.status !== 200 || response.data.jtype !== "afb-reply") {
-                                            notifyError ("uninstall", response);
+                                    AppCall.get ("afm-main", "uninstall", {id: scope.appID}, function(jresp, errcode) {
+                                        if (errcode !== 200 || jresp.jtype !== "afb-reply") {
+                                            notifyError ("uninstall", jresp);
                                             return;
                                         }
                                         
-                                        notifySuccess (action, response);
+                                        notifySuccess (action, jresp);
                                     });
                                     break;