Commit 1c1ea8fe authored by Yadd's avatar Yadd
Browse files

"Delete virtual host" and "force" system to upload an old config

parent 78506944
...@@ -99,12 +99,14 @@ sub new { ...@@ -99,12 +99,14 @@ sub new {
sub saveConf { sub saveConf {
my ( $self, $conf ) = @_; my ( $self, $conf ) = @_;
my $last = $self->lastCfg;
# If configuration was modified, return an error # If configuration was modified, return an error
return CONFIG_WAS_CHANGED if ( not $self->{force} ) {
if ( not( $self->{force} ) return CONFIG_WAS_CHANGED if ( $conf->{cfgNum} != $last );
and ( $conf->{cfgNum} != $self->lastCfg or $self->isLocked ) ); return DATABASE_LOCKED if ( $self->isLocked or not $self->lock );
$self->lock or return DATABASE_LOCKED; }
$conf->{cfgNum}++ unless ( $self->{cfgNumFixed} ); $conf->{cfgNum} = $last + 1 unless ( $self->{cfgNumFixed} );
$msg = "Configuration $conf->{cfgNum} stored"; $msg = "Configuration $conf->{cfgNum} stored";
return $self->store($conf); return $self->store($conf);
} }
......
...@@ -66,15 +66,15 @@ function display(div,title) { ...@@ -66,15 +66,15 @@ function display(div,title) {
$('#content_'+div).removeClass('hidden'); $('#content_'+div).removeClass('hidden');
$('#content_'+div).addClass('content'); $('#content_'+div).addClass('content');
$('#content_title').html(title); $('#content_title').html(title);
$('#newkb,#newrb,#delkb,#newkbr,#newrbr').css('display','none'); $('#newkb,#newrb,#delkb,#newkbr,#newrbr,#bdelvh').hide();
} }
function none(id) { function none(id) {
display('default','Lemonldap::NG Manager'); display('default','');
} }
function hashRoot(){ function hashRoot(){
currentId=simpleTreeCollection[0].getSelected().attr('id'); currentId=simpleTreeCollection[0].getSelected().attr('id');
display('default','Lemonldap::NG Manager'); display('default','');
$('#newkbr').css('display',''); $('#newkbr').show();
} }
function authParams(id) { function authParams(id) {
currentId=id; currentId=id;
...@@ -85,8 +85,8 @@ function btext(id) { ...@@ -85,8 +85,8 @@ function btext(id) {
currentId=id; currentId=id;
$('#btextKey').attr('value',lmtext(id)); $('#btextKey').attr('value',lmtext(id));
$('#btextValue').attr('value',lmdata(id)); $('#btextValue').attr('value',lmdata(id));
display('btext','Clef'); display('btext',lmtext(id));
$('#newkb,#delkb').css('display',''); $('#newkb,#delkb').show();
} }
function bool(id) { function bool(id) {
currentId=id; currentId=id;
...@@ -108,6 +108,14 @@ function securedCookieValues(id){ ...@@ -108,6 +108,14 @@ function securedCookieValues(id){
$('#securedCookie'+lmdata(id)).attr('checked',1); $('#securedCookie'+lmdata(id)).attr('checked',1);
display('securedCookie',lmtext(id)); display('securedCookie',lmtext(id));
} }
function vhost(id){
currentId=id;
display('none',lmtext(id));
$('#bdelvh').show();
}
function delvh(id){
if(confirm("Are you sure ?")){alert(id);$('#'+id).remove();}
}
function rules(id){ function rules(id){
currentId=id; currentId=id;
var t=lmtext(id); var t=lmtext(id);
...@@ -117,14 +125,14 @@ function rules(id){ ...@@ -117,14 +125,14 @@ function rules(id){
if(t=='default'){$('#rulKey').attr('readonly','readonly')} if(t=='default'){$('#rulKey').attr('readonly','readonly')}
else{ else{
$('#rulKey').attr('readonly',''); $('#rulKey').attr('readonly','');
$('#delkb').css('display','') $('#delkb').show();
} }
$('#newrb').css('display',''); $('#newrb').show();
} }
function rulesRoot(id){ function rulesRoot(id){
currentId=id; currentId=id;
display('default','Lemonldap::NG Manager'); display('default','');
$('#newrbr').css('display','block'); $('#newrbr').show();
} }
function reloadAuthParams() { function reloadAuthParams() {
setlmdata(currentId,$('#authText').attr('value')); setlmdata(currentId,$('#authText').attr('value'));
...@@ -193,11 +201,12 @@ function newVh(name){ ...@@ -193,11 +201,12 @@ function newVh(name){
$('>span',s).attr('name',name).attr('help','default').attr('id','text_'+vhId); $('>span',s).attr('name',name).attr('help','default').attr('id','text_'+vhId);
}); });
} }
function uploadConf(){ function uploadConf(f){
if(!(f==1))f=0;
$.ajax({ $.ajax({
type:"POST", type:"POST",
url:scriptname, url:scriptname,
data:{data: $('#li_cm9vdA2').html()}, data:{data: $('#li_cm9vdA2').html(),force: f},
dataType:'json', dataType:'json',
success:function(data){ success:function(data){
var c='<h3>'+data.result.msg+'</h3><dl>'; var c='<h3>'+data.result.msg+'</h3><dl>';
...@@ -219,7 +228,7 @@ function uploadConf(){ ...@@ -219,7 +228,7 @@ function uploadConf(){
c+='<dt>'+m+'</dt><dd>'+data.warnings[m]+'</dd>'; c+='<dt>'+m+'</dt><dd>'+data.warnings[m]+'</dd>';
} }
} }
c+='</dl>'; c+='</dl>'+data.result.other;
$('#help_content').html(c); $('#help_content').html(c);
}, },
error:function(xhr, ajaxOptions, thrownError){ error:function(xhr, ajaxOptions, thrownError){
......
...@@ -54,6 +54,10 @@ var scriptname='<TMPL_VAR NAME="SCRIPT_NAME">';var imagepath='<TMPL_VAR NAME="DI ...@@ -54,6 +54,10 @@ var scriptname='<TMPL_VAR NAME="SCRIPT_NAME">';var imagepath='<TMPL_VAR NAME="DI
<lang en="New virtual host" fr="Nouvel hôte virtuel" /> <lang en="New virtual host" fr="Nouvel hôte virtuel" />
</button> </button>
<button id="bdelvh" style="display:none;" onclick="delvh(currentId);" class="ui-state-default ui-corner-all">
<lang en="Delete virtual host" fr="Supprimer l'hôte virtuel" />
</button>
<button id="newkbr" style="display:none;" onclick="newKeyR();return false;" class="ui-state-default ui-corner-all"> <button id="newkbr" style="display:none;" onclick="newKeyR();return false;" class="ui-state-default ui-corner-all">
<lang en="New key" fr="Nouvelle clef" /> <lang en="New key" fr="Nouvelle clef" />
</button> </button>
...@@ -78,6 +82,7 @@ var scriptname='<TMPL_VAR NAME="SCRIPT_NAME">';var imagepath='<TMPL_VAR NAME="DI ...@@ -78,6 +82,7 @@ var scriptname='<TMPL_VAR NAME="SCRIPT_NAME">';var imagepath='<TMPL_VAR NAME="DI
<div id="edition" class="ui-widget ui-corner-all"> <div id="edition" class="ui-widget ui-corner-all">
<span id="content_title">&nbsp;</span>
<form action="#" onsubmit="return false"> <form action="#" onsubmit="return false">
......
...@@ -340,13 +340,13 @@ sub ajaxNode { ...@@ -340,13 +340,13 @@ sub ajaxNode {
$param .= "&amp;cfgNum=$self->{cfgNum}"; $param .= "&amp;cfgNum=$self->{cfgNum}";
return return
$self->li($id) $self->li($id)
. $self->span( $id, $text, $data, undef, $help, $noT ) . $self->span( $id, $text, $data, $js, $help, $noT )
. "<ul class=\"ajax\">" . "<ul class=\"ajax\">"
. $self->li("sub_$id") . $self->li("sub_$id")
. ".{url:$ENV{SCRIPT_NAME}?$param" . ".{url:$ENV{SCRIPT_NAME}?$param"
. ( $js ? ",js:$js" : '' )
. ( $call ? ",call:$call" : '' ) # . ( $js ? ",js:$js" : '' )
. "}</li></ul></li>\n"; . ( $call ? ",call:$call" : '' ) . "}</li></ul></li>\n";
} }
## @method protected string span(string id,string text,string param,string help,string js,string data,boolean noT) ## @method protected string span(string id,string text,string param,string help,string js,string data,boolean noT)
...@@ -368,13 +368,14 @@ sub span { ...@@ -368,13 +368,14 @@ sub span {
$js ||= "none"; $js ||= "none";
$id = "li_" . encode_base64( $id, '' ); $id = "li_" . encode_base64( $id, '' );
$id =~ s/(=*)$/length($1)/e; $id =~ s/(=*)$/length($1)/e;
$js .= "('$id')" unless ( $js =~ /\(/ );
$data =~ s/"/&#39;/g; $data =~ s/"/&#39;/g;
$tmp =~ s/"/&#39;/g; $tmp =~ s/"/&#39;/g;
$text = join ' ', map { $self->translate($_) } split /\s+/, $text $text = join ' ', map { $self->translate($_) } split /\s+/, $text
unless ($noT); unless ($noT);
$text = $self->escapeHTML($text); $text = $self->escapeHTML($text);
return return
"<span name=\"$tmp\" id=\"text_$id\" onclick=\"$js('$id')\" help=\"$help\" value=\"$data\">$text</span> "<span name=\"$tmp\" id=\"text_$id\" onclick=\"$js\" help=\"$help\" value=\"$data\">$text</span>
"; ";
} }
......
...@@ -131,20 +131,28 @@ sub confUpload { ...@@ -131,20 +131,28 @@ sub confUpload {
$errors->{result}->{msg} = $self->translate('syntaxError'); $errors->{result}->{msg} = $self->translate('syntaxError');
} }
else { else {
$self->confObj->{force} = 1 if ( $self->param('force') );
$errors->{result}->{cfgNum} = $self->confObj->saveConf($newConf); $errors->{result}->{cfgNum} = $self->confObj->saveConf($newConf);
$errors->{result}->{other} = '';
$errors->{result}->{msg} = ( $errors->{result}->{msg} = (
$errors->{result}->{cfgNum} > 0 $errors->{result}->{cfgNum} > 0
? $self->translate('confSaved') ? $self->translate('confSaved')
: $self->translate( : $self->translate(
{ {
CONFIG_WAS_CHANGED => 'confWasChanged', CONFIG_WAS_CHANGED, 'confWasChanged',
UNKNOWN_ERROR => 'unknownError', UNKNOWN_ERROR, 'unknownError',
DATABASE_LOCKED => 'databaseLocked', DATABASE_LOCKED, 'databaseLocked',
UPLOAD_DENIED => 'uploadDenied', UPLOAD_DENIED, 'uploadDenied',
SYNTAX_ERROR => 'syntaxError', SYNTAX_ERROR, 'syntaxError',
}->{ $errors->{result}->{cfgNum} } }->{ $errors->{result}->{cfgNum} }
) )
); );
if ( $errors->{result}->{cfgNum} == CONFIG_WAS_CHANGED
or $errors->{result}->{cfgNum} == DATABASE_LOCKED )
{
$errors->{result}->{other} = '<a href="javascript:uploadConf(1)">'
. $self->translate('clickHereToForce') . '</a>';
}
} }
my $buf = '{'; my $buf = '{';
my $i = 0; my $i = 0;
......
...@@ -200,7 +200,7 @@ sub struct { ...@@ -200,7 +200,7 @@ sub struct {
# VIRTUAL HOSTS # # VIRTUAL HOSTS #
################# #################
virtualHosts => { virtualHosts => {
_nodes => ['nhash:/locationRules:virtualHosts:none'], _nodes => ['nhash:/locationRules:virtualHosts:vhost'],
_upload => ['/exportedHeaders'], _upload => ['/exportedHeaders'],
_help => 'default', _help => 'default',
_call => '$(\'#bnewvh\').show();', _call => '$(\'#bnewvh\').show();',
......
...@@ -50,6 +50,7 @@ sub en { ...@@ -50,6 +50,7 @@ sub en {
advancedParams => 'Advanced parameters', advancedParams => 'Advanced parameters',
authentication => 'Authentication module', authentication => 'Authentication module',
authParams => 'Authentication parameters', authParams => 'Authentication parameters',
clickHereToForce => 'Click here to force',
Configuration => 'Configuration', Configuration => 'Configuration',
confSaved => 'Configuration saved', confSaved => 'Configuration saved',
confWasChanged => 'Configuration has been changed', confWasChanged => 'Configuration has been changed',
...@@ -114,6 +115,7 @@ sub fr { ...@@ -114,6 +115,7 @@ sub fr {
advancedParams => 'Paramètres avancés', advancedParams => 'Paramètres avancés',
authentication => "Module d'authentification", authentication => "Module d'authentification",
authParams => "Paramètres d'authentification", authParams => "Paramètres d'authentification",
clickHereToForce => 'Clicker ici pour forcer',
Configuration => 'Configuration', Configuration => 'Configuration',
confSaved => 'Configuration sauvegardée', confSaved => 'Configuration sauvegardée',
confWasChanged => 'Configuration modifiée entre-temps', confWasChanged => 'Configuration modifiée entre-temps',
......
Supports Markdown
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