[dashboard] Unify progress button to wait for all facets to finish
@@ -1526,6 +1526,14 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
};
self.isRetrievingResults = ko.observable(false);
self.hasRetrievedResults = ko.observable(true);
+ self.asyncSearchesCounter = ko.observable(0);
+ self.asyncSearchesCounter.subscribe(function(newVal) {
+ if (newVal == 0) {
+ self.isRetrievingResults(false);
+ self.hasRetrievedResults(true);
+ $('.btn-loading').button('reset');
+ }
+ });
self.showCores = ko.observable(false);
self.showCores.subscribe(function(newValue) {
@@ -1671,6 +1679,9 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
} else {
self._make_grid_result(data);
}
+
+ self.asyncSearchesCounter(self.asyncSearchesCounter() - 1);
+
//if (facet.queryResult().result['handle'].has_result_set()) {
// self.fetchResultSize(facet);
//}
@@ -1696,9 +1707,8 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
});
};
- // self.searchAsync
- self.search = function (callback) {
+ self.search = function (callback) { // self.searchAsync == self.collection.async()
$(".jHueNotify").hide();
logGA('search');
self.isRetrievingResults(true);
@@ -1761,7 +1771,8 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
self.checkStatus(facet);
});
- }); // Join save dashboard history
+ });
+ self.asyncSearchesCounter(multiQs.length + 1);
}
$.each(self.fieldAnalyses(), function (index, analyse) { // Invalidate stats analysis
@@ -1821,9 +1832,11 @@ var SearchViewModel = function (collection_json, query_json, initial_json) {
$(document).trigger("error", xhr.responseText);
})
.always(function () {
+ if (! self.collection.async()) {
self.isRetrievingResults(false);
self.hasRetrievedResults(true);
$('.btn-loading').button('reset');
+ }
});
};
