Configure applications in categories in Manager - need tests (#29)

This commit is contained in:
Clément Oudot 2010-09-22 13:59:35 +00:00
parent 759776aae7
commit 6a870286b2
4 changed files with 173 additions and 17 deletions

View File

@ -64,7 +64,7 @@ $(document).ready(function(){
simpleTreeToggleJqueryClasses(); simpleTreeToggleJqueryClasses();
}, },
animate:true, animate:true,
docToFolderConvert:false docToFolderConvert:true
}); });
if(treejquerycss){simpleTreeDefaultJqueryClasses();} if(treejquerycss){simpleTreeDefaultJqueryClasses();}
@ -1032,6 +1032,7 @@ function newCategoryR(){
function delCategory(){ function delCategory(){
delKey(); delKey();
} }
function applicationListCategory(id){ function applicationListCategory(id){
currentId=id; currentId=id;
$('#applicationListCategoryKey').attr('value',lmtext(id)); $('#applicationListCategoryKey').attr('value',lmtext(id));
@ -1040,3 +1041,46 @@ function applicationListCategory(id){
$('#delcategory,#newapplicationr').show(); $('#delcategory,#newapplicationr').show();
} }
function newApplicationR(){
var name = prompt(text4newApplication,'myapplication');
if(!name){return false;}
var newIdValue=newId(currentId);
simpleTreeCollection[0].addNode(newIdValue,name,function(d,s){
$('>span',s).attr('onClick','applicationListApplication("'+newIdValue+'")').attr('name',name).attr('value','My application|http://www.example.com|This is a nice application|logo.png|auto').attr('id','text_'+newIdValue);
applicationListApplication(newIdValue);
});
return false;
}
function delApplication(){
delKey();
}
function setlmapplication(id){
var key=$('#applicationListApplicationKey').attr('value');
var name=$('#applicationListApplicationName').attr('value');
var url=$('#applicationListApplicationURL').attr('value');
var desc=$('#applicationListApplicationDescription').attr('value');
var logo=$('#applicationListApplicationLogo').attr('value');
var display=$('#applicationListApplicationDisplay').attr('value');
setlmtext(id,key);
setlmdata(id,name+'|'+url+'|'+desc+'|'+logo+'|'+display);
}
function applicationListApplication(id){
currentId=id;
$('#applicationListApplicationKey').attr('value',lmtext(id));
var t=lmdata(id).split('|');
$('#applicationListApplicationName').attr('value',t[0]);
$('#applicationListApplicationURL').attr('value',t[1]);
$('#applicationListApplicationDescription').attr('value',t[2]);
$('#applicationListApplicationLogo').attr('value',t[3]);
formateSelect('applicationListApplicationDisplay',[
'auto=Automatic',
'on=On',
'off=Off',
],t[4]);
display('applicationListApplication',lmtext(id));
$('#delapplication').show();
}

View File

@ -466,7 +466,7 @@
</button> </button>
</div> </div>
<!-- applicationList --> <!-- applicationList Category-->
<div id="content_applicationListCategory" class="hidden"> <div id="content_applicationListCategory" class="hidden">
<table> <table>
<tr> <tr>
@ -484,6 +484,40 @@
</button> </button>
</div> </div>
<!-- applicationList Application-->
<div id="content_applicationListApplication" class="hidden">
<table>
<tr>
<td><lang en="Key" fr="Nom de la clef"/></td>
<td><input type="text" id="applicationListApplicationKey" /></td>
</tr>
<tr>
<td><lang en="Display name" fr="Nom à afficher"/></td>
<td><input type="text" id="applicationListApplicationName" /></td>
</tr>
<tr>
<td><lang en="Adress" fr="Adresse"/></td>
<td><input type="text" id="applicationListApplicationURL" /></td>
</tr>
<tr>
<td><lang en="Description" fr="Description"/></td>
<td><textarea id="applicationListApplicationDescription" /></textarea></td>
</tr>
<tr>
<td><lang en="Logo (file name)" fr="Logo (nom du fichier)"/></td>
<td><input type="text" id="applicationListApplicationLogo" /></td>
</tr>
<tr>
<td><lang en="Display mode" fr="Mode d'affichage"/></td>
<td><select id="applicationListApplicationDisplay"></select></td>
</tr>
</table>
<br />
<button onclick="setlmapplication(currentId);return false;" class="ui-state-default ui-corner-all">
<lang en="Apply" fr="Appliquer" />
</button>
</div>
</div> </div>
</form> </form>

View File

@ -233,26 +233,71 @@ sub confNode {
} }
# Loop on categories # Loop on categories
foreach ( sort keys %$h ) { foreach my $catid ( sort keys %$h ) {
# Build ID # Build ID
my $id = "$target/$_"; my $id = "$target/$catid";
$id =~ s/=*$//; $id =~ s/=*$//;
# Display menu item # Display menu item
$self->lmLog( "Display menu item for category $_", 'debug' ); $self->lmLog( "Display menu item for category $catid", 'debug' );
# Here, "notranslate" is set to true : hashvalues must not be # Here, "notranslate" is set to true : hashvalues must not be
# translated # translated
$res .= $self->li($id) $res .= $self->li($id)
. $self->span( . $self->span(
id => $id, id => $id,
text => "$_", text => "$catid",
data => $h->{$_}->{catname}, data => $h->{$catid}->{catname},
js => $js, js => $js,
help => $help, help => $help,
noT => 1 noT => 1
);
delete $h->{$catid}->{type};
delete $h->{$catid}->{catname};
# Loop on applications
if ( %{ $h->{$catid} } ) {
$res .= '<ul>';
# $res .= '<li class="line">&nbsp;</li>';
}
foreach my $appid ( sort keys %{ $h->{$catid} } ) {
$id = "$target/$catid/$appid";
$id =~ s/=*$//;
my $data =
$h->{$catid}->{$appid}->{options}->{name} . "|"
. $h->{$catid}->{$appid}->{options}->{uri} . "|"
. $h->{$catid}->{$appid}->{options}->{description} . "|"
. $h->{$catid}->{$appid}->{options}->{logo} . "|"
. $h->{$catid}->{$appid}->{options}->{display};
# Display menu item
$self->lmLog( "Display menu item for application $appid",
'debug' );
$res .= $self->li($id)
. $self->span(
id => $id,
text => "$appid",
data => $data,
js => "applicationListApplication",
help => $help,
noT => 1
) . "</li>"; ) . "</li>";
}
if ( %{ $h->{$catid} } ) {
$res .= '</ul>';
}
$res .= "</li>";
} }
} }

