Commit 572f1d09 authored by Mathieu Rodic's avatar Mathieu Rodic

[CODE] Serious cleaning and factorization in advanced graphs

parent 0880dfad
...@@ -272,13 +272,19 @@ gargantext.controller("DatasetController", function($scope, $http) { ...@@ -272,13 +272,19 @@ gargantext.controller("DatasetController", function($scope, $http) {
$scope.entities = undefined; $scope.entities = undefined;
$scope.filters = []; $scope.filters = [];
$http.get(url, {cache: true}).success(function(response){ $http.get(url, {cache: true}).success(function(response){
$scope.entities = { $scope.entities = [
metadata: response.data, {
ngrams: [ key: 'metadata',
columns: response.data
},
{
key: 'ngrams',
columns: [
{key:'terms', type:'string'}, {key:'terms', type:'string'},
{key:'terms count', type:'integer'} {key:'terms count', type:'integer'}
] ],
}; }
];
}); });
$scope.updateQuery(); $scope.updateQuery();
}; };
...@@ -309,7 +315,7 @@ gargantext.controller("DatasetController", function($scope, $http) { ...@@ -309,7 +315,7 @@ gargantext.controller("DatasetController", function($scope, $http) {
} }
} }
filters.push({ filters.push({
field: filter.entity + '.' + filter.column, field: filter.entity.key + '.' + filter.column.key,
operator: filter.operator, operator: filter.operator,
value: filter.value value: filter.value
}); });
......
...@@ -237,22 +237,10 @@ ...@@ -237,22 +237,10 @@
<li ng-repeat="filter in filters"> <li ng-repeat="filter in filters">
<button ng-click="removeFilter($index)" title="remove this filter">x</button> <button ng-click="removeFilter($index)" title="remove this filter">x</button>
<span>...where the </span> <span>...where the </span>
<select ng-model="filter.entity"> <select ng-model="filter.entity" ng-options="entity as entity.key for entity in entities"></select>
<option ng-repeat="(entityName, entityColumns) in entities" value="{{entityName}}">{{entityName}}</option> <select ng-if="filter.entity" ng-model="filter.column" ng-options="column as column.key for column in filter.entity.columns | orderBy:'key'"></select>
</select> <select ng-if="filter.column" ng-model="filter.operator" ng-options="operator.key as operator.label for operator in operators[filter.column.type]"></select>
<span ng-if="filter.entity"> <input ng-if="filter.operator" type="text" ng-model="filter.value" ng-change="updateQuery()">
<select ng-model="filter.column">
<option ng-repeat="column in entities[filter.entity] | orderBy:'key'" value="{{column.key}}">{{column.key}}</option>
</select>
<span ng-if="filter.column" ng-repeat="column in entities[filter.entity]">
<span ng-if="column.key == filter.column">
<select ng-model="filter.operator">
<option ng-repeat="operator in operators[column.type]" value="{{operator.key}}">{{operator.label}}</option>
</select>
<input type="text" ng-model="filter.value" ng-change="updateQuery()">
</span>
</span>
</span>
</li> </li>
</ul> </ul>
<button ng-click="addFilter()">Add a filter...</button> <button ng-click="addFilter()">Add a filter...</button>
......
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