mirror of https://github.com/apache/archiva.git
fix search query
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1294405 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
202a699884
commit
7c71fde835
|
@ -56,7 +56,7 @@ public interface SearchService
|
|||
List<Artifact> quickSearch( @QueryParam( "queryString" ) String queryString )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "quickSearch" )
|
||||
@Path( "quickSearchWithRepositories" )
|
||||
@POST
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@RedbackAuthorization( noPermission = true, noRestriction = true )
|
||||
|
|
|
@ -598,6 +598,9 @@ $(function() {
|
|||
}
|
||||
|
||||
SearchRequest=function(){
|
||||
|
||||
this.queryTerms=ko.observable();
|
||||
|
||||
//private String groupId;
|
||||
this.groupId=ko.observable();
|
||||
|
||||
|
@ -614,7 +617,7 @@ $(function() {
|
|||
this.className=ko.observable();
|
||||
|
||||
//private List<String> repositories = new ArrayList<String>();
|
||||
this.repositories=ko.observableArray();
|
||||
this.repositories=ko.observableArray([]);
|
||||
|
||||
//private String bundleVersion;
|
||||
this.bundleVersion=ko.observable();
|
||||
|
@ -635,21 +638,20 @@ $(function() {
|
|||
this.includePomArtifacts=ko.observable(false);
|
||||
}
|
||||
|
||||
|
||||
SearchParameters=function(){
|
||||
this.basicQueryString=ko.observable();
|
||||
this.searchRequest=ko.observable(new SearchRequest());
|
||||
ResultViewModel=function(artifacts){
|
||||
this.artifacts=artifacts;
|
||||
}
|
||||
|
||||
|
||||
SearchViewModel=function(){
|
||||
this.searchParameters=ko.observable(new SearchParameters());
|
||||
this.searchRequest=ko.observable(new SearchRequest());
|
||||
this.observableRepoIds=ko.observableArray([]);
|
||||
this.selectedRepoIds=[];
|
||||
|
||||
basicSearch=function(){
|
||||
//$.log("query:"+this.searchParameters().basicQueryString());
|
||||
//$.log("repoIds:"+this.selectedRepoIds);
|
||||
var queryTerm=this.searchParameters().basicQueryString();
|
||||
var queryTerm=this.searchRequest().queryTerms();
|
||||
if (!queryTerm || $.trim(queryTerm).length<1){
|
||||
$.log("empty");
|
||||
var errorList=[{
|
||||
|
@ -662,8 +664,28 @@ $(function() {
|
|||
// cleanup previours error message
|
||||
customShowError("#main-content #search-basic-form", null, null, []);
|
||||
}
|
||||
$("#main-content #search-results" ).html(mediumSpinnerImg());
|
||||
var searchResults=$("#main-content #search-results" );
|
||||
searchResults.html(mediumSpinnerImg());
|
||||
this.searchRequest().repositories=this.selectedRepoIds;
|
||||
$.ajax("restServices/archivaServices/searchService/quickSearchWithRepositories",
|
||||
{
|
||||
type: "POST",
|
||||
data: "{\"searchRequest\": " + ko.toJSON(this.searchRequest)+"}",
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var resultViewModel=new ResultViewModel(mapArtifacts(data));
|
||||
searchResults.attr("data-bind","template:{name:'search-results-view-tmpl'}");
|
||||
ko.applyBindings(resultViewModel,searchResults.get(0));
|
||||
activateSearchResultsTab();
|
||||
},
|
||||
error: function(data) {
|
||||
var res = $.parseJSON(data.responseText);
|
||||
displayRestError(res);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
<label class="control-label" for="search-terms"></label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-medium search-query" id="search-terms" name="search-terms" size="50"
|
||||
data-bind="value: searchParameters().basicQueryString" placeholder="${$.i18n.prop('search.artifact.search.form.query.terms')}"/>
|
||||
data-bind="value: searchRequest().queryTerms" placeholder="${$.i18n.prop('search.artifact.search.form.query.terms')}"/>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn" data-bind="click: basicSearch">Search</button>
|
||||
|
@ -211,35 +211,35 @@
|
|||
<label class="control-label" for="groupId">${$.i18n.prop('search.artifact.search.form.query.groupId')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-medium search-query" id="groupId" name="groupId" size="50"
|
||||
data-bind="value: searchParameters().searchRequest().groupId"/>
|
||||
data-bind="value: searchRequest().groupId"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="artifactId">${$.i18n.prop('search.artifact.search.form.query.artifactId')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-medium search-query" id="artifactId" name="artifactId" size="50"
|
||||
data-bind="value: searchParameters().searchRequest().artifactId"/>
|
||||
data-bind="value: searchRequest().artifactId"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="artifactId">${$.i18n.prop('search.artifact.search.form.query.version')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-medium search-query" id="version" name="version" size="50"
|
||||
data-bind="value: searchParameters().searchRequest().version"/>
|
||||
data-bind="value: searchRequest().version"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="artifactId">${$.i18n.prop('search.artifact.search.form.query.packaging')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-medium search-query" id="packaging" name="packaging" size="50"
|
||||
data-bind="value: searchParameters().searchRequest().packaging"/>
|
||||
data-bind="value: searchRequest().packaging"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="artifactId">${$.i18n.prop('search.artifact.search.form.query.className')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-medium search-query" id="className" name="className" size="50"
|
||||
data-bind="value: searchParameters().searchRequest().className"/>
|
||||
data-bind="value: searchRequest().className"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
@ -263,3 +263,11 @@
|
|||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
<script id="search-results-view-tmpl" type="text/html">
|
||||
{{if artifacts.length==0}}
|
||||
no results
|
||||
{{else}}
|
||||
results
|
||||
{{/if}}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue