mirror of https://github.com/apache/archiva.git
[MRM-918] Switch for disabling user registration.
implements ui part. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1384696 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fa31d5bba5
commit
745421c230
|
@ -207,6 +207,13 @@ public interface ArchivaAdministrationService
|
|||
UiConfiguration getUiConfiguration()
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "registrationDisabled" )
|
||||
@GET
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@RedbackAuthorization( noRestriction = true, noPermission = true )
|
||||
Boolean registrationDisabled()
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "setUiConfiguration" )
|
||||
@POST
|
||||
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
|
|
|
@ -48,7 +48,7 @@ import java.util.List;
|
|||
* @author Olivier Lamy
|
||||
* @since 1.4-M1
|
||||
*/
|
||||
@Service( "archivaAdministrationService#default" )
|
||||
@Service ( "archivaAdministrationService#default" )
|
||||
public class DefaultArchivaAdministrationService
|
||||
extends AbstractRestService
|
||||
implements ArchivaAdministrationService
|
||||
|
@ -57,7 +57,7 @@ public class DefaultArchivaAdministrationService
|
|||
private ArchivaAdministration archivaAdministration;
|
||||
|
||||
@Inject
|
||||
@Named( value = "managedRepositoryContent#legacy" )
|
||||
@Named ( value = "managedRepositoryContent#legacy" )
|
||||
private ManagedRepositoryContent repositoryContent;
|
||||
|
||||
@Inject
|
||||
|
@ -342,6 +342,11 @@ public class DefaultArchivaAdministrationService
|
|||
}
|
||||
}
|
||||
|
||||
public Boolean registrationDisabled()
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
return getUiConfiguration().isDisableRegistration();
|
||||
}
|
||||
|
||||
public UiConfiguration getUiConfiguration()
|
||||
throws ArchivaRestServiceException
|
||||
|
|
|
@ -573,14 +573,15 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
|||
dataType: 'json',
|
||||
success: function(data){
|
||||
mainContent.html($("#ui-configuration-screen").tmpl());
|
||||
var uiConfiguration=new UiConfiguration(data.showFindArtifacts,data.appletFindEnabled,data.disableEasterEggs,data.applicationUrl);
|
||||
var uiConfiguration=new UiConfiguration(data.showFindArtifacts,data.appletFindEnabled,data.disableEasterEggs,
|
||||
data.applicationUrl,data.disableRegistration);
|
||||
var uiConfigurationViewModel=new UiConfigurationViewModel(uiConfiguration);
|
||||
ko.applyBindings(uiConfigurationViewModel,mainContent.get(0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
UiConfiguration=function(showFindArtifacts,appletFindEnabled,disableEasterEggs,applicationUrl){
|
||||
UiConfiguration=function(showFindArtifacts,appletFindEnabled,disableEasterEggs,applicationUrl,disableRegistration){
|
||||
this.showFindArtifacts = ko.observable(showFindArtifacts);
|
||||
|
||||
this.appletFindEnabled = ko.observable(appletFindEnabled);
|
||||
|
@ -588,6 +589,9 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
|||
this.disableEasterEggs = ko.observable(disableEasterEggs);
|
||||
|
||||
this.applicationUrl = ko.observable(applicationUrl);
|
||||
|
||||
// default to false
|
||||
this.disableRegistration = ko.observable(disableRegistration?disableRegistration:false);
|
||||
}
|
||||
|
||||
UiConfigurationViewModel=function(uiConfiguration){
|
||||
|
|
|
@ -126,35 +126,45 @@ function(jquery,ui,sammy,tmpl) {
|
|||
// Change UI with appearance settings //
|
||||
//------------------------------------//
|
||||
updateAppearanceToolBar=function() {
|
||||
$.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", {
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var organisationLogo=$("#organisation-logo");
|
||||
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";
|
||||
$.ajax("restServices/archivaServices/archivaAdministrationService/registrationDisabled", {
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
//var disableRegistration=data.disableRegistration;
|
||||
if( data){
|
||||
$.log("disableRegistration");
|
||||
$("#topbar-menu").find("#register-link" ).hide();
|
||||
}
|
||||
$.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", {
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var organisationLogo=$("#main-content").find("#organisation-logo");
|
||||
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>";
|
||||
organisationLogo.html(link);
|
||||
}
|
||||
link+="</a>";
|
||||
organisationLogo.html(link);
|
||||
}
|
||||
if (!data.url && data.name){
|
||||
organisationLogo.html("<a href='/' class='brand'>"+data.name+"</a>");
|
||||
}
|
||||
if (!data.url && !data.name){
|
||||
if (!data.url && data.name){
|
||||
organisationLogo.html("<a href='/' class='brand'>"+data.name+"</a>");
|
||||
}
|
||||
if (!data.url && !data.name){
|
||||
organisationLogo.html("<a href='/' class='brand'>Archiva</a>");
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
organisationLogo.html("<a href='/' class='brand'>Archiva</a>");
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
organisationLogo.html("<a href='/' class='brand'>Archiva</a>");
|
||||
}
|
||||
});
|
||||
});
|
||||
}});
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -328,10 +328,18 @@
|
|||
<div class="control-group">
|
||||
<label class="control-label" for="maxTotal">${$.i18n.prop('ui-configuration.applicationUrl')}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="xlarge required digits" id="applicationUrl" name="applicationUrl" size="8"
|
||||
<input type="text" class="input-xlarge required digits" id="applicationUrl" name="applicationUrl" size="8"
|
||||
data-bind="value: uiConfiguration().applicationUrl"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="disableRegistration">${$.i18n.prop('ui-configuration.applicationUrl.disableRegistration')}</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" id="disableRegistration" name="disableRegistration" data-bind="checked: uiConfiguration().disableRegistration"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
<button id="ui-configuration-btn-save" data-bind="click: save" class="btn">${$.i18n.prop('save')}</button>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue