Commit dfc1d59b authored by Mathieu Rodic's avatar Mathieu Rodic

BUGFIX - Solved the CSRF problem

parent 60517996
/*
AngularJS v1.2.28
(c) 2010-2014 Google, Inc. http://angularjs.org
License: MIT
*/
(function(p,f,n){'use strict';f.module("ngCookies",["ng"]).factory("$cookies",["$rootScope","$browser",function(e,b){var c={},g={},h,k=!1,l=f.copy,m=f.isUndefined;b.addPollFn(function(){var a=b.cookies();h!=a&&(h=a,l(a,g),l(a,c),k&&e.$apply())})();k=!0;e.$watch(function(){var a,d,e;for(a in g)m(c[a])&&b.cookies(a,n);for(a in c)d=c[a],f.isString(d)||(d=""+d,c[a]=d),d!==g[a]&&(b.cookies(a,d),e=!0);if(e)for(a in d=b.cookies(),c)c[a]!==d[a]&&(m(d[a])?delete c[a]:c[a]=d[a])});return c}]).factory("$cookieStore",
["$cookies",function(e){return{get:function(b){return(b=e[b])?f.fromJson(b):b},put:function(b,c){e[b]=f.toJson(c)},remove:function(b){delete e[b]}}}])})(window,window.angular);
//# sourceMappingURL=angular-cookies.min.js.map
......@@ -86,12 +86,15 @@ var groupings = {
};
// application definition
var gargantext = angular.module('Gargantext', ['n3-charts.linechart']);
// Define the application
var gargantext = angular.module('Gargantext', ['n3-charts.linechart', 'ngCookies'])
// tuning the application's scope
angular.module('Gargantext').run(['$rootScope', function($rootScope){
// Customize the application's scope
angular.module('Gargantext').run(function($rootScope, $http, $cookies){
// Access Math library from anywhere in the scope of the application
$rootScope.Math = Math;
// Access to an HSB to RGB converter
$rootScope.getColor = function(i, n){
var h = .3 + (i / n) % 1;
var s = .7;
......@@ -116,6 +119,7 @@ angular.module('Gargantext').run(['$rootScope', function($rootScope){
var color = 'rgb(' + r + ',' + g + ',' + b + ')';
return color;
};
// Access to a range function, very similar to the one available in Python
$rootScope.range = function(min, max, step){
if (max == undefined){
max = min;
......@@ -128,9 +132,12 @@ angular.module('Gargantext').run(['$rootScope', function($rootScope){
}
return output;
};
}]);
// For CSRF token compatibility with Django
$http.defaults.headers.post['X-CSRFToken'] = $cookies['csrftoken'];
});
// Controller for queries
gargantext.controller("QueryController", function($scope, $http) {
// query-specific information
$scope.filters = [];
......@@ -202,7 +209,7 @@ gargantext.controller("QueryController", function($scope, $http) {
}
});
// Controller for datasets
gargantext.controller("DatasetController", function($scope, $http) {
// query-specific information
$scope.mesured = 'nodes.count';
......@@ -276,7 +283,7 @@ gargantext.controller("DatasetController", function($scope, $http) {
}
});
// Controller for graphs
gargantext.controller("GraphController", function($scope, $http, $element) {
// initialization
$scope.datasets = [{}];
......@@ -450,8 +457,8 @@ gargantext.controller("GraphController", function($scope, $http, $element) {
});
// For debugging only!
// Only for debugging!
/*
setTimeout(function(){
// first dataset
$('div.corpus select').change();
......@@ -478,4 +485,5 @@ setTimeout(function(){
// // refresh
// // $('button.refresh').first().click();
}, 500);
}, 250);
\ No newline at end of file
}, 250);
*/
\ No newline at end of file
......@@ -331,6 +331,7 @@
-->
{% endverbatim %}
<script type="text/javascript" src="{% static "js/angular.min.js" %}"></script>
<script type="text/javascript" src="{% static "js/angular-cookies.min.js" %}"></script>
<script type="text/javascript" src="{% static "js/d3/d3.v2.min.js" %}"></script>
<script type="text/javascript" src="{% static "js/d3/n3.line-chart.min.js" %}"></script>
<!-- <script type="text/javascript" src="{% static "js/d3/angular-charts.js" %}"></script> -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment