[dashboard] First version of total number of rows
@@ -1619,13 +1619,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
}
else if (facet.queryResult.status() == 'available') {
self.fetchResult(facet);
-
facet.queryResult.progress(100);
-
- if (facet.queryResult.result['handle'].has_result_set()) {
- //self.fetchResultSize();
- console.log('fetch result size()');
- }
}
else if (facet.queryResult.status() == 'success') {
facet.queryResult.progress(99);
@@ -1643,7 +1637,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
});
};
- self.fetchResult = function(facet) { // If coll grid or real facet
+ self.fetchResult = function(facet) {
$.post("/search/search", {
collection: ko.mapping.toJSON(self.collection),
query: ko.mapping.toJSON(self.query),
@@ -1657,8 +1651,31 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
} else {
facet._make_grid_result(data);
}
+// if (facet.queryResult.result['handle'].has_result_set()) {
+// self.fetchResultSize(facet);
+// }
});
}
+
+ self.fetchResultSize = function(facet) {
+ $.post("/notebook/api/fetch_result_size", {
+ notebook: ko.mapping.toJSON({type: facet.queryResult.type()}),
+ snippet: ko.mapping.toJSON(facet.queryResult)
+ }, function (data) {
+ if (data.status == 0) {
+ if (data.result.rows != null) {
+ facet.response().response.numFound(data.result.rows);
+ }
+ } else if (data.status == 5) {
+ // No supported yet for this snippet
+ } else {
+ $(document).trigger("error", data.message);
+ }
+ }).fail(function (xhr, textStatus, errorThrown) {
+ $(document).trigger("error", xhr.responseText);
+ });
+ };
+
// self.searchAsync
self.search = function (callback) {
@@ -1756,8 +1773,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
progress: 0,
});
- self.queryResult = query; // Todo add to model
-
+ self.queryResult = query;
self.checkStatus(self);
}
}
@@ -1805,6 +1821,7 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
});
// Delete norm_facets that were deleted
+ //data.response.numFound = ko.observable(data.response.numFound);
self.response(data);
if (data.error) {
