Show summary of Examine search results (#14300)

This commit is contained in:
Bjarne Fyrstenborg
2023-05-31 17:25:24 +02:00
committed by GitHub
parent e6903bffcd
commit 676efb9f89
7 changed files with 35 additions and 6 deletions

View File

@@ -607,6 +607,8 @@
</key>
<key alias="indexCannotRebuild">Dette index kan ikke genbygges for det ikke har nogen</key>
<key alias="iIndexPopulator">IIndexPopulator</key>
<key alias="noResults">Der blev ikke fundet nogen resultater</key>
<key alias="searchResultsFound">Viser %0% - %1% af %2% resultat(er) - Side %3% af %4%</key>
</area>
<area alias="placeholders">
<key alias="username">Indtast dit brugernavn</key>

View File

@@ -628,6 +628,8 @@
</key>
<key alias="indexCannotRebuild">This index cannot be rebuilt because it has no assigned</key>
<key alias="iIndexPopulator">IIndexPopulator</key>
<key alias="noResults">No results were found</key>
<key alias="searchResultsFound">Showing %0% - %1% of %2% result(s) - Page %3% of %4%</key>
</area>
<area alias="placeholders">
<key alias="username">Enter your username</key>

View File

@@ -644,6 +644,8 @@
</key>
<key alias="indexCannotRebuild">This index cannot be rebuilt because it has no assigned</key>
<key alias="iIndexPopulator">IIndexPopulator</key>
<key alias="noResults">No results were found</key>
<key alias="searchResultsFound">Showing %0% - %1% of %2% result(s) - Page %3% of %4%</key>
</area>
<area alias="placeholders">
<key alias="username">Enter your username</key>

View File

@@ -5,6 +5,9 @@ namespace Umbraco.Cms.Core.Models.ContentEditing;
[DataContract(Name = "results", Namespace = "")]
public class SearchResults
{
[DataMember(Name = "pageSize")]
public int PageSize { get; set; }
[DataMember(Name = "totalRecords")]
public long TotalRecords { get; set; }

View File

@@ -91,6 +91,7 @@ public class ExamineManagementController : UmbracoAuthorizedJsonController
return new SearchResults
{
PageSize = pageSize,
TotalRecords = results.TotalItemCount,
Results = results.Select(x => new SearchResult
{

View File

@@ -195,21 +195,23 @@ function ExamineManagementController($http, $q, $timeout, umbRequestHelper, loca
searcher.isProcessing = true;
const pageIndex = pageNumber ? (pageNumber - 1) : 0;
umbRequestHelper.resourcePromise(
$http.get(umbRequestHelper.getApiUrl("examineMgmtBaseUrl",
"GetSearchResults",
{
searcherName: searcher.name,
query: encodeURIComponent(vm.searchText),
pageIndex: pageNumber ? (pageNumber - 1) : 0
pageIndex: pageIndex
})),
'Failed to search')
.then(searchResults => {
searcher.isProcessing = false;
vm.searchResults = searchResults
vm.searchResults = searchResults;
vm.searchResults.pageIndex = pageIndex;
vm.searchResults.pageNumber = pageNumber ? pageNumber : 1;
//20 is page size
vm.searchResults.totalPages = Math.ceil(vm.searchResults.totalRecords / 20);
vm.searchResults.totalPages = Math.ceil(vm.searchResults.totalRecords / vm.searchResults.pageSize);
// add URLs to edit well known entities
_.each(vm.searchResults.results, function (result) {
var section = result.values["__IndexType"][0];

View File

@@ -323,15 +323,32 @@
<td class="tr nowrap">
<button type="button"
class="table__action-overlay color-green"
ng-click="vm.showSearchResultDialog(result.values)">({{ ::result.fieldCount }} <localize key="examineManagement_fields">fields</localize>)</button>
ng-click="vm.showSearchResultDialog(result.values)">
({{ ::result.fieldCount }} <localize key="examineManagement_fields">fields</localize>)
</button>
</td>
<td class="tr nowrap umb-avatar--white">
<span title="{{ result.score }}">
<span ng-attr-title="{{ result.score }}">
{{ ::result.score | number:4 }}
</span>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="{{vm.showSearchResultFields.length + 4}}">
<localize key="examineManagement_noResults" ng-if="::vm.searchResults.totalRecords === 0">
No results were found
</localize>
<localize key="examineManagement_searchResultsFound"
tokens="[(vm.searchResults.pageIndex * vm.searchResults.pageSize) + 1, (vm.searchResults.pageIndex * vm.searchResults.pageSize) + vm.searchResults.results.length, vm.searchResults.totalRecords, vm.searchResults.pageNumber, vm.searchResults.totalPages]"
watch-tokens="true"
ng-if="::vm.searchResults.totalRecords > 0">
Showing %0% - %1% of %2% result(s) - Page %3% of %4%
</localize>
</td>
</tr>
</tfoot>
</table>
</div>