]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1585] rewrite appareance page
authorOlivier Lamy <olamy@apache.org>
Tue, 20 Mar 2012 15:57:31 +0000 (15:57 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 20 Mar 2012 15:57:31 +0000 (15:57 +0000)
Submitted by Adrien Lecharpentier.

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

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java
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
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/topbar.html

index 8012a29b5cf56a05b1fe20ceec4fe4e981f83c5a..95bab990a871f6e0bb336945d69ea3858263a3f8 100644 (file)
@@ -189,7 +189,7 @@ public interface ArchivaAdministrationService
     @Path( "getOrganisationInformation" )
     @GET
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
-    @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+    @RedbackAuthorization( noPermission = true, noRestriction = true)
     OrganisationInformation getOrganisationInformation()
         throws ArchivaRestServiceException;
 
index 56c3880a0705bbc56d25d8db97d562f1d595a079..587232a7fa5bc6cd795f7efd041866b1b80ec1ec 100644 (file)
@@ -138,6 +138,7 @@ menu.topbar.quicksearch=Quick Search
 menu.legacy-artifact-support=Legacy Support
 menu.repository-scanning=Repository Scanning
 menu.system-status=System Status
+menu.appearance-configuration=Appearance
 
 #user
 user.change.password.required=Change password required
@@ -346,7 +347,14 @@ system-status.scanning.consumers.grid.header.total=Total
 system-status.scanning.consumers.grid.header.average=Average
 system-status.scanning.consumers.grid.header.invocations.time=Invocations time
 
-
-
+# appearance configuration
+appearance-configuration.title-page=Configure appearance
+appearance-configuration.organisation-details=Details
+apperance-configuration.details-description=Enter the details of your organization below.
+appearance-configuration.name-label=Name
+appearance-configuration.url-label=URL
+appearance-configuration.logoLocation-label=Logo Location
+appearance-configuration.updated=Appearance has been updated
+appearance-configuration.updating-error=Error during appearance setting
 
 
index 6ebafb9b36c72a2a6102d6e6979d2647a7793700..649a00cfa7105b07d3b7dbcbbbcdf2af1b479201 100644 (file)
@@ -740,5 +740,86 @@ $(function() {
     displayServerTime();
   }
 
+  //---------------------------
+  // network configuration part
+  //---------------------------
+  OrganisationInformation=function(name,url,logoLocation){
+    this.name=ko.observable(name);
+    this.url=ko.observable(url);
+    this.logoLocation=ko.observable(logoLocation);
+  }
+  mapOrganisationInformation=function(data){
+    return new OrganisationInformation(data.name, data.url, data.logoLocation);
+  }
+  mapOrganisationInformations=function(data){
+    if (data!=null){
+      return $.isArray(data)? $.map(data, function(item){
+        return mapOrganisationInformation(item);
+      }):[mapOrganisationInformation(data)];
+    }
+  }
+  activateOrganisationInformationFormValidation=function(){
+    var validate = $("#main-content #appearance-configuration-form-id").validate({
+      rules: {
+        name: {
+          required: true
+        },
+        url: {
+          required:true,
+          url:true
+        },
+        logoLocation: {
+          required:false,
+          url:true
+        }
+      },
+      showErrors: function(validator, errorMap, errorList) {
+        customShowError("#main-content #appearance-configuration-form-id", validator, errorMap, errorMap);
+      }
+    })
+  }
+  OrganisationInformationViewModel=function(organisationInformation){
+    activateOrganisationInformationFormValidation();
+    this.organisationInformation=ko.observable(organisationInformation);
 
+    this.save=function(){
+      if (!$("#main-content #appearance-configuration-form-id").valid()) {
+          return;
+      }
+      clearUserMessages();
+      $.ajax("restServices/archivaServices/archivaAdministrationService/setOrganisationInformation", {
+        type: "POST",
+        contentType: "application/json",
+        data: ko.toJSON(this.organisationInformation),
+        dataType: "json",
+        success: function(data){
+          displaySuccessMessage($.i18n.prop('appearance-configuration.updated'));
+          updateAppearanceToolBar();
+        },
+        error: function(data){
+          displayErrorMessage($.i18n.prop('appearance-configuration.updating-error'));
+        }
+      });
+    }
+  }
+  displayAppearanceConfiguration=function(){
+    screenChange();
+    var mainContent=$("#main-content");
+    mainContent.html($("#changeAppearance").tmpl());
+
+    $.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", {
+      type: "GET",
+      dataType: 'json',
+      success: function(data) {
+        var organisationInformation=new OrganisationInformation(data.name,data.url,data.logoLocation);
+        var organisationInformationViewModel=new OrganisationInformationViewModel(organisationInformation);
+        ko.applyBindings(organisationInformationViewModel, mainContent.get(0));
+        var validator = $("#main-content #appearance-configuration-form-id").validate({
+          showErrors: function(validator,errorMap,errorList) {
+            customShowError(mainContent.find("#appearance-configuration-form-id").get(0),validator,errorMap,errorMap);
+          }
+        });
+      }
+    });
+  }
 });
