Gets searching working in the dashboard, updates to latest examine

This commit is contained in:
Shannon
2018-12-04 14:25:37 +11:00
parent fce5b29b1c
commit 56d1a317c0
29 changed files with 235 additions and 147 deletions

View File

@@ -7,19 +7,33 @@ function ExamineManagementController($scope, umbRequestHelper, $http, $q, $timeo
vm.loading = true;
vm.viewState = "list";
vm.selectedIndex = null;
vm.selectedSearcher = null;
vm.searchResults = null;
vm.showIndexInfo = showIndexInfo;
vm.showSearcherInfo = showSearcherInfo;
vm.search = search;
vm.toggle = toggle;
vm.rebuildIndex = rebuildIndex;
vm.closeSearch = closeSearch;
vm.setViewState = setViewState;
vm.nextSearchResultPage = nextSearchResultPage;
vm.prevSearchResultPage = prevSearchResultPage;
vm.goToPageSearchResultPage = goToPageSearchResultPage;
vm.infoOverlay = null;
function nextSearchResultPage(pageNumber) {
search(vm.selectedIndex ? vm.selectedIndex : vm.selectedSearcher, null, pageNumber);
}
function prevSearchResultPage(pageNumber) {
search(vm.selectedIndex ? vm.selectedIndex : vm.selectedSearcher, null, pageNumber);
}
function goToPageSearchResultPage(pageNumber) {
search(vm.selectedIndex ? vm.selectedIndex : vm.selectedSearcher, null, pageNumber);
}
function setViewState(state) {
vm.searchResults = null;
vm.viewState = state;
}
@@ -49,7 +63,7 @@ function ExamineManagementController($scope, umbRequestHelper, $http, $q, $timeo
}
index.isProcessing = false;
} else {
$timeout(function() {
$timeout(() => {
//don't continue if we've tried 100 times
if (index.processingAttempts < 100) {
checkProcessing(index, checkActionName);
@@ -65,23 +79,34 @@ function ExamineManagementController($scope, umbRequestHelper, $http, $q, $timeo
});
}
function search(searcher, e) {
function search(searcher, e, pageNumber) {
//deal with accepting pressing the enter key
if (e && e.keyCode !== 13) {
return;
}
if (!searcher) {
throw "searcher parameter is required";
}
searcher.isProcessing = true;
umbRequestHelper.resourcePromise(
$http.get(umbRequestHelper.getApiUrl("examineMgmtBaseUrl",
"GetSearchResults",
{
searcherName: searcher.name,
query: encodeURIComponent(searcher.searchText),
queryType: searcher.searchType
query: encodeURIComponent(vm.searchText),
pageIndex: pageNumber ? (pageNumber - 1) : 0
})),
'Failed to search')
.then(function(searchResults) {
searcher.isSearching = true;
searcher.searchResults = searchResults;
.then(searchResults => {
searcher.isProcessing = false;
vm.searchResults = searchResults
vm.searchResults.pageNumber = pageNumber ? pageNumber : 1;
//20 is page size
vm.searchResults.totalPages = Math.ceil(vm.searchResults.totalRecords / 20);
});
}
@@ -111,19 +136,12 @@ function ExamineManagementController($scope, umbRequestHelper, $http, $q, $timeo
//rebuilding has started, nothing is returned accept a 200 status code.
//lets poll to see if it is done.
$timeout(function() {
checkProcessing(index, "PostCheckRebuildIndex");
},
1000);
$timeout(() => { checkProcessing(index, "PostCheckRebuildIndex"), 1000 });
});
}
}
function closeSearch(searcher) {
searcher.isSearching = true;
}
function init() {
//go get the data
@@ -142,17 +160,14 @@ function ExamineManagementController($scope, umbRequestHelper, $http, $q, $timeo
umbRequestHelper.resourcePromise(
$http.get(umbRequestHelper.getApiUrl("examineMgmtBaseUrl", "GetSearcherDetails")),
'Failed to retrieve searcher details')
.then(function (data) {
.then(data => {
vm.searcherDetails = data;
for (var s in vm.searcherDetails) {
vm.searcherDetails[s].searchType = "text";
}
})
])
.then(function () {
//all init loading is complete
vm.loading = false;
});
.then(() => { vm.loading = false });
}
init();

View File

@@ -8,11 +8,11 @@
</umb-box>
</div>
<div ng-show="loading">
<div ng-show="vm.loading">
<umb-load-indicator></umb-load-indicator>
</div>
<div ng-hide="loading">
<div ng-hide="vm.loading">
<div ng-if="vm.viewState === 'list'" class="umb-healthcheck-group__details">
<div class="umb-healthcheck-group__details-group">
@@ -109,6 +109,8 @@
<div class="umb-healthcheck-group__details-checks">
<!-- Health Status -->
<div class="umb-healthcheck-group__details-check">
<div class="umb-healthcheck-group__details-check-title">
@@ -138,6 +140,8 @@
</div>
<!-- Index Stats -->
<div class="umb-healthcheck-group__details-check">
<div class="umb-healthcheck-group__details-check-title">
@@ -163,6 +167,8 @@
</div>
<!-- Search Tool -->
<div class="umb-healthcheck-group__details-check">
<div class="umb-healthcheck-group__details-check-title">
@@ -178,43 +184,57 @@
<div class="umb-healthcheck-group__details-status-action">
<ng-form name="searchTools">
<div class="row form-search">
<div>
<input type="text" class="search-query" ng-model="vm.searchText" no-dirty-check />
<input type="text" class="search-query"
ng-model="vm.searchText" no-dirty-check
ng-keypress="vm.search(vm.selectedIndex, $event)"/>
<umb-button disabled="vm.selectedIndex.isProcessing"
type="button"
button-style="success"
action="vm.search(searcher)"
action="vm.search(vm.selectedIndex)"
label="Search">
</umb-button>
<table ng-hide="searcher.isProcessing" class="table table-bordered table-condensed">
<thead>
<tr>
<th class="score">Score</th>
<th class="id">Id</th>
<th>Values</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="result in searcher.searchResults">
<td>{{result.Score}}</td>
<td>{{result.Id}}</td>
<td>
<span ng-repeat="(key,val) in result.Fields track by $index">
<span class=""><em>{{key}}</em>:</span>
<span class="text-info">{{val}}</span>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div ng-hide="vm.selectedIndex.isProcessing || !vm.searchResults">
<br/>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th class="score">Score</th>
<th class="id">Id</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="result in vm.searchResults.results track by result.id">
<td>{{result.score}}</td>
<td>{{result.id}}</td>
<td>
<span>{{result.values['nodeName']}}</span>&nbsp;
<a class="color-green" href=""><em>({{result.fieldCount}} fields)</em></a>
</td>
</tr>
</tbody>
</table>
<div class="flex justify-center">
<umb-pagination
page-number="vm.searchResults.pageNumber"
total-pages="vm.searchResults.totalPages"
on-next="vm.nextSearchResultPage"
on-prev="vm.prevSearchResultPage"
on-go-to-page="vm.goToPageSearchResultPage">
</umb-pagination>
</div>
</div>
</ng-form>
</div>
</div>