Commit fad733f6 authored by Mathieu Rodic's avatar Mathieu Rodic

[FEATURE] Added autocompletion for ngrams filters in advanced charts, part II

https://forge.iscpif.fr/issues/1363
parent 9ffdc327
...@@ -288,6 +288,20 @@ gargantext.controller("DatasetController", function($scope, $http) { ...@@ -288,6 +288,20 @@ gargantext.controller("DatasetController", function($scope, $http) {
}); });
$scope.updateQuery(); $scope.updateQuery();
}; };
// query ngrams
$scope.getNgrams = function(query) {
var url = '/api/nodes/' + $scope.corpusId + '/children/ngrams?limit=10&contain=' + encodeURI(query);
var appendTransform = function(defaults, transform) {
defaults = angular.isArray(defaults) ? defaults : [defaults];
return defaults.concat(transform);
}
return $http.get(url, {
transformResponse: appendTransform($http.defaults.transformResponse, function(value) {
console.log(value.data)
return value.data;
})
});
};
// filtering informations retrieval // filtering informations retrieval
$scope.operators = operators; $scope.operators = operators;
// add a filter // add a filter
...@@ -319,11 +333,13 @@ gargantext.controller("DatasetController", function($scope, $http) { ...@@ -319,11 +333,13 @@ gargantext.controller("DatasetController", function($scope, $http) {
angular.forEach(filter.value, function(ngram) { angular.forEach(filter.value, function(ngram) {
termsList.push(ngram.terms); termsList.push(ngram.terms);
}); });
if (termsList.length) {
filters.push({ filters.push({
field: 'ngrams.terms', field: 'ngrams.terms',
operator: 'in', operator: 'in',
value: termsList value: termsList
}); });
}
} else { } else {
filters.push({ filters.push({
field: filter.entity.key + '.' + filter.column.key, field: filter.entity.key + '.' + filter.column.key,
...@@ -375,18 +391,6 @@ gargantext.controller("GraphController", function($scope, $http, $element) { ...@@ -375,18 +391,6 @@ gargantext.controller("GraphController", function($scope, $http, $element) {
columnsHGap: 5 columnsHGap: 5
} }
}; };
// query ngrams
$scope.getNgrams = function(query) {
var appendTransform = function(defaults, transform) {
defaults = angular.isArray(defaults) ? defaults : [defaults];
return defaults.concat(transform);
}
return $http.get('/api/nodes/26128/children/ngrams?limit=10&contain=' + encodeURI(query), {
transformResponse: appendTransform($http.defaults.transformResponse, function(value) {
return value.data;
})
});
};
// add a dataset // add a dataset
$scope.addDataset = function() { $scope.addDataset = function() {
$scope.datasets.push({}); $scope.datasets.push({});
......
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