\ No newline at end of file
index 2d50df70e1ae39672a58c151cf0afe7d47204005..e4bfc985c64c91362881287a0e12507f44e0b640 100644 (file)
@@ -156,6 +156,10 @@ $(function() {
         displayBrowse(true);
         return;
       }
+      if (screen=='appearance-configuration'&& hasKarma('archiva-manage-configuration')){
+        displayAppearanceConfiguration();
+        return
+      }
     }
     // by default display search screen
     displaySearch();
@@ -261,6 +265,39 @@ $(function() {
     });
   }
 
+    //------------------------------------//
+    // Change UI with appearance settings //
+    //------------------------------------//
+    updateAppearanceToolBar=function() {
+        $.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", {
+            type: "GET",
+            dataType: 'json',
+            success: function(data) {
+                if(data.url){
+                  var url = data.url.startsWith("http://") || data.url.startsWith("https://") ? data.url : "http://"+data.url;
+                  var link="<a href='"+url+"' class='brand'>";
+                  if (data.logoLocation) {
+                      link+="<img src='"+data.logoLocation+"' style='max-height: 30px'/>";
+                  } else if (data.name) {
+                      link+=data.name;
+                  } else {
+                      link+="Archiva";
+                  }
+                  link+="</a>";
+                  $("#organisation-logo").html(link);
+                }
+              if (!data.url && data.name){
+                $("#organisation-logo").html("<a href='/' class='brand'>"+data.name+"</a>");
+              }
+              if (!data.url && !data.name){
+                $("#organisation-logo").html("<a href='/' class='brand'>Archiva</a>");
+              }
+            },
+            error: function() {
+                $("#organisation-logo").html("<a href='/' class='brand'>Archiva</a>");
+            }
+        });
+    }
 
 
   startArchivaApplication=function(){
@@ -315,6 +352,7 @@ $(function() {
                                                                .append( "<a>" + item.artifactId + "</a>" )
                                                                .appendTo( ul );
                                                };;
+    updateAppearanceToolBar();
   }
   startArchivaApplication();
 
index 318cf3b6ad14c4518d391246c89415f34dad381a..14504c4a9bf175d01048d4e1fbd0bf96068fcdf5 100644 (file)
   {{/if}}
 </script>
 
+<script id="changeAppearance" type="text/html">
+    <div class="page-header">
+        <h2>${$.i18n.prop('appearance-configuration.title-page')}</h2>
+    </div>
+
+    <h2>${$.i18n.prop('appearance-configuration.organisation-details')}</h2>
+
+    <p>
+        ${$.i18n.prop('apperance-configuration.details-description')}
+    </p>
+    
+    <form id="appearance-configuration-form-id" class="well form-horizontal">
+        <fieldset id="appearance-configuration-fielset-id">
+            <div class="control-group">
+                <label class="control-label" for="name">${$.i18n.prop('appearance-configuration.name-label')}</label>
+                <div class="controls">
+                    <input type="text" class="xlarge required" id="name" name="name" size="50"
+                           data-bind="value: organisationInformation().name"/>
+                </div>
+            </div>
+            <div class="control-group">
+                <label class="control-label" for="name">${$.i18n.prop('appearance-configuration.url-label')}</label>
+                <div class="controls">
+                    <input type="text" class="xlarge required" id="url" name="url" size="50"
+                           data-bind="value: organisationInformation().url"/>
+                </div>
+            </div>
+            <div class="control-group">
+                <label class="control-label"
+                       for="name">${$.i18n.prop('appearance-configuration.logoLocation-label')}</label>
+                <div class="controls">
+                    <input type="text" class="xlarge" id="logoLocation" name="logoLocation" size="50"
+                           data-bind="value: organisationInformation().logoLocation"/>
+                </div>
+            </div>
+        </fieldset>
+        <button id="appearance-configuration-btn-save" data-bind="click: save" class="btn">${$.i18n.prop('save')}</button>
+    </form>
+</script>
 
 
index bb59636bc6ef09f8cc351b85113a23fbabfc98fc..cf1c79a50cb6905d8bc3ce006d541138dfdcc5ce 100644 (file)
@@ -54,6 +54,9 @@
       <li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
         <a href="#" id="menu-system-status-list-a" onclick="displaySystemStatus()">${$.i18n.prop('menu.system-status')}</a>
       </li>
+      <li style="display:none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
+        <a href="#" id="menu-appearance-list-a" onclick="displayAppearanceConfiguration()">${$.i18n.prop('menu.appearance-configuration')}</a>
+      </li>
 
 
     </ul>
index 7409f749c7de61e14c76235f2c3e1f5cc4541da0..4b531777ba361304aaadfad63b21f808fc85822f 100644 (file)
@@ -21,7 +21,7 @@
 
   <div style="max-height: 40px" class="navbar-inner">
     <div class="container-fluid">
-      <a class="brand pull-left" href="index.html">Archiva</a>
+      <div id="organisation-logo" class="pull-left"></div>
       <div class="nav-collapse">
       <ul class="nav pull-right">
         <li id="create-admin-link" class="pull-right" style="display: none">