[MRM-1585] rewrite appareance page

Submitted by Adrien Lecharpentier.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1302957 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-20 15:57:31 +00:00
parent 52b9c651fa
commit 807d29a1e1
7 changed files with 173 additions and 4 deletions

View File

@ -189,7 +189,7 @@ public interface ArchivaAdministrationService
@Path( "getOrganisationInformation" ) @Path( "getOrganisationInformation" )
@GET @GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) @RedbackAuthorization( noPermission = true, noRestriction = true)
OrganisationInformation getOrganisationInformation() OrganisationInformation getOrganisationInformation()
throws ArchivaRestServiceException; throws ArchivaRestServiceException;

View File

@ -138,6 +138,7 @@ menu.topbar.quicksearch=Quick Search
menu.legacy-artifact-support=Legacy Support menu.legacy-artifact-support=Legacy Support
menu.repository-scanning=Repository Scanning menu.repository-scanning=Repository Scanning
menu.system-status=System Status menu.system-status=System Status
menu.appearance-configuration=Appearance
#user #user
user.change.password.required=Change password required 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.average=Average
system-status.scanning.consumers.grid.header.invocations.time=Invocations time 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

View File

@ -740,5 +740,86 @@ $(function() {
displayServerTime(); 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);
}
});
}
});
}
}); });

View File

@ -156,6 +156,10 @@ $(function() {
displayBrowse(true); displayBrowse(true);
return; return;
} }
if (screen=='appearance-configuration'&& hasKarma('archiva-manage-configuration')){
displayAppearanceConfiguration();
return
}
} }
// by default display search screen // by default display search screen
displaySearch(); 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(){ startArchivaApplication=function(){
@ -315,6 +352,7 @@ $(function() {
.append( "<a>" + item.artifactId + "</a>" ) .append( "<a>" + item.artifactId + "</a>" )
.appendTo( ul ); .appendTo( ul );
};; };;
updateAppearanceToolBar();
} }
startArchivaApplication(); startArchivaApplication();

View File

@ -466,5 +466,44 @@
{{/if}} {{/if}}
</script> </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>

View File

@ -54,6 +54,9 @@
<li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}"> <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> <a href="#" id="menu-system-status-list-a" onclick="displaySystemStatus()">${$.i18n.prop('menu.system-status')}</a>
</li> </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> </ul>

View File

@ -21,7 +21,7 @@
<div style="max-height: 40px" class="navbar-inner"> <div style="max-height: 40px" class="navbar-inner">
<div class="container-fluid"> <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"> <div class="nav-collapse">
<ul class="nav pull-right"> <ul class="nav pull-right">
<li id="create-admin-link" class="pull-right" style="display: none"> <li id="create-admin-link" class="pull-right" style="display: none">