* under the License.
*/
+import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
+import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
import org.apache.archiva.web.runtime.ArchivaRuntimeInfo;
import org.apache.archiva.web.model.ApplicationRuntimeInfo;
import org.apache.commons.lang.StringUtils;
/**
* @author Olivier Lamy
*/
-@Service( "runtimeInfoService#rest" )
+@Service("runtimeInfoService#rest")
public class DefaultRuntimeInfoService
implements RuntimeInfoService
{
private ArchivaRuntimeInfo archivaRuntimeInfo;
+ @Inject
+ private ArchivaRuntimeConfigurationService archivaRuntimeConfigurationService;
+
@Context
protected HttpServletRequest httpServletRequest;
}
public ApplicationRuntimeInfo getApplicationRuntimeInfo( String locale )
+ throws ArchivaRestServiceException
{
ApplicationRuntimeInfo applicationRuntimeInfo = new ApplicationRuntimeInfo();
applicationRuntimeInfo.setBuildNumber( this.archivaRuntimeInfo.getBuildNumber() );
new Locale( StringUtils.isEmpty( locale ) ? "en" : locale ) );
applicationRuntimeInfo.setTimestampStr( sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) ) );
+ applicationRuntimeInfo.setRedbackRuntimeConfiguration(
+ archivaRuntimeConfigurationService.getRedbackRuntimeConfigurationAdmin() );
+
return applicationRuntimeInfo;
}
* under the License.
*/
+import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.web.model.ApplicationRuntimeInfo;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
* @author Olivier Lamy
* @since 1.4-M3
*/
-@Path( "/runtimeInfoService/" )
+@Path("/runtimeInfoService/")
public interface RuntimeInfoService
{
- @Path( "archivaRuntimeInfo/{locale}" )
+ @Path("archivaRuntimeInfo/{locale}")
@GET
- @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
- @RedbackAuthorization( noRestriction = true )
- ApplicationRuntimeInfo getApplicationRuntimeInfo( @PathParam( "locale" ) String locale );
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ @RedbackAuthorization(noRestriction = true)
+ ApplicationRuntimeInfo getApplicationRuntimeInfo( @PathParam("locale") String locale )
+ throws ArchivaRestServiceException;
- @Path( "logMissingI18n" )
+ @Path("logMissingI18n")
@GET
- @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
- @RedbackAuthorization( noRestriction = true )
- Boolean logMissingI18n( @QueryParam( "key" ) String key );
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ @RedbackAuthorization(noRestriction = true)
+ Boolean logMissingI18n( @QueryParam("key") String key );
}
* under the License.
*/
+import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
+
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Calendar;
* @author Olivier Lamy
* @since 1.4-M3
*/
-@XmlRootElement( name = "applicationRuntimeInfo" )
+@XmlRootElement(name = "applicationRuntimeInfo")
public class ApplicationRuntimeInfo
{
private boolean devMode = false;
private String timestampStr;
+ private RedbackRuntimeConfiguration redbackRuntimeConfiguration;
+
public ApplicationRuntimeInfo()
{
this.devMode = Boolean.getBoolean( "archiva.devMode" );
this.timestampStr = timestampStr;
}
+ public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
+ {
+ return redbackRuntimeConfiguration;
+ }
+
+ public void setRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
+ {
+ this.redbackRuntimeConfiguration = redbackRuntimeConfiguration;
+ }
+
@Override
public String toString()
{
sb.append( ", logMissingI18n=" ).append( logMissingI18n );
sb.append( ", baseUrl='" ).append( baseUrl ).append( '\'' );
sb.append( ", timestampStr='" ).append( timestampStr ).append( '\'' );
+ sb.append( ", redbackRuntimeConfiguration=" ).append( redbackRuntimeConfiguration );
sb.append( '}' );
return sb.toString();
}
"archiva.search": "archiva/search",
"archiva.proxy-connectors-rules": "archiva/proxy-connectors-rules",
"archiva.docs": "archiva/docs",
- "archiva.main": "archiva/main"
+ "archiva.main": "archiva/main",
+ "archiva.knockout.properties": "archiva/knockout-properties"
}
});
- requirejs(['jquery','jquery.tmpl','jquery.ui','i18n','sammy','startup','utils','domReady!','archiva.main'], function () {
+ requirejs(['jquery','jquery.tmpl','jquery.ui','i18n','sammy','startup','utils','domReady!','archiva.main','archiva.general-admin'], function () {
loadi18n(function () {
$.ajax({
url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(),
dataType: 'json',
success:function(data){
- window.archivaDevMode=data.devMode;
- window.archivaJavascriptLog=data.javascriptLog;
- window.archivaRuntimeInfo=data;
+ window.archivaDevMode=data.devMode;
+ window.archivaJavascriptLog=data.javascriptLog;
+ window.archivaRuntimeInfo=data;
- require(['sammy','jquery','i18n','jquery.tmpl','archiva.main','utils','domReady!'],function () {
- startArchivaApplication();
- $("#loadingDiv").hide();
- drawQuickSearchAutocomplete();
- })
+ window.redbackRuntimeConfiguration=mapRedbackRuntimeConfiguration(data.redbackRuntimeConfiguration);
+
+ $.log("security.rememberme.enabled key value:"+ window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled'));
+
+ require(['sammy','jquery','i18n','jquery.tmpl','archiva.main','utils','domReady!'],function () {
+ startArchivaApplication();
+ $("#loadingDiv").hide();
+ drawQuickSearchAutocomplete();
+ })
}
})
});
* under the License.
*/
define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout","knockout.simpleGrid",
- "knockout.sortable","jquery.validate","bootstrap"]
+ "knockout.sortable","jquery.validate","bootstrap","archiva.knockout.properties"]
, function(jquery,i18n,utils,jqueryTmpl,ko) {
//-------------------------
self.modified(true);
$.log("configurationPropertiesEntries modified")
});
+
+ this.findPropertyValue=function(key){
+ for(var i=0;i<self.configurationPropertiesEntries().length;i++){
+ if(self.configurationPropertiesEntries()[i].key==key){
+ var val = self.configurationPropertiesEntries()[i].value;
+ $.log("findPropertyValue " + key + "->" + val);
+ return val;
+ }
+ }
+ }
}
mapRedbackRuntimeConfiguration=function(data){
this.usedUserManagerImpls=ko.observableArray([]);
+ self.gridViewModel = new ko.simpleGrid.viewModel({
+ data: self.redbackRuntimeConfiguration().configurationPropertiesEntries,
+ columns: [
+ {
+ headerText: $.i18n.prop('redback.runtime.properties.key.label'),
+ rowText: "key"
+ },
+ {
+ headerText: $.i18n.prop('redback.runtime.properties.value.label'),
+ rowText: "value"
+ }
+ ],
+ pageSize: 10,//self.redbackRuntimeConfiguration().configurationPropertiesEntries.length,
+ gridUpdateCallBack: function(){
+
+ }
+ });
+
findUserManagerImplementationInformation=function(id){
for(var i= 0;i<self.userManagerImplementationInformations().length;i++){
$.log(id+""+self.userManagerImplementationInformations()[i].beanId);
var userMessages=$("#user-messages");
userMessages.html(mediumSpinnerImg());
self.redbackRuntimeConfiguration().userManagerImpls=ko.observableArray([]);
- $.log("length:"+self.usedUserManagerImpls().length);
+
for(var i=0;i<self.usedUserManagerImpls().length;i++){
var beanId=self.usedUserManagerImpls()[i].beanId;
$.log("beanId:"+beanId);
self.redbackRuntimeConfiguration().userManagerImpls.push(beanId);
}
- $.log("length:"+self.redbackRuntimeConfiguration().userManagerImpls().length);
- $.log("json:"+ko.toJSON(self.redbackRuntimeConfiguration));
+ $.log("rememberme enabled:"+self.redbackRuntimeConfiguration().findPropertyValue("security.rememberme.enabled"));
$.ajax("restServices/archivaServices/archivaRuntimeConfigurationService/redbackRuntimeConfiguration",
{
type: "PUT",
type: "GET",
dataType: 'json',
success: function(data) {
+ // TODO use window.redbackRuntimeConfiguration ?
var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data);
var redbackRuntimeConfigurationViewModel =
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
- mainContent.html( $( "#runtime-configuration-main" ).tmpl() );
- ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#runtime-configuration-content" ).get(0));
+ mainContent.html( $("#redback-runtime-configuration-main" ).tmpl() );
+ ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0));
activatePopoverDoc();
}
});
*/
Entry=function(key,value,subscribeFn){
var self=this;
+ this.modified=ko.observable(false);
+ this.modified.subscribe(function(newValue){
+ $.log("Entry modified");
+ });
+
this.key=ko.observable(key);
- if(subscribeFn){
- this.key.subscribe(function(newValue){subscribeFn(newValue)});
- }
+ this.key.subscribe(function(newValue){
+ self.modified(true);
+ if(subscribeFn){
+ subscribeFn(newValue)
+ }
+ });
+
this.value=ko.observable(value);
- if(subscribeFn){
- this.value.subscribe(function(newValue){$.log("value modified");subscribeFn(newValue);});
- }
+ this.value.subscribe(function(newValue){
+ self.modified(true);
+ if(subscribeFn){
+ subscribeFn(newValue)
+ }
+ });
+
+
}
/**
- (function(factory) {
- if (typeof define === "function" && define.amd) {
- // AMD anonymous module
- define("knockout.simpleGrid",["jquery","knockout","utils","i18n"], factory);
- } else {
- // No module loader (plain <script> tag) - put directly in global namespace
- factory(window.ko, jQuery);
- }
- })(function ($,ko,utils,i18n) {
-
-
- ko.simpleGrid = {
- // Defines a view model class you can use to populate a grid
- viewModel: function (configuration) {
- this.data = configuration.data;
- this.currentPageIndex = ko.observable(0);
- this.pageSize = configuration.pageSize || 5;
- this.columns = configuration.columns;
-
- this.itemsOnCurrentPage = ko.computed(function () {
- var startIndex = this.pageSize * this.currentPageIndex();
- return this.data.slice(startIndex, startIndex + this.pageSize);
- }, this);
-
- this.maxPageIndex = ko.computed(function () {
- return Math.ceil(ko.utils.unwrapObservable(this.data).length / this.pageSize);
- }, this);
- this.i18n=function(key){
- return $.i18n.prop(key);
- };
- this.gridUpdateCallBack = configuration.gridUpdateCallBack;
- this.pageLinksUpdateCallBack = configuration.pageLinksUpdateCallBack;
-
- }
+(function(factory) {
+ if (typeof define === "function" && define.amd) {
+ // AMD anonymous module
+ define("knockout.simpleGrid",["jquery","knockout","utils","i18n"], factory);
+ } else {
+ // No module loader (plain <script> tag) - put directly in global namespace
+ factory(window.ko, jQuery);
+ }
+})(function ($,ko,utils,i18n) {
+
+
+ ko.simpleGrid = {
+ // Defines a view model class you can use to populate a grid
+ viewModel: function (configuration) {
+ this.data = configuration.data;
+ this.currentPageIndex = ko.observable(0);
+ this.pageSize = configuration.pageSize || 5;
+ this.columns = configuration.columns;
+
+ this.itemsOnCurrentPage = ko.computed(function () {
+ var startIndex = this.pageSize * this.currentPageIndex();
+ return this.data.slice(startIndex, startIndex + this.pageSize);
+ }, this);
+
+ this.maxPageIndex = ko.computed(function () {
+ return Math.ceil(ko.utils.unwrapObservable(this.data).length / this.pageSize);
+ }, this);
+ this.i18n=function(key){
+ return $.i18n.prop(key);
};
+ this.gridUpdateCallBack = configuration.gridUpdateCallBack;
+ this.pageLinksUpdateCallBack = configuration.pageLinksUpdateCallBack;
+
+ }
+ };
- // Templates used to render the grid
- var templateEngine = new ko.jqueryTmplTemplateEngine();
+ // Templates used to render the grid
+ var templateEngine = new ko.jqueryTmplTemplateEngine();
- // The "simpleGrid" binding
- ko.bindingHandlers.simpleGrid = {
- // This method is called to initialize the node, and will also be called again if you change what the grid is bound to
- update: function (element, viewModelAccessor, allBindingsAccessor) {
- var viewModel = viewModelAccessor(), allBindings = allBindingsAccessor();
+ // The "simpleGrid" binding
+ ko.bindingHandlers.simpleGrid = {
+ // This method is called to initialize the node, and will also be called again if you change what the grid is bound to
+ update: function (element, viewModelAccessor, allBindingsAccessor) {
+ var viewModel = viewModelAccessor(), allBindings = allBindingsAccessor();
- // Empty the element
- while(element.firstChild) {
- ko.removeNode(element.firstChild);
- }
+ // Empty the element
+ while(element.firstChild) {
+ ko.removeNode(element.firstChild);
+ }
- // Allow the default templates to be overridden
- var gridTemplateName = allBindings.simpleGridTemplate || "ko_usersGrid_grid",
- pageLinksTemplateName = allBindings.simpleGridPagerTemplate || "ko_simpleGrid_pageLinks";
+ // Allow the default templates to be overridden
+ var gridTemplateName = allBindings.simpleGridTemplate || "ko_usersGrid_grid",
+ pageLinksTemplateName = allBindings.simpleGridPagerTemplate || "ko_simpleGrid_pageLinks";
- // Render the main grid
- var gridContainer = element.appendChild(document.createElement("DIV"));
- ko.renderTemplate(gridTemplateName, viewModel, { templateEngine: templateEngine }, gridContainer, "replaceNode")
- .subscribe(viewModel.gridUpdateCallBack?viewModel.gridUpdateCallBack:function(){});
+ // Render the main grid
+ var gridContainer = element.appendChild(document.createElement("DIV"));
+ ko.renderTemplate(gridTemplateName, viewModel, { templateEngine: templateEngine }, gridContainer, "replaceNode")
+ .subscribe(viewModel.gridUpdateCallBack?viewModel.gridUpdateCallBack:function(){});
- if (viewModel.gridUpdateCallBack) viewModel.gridUpdateCallBack();
+ if (viewModel.gridUpdateCallBack) viewModel.gridUpdateCallBack();
- // Render the page links
- var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0);
- var renderedTemplate = ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode");
- if (renderedTemplate.subscribe){
- renderedTemplate.subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){});
- }
- if (viewModel.pageLinksUpdateCallBack) viewModel.pageLinksUpdateCallBack();
- }
- };
+ // Render the page links
+ var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0);
+ var renderedTemplate = ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode");
+ if (renderedTemplate.subscribe){
+ renderedTemplate.subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){});
+ }
+ if (viewModel.pageLinksUpdateCallBack) viewModel.pageLinksUpdateCallBack();
+ }
+ };
})
$.log("user not in cookie");
}
+ var rememberMe=window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled');
+ $.log("rememberMe:"+rememberMe);
+ if (rememberMe!='true'){
+ $("#user-login-form-rememberme-label" ).hide();
+ $("#user-login-form-rememberme" ).attr("disabled","true");
+ if($("#user-login-form-rememberme" ).get(0 ).checked){
+ $("#user-login-form-rememberme" ).get(0 ).checked=false;
+ }
+ }
+
var userLoginForm = $("#user-login-form");
userLoginForm.validate({
</tbody>
</script>
-<script type="text/html" id="runtime-configuration-main">
+<script type="text/html" id="redback-runtime-configuration-main">
<div class="page-header">
<h2>${$.i18n.prop('redback-runtime-configuration.title')}</h2>
</div>
- <div id="runtime-configuration-content" data-bind='template: {name:"redback-runtime-configuration-content-tmpl"}'>
+ <div id="redback-runtime-configuration-content" data-bind='template: {name:"redback-runtime-configuration-content-tmpl"}'>
</div>
</script>
</div>
<div class="tab-pane" id="redback-runtime-properties-content">
- <div class="well">
- <table>
- <thead>
- <tr>
- <th></th>
- <th>${$.i18n.prop('redback.runtime.properties.key.label')}</th>
- <th>${$.i18n.prop('redback.runtime.properties.value.label')}</th>
- </tr>
- </thead>
- <tbody>
- {{each(i, property) redbackRuntimeConfiguration().configurationPropertiesEntries}}
- <tr>
- <td>
- {{var key = property.key}}
- <a class="popover-doc"
- data-original-title="${$.i18n.prop('redback.runtime.properties.help.title')}"
- data-content="${$.i18n.prop(key+'.help.content')}">
- <span class="btn btn-info"><i class="icon-question-sign icon-white"></i></span>
- </a>
- </td>
- <td><input type="text" class="input-xxlarge" value="${property.key}"></td>
- <td><input type="text" class="input-xlarge" value="${property.value}"></td>
- </tr>
- {{/each}}
- </tbody>
+ <div class="well">
+ <table id="proxyConnectorsTable"
+ data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'properties-grid',pageLinksId:'properties-grid-pagination'">
</table>
+ <div id="properties-grid-pagination"></div>
</div>
</div>
<div>
<button data-bind="click: saveRedbackRuntimeConfiguration,css:{ 'btn-warning': redbackRuntimeConfiguration().modified() | redbackRuntimeConfiguration().ldapConfiguration().modified() }"
- id="redback-archiva-runtime-configuration-save"class="btn">${$.i18n.prop('save')}</button>
+ id="redback-runtime-configuration-save"class="btn">${$.i18n.prop('save')}</button>
</div>
</script>
-<script id="configurationPropertiesEntries-tmpl" type="text/html">
+<script id='properties-grid' type='text/html'>
+ <thead>
+ <tr>
+ <th></th>
+ <th>${$.i18n.prop('redback.runtime.properties.key.label')}</th>
+ <th>${$.i18n.prop('redback.runtime.properties.value.label')}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{each(i, row) itemsOnCurrentPage()}}
+ <tr>
+ <td>
+ {{var key = row.key}}
+ <a class="popover-doc"
+ data-original-title="${$.i18n.prop('redback.runtime.properties.help.title')}"
+ data-content="${$.i18n.prop(key+'.help.content')}">
+ <span class="btn btn-info"><i class="icon-question-sign icon-white"></i></span>
+ </a>
+ </td>
+ <td>${row.key}</td>
+ <td><input type="text" class="input-xxlarge" data-bind="value: row.value"></td>
+ </tr>
+ {{/each}}
+ </tbody>
</script>
</div>
<div class="modal-footer" id="modal-login-footer">
<div class="pull-left">
- <label class="checkbox">
+ <label class="checkbox" id="user-login-form-rememberme-label">
<input type="checkbox" id="user-login-form-rememberme">${$.i18n.prop('rememberme')}
</label>
</div>