From c3d527f2bc011cd622eee353b9e4ef2b7e6ab059 Mon Sep 17 00:00:00 2001 From: baldo Date: Tue, 7 Jun 2016 14:40:05 +0200 Subject: [PATCH] Fix: HTTP handling was broken after updating libs. --- app/scripts/controllers/deleteNodeCtrl.js | 5 +++-- app/scripts/controllers/newNodeCtrl.js | 6 +++--- app/scripts/controllers/updateNodeCtrl.js | 6 +++--- app/scripts/directives/nodeForm.js | 6 +++--- app/scripts/directives/tokenForm.js | 4 ++-- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/scripts/controllers/deleteNodeCtrl.js b/app/scripts/controllers/deleteNodeCtrl.js index c935854..4d8e09d 100644 --- a/app/scripts/controllers/deleteNodeCtrl.js +++ b/app/scripts/controllers/deleteNodeCtrl.js @@ -9,10 +9,11 @@ angular.module('ffffng') $scope.onSubmitToken = function (token) { $scope.token = token; return NodeService.getNode(token) - .success(function (node) { + .then(function (response) { + var node = response.data; ConfirmDeletionDialog.open(node).result.then(function () { NodeService.deleteNode(token) - .success(function () { + .then(function () { $scope.deleted = true; $scope.hostname = node.hostname; }); diff --git a/app/scripts/controllers/newNodeCtrl.js b/app/scripts/controllers/newNodeCtrl.js index ec7de24..f8e0f22 100644 --- a/app/scripts/controllers/newNodeCtrl.js +++ b/app/scripts/controllers/newNodeCtrl.js @@ -16,9 +16,9 @@ angular.module('ffffng') $scope.save = function (node) { return NodeService.createNode(node) - .success(function (response) { - $scope.node = response.node; - $scope.token = response.token; + .then(function (response) { + $scope.node = response.data.node; + $scope.token = response.data.token; $scope.saved = true; }); }; diff --git a/app/scripts/controllers/updateNodeCtrl.js b/app/scripts/controllers/updateNodeCtrl.js index 21d38b7..44b825d 100644 --- a/app/scripts/controllers/updateNodeCtrl.js +++ b/app/scripts/controllers/updateNodeCtrl.js @@ -21,9 +21,9 @@ angular.module('ffffng') $scope.save = function (node) { return NodeService.updateNode(node, $scope.token) - .success(function (response) { - $scope.node = response.node; - $scope.token = response.token; + .then(function (response) { + $scope.node = response.data.node; + $scope.token = response.data.token; $scope.saved = true; }); }; diff --git a/app/scripts/directives/nodeForm.js b/app/scripts/directives/nodeForm.js index 961fc78..1f10ae4 100644 --- a/app/scripts/directives/nodeForm.js +++ b/app/scripts/directives/nodeForm.js @@ -159,11 +159,11 @@ angular.module('ffffng') } $scope.error = null; - $scope.save(node).catch(function (response, code) { + $scope.save(node).catch(function (response) { // error - switch (code) { + switch (response.status) { case 409: // conflict - $scope.error = duplicateError[response.field]; + $scope.error = duplicateError[response.data.field]; break; default: $scope.error = 'Es ist ein Fehler aufgetreten. Versuche es später noch einmal.'; diff --git a/app/scripts/directives/tokenForm.js b/app/scripts/directives/tokenForm.js index 1655367..62f2adc 100644 --- a/app/scripts/directives/tokenForm.js +++ b/app/scripts/directives/tokenForm.js @@ -15,8 +15,8 @@ angular.module('ffffng') $scope.error = null; $scope.onSubmit(token) - .catch(function (response, code) { - switch (code) { + .catch(function (response) { + switch (response.status) { case 404: // not found $scope.error = 'Zum Token wurde kein passender Eintrag gefunden.'; break;