diff options
7 files changed, 173 insertions, 4 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java index 8012a29b5..95bab990a 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java @@ -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; 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 56c3880a0..587232a7f 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 @@ -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 diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js index 6ebafb9b3..649a00cfa 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js @@ -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 diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 2d50df70e..e4bfc985c 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -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(); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html index 318cf3b6a..14504c4a9 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html @@ -466,5 +466,44 @@ {{/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> diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html index bb59636bc..cf1c79a50 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html @@ -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> diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/topbar.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/topbar.html index 7409f749c..4b531777b 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/topbar.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/topbar.html @@ -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"> |