View File

@ -36,7 +36,6 @@ sub confUpload {
my $vhostname; my $vhostname;
my $idpname; my $idpname;
my $spname; my $spname;
my $catid;
# 1. ANALYSE DATAS # 1. ANALYSE DATAS
@ -64,6 +63,10 @@ sub confUpload {
$_->getAttribute('value') $_->getAttribute('value')
); );
# For menu categories and applications
my $catid = undef;
my $appid = undef;
# Unescape value # Unescape value
$value = uri_unescape($value); $value = uri_unescape($value);
@ -98,11 +101,17 @@ sub confUpload {
$spname = $name; $spname = $name;
} }
# Get menu category id # Get menu category and application id
if ( $id =~ /applicationList(\/[^\/]*)?$/ ) { if ( $id =~ /applicationList/ ) {
if ( $value =~ /^(.*)?\|(.*)?\|(.*)?\|(.*)?\|(.*?)$/ ) {
$self->lmLog( "Entering application $name", 'debug' );
$appid = $name;
}
else {
$self->lmLog( "Entering category $name", 'debug' ); $self->lmLog( "Entering category $name", 'debug' );
$catid = $name; $catid = $name;
} }
}
# Manage new keys # Manage new keys
if ($NK) { if ($NK) {
@ -113,7 +122,7 @@ sub confUpload {
# Special case: avoid bug with node created from parent node # Special case: avoid bug with node created from parent node
if ( $id =~ if ( $id =~
/^(virtualHosts|samlIDPMetaDataExportedAttributes|samlSPMetaDataExportedAttributes|generalParameters\/authParams\/choiceParams|generalParameters\/portalParams\/portalMenu\/applicationList|applicationList)/ /^(virtualHosts|samlIDPMetaDataExportedAttributes|samlSPMetaDataExportedAttributes|generalParameters\/authParams\/choiceParams)/
) )
{ {
$self->lmLog( "Special trigger for $id (attribute $name)", $self->lmLog( "Special trigger for $id (attribute $name)",
@ -139,12 +148,11 @@ s/^samlSPMetaDataExportedAttributes\/([^\/]*)?.*/samlSPMetaDataExportedAttribute
$id =~ $id =~
s/^generalParameters\/authParams\/choiceParams\/([^\/]*)?.*/authChoiceModules\/$name/; s/^generalParameters\/authParams\/choiceParams\/([^\/]*)?.*/authChoiceModules\/$name/;
# Applications list category
$id =~
s/^(generalParameters\/portalParams\/portalMenu\/)?applicationList$/applicationList\/$name/;
} }
# Do nothing for applicationList (managed at stage 1.3.2)
elsif ( $id =~ /applicationList/) {}
# Normal case # Normal case
else { else {
$id =~ s/(?:\/[^\/]*)?$/\/$name/; $id =~ s/(?:\/[^\/]*)?$/\/$name/;
@ -228,7 +236,7 @@ s/^(samlSPMetaDataXML|samlSPMetaDataExportedAttributes|samlSPMetaDataOptions)\/(
# 1.3.2 Store accepted parameter in $newConf # 1.3.2 Store accepted parameter in $newConf
# Special trick for categories and applications # Menu category
if ( defined $catid ) { if ( defined $catid ) {
$self->lmLog( "Register category $catid data", 'debug' ); $self->lmLog( "Register category $catid data", 'debug' );
@ -240,7 +248,32 @@ s/^(samlSPMetaDataXML|samlSPMetaDataExportedAttributes|samlSPMetaDataOptions)\/(
$self->setKeyToH( $newConf, "applicationList/$catid/type", $self->setKeyToH( $newConf, "applicationList/$catid/type",
"category" ); "category" );
$catid = undef; }
# Menu application
elsif ( defined $appid ) {
$self->lmLog( "Register application $appid data", 'debug' );
($catid) = ( $id =~ /applicationList\/([^\/]+)?/ );
# Get options from splitted value
my @t = split( /\|/, $value );
# Set applications options
$self->setKeyToH( $newConf,
"applicationList/$catid/$appid/options/name", $t[0] );
$self->setKeyToH( $newConf,
"applicationList/$catid/$appid/options/uri", $t[1] );
$self->setKeyToH( $newConf,
"applicationList/$catid/$appid/options/description", $t[2] );
$self->setKeyToH( $newConf,
"applicationList/$catid/$appid/options/logo", $t[3] );
$self->setKeyToH( $newConf,
"applicationList/$catid/$appid/options/display", $t[4] );
# Set type to application
$self->setKeyToH( $newConf, "applicationList/$catid/$appid/type",
"application" );
} }
else { else {
$self->setKeyToH( $self->setKeyToH(