summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-02-28 00:03:47 +0000
committerOlivier Lamy <olamy@apache.org>2012-02-28 00:03:47 +0000
commitc6946043df45f87faaa268e0918213910561b0ce (patch)
tree6b93016d3a2c669cbdc7060fcc28218d7a37d0b0
parent7c71fde835415e5f2c928136b18a8302d0ba661b (diff)
downloadarchiva-c6946043df45f87faaa268e0918213910561b0ce.tar.gz
archiva-c6946043df45f87faaa268e0918213910561b0ce.zip
start displaying search results in a grid
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1294406 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties4
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js49
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html27
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js8
4 files changed, 67 insertions, 21 deletions
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
index f0c7bd8a4..b9c2abe0d 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
@@ -217,3 +217,7 @@ search.artifact.search.form.advanced=Advanced Parameters
search.artifact.search.form.query.artifactId=Artifact ID
search.artifact.search.form.repositories.all=All
search.artifact.search.form.terms.empty=You must enter some search terms.
+search.artifact.noresults=No results found.
+search.artifact.results.groupId=Group ID
+search.artifact.results.artifactId=Artifact ID
+search.artifact.results.version=Version
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
index 2fb7b181c..7885cc422 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
@@ -639,15 +639,38 @@ $(function() {
}
ResultViewModel=function(artifacts){
- this.artifacts=artifacts;
+ var self=this;
+ this.artifacts=ko.observableArray(artifacts);
+ this.gridViewModel = new ko.simpleGrid.viewModel({
+ data: self.artifacts,
+ columns: [
+ {
+ headerText: $.i18n.prop('search.artifact.results.groupId'),
+ rowText: "groupId"
+ },
+ {
+ headerText: $.i18n.prop('search.artifact.results.artifactId'),
+ rowText: "artifactId"
+ },
+ {
+ headerText: $.i18n.prop('search.artifact.results.version'),
+ rowText: "version"
+ }
+ ],
+ pageSize: 10,
+ gridUpdateCallBack: function(){
+
+ }
+ });
}
SearchViewModel=function(){
+ var self=this;
this.searchRequest=ko.observable(new SearchRequest());
this.observableRepoIds=ko.observableArray([]);
this.selectedRepoIds=[];
-
+ this.resultViewModel=new ResultViewModel([]);
basicSearch=function(){
//$.log("query:"+this.searchParameters().basicQueryString());
//$.log("repoIds:"+this.selectedRepoIds);
@@ -664,8 +687,8 @@ $(function() {
// cleanup previours error message
customShowError("#main-content #search-basic-form", null, null, []);
}
- var searchResults=$("#main-content #search-results" );
- searchResults.html(mediumSpinnerImg());
+ var searchResultsGrid=$("#main-content #search-results #search-results-grid" );
+ $("#main-content #user-messages").html(mediumSpinnerImg());
this.searchRequest().repositories=this.selectedRepoIds;
$.ajax("restServices/archivaServices/searchService/quickSearchWithRepositories",
{
@@ -674,10 +697,20 @@ $(function() {
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();
+ clearUserMessages();
+ var artifacts=mapArtifacts(data);
+ if (artifacts.length<1){
+ displayWarningMessage( $.i18n.prop("search.artifact.noresults"));
+ return;
+ } else {
+ self.resultViewModel.artifacts(artifacts);
+ if (!searchResultsGrid.attr("data-bind")){
+ searchResultsGrid.attr("data-bind",
+ "simpleGrid: gridViewModel,simpleGridTemplate:'search-results-view-grid-tmpl',pageLinksId:'search-results-view-grid-pagination'");
+ ko.applyBindings(self.resultViewModel,searchResultsGrid.get(0));
+ }
+ activateSearchResultsTab();
+ }
},
error: function(data) {
var res = $.parseJSON(data.responseText);
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html
index 338c0f4bd..ae212d7c6 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html
@@ -255,7 +255,9 @@
<div id="search-results" class="tab-pane">
- No Results yet. Try a search !
+ <table class="table table-striped table-bordered" id="search-results-grid">
+ </table>
+ <div id="search-results-view-grid-pagination"></div>
</div>
</div>
@@ -264,10 +266,21 @@
</script>
-<script id="search-results-view-tmpl" type="text/html">
- {{if artifacts.length==0}}
- no results
- {{else}}
- results
- {{/if}}
+<script id="search-results-view-grid-tmpl" type="text/html">
+ <thead>
+ <tr>
+ {{each(i, columnDefinition) columns}}
+ <th title="${ columnDefinition.title }">${ columnDefinition.headerText }</th>
+ {{/each}}
+ </tr>
+ </thead>
+ <tbody>
+ {{each(i, row) itemsOnCurrentPage()}}
+ <tr>
+ {{each(j, columnDefinition) columns}}
+ <td>${ typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText] }</td>
+ {{/each}}
+ </tr>
+ {{/each}}
+ </tbody>
</script>
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
index 4c2ca96ee..68f7cfa30 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
@@ -64,12 +64,8 @@
// Render the page links
var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0);
- if (viewModel.pageLinksUpdateCallBack){
- ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode")
- .subscribe(viewModel.pageLinksUpdateCallBack);
- } else {
- ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode");
- }
+ ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode")
+ .subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){});
if (viewModel.pageLinksUpdateCallBack) viewModel.pageLinksUpdateCallBack();
}
};