]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1577] rewrite legacy path admin page
authorOlivier Lamy <olamy@apache.org>
Tue, 6 Mar 2012 18:31:44 +0000 (18:31 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 6 Mar 2012 18:31:44 +0000 (18:31 +0000)
grid done.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1297638 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html
pom.xml

index 19dc750d405161d1ee4e25ee970a69089d87b78d..119a477559f1ed267e6696c00feaf67a0504456c 100644 (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
@@ -241,4 +242,6 @@ search.artifact.search.form.query.bundleRequireBundle=Require Bundle
 
 #login
 login.username.placehoder=Username
-login.password.placehoder=Password
\ No newline at end of file
+login.password.placehoder=Password
+
+#legacy artifact path support
index 9711235e4783dda297f7c74797142253fc8bd2f2..53907404cded054636d795c11974b196c4d6e669 100644 (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){
+
+    }
+
+    removeLegacyArtifactPath=function(legacyArtifactPath){
+
+    }
+
+    updateLegacyArtifactPath=function(legacyArtifactPath){
+
+    }
 
   }
 
-  displayLegacySupport=function(){
+  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();
+        }
+    });
+
 
-    var legacyPathViewModel=new LegacyPathViewModel();
+  }
+
+
+  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"));
 
-    ko.applyBindings(legacyPathViewModel,mainContent.find("#legacy-path-screen" ).get(0))
   }
 
+  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");
+  }
+
+
 });
\ No newline at end of file
index 9db28f811a2b8b9cda09eac4598afd6d65cafcd2..d8f33fb33b5fa959cb7919f0ffa3b3fb16f5ad50 100644 (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
index d484b0297e9015e13cc030cc6a5faed3a82b61cd..9ebecb04e737784a8f3f98f2c51906c8043c48ff 100644 (file)
   ~ 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='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>
 
-<script id="legacy-path-div" type="text/html">
-   foo
-</script>
\ No newline at end of file
index 1af0b573e15837ce39da76a741218e23f6ee90ec..9d3125a1ab03f7cb23d49c85ff198933f3de314d 100644 (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>
 
diff --git a/pom.xml b/pom.xml
index 513744ceddd6f329dc29871f62d9fadb3bb5a29b..440d5506434fbcb96661edabe94e8d6e2a0e8b95 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <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>