More loading feedback (client)

This commit is contained in:
jendib 2013-08-20 00:57:22 +02:00
parent 464d43194b
commit 0bc658a396
6 changed files with 130 additions and 117 deletions

View File

@ -10,6 +10,7 @@ import java.util.Set;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.queries.TermsFilter;
@ -171,12 +172,17 @@ public class LuceneDao {
TermsFilter userFilter = new TermsFilter(terms);
// Search
IndexSearcher searcher = new IndexSearcher(AppContext.getInstance().getIndexingService().getDirectoryReader());
DirectoryReader directoryReader = AppContext.getInstance().getIndexingService().getDirectoryReader();
Set<String> documentIdList = new HashSet<String>();
if (directoryReader == null) {
// The directory reader is not yet initialized (probably because there is nothing indexed)
return documentIdList;
}
IndexSearcher searcher = new IndexSearcher(directoryReader);
TopDocs topDocs = searcher.search(query, userFilter, Integer.MAX_VALUE);
ScoreDoc[] docs = topDocs.scoreDocs;
// Extract document IDs
Set<String> documentIdList = new HashSet<String>();
for (int i = 0; i < docs.length; i++) {
org.apache.lucene.document.Document document = searcher.doc(docs[i].doc);
String type = document.get("type");

View File

@ -128,7 +128,6 @@ public class IndexingService extends AbstractScheduledService {
public DirectoryReader getDirectoryReader() {
if (directoryReader == null) {
if (!DirectoryReader.indexExists(directory)) {
log.info("Lucene directory not yet created");
return null;
}
try {

View File

@ -60,7 +60,7 @@
<div class="navbar" ng-controller="Navigation">
<div class="navbar-inner">
<div class="container">
<div class="brand loader" ng-class="{hide: !isLoading() }">
<div class="brand loader hidden-phone" ng-class="{hide: !isLoading() }">
<img src="img/loader.gif" />
</div>

View File

@ -1,3 +1,6 @@
<img src="img/loader.gif" ng-if="!document && isEdit()" />
<div ng-if="document || !isEdit()">
<form class="form-horizontal" name="documentForm">
<div class="control-group" ng-class="{ error: !documentForm.title.$valid }">
<label class="control-label" for="inputTitle">Title</label>
@ -54,3 +57,4 @@
</div>
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{ alert.msg }}</alert>
</div>

View File

@ -1,3 +1,6 @@
<img src="img/loader.gif" ng-if="!user && isEdit()" />
<div ng-if="user || !isEdit()">
<h2 ng-show="isEdit()">Edit
<small>"{{ user.username }}"</small>
</h2>
@ -60,3 +63,4 @@
</div>
</form>
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{ alert.msg }}</alert>
</div>