[MRM-1577] rewrite legacy path admin page

grid done.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1297638 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-06 18:31:44 +00:00
parent 09a3de2d63
commit 024b2290c7
6 changed files with 210 additions and 13 deletions

View File

@ -127,6 +127,7 @@ menu.artifacts=Artifacts
menu.artifacts.search=Search
menu.artifacts.browse=Browse
menu.topbar.quicksearch=Quick Search
menu.legacy-artifact-support=Legacy Support
#user
user.change.password.required=Change password required
@ -242,3 +243,5 @@ search.artifact.search.form.query.bundleRequireBundle=Require Bundle
#login
login.username.placehoder=Username
login.password.placehoder=Password
#legacy artifact path support

View File

@ -22,19 +22,147 @@ $(function() {
// legacy path part
//-------------------------
LegacyArtifactPath=function(path,groupId,artifactId,version,classifier,type){
//private String path;
this.path=ko.observable(path);
/**
* The artifact reference, as " [groupId] :
* [artifactId] : [version] : [classifier] : [type] ".
*/
//private String artifact;
//this.artifact=ko.observable(artifact);
//private String groupId;
this.groupId=ko.observable(groupId);
//private String artifactId;
this.artifactId=ko.observable(artifactId);
//private String version;
this.version=ko.observable(version);
//private String classifier;
this.classifier=ko.observable(classifier);
//private String type;
this.type=ko.observable(type);
this.modified=ko.observable();
this.artifact = ko.computed(function() {
var artifactValue="";
if (this.groupId()){
artifactValue+=this.groupId();
}
if (this.artifactId()){
artifactValue+=":"+this.artifactId();
}
if (this.version()){
artifactValue+=":"+this.version();
}
if (this.classifier()){
artifactValue+=":"+this.classifier();
}
if (this.type()){
artifactValue+=":"+this.type();
}
return artifactValue;
}, this);
}
mapLegacyArtifactPaths=function(data){
if (data){
return $.isArray(data)? $.map(data,function(item){
return mapLegacyArtifactPath(item);
}):[mapLegacyArtifactPath(data)];
}
return [];
}
mapLegacyArtifactPath=function(data){
return data?new LegacyArtifactPath(data.path,data.groupId,data.artifactId,data.version,data.classifier,data.type):null;
}
LegacyPathViewModel=function(){
var self=this;
this.legacyArtifactPaths=ko.observableArray([]);
this.gridViewModel = new ko.simpleGrid.viewModel({
data: self.legacyArtifactPaths,
columns: [
{
headerText: $.i18n.prop('legacy-artifact-paths.path'),
rowText: "path"
},
{
headerText: $.i18n.prop('legacy-artifact-paths.artifact'),
rowText: "artifact"
}
],
pageSize: 5,
gridUpdateCallBack: function(networkProxy){
$("#main-content #legacy-artifact-paths-table [title]").tooltip();
}
});
editLegacyArtifactPath=function(legacyArtifactPath){
}
displayLegacySupport=function(){
removeLegacyArtifactPath=function(legacyArtifactPath){
}
updateLegacyArtifactPath=function(legacyArtifactPath){
}
}
displayLegacyArtifactPathSupport=function(){
clearUserMessages();
var mainContent=$("#main-content");
mainContent.html($("#legacy-path-main" ).html());
mainContent.html($("#legacy-artifact-path-main" ).html());
$.ajax("restServices/archivaServices/archivaAdministrationService/getLegacyArtifactPaths", {
type: "GET",
dataType: 'json',
success: function(data){
var legacyPathViewModel=new LegacyPathViewModel();
var legacyPaths=mapLegacyArtifactPaths(data);
$.log("legacyPaths:"+legacyPaths.length);
legacyPathViewModel.legacyArtifactPaths(legacyPaths);
ko.applyBindings(legacyPathViewModel,mainContent.find("#legacy-artifact-paths-view" ).get(0));
activateLegacyArtifactPathsGridTab();
}
});
ko.applyBindings(legacyPathViewModel,mainContent.find("#legacy-path-screen" ).get(0))
}
activateLegacyArtifactPathsGridTab=function(){
var mainContent = $("#main-content");
mainContent.find("#legacy-artifact-paths-view-tabs-li-edit").removeClass("active");
mainContent.find("#legacy-artifact-paths-edit").removeClass("active");
mainContent.find("#legacy-artifact-paths-view-tabs-li-grid").addClass("active");
mainContent.find("#legacy-artifact-paths-view").addClass("active");
mainContent.find("#legacy-artifact-paths-view-tabs-li-edit a").html($.i18n.prop("add"));
}
activateLegacyArtifactPathsEditTab=function(){
var mainContent = $("#main-content");
mainContent.find("#legacy-artifact-paths-view-tabs-li-grid").removeClass("active");
mainContent.find("#legacy-artifact-paths-view").removeClass("active");
mainContent.find("#legacy-artifact-paths-view-tabs-li-edit").addClass("active");
mainContent.find("#legacy-artifact-paths-edit").addClass("active");
}
});

View File

@ -82,11 +82,14 @@ $(function() {
var screen = $.urlParam('screen');
$.log("screen:"+screen+',operations:'+window.redbackModel.operatioNames);
if(screen){
if(screen=='proxy-connectors'&& $.inArray('archiva-manage-configuration',window.redbackModel.operatioNames)>=0){
displayProxyConnectors();
return;
}
if(screen=="legacy-artifact-path-support"&& $.inArray('archiva-manage-configuration',window.redbackModel.operatioNames)>=0){
displayLegacyArtifactPathSupport();
return;
}
}
// by default display search screen

View File

@ -16,10 +16,73 @@
~ specific language governing permissions and limitations
~ under the License.
-->
<script id="legacy-path-main" type="text/html">
<div id="legacy-path-screen" data-bind='template:{name:"legacy-path-div"}'></div>
<script id="legacy-artifact-path-main" type="text/html">
<div id="legacy-artifact-path-screen">
<div class="page-header">
<h2>${$.i18n.prop('legacy-artifact-paths.list')}</h2>
</div>
<ul id="legacy-artifact-paths-view-tabs" class="nav nav-tabs">
<li id="legacy-artifact-paths-view-tabs-li-grid">
<a data-toggle="tab" href="#legacy-artifact-paths-view" id="legacy-artifact-paths-view-tabs-a-grid">${$.i18n.prop('legacy-artifact-paths.grid.tab.title')}</a>
</li>
<li id="legacy-artifact-paths-view-tabs-li-edit">
<a data-toggle="tab" href="#legacy-artifact-paths-edit">${$.i18n.prop('add')}</a>
</li>
</ul>
<div id="legacy-artifact-paths-view-tabs-content" class="tab-content">
<div id="legacy-artifact-paths-view" class="tab-pane">
<table class="table table-striped table-bordered" id="legacy-artifact-paths-table"
data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko-legacy-artifact-paths-grid',pageLinksId:'legacy-artifact-pathsPagination'">
</table>
<div id="legacy-artifact-pathsPagination"></div>
</div>
<div id="network-proxies-edit" class="tab-pane" data-bind='template: {name:"legacy-artifact-paths-edit-tmpl"}'></div>
</div>
</div>
</script>
<script id="legacy-path-div" type="text/html">
foo
<script id='ko-legacy-artifact-paths-grid' type='text/x-jquery-tmpl'>
<thead>
<tr>
{{each(i, columnDefinition) columns}}
<th>${ columnDefinition.headerText }</th>
{{/each}}
<th>${$.i18n.prop('edit')}</th>
<th>${$.i18n.prop('delete')}</th>
<th>${$.i18n.prop('modified')}</th>
</tr>
</thead>
<tbody>
{{each(i, row) itemsOnCurrentPage()}}
<tr data-bind="css:{ 'modified': row.modified()}">
{{each(j, columnDefinition) columns}}
{{var val = (typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText])}}
<td>
${val}
</td>
{{/each}}
<td>
<a href="#" data-bind="click: function(){ editLegacyArtifactPath(row) }">
<img src="images/edit-find-22-22.png" title="${$.i18n.prop('edit')}">
</a>
</td>
<td>
<a href="#" data-bind="click: function(){ removeLegacyArtifactPath(row) }">
<img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
</a>
</td>
{{if row.modified()}}
<td>
<a href="#" data-bind="click: function(){ updateLegacyArtifactPath(row) }" class="btn btn-warning">${$.i18n.prop('save')}</a>
</td>
{{else}}
<td></td>
{{/if}}
</tr>
{{/each}}
</tbody>
</script>

View File

@ -43,7 +43,7 @@
<a href="#" id="menu-network-proxies-list-a" onclick="displayNetworkProxies()">${$.i18n.prop('menu.network-proxies')}</a>
</li>
<li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
<a href="#" id="menu-legacy-support-list-a" onclick="displayLegacySupport()">${$.i18n.prop('menu.legacy-support')}</a>
<a href="#" id="menu-legacy-support-list-a" onclick="displayLegacyArtifactPathSupport()">${$.i18n.prop('menu.legacy-artifact-support')}</a>
</li>
</ul>

View File

@ -1603,7 +1603,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>2.4-SNAPSHOT</version>
<configuration>
<source>1.5</source>
<target>1.5</target>