Skip to content

some cleanup so the solr gui will render mp3 files correctly. #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,16 @@ public void setDocIdPrefix(String docIdPrefix) {
this.docIdPrefix = docIdPrefix;
}

public Integer getFeedCount() {
return feedCount;
}

public long getStart() {
return start;
}

public void setStart(long start) {
this.start = start;
}

}
5 changes: 5 additions & 0 deletions src/main/java/org/myrobotlab/service/FileConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void setConfig(ConnectorConfig config) {
@Override
public void startCrawling() {
state = ConnectorState.RUNNING;
setStart(System.currentTimeMillis());
Path startPath = Paths.get(((FileConnectorConfig)config).directory);
log.info("Started Crawling {}", startPath);
try {
Expand Down Expand Up @@ -74,9 +75,11 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) th
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (interrupted) {
log.info("Interrupted, terminating crawl.");
state = ConnectorState.INTERRUPTED;
return FileVisitResult.TERMINATE;
}
log.info("Crawling {} Feed Count {}" , file.toFile().getAbsolutePath(), getFeedCount());;
String docId = getDocIdPrefix() + file.toFile().getAbsolutePath();
Document doc = new Document(docId);
doc.setField("last_modified", new Date(attrs.lastModifiedTime().toMillis()));
Expand All @@ -93,9 +96,11 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
if (interrupted) {
log.info("Interrupted, terminating crawl.");
state = ConnectorState.INTERRUPTED;
return FileVisitResult.TERMINATE;
}
log.warn("Failed Crawling {} Feed Count {}" , file.toFile().getAbsolutePath(), getFeedCount());
String docId = getDocIdPrefix() + file.toFile().getAbsolutePath();
Document doc = new Document(docId);
doc.setField("type", "file");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public DocumentPipelineMeta() {
addDependency("com.thoughtworks.xstream", "xstream", "1.4.19");

// FIXME - add service page, python script, give example of how to use
setAvailable(false);
setAvailable(true);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ angular.module('mrlapp.service.SolrGui', []).controller('SolrGuiCtrl', ['$scope'
$scope.filters = [];
// TODO: maybe some other fields..
// TODO: support range facets
$scope.facetFields = ['type', 'artist_facet', 'album_facet', 'genre_facet', 'year_facet', 'sender_type', 'sender','method'];
$scope.facetFields = ['type', 'artist_facet', 'album_facet', 'genre_facet', 'year_facet', 'sender_type', 'sender','method', 'content_type_facet'];
// GOOD TEMPLATE TO FOLLOW
this.updateState = function(service) {
Expand Down
151 changes: 75 additions & 76 deletions src/main/resources/resource/WebGui/app/service/views/SolrGui.html
Original file line number Diff line number Diff line change
@@ -1,81 +1,80 @@
<div>
<!-- for debugging Data: {{service}} <br/> -->
<div class="form-group">
<!-- for debugging Data: {{service}} <br/> -->
<div class="form-group">
<form>
<label>QueryString</label>
<input type="text" ng-model="queryString" class="form-control typeHereField ng-pristine ng-valid ng-empty ng-touched" ng-submit="execNewSearch()"/>
<input type="submit" ng-click="execNewSearch()" value="Search" />
</form>
</div>
<br/>
<span ng-repeat="filter in filters">{{filter}} <a ng-click="removeFilter(filter)">[x]</a> </span>
<br/>

<!-- Query String: {{queryString}} <br/> -->
Displaying search results {{startOffset+1}} to {{endOffset}} of {{numFound}} in {{solrResults.responseHeader.QTime}} milliseconds.

<a ng-click="prevPage()">Previous</a> <a ng-click="nextPage()">Next</a>
<br/>

<table class="facetAndSearchResults">
<label>QueryString</label>
<input type="text" ng-model="queryString" class="form-control typeHereField ng-pristine ng-valid ng-empty ng-touched" ng-submit="execNewSearch()"/>
<input type="submit" ng-click="execNewSearch()" value="Search" />
</form>
</div>
<br/>
<span ng-repeat="filter in filters">{{filter}} <a ng-click="removeFilter(filter)">[x]</a> </span>
<br/>
<!-- {{solrResults}} -->
<!-- Query String: {{queryString}} <br/> -->
Displaying search results {{startOffset+1}} to {{endOffset}} of {{numFound}} in {{solrResults.responseHeader.QTime}} milliseconds.
<br/>
<table class="facetAndSearchResults">
<tr VALIGN=TOP>
<td>
<table class="facetResults">
<tr ng-repeat="(field, buckets) in solrResults.facet_counts.facet_fields track by $index">
<td >
<table class="facetResult">
<tr>
<th>{{field}}</th>
</tr>
<tr>
<td><li ng-repeat="(bucket, count) in buckets"><a ng-click="filter(field, bucket)">{{bucket}}</a> ({{count}})</li></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td>
<table class="table table-striped">
<tr ng-repeat="result in solrResults.response track by $index" class="ng-scope">
<td>
<!-- we want to conditionally render a different template depending on the type of doc it is. -->
<div ng-if="result.content_type == 'audio/mpeg'">
<!-- here we can render specific fields like artist/album/song.. -->
<div ng-if="result.title[0]"><a ng-click="playFile(result.filepath)">{{result.title[0]}}</a></div>
<div ng-if="!result.title[0]"><a ng-click="playFile(result.filepath)">{{result.filepath[0]}}</a></div>
<div ng-if="result.artist[0]">Artist: {{result.artist[0]}}</div>
<div ng-if="result.album[0]">Album: {{result.album[0]}}</div>
<div ng-if="result.year[0]">Year: {{result.year[0]}}</div>
<div ng-if="result.genre[0]">Genre: {{result.genre[0]}}</div>
Filepath: {{result.filepath[0]}}
</div>
<!-- unknown result type... render all fields. -->
<div ng-if="result.content_type != 'audio/mpeg'">
<!-- this is not a song.. -->
<b>Doc: {{$index + startOffset + 1}}</b>

<table class="searchResult" class>
<tr ng-repeat="(key, value) in result">
<td><strong>{{key}}</strong></td>
<td ng-if="key == 'bytes'"><img height="100" ng-src="{{value}}"/></td>
<td ng-if="key == 'filepath'"><a ng-click="playFile(value)">{{value}}</a></td>
<td ng-if="key != 'bytes' && key != 'filepath'">{{value}}</td>
</tr>
</table>

</div>
</td>
</tr>
</table>
</td>
<td>
<table class="facetResults">
<tr ng-repeat="(field, buckets) in solrResults.facet_counts.facet_fields track by $index">
<td >
<table class="facetResult">
<tr>
<th>{{field}}</th>
</tr>
<tr>
<td><li ng-repeat="(bucket, count) in buckets"><a ng-click="filter(field, bucket)">{{bucket}}</a> ({{count}})</li></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td>
<table class="table table-striped">
<tr><td><a ng-click="prevPage()">Previous</a> <a ng-click="nextPage()">Next</a></td></tr>
<tr ng-repeat="result in solrResults.response.docs track by $index" class="ng-scope">
<td>
<!-- we want to conditionally render a different template depending on the type of doc it is. -->
<div ng-if="result.content_type[0] == 'audio/mpeg'">
<!-- <b>Doc: {{$index + startOffset + 1}}</b> -->
<!-- here we can render specific fields like artist/album/song.. -->
<div ng-if="result.title[0]"><a ng-click="playFile(result.filepath)">{{result.title[0]}}</a></div>
<div ng-if="!result.title[0]"><a ng-click="playFile(result.filepath)">{{result.filepath[0]}}</a></div>
<div ng-if="result.artist[0]">Artist: {{result.artist[0]}}</div>
<div ng-if="result.album[0]">Album: {{result.album[0]}}</div>
<div ng-if="result.year[0]">Year: {{result.year[0]}}</div>
<div ng-if="result.genre[0]">Genre: {{result.genre[0]}}</div>
Filepath: {{result.filepath[0]}}
</div>
<!-- unknown result type... render all fields. -->
<div ng-if="result.content_type[0] != 'audio/mpeg'">
<!-- this is not a song.. -->
<!-- <b>Doc: {{$index + startOffset + 1}}</b> -->
<table class="searchResult" class>
<tr ng-repeat="(key, value) in result">
<td><strong>{{key}}</strong></td>
<td ng-if="key == 'bytes'"><img height="100" ng-src="{{value}}"/></td>
<td ng-if="key == 'filepath'"><a ng-click="playFile(value)">{{value}}</a></td>
<td ng-if="key != 'bytes' && key != 'filepath'">{{value}}</td>
</tr>
</table>
</div>
</td>
</tr>
<!-- bottom pagination link -->
<tr><td><a ng-click="prevPage()">Previous</a> <a ng-click="nextPage()">Next</a></td></tr>
</table>
</td>
</tr>
</table>
<div ng-switch on="size">
<div class="animate-switch" ng-switch-when="small">Small view</div>
<div class="animate-switch" ng-switch-when="medium">Medium view<br>mevi</div>
<div class="animate-switch" ng-switch-when="large">Large view<br>lavi<br>lavi</div>
<div class="animate-switch" ng-switch-when="full">Full view<br>fuvi<br>fuvi<br>fuvi</div>
</div>
</table>

<div ng-switch on="size">
<div class="animate-switch" ng-switch-when="small">Small view</div>
<div class="animate-switch" ng-switch-when="medium">Medium view<br>mevi</div>
<div class="animate-switch" ng-switch-when="large">Large view<br>lavi<br>lavi</div>
<div class="animate-switch" ng-switch-when="full">Full view<br>fuvi<br>fuvi<br>fuvi</div>
</div>
</div>