fix admin create box call

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1360437 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-07-11 22:03:04 +00:00
parent 450f03a6a6
commit 69f92105d5
2 changed files with 91 additions and 86 deletions

View File

@ -129,45 +129,6 @@ function() {
$.log("hideElementWithKarma");
}
userLoggedCallbackFn=function(user){
$.log("userLoggedCallbackFn:"+ (user?user.username:null));
if (!user) {
$("#login-link").show();
$("#register-link").show();
$("#change-password-link").hide();
checkUrlParams();
} else {
$("#change-password-link").show();
$("#logout-link").show();
$("#register-link").hide();
$("#login-link").hide();
decorateMenuWithKarma(user);
}
}
checkSecurityLinks=function(){
userLogged(userLoggedCallbackFn);
}
checkCreateAdminLink=function(){
$.ajax("restServices/redbackServices/userService/isAdminUserExists", {
type: "GET",
dataType: 'json',
success: function(data) {
var adminExists = data;
if (adminExists == false) {
$("#create-admin-link").show();
$("#login-link").hide();
$("#register-link").hide();
} else {
$("#create-admin-link").hide();
}
$.log("adminExists:"+adminExists);
}
});
}
//------------------------------------//
// Change UI with appearance settings //
//------------------------------------//
@ -235,58 +196,101 @@ function() {
this.activeMenuId = ko.observable();
window.sammyArchivaApplication = Sammy(function () {
// #artifact-(optionnal repositoryId)
// format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin
// or groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1
this.get('#artifact/:groupId/:artifactId',function(context){
var groupId= this.params['groupId'];
var artifactId= this.params['artifactId'];
$.log("get #artifact:"+groupId+":"+artifactId);
goToBrowseArtifactDetail(groupId,artifactId);//,null,null);
return;
this.get('#open-admin-create-box',function(){
$.log("#open-admin-create-box");
adminCreateBox();
});
});
this.get('#artifact:repositoryId/:groupId/:artifactId/:version',function(context){
// #artifact-(optionnal repositoryId)
// format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin
// or groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1
this.get('#artifact/:groupId/:artifactId',function(context){
var groupId= this.params['groupId'];
var artifactId= this.params['artifactId'];
$.log("get #artifact:"+groupId+":"+artifactId);
goToBrowseArtifactDetail(groupId,artifactId);//,null,null);
return;
var repositoryId = this.params['repositoryId'];
var groupId= this.params['groupId'];
var artifactId= this.params['artifactId'];
var version= this.params['version'];
});
this.get('#artifact:repositoryId/:groupId/:artifactId/:version',function(context){
if(!version){
displayBrowseArtifactDetail(splitted[0],splitted[1]);//,null,null);
} else {
generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId);
}
});
this.get('#browse/:groupId',function(context){
var groupId = this.params['groupId'];
if (groupId){
displayBrowseGroupId(groupId);
} else {
displayBrowse(true);
}
});
this.get('#:folder', function () {
self.activeMenuId(this.params.folder);
var baseItems = self.artifactMenuItems?self.artifactMenuItems:[];
ko.utils.arrayFirst(baseItems.concat(self.usersMenuItems, self.administrationMenuItems), function(p) {
if ( p.href == "#"+self.activeMenuId()) {
p.func();
return;
}
});
var repositoryId = this.params['repositoryId'];
var groupId= this.params['groupId'];
var artifactId= this.params['artifactId'];
var version= this.params['version'];
});
this.get('#open-admin-create-box',function(){
$.log("#open-admin-create-box");
adminCreateBox();
});
//this.get('', function () { this.app.runRoute('get', '#search') });
} );
if(!version){
displayBrowseArtifactDetail(splitted[0],splitted[1]);//,null,null);
} else {
generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId);
}
});
this.get('#browse/:groupId',function(context){
var groupId = this.params['groupId'];
if (groupId){
displayBrowseGroupId(groupId);
} else {
displayBrowse(true);
}
});
this.get('#:folder', function () {
var folder = this.params.folder;
self.activeMenuId(folder);
var baseItems = self.artifactMenuItems?self.artifactMenuItems:[];
ko.utils.arrayFirst(baseItems.concat(self.usersMenuItems, self.administrationMenuItems), function(p) {
if ( p.href == "#"+self.activeMenuId()) {
p.func();
return;
}
});
});
//this.get('', function () { this.app.runRoute('get', '#search') });
});
sammyArchivaApplication.run();
}
userLoggedCallbackFn=function(user){
$.log("userLoggedCallbackFn:"+ (user?user.username:null));
if (!user) {
$("#login-link").show();
$("#register-link").show();
$("#change-password-link").hide();
checkUrlParams();
} else {
$("#change-password-link").show();
$("#logout-link").show();
$("#register-link").hide();
$("#login-link").hide();
decorateMenuWithKarma(user);
}
}
checkSecurityLinks=function(){
userLogged(userLoggedCallbackFn);
}
checkCreateAdminLink=function(callbackFn){
$.ajax("restServices/redbackServices/userService/isAdminUserExists", {
type: "GET",
dataType: 'json',
success: function(data) {
var adminExists = data;
if (adminExists == false) {
$("#create-admin-link").show();
$("#login-link").hide();
$("#register-link").hide();
} else {
$("#create-admin-link").hide();
}
if(callbackFn){
callbackFn()
}
$.log("adminExists:"+adminExists);
}
});
}
startArchivaApplication=function(){
$.log("startArchivaApplication");

View File

@ -296,10 +296,11 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno
* open a modal box to create admin user
*/
adminCreateBox=function() {
$.log("adminCreateBox");
window.redbackModel.createUser=true;
$("#main-content").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}');
var viewModel = new AdminUserViewModel();
ko.applyBindings(viewModel);
ko.applyBindings(viewModel,$("#main-content" ).get(0));
$("#user-create").validate({
rules: {
confirmPassword: {