Commit 567dd1d2 authored by Yadd's avatar Yadd
Browse files

New manager in progress: now displays errors on upload

parent 4d47d927
......@@ -82,7 +82,7 @@ LDAPSUFFIX=dc=example,dc=com
VERSION=`head -n1 changelog |sed -e 's/lemonldap-ng (//' -e 's/).*$$//'`
PORTALSKINS=`ls lemonldap-ng-portal/example/skins/`
MANAGERSKINS=`ls lemonldap-ng-manager/example/skins/`
DIFF=diff -aburN -x '*.bak' -x .svn
DIFF=diff -aburN -x '*.bak' -x .svn -x '*.swp'
SRCCOMMONDIR=lemonldap-ng-common
SRCHANDLERDIR=lemonldap-ng-handler
......
......@@ -5,153 +5,166 @@
var simpleTreeCollection;
$(document).ready(function(){
/* Drag and resize divs (require jQuery UI)*/
$("#help").draggable({ handle: 'h1', opacity: '0.70' });
$("#help").resizable({ handles: 'all', alsoResize: '#help_content', ghost: 'true'});
/* Simple Tree */
simpleTreeCollection = $(".simpleTree").simpleTree({
autoclose: false,
drag: false,
afterClick:function(node){
var span=$('span:first',node);
$('#help_content').load(scriptname+'?help='+span.attr('help'));
},
afterDblClick:function(node){
//alert("text-"+$("span:first",node).text());
},
afterMove:function(destination, source, pos){
//alert("destination-"+$("span:first",destination).text()+" source-"+$("span:first",source).text()+" pos-"+pos);
},
afterAjax:function() {
//alert("Loaded");
},
animate:true
//,docToFolderConvert:true
});
/* Drag and resize divs (require jQuery UI)*/
$("#help").draggable({ handle: 'h1', opacity: '0.70' });
$("#help").resizable({ handles: 'all', alsoResize: '#help_content', ghost: 'true'});
/* Simple Tree */
simpleTreeCollection = $(".simpleTree").simpleTree({
autoclose: false,
drag: false,
afterClick:function(node){
var span=$('span:first',node);
$('#help_content').load(scriptname+'?help='+span.attr('help'));
},
afterDblClick:function(node){
//alert("text-"+$("span:first",node).text());
},
afterMove:function(destination, source, pos){
//alert("destination-"+$("span:first",destination).text()+" source-"+$("span:first",source).text()+" pos-"+pos);
},
afterAjax:function() {
//alert("Loaded");
},
animate:true
//,docToFolderConvert:true
});
});
var currentId;
function lmtext(id){
return $('#text_'+id).attr('name');
return $('#text_'+id).attr('name');
}
function lmdata(id){
return $('#text_'+id).attr('value');
return $('#text_'+id).attr('value');
}
function lmparent(id){
return $('#'+id).parent().parent().attr('id');
return $('#'+id).parent().parent().attr('id');
}
function setlmtext(id,v){
if(v.length==0){
alert("Null value");
}
else {
$('#text_'+id).attr('name',v);
$('#text_'+id).text(v);
}
if(v.length==0){
alert("Null value");
}
else {
$('#text_'+id).attr('name',v);
$('#text_'+id).text(v);
}
}
function setlmdata(id,v){
$('#text_'+id).attr('value',v);
$('#text_'+id).attr('value',v);
}
function display(div,title) {
var divs=$('#content').children();
divs.toggleClass('hidden',true);
divs.removeClass('content');
$('#content_'+div).removeClass('hidden');
$('#content_'+div).addClass('content');
$('#content_title').html(title);
$('#newkb,#newrb,#delkb,#newkbr,#newrbr').css('display','none');
var divs=$('#content').children();
divs.toggleClass('hidden',true);
divs.removeClass('content');
$('#content_'+div).removeClass('hidden');
$('#content_'+div).addClass('content');
$('#content_title').html(title);
$('#newkb,#newrb,#delkb,#newkbr,#newrbr').css('display','none');
}
function none(id) {
display('default','Lemonldap::NG Manager');
display('default','Lemonldap::NG Manager');
}
function hashRoot(){
currentId=simpleTreeCollection[0].getSelected().attr('id');
display('default','Lemonldap::NG Manager');
$('#newkbr').css('display','');
currentId=simpleTreeCollection[0].getSelected().attr('id');
display('default','Lemonldap::NG Manager');
$('#newkbr').css('display','');
}
function btext(id) {
currentId=id;
$('#btextKey').attr('value',lmtext(id));
$('#btextValue').attr('value',lmdata(id));
display('btext','Clef');
$('#newkb,#delkb').css('display','');
currentId=id;
$('#btextKey').attr('value',lmtext(id));
$('#btextValue').attr('value',lmdata(id));
display('btext','Clef');
$('#newkb,#delkb').css('display','');
}
function int(id) {
currentId=id;
$('#int').attr('value',lmdata(id));
display('int',lmtext(id));
currentId=id;
$('#int').attr('value',lmdata(id));
display('int',lmtext(id));
}
function text(id) {
currentId=id;
$('#text').attr('value',lmdata(id));
display('text',lmtext(id));
currentId=id;
$('#text').attr('value',lmdata(id));
display('text',lmtext(id));
}
function securedCookieValues(id){
currentId=id;
$('#securedCookie'+lmdata(id)).attr('checked',1);
display('securedCookie',lmtext(id));
currentId=id;
$('#securedCookie'+lmdata(id)).attr('checked',1);
display('securedCookie',lmtext(id));
}
function rules(id){
currentId=id;
var t=lmtext(id);
$('#rulKey').attr('value',lmtext(id));
$('#rulValue').attr('value',lmdata(id));
display('rules',lmtext(lmparent(id)));
if(t=='default'){$('#rulKey').attr('readonly','readonly')}
else{
$('#rulKey').attr('readonly','');
$('#delkb').css('display','')
}
$('#newrb').css('display','');
currentId=id;
var t=lmtext(id);
$('#rulKey').attr('value',lmtext(id));
$('#rulValue').attr('value',lmdata(id));
display('rules',lmtext(lmparent(id)));
if(t=='default'){$('#rulKey').attr('readonly','readonly')}
else{
$('#rulKey').attr('readonly','');
$('#delkb').css('display','')
}
$('#newrb').css('display','');
}
function rulesRoot(id){
display('default','Lemonldap::NG Manager');
$('#newrbr').css('display','');
display('default','Lemonldap::NG Manager');
$('#newrbr').css('display','');
}
var count=0;
var text4newKey='Key';
var value4newKey='Value';
function newId(c){
count++;
c=c.replace(/^NewID_(.*)_\d+$/,'$1');
return 'NewID_'+c+'_'+count;
count++;
c=c.replace(/^NewID_(.*)_\d+$/,'$1');
return 'NewID_'+c+'_'+count;
}
function newKeyR(){
var newIdValue=newId(currentId);
simpleTreeCollection[0].addNode(newIdValue,text4newKey,function(d,s){
$('>span',s).attr('onClick','btext("'+newIdValue+'")').attr('name',text4newKey).attr('value',value4newKey).attr('id','text_'+newIdValue);
btext(newIdValue);
});
return false;
var newIdValue=newId(currentId);
simpleTreeCollection[0].addNode(newIdValue,text4newKey,function(d,s){
$('>span',s).attr('onClick','btext("'+newIdValue+'")').attr('name',text4newKey).attr('value',value4newKey).attr('id','text_'+newIdValue);
btext(newIdValue);
});
return false;
}
function newKey(){
var newIdValue=newId(currentId);
simpleTreeCollection[0].newNodeAfter(newIdValue,text4newKey,function(d,s){
$('>span',s).attr('onClick','btext("'+newIdValue+'")').attr('name',text4newKey).attr('value',value4newKey).attr('id','text_'+newIdValue);
btext(newIdValue);
});
return false;
var newIdValue=newId(currentId);
simpleTreeCollection[0].newNodeAfter(newIdValue,text4newKey,function(d,s){
$('>span',s).attr('onClick','btext("'+newIdValue+'")').attr('name',text4newKey).attr('value',value4newKey).attr('id','text_'+newIdValue);
btext(newIdValue);
});
return false;
}
function newRule(){
var newIdValue=newId(currentId);
simpleTreeCollection[0].newNodeAfter(newIdValue,text4newKey,function(d,s){
$('>span',s).attr('onClick','rules("'+newIdValue+'")').attr('name',text4newKey).attr('value',value4newKey).attr('id','text_'+newIdValue);
rules(newIdValue);
});
return false;
var newIdValue=newId(currentId);
simpleTreeCollection[0].newNodeAfter(newIdValue,text4newKey,function(d,s){
$('>span',s).attr('onClick','rules("'+newIdValue+'")').attr('name',text4newKey).attr('value',value4newKey).attr('id','text_'+newIdValue);
rules(newIdValue);
});
return false;
}
function delKey(){
$('#'+currentId).prev().remove();
$('#'+currentId).remove();
$('#'+currentId).prev().remove();
$('#'+currentId).remove();
}
function uploadConf(){
$.post(scriptname,{data: $('#li_cm9vdA2').html()},function(data){
var tmp=lmtext('li_cm9vdA2');
tmp=tmp.replace(/\d+/,data.result.cfgNum);
setlmtext('li_cm9vdA2',tmp);
setlmdata('li_cm9vdA2',data.result.cfgNum);
}
,'json');
$.ajax({
type:"POST",
url:scriptname,
data:{data: $('#li_cm9vdA2').html()},
dataType:'json',
success:function(data){
if(data.result.cfgNum<=0){
$.each(data.errors,function(key,state){
alert(key+': '+state);
});
}
else{
var tmp=lmtext('li_cm9vdA2');
tmp=tmp.replace(/\d+/,data.result.cfgNum);
setlmtext('li_cm9vdA2',tmp);
setlmdata('li_cm9vdA2',data.result.cfgNum);
}
},
error:function(xhr, ajaxOptions, thrownError){
alert('Request failed. Error code: '+xhr.status+', '+thrownError);
}
});
}
......@@ -111,11 +111,11 @@ $.fn.simpleTree = function(opt){
if(url && url.indexOf('url:'))
{
url=$.trim(url.replace(/.*\{url:(.*)\}/i ,'$1'));
var js='';
if(url.indexOf(',js:')){
js=$.trim(url.replace(/.*,js:(.*)/i ,'$1'));
url=$.trim(url.replace(/,js:.*/i ,''));
}
var js='';
if(url.indexOf(',js:')){
js=$.trim(url.replace(/.*,js:(.*)/i ,'$1'));
url=$.trim(url.replace(/,js:.*/i ,''));
}
$.ajax({
type: "GET",
url: url,
......@@ -125,7 +125,7 @@ $.fn.simpleTree = function(opt){
node.removeAttr('class');
node.html(responce);
$.extend(node,{url:url});
if($('li',node).length==0)TREE.convertToFolder(node.parent());
if($('li',node).length==0)TREE.convertToFolder(node.parent());
TREE.setTreeNodes(node, true);
if(typeof TREE.option.afterAjax == 'function')
{
......@@ -135,7 +135,11 @@ $.fn.simpleTree = function(opt){
{
callback(node);
}
if(js.length)$('>span',node.parent()).click(function(){eval(js+'()')});
if(js.length)$('>span',node.parent()).click(function(){eval(js+'()')});
},
error: function(xhr, ajaxOptions, thrownError){
TREE.closeNearby(node);
alert('Failed to get remote datas. Error code: '+xhr.status+', '+thrownError);
}
});
}
......@@ -439,21 +443,21 @@ $.fn.simpleTree = function(opt){
callback(dragNode_destination, dragNode_source);
}
};
TREE.newNodeAfter = function(id, text, callback)
{
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span></li></u></li>');
TREE.setTreeNodes(temp_node,true);
destination = TREE.getSelected().parent().parent();
dragNode_source = $('.doc-last',temp_node);
TREE.moveNodeToFolder(destination);
temp_node.remove();
TREE.newNodeAfter = function(id, text, callback)
{
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span></li></u></li>');
TREE.setTreeNodes(temp_node,true);
destination = TREE.getSelected().parent().parent();
dragNode_source = $('.doc-last',temp_node);
TREE.moveNodeToFolder(destination);
temp_node.remove();
if(typeof(callback) == 'function')
{
callback(dragNode_destination, dragNode_source);
}
//existing.after(temp_node);
//temp_node.remove();
};
//existing.after(temp_node);
//temp_node.remove();
};
TREE.delNode = function(callback)
{
dragNode_source = TREE.getSelected();
......
......@@ -125,15 +125,26 @@ sub confUpload {
}
#print STDERR Dumper( $newConf, $errors );
#print STDERR Dumper($errors);
$errors->{result}->{cfgNum} = $self->confObj->saveConf($newConf)
unless ( $errors->{errors} );
print STDERR Dumper($errors);
if ( $errors->{errors} ) {
$errors->{result}->{cfgNum} = 0;
}
else {
$errors->{result}->{cfgNum} = $self->confObj->saveConf($newConf);
}
my $buf = '{';
my $i = 0;
while ( my ( $type, $h ) = each %$errors ) {
$buf .= ',' if ($i);
$buf .= "'$type':{";
$buf .= join( ',', map { "'$_':'$h->{$_}'" } keys %$h );
$buf .= join(
',',
map {
$h->{$_} =~ s/'/\\'/;
$h->{$_} =~ s/\n/ /g;
"'$_':'$h->{$_}'"
} keys %$h
);
$buf .= '}';
$i++;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment