JS app moved to appconfig. Noty notifications added
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
var app = angular.module('memberApp', ['ngRoute', 'ngAnimate', 'ui.bootstrap']);
|
||||
|
||||
app.config(['$httpProvider', function ($httpProvider) {
|
||||
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
|
||||
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
|
||||
}]);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,17 +11,18 @@ app.controller("getController", function($scope, $http, $window, $location){
|
||||
$scope.delete_member = function(id) {
|
||||
$http.delete("/members/api/member/" + id).then(
|
||||
function(response) {
|
||||
$window.alert("Onnistui! Hyvä Harry!");
|
||||
noty({ text: "Onnistui! Hyvä Harry!"});
|
||||
$location.path("#/list");
|
||||
},
|
||||
function(response) {
|
||||
$window.alert("Epäonnistui. Yritä uudelleen.");
|
||||
noty({ text: "Epäonnistui. Yritä uudelleen."});
|
||||
$location.path("#/list");
|
||||
}
|
||||
);
|
||||
};
|
||||
})
|
||||
.directive('ngConfirmClick',
|
||||
});
|
||||
|
||||
app.directive('ngConfirmClick',
|
||||
[
|
||||
function()
|
||||
{ return {
|
||||
@@ -38,7 +39,7 @@ function()
|
||||
}
|
||||
}}]);
|
||||
|
||||
app.controller("postController", function($scope, $http) {
|
||||
app.controller("postController", function($scope, $http, $location) {
|
||||
$scope.firstName = "";
|
||||
$scope.lastName = "";
|
||||
$scope.email = "";
|
||||
@@ -46,7 +47,10 @@ app.controller("postController", function($scope, $http) {
|
||||
$scope.JAS = "";
|
||||
$scope.POR = "";
|
||||
$scope.send = function() {
|
||||
$http.post("/members/api/member/", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR});
|
||||
$http.post("/members/api/member/", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR}).then(function(data){
|
||||
noty({ text: "Jäsenhakemus lähetetty"});
|
||||
$location.path("#/list");
|
||||
});
|
||||
}
|
||||
});
|
||||
app.controller("editController", function($scope, $http, $route, $routeParams, $window, $location) {
|
||||
@@ -57,7 +61,7 @@ app.controller("editController", function($scope, $http, $route, $routeParams, $
|
||||
|
||||
$scope.send = function() {
|
||||
$http.put("/members/api/member/"+$scope.member.id, $scope.member).then(function(data){
|
||||
$window.alert("Jäsentiedot tallennettu");
|
||||
noty({ text: "Jäsentiedot tallennettu"});
|
||||
$location.path("#/list");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
var app = angular.module('memberApp', ['ngRoute']);
|
||||
|
||||
|
||||
app.config(['$httpProvider', function ($httpProvider) {
|
||||
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
|
||||
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
|
||||
}]);
|
||||
|
||||
app.config(['$routeProvider', function($routeProvider){
|
||||
$routeProvider
|
||||
.when('/',{
|
||||
|
||||
@@ -10,13 +10,17 @@
|
||||
|
||||
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
||||
<link href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel = "stylesheet">
|
||||
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
||||
|
||||
<link href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" rel = "stylesheet">
|
||||
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.6/angular.js"></script>
|
||||
<script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-route.js"></script>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-animate.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
|
||||
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.0.1.js"></script>
|
||||
{%load staticfiles %}
|
||||
<script src="/static/js/jquery.noty.packaged.js"></script>
|
||||
<script src="/static/js/appconfig.js"></script>
|
||||
<script src="/static/js/alert.js"></script>
|
||||
<script src="/static/js/members_routers.js"></script>
|
||||
<script src="/static/js/members_controllers.js"></script>
|
||||
<link href="/static/css/simple-sidebar.css" rel="stylesheet">
|
||||
@@ -42,6 +46,6 @@
|
||||
<div ng-view></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user