From 54bbc1321652f7b1b55130fe953ff25548fc1f20 Mon Sep 17 00:00:00 2001 From: HooVee Date: Mon, 15 Aug 2016 21:45:31 +0300 Subject: [PATCH] Made http get calls to functions --- members/static/html/muokkaa_hakemusta.html | 2 +- members/static/js/members_controllers.js | 41 ++++++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/members/static/html/muokkaa_hakemusta.html b/members/static/html/muokkaa_hakemusta.html index 0d71c95..9e24d07 100644 --- a/members/static/html/muokkaa_hakemusta.html +++ b/members/static/html/muokkaa_hakemusta.html @@ -4,7 +4,7 @@
- +
diff --git a/members/static/js/members_controllers.js b/members/static/js/members_controllers.js index 3f4001d..13f4c86 100644 --- a/members/static/js/members_controllers.js +++ b/members/static/js/members_controllers.js @@ -1,13 +1,16 @@ app.controller("getController", function($scope, $http, $window, $location){ $scope.members = []; - $http.get("/members/api/members").then(function(response){ - $scope.members = response.data; - // map trues and falses to more user-friendly format - _.each($scope.members, function(m){ - m.jas = m.jas ? "Kyllä" : "Ei"; - m.AYY = m.AYY ? "Kyllä" : "Ei"; - }); - }); + $scope.getFunction = function() { + $http.get("/members/api/members").then(function(response){ + $scope.members = response.data; + // map trues and falses to more user-friendly format + _.each($scope.members, function(m){ + m.jas = m.jas ? "Kyllä" : "Ei"; + m.AYY = m.AYY ? "Kyllä" : "Ei"; + }); + }); + }; + $scope.getFunction(); $scope.delete_member = function(id) { $http.delete("/members/api/member/" + id).then( function(response) { @@ -26,8 +29,7 @@ app.controller("getController", function($scope, $http, $window, $location){ // ] // http://ned.im/noty/#/about }); - - $location.path("/list"); + $scope.getFunction(); }, function(response) { noty({ @@ -36,7 +38,7 @@ app.controller("getController", function($scope, $http, $window, $location){ type: "error", timeout: 10000 }); - $location.path("/list"); + $scope.getFunction(); } ); }; @@ -125,9 +127,12 @@ app.controller("editController", function($scope, $http, $route, $routeParams, $ }); app.controller("applController", function($scope, $http, $route, $routeParams, $window, $location){ - $http.get("/members/api/requests").then(function(response){ - $scope.applications = response.data; - }); + $scope.applGetFunction = function() { + $http.get("/members/api/requests").then(function(response){ + $scope.applications = response.data; + }); + }; + $scope.applGetFunction(); $scope.send_appl = function(id) { $http.post("/members/api/request/" + id).then( function(response) { @@ -137,7 +142,7 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $ type: "success", timeout: 10000 }); - $location.path("/applications"); + $scope.applGetFunction(); }, function(response) { noty({ @@ -146,7 +151,7 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $ type: "success", timeout: 10000 }); - $location.path("/applications"); + $scope.applGetFunction(); } ); }; @@ -159,7 +164,7 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $ type: "success", timeout: 10000 }); - $location.path("/applications"); + $scope.applGetFunction(); }, function(response) { noty({ @@ -168,7 +173,7 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $ type: "success", timeout: 10000 }); - $location.path("/applications"); + $scope.applGetFunction(); } ); };