Commit 445ea61e authored by Clément OUDOT's avatar Clément OUDOT

First work on notifications explorer (#328):

* Browse notifications (notifications not done)
* Delete selected notification
parent 25500068
......@@ -310,8 +310,9 @@ install_manager_site: install_conf_dir
done; \
fi
@$(PERL) -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
# Sessions explorer install
# Sessions explorer and notifications explorer install
@cp -pR --remove-destination ${SRCMANAGERDIR}/example/sessions.pl $(RSESSIONSEXPLORERDIR)
@cp -pR --remove-destination ${SRCMANAGERDIR}/example/notifications.pl $(RSESSIONSEXPLORERDIR)
@rm -rf $$(find ${RMANAGERDIR} ${RMANAGERSKINSDIR} \
${RSESSIONSEXPLORERDIR} \
$(RCONFDIR) -type d -name .svn)
......@@ -591,6 +592,7 @@ debian-diff:
@$(DIFF) lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm $(DIFFPREFIX)/usr/share/perl5/Lemonldap/NG/Manager.pm ||true
@$(DIFF) lemonldap-ng-manager/example/index.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/index.pl ||true
@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/sessions.pl ||true
@$(DIFF) lemonldap-ng-manager/example/notifications.pl $(DIFFPREFIX)/var/lib/lemonldap-ng/manager/notifications.pl ||true
@$(DIFF) --ignore-matching-lines='.*POSIX.*' lemonldap-ng-manager/example/scripts/lmConfigEditor $(DIFFPREFIX)/usr/share/lemonldap-ng/bin/lmConfigEditor ||true
@for i in $(MANAGERSKINS); do \
$(DIFF) -x 'jquery*' lemonldap-ng-manager/example/skins/$$i $(DIFFPREFIX)/usr/share/lemonldap-ng/manager-skins/$$i; \
......@@ -625,6 +627,7 @@ default-diff:
@$(DIFF) lemonldap-ng-manager/example/skins $(LMPREFIX)/htdocs/manager/skins ||true
@$(DIFF) lemonldap-ng-manager/example/index.pl $(LMPREFIX)/htdocs/manager/index.pl ||true
@$(DIFF) lemonldap-ng-manager/example/sessions.pl $(LMPREFIX)/htdocs/manager/sessions.pl ||true
@$(DIFF) lemonldap-ng-manager/example/notifications.pl $(LMPREFIX)/htdocs/manager/notifications.pl ||true
@$(DIFF) --ignore-matching-lines='.*POSIX.*' lemonldap-ng-manager/example/scripts/lmConfigEditor $(LMPREFIX)/bin/lmConfigEditor ||true
tidy: clean
......
......@@ -3,6 +3,7 @@ example/index.pl
example/mrtg/lmng-mrtg
example/mrtg/mrtg.cfg.example
example/notfound.html
example/notifications.pl
example/scripts/lmConfigEditor
example/sessions.pl
example/skins/default/css/accordion.css
......@@ -48,10 +49,12 @@ example/skins/default/js/jquery-ui-1.8.6.custom.min.js
example/skins/default/js/jquery.ajaxfileupload.js
example/skins/default/js/jquery.cookie.js
example/skins/default/js/manager.js
example/skins/default/js/notifications.js
example/skins/default/js/sessions.js
example/skins/default/js/tree.js
example/skins/default/lemonldap-ng.ico
example/skins/default/manager.tpl
example/skins/default/notifications.tpl
example/skins/default/sessions.tpl
example/skins/default/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png
example/skins/default/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png
......@@ -87,6 +90,7 @@ lib/Lemonldap/NG/Manager.pm
lib/Lemonldap/NG/Manager/_i18n.pm
lib/Lemonldap/NG/Manager/_Struct.pm
lib/Lemonldap/NG/Manager/Downloader.pm
lib/Lemonldap/NG/Manager/Notifications.pm
lib/Lemonldap/NG/Manager/Request.pm
lib/Lemonldap/NG/Manager/Sessions.pm
lib/Lemonldap/NG/Manager/Uploader.pm
......
#!/usr/bin/perl
use strict;
use Lemonldap::NG::Manager::Notifications;
use HTML::Template;
my $cgi = Lemonldap::NG::Manager::Notifications->new(
{
# SESSION EXPLORER CUSTOMIZATION
#managerSkin => 'default',
# ACCESS TO CONFIGURATION
# By default, Lemonldap::NG uses the default storage.conf file to know
# where to find is configuration
# (generaly /etc/lemonldap-ng/storage.conf)
# You can specify by yourself this file :
#configStorage => { type => 'File', dirName => '/path/to/my/file' },
# You can also specify directly the configuration
# (see Lemonldap::NG::Handler::SharedConf(3))
#configStorage => {
# type => 'File',
# directory => '/usr/local/lemonlda-ng/conf/'
#},
}
) or Lemonldap::NG::Common::CGI->abort('Unable to start notifications explorer');
my $skin = $cgi->{managerSkin} or $cgi->abort('managerSkin is not defined');
my $css = 'tree.css';
my $css_theme = 'ui-lightness';
my $skin_dir = 'skins';
my $main_dir = $cgi->{managerHtdocsPath};
my $template = HTML::Template->new(
filename => "$main_dir/$skin_dir/$skin/notifications.tpl",
die_on_bad_params => 0,
cache => 0,
filter => sub { $cgi->translate_template(@_) },
);
$template->param( SCRIPT_NAME => $ENV{SCRIPT_NAME} );
$template->param( TREE => $cgi->tree() );
$template->param( DIR => "$skin_dir/$skin" );
$template->param( CSS => $css );
$template->param( CSS_THEME => $css_theme );
print $cgi->header('text/html; charset=utf-8');
print $template->output;
function displayNotification(id) {
$.ajax({
type:"POST",
url:scriptname,
data:{'notification':id},
dataType:'html',
success:function(data){
$('#data').html(data);
},
error:function(xhr, ajaxOptions, thrownError){
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError);
}
});
}
function del(id) {
$.ajax({
type:"POST",
url:scriptname,
data:{'delete':id},
dataType:'html',
success:function(data){
$('#data').html(data);
// Delete session from tree
$('#uid'+id).remove();
$('#ip'+id).remove();
},
error:function(xhr, ajaxOptions, thrownError){
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError);
}
});
}
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title><lang en="LemonLDAP::NG notification explorer" fr="Explorateur de notifications LemonLDAP::NG"/></title>
<link href="<TMPL_VAR NAME="DIR">/lemonldap-ng.ico" rel="icon" type="image/x-icon" />
<link href="<TMPL_VAR NAME="DIR">/lemonldap-ng.ico" rel="shortcut icon" />
<!-- jQuery UI CSS -->
<link rel="stylesheet" type="text/css" id="csstheme" href="<TMPL_VAR NAME="DIR">/<TMPL_VAR NAME="CSS_THEME">/jquery-ui-1.8.6.custom.css" />
<!-- Manager CSS -->
<link rel="stylesheet" type="text/css" id="cssmenu" href="<TMPL_VAR NAME="DIR">/css/<TMPL_VAR NAME="CSS">" />
<script src="<TMPL_VAR NAME="DIR">/js/jquery-1.4.2.min.js" type="text/JavaScript"></script>
<script src="<TMPL_VAR NAME="DIR">/js/jquery-ui-1.8.6.custom.min.js" type="text/JavaScript"></script>
<script src="<TMPL_VAR NAME="DIR">/js/jquery.cookie.js" type="text/JavaScript"></script>
<script src="<TMPL_VAR NAME="DIR">/js/tree.js" type="text/JavaScript"></script>
<script src="<TMPL_VAR NAME="DIR">/js/notifications.js" type="text/JavaScript"></script>
<script type="text/JavaScript">//<![CDATA[
var scriptname='<TMPL_VAR NAME="SCRIPT_NAME">';
var imagepath='<TMPL_VAR NAME="DIR">/images/';
var csspath='<TMPL_VAR NAME="DIR">/css/';
var jqueryuiversion='1.8.6';
var css_menu='<TMPL_VAR NAME="CSS">';
var css_theme='<TMPL_VAR NAME="CSS_THEME">';
var themepath='<TMPL_VAR NAME="DIR">/';
var treejquerycss='false';
var treeautoclose='false';
//]]></script>
<script src="<TMPL_VAR NAME="DIR">/js/manager.js" type="text/JavaScript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
</head>
<body>
<!-- Tree CSS choice -->
<div id="css-switch" title="<lang en="Menu style" fr="Style de menu" />">
<div id="organization">
<p class="ui-widget-header ui-corner-all"><lang en="Organization" fr="Organisation" /></p>
<button alt="tree"><lang en="Tree" fr="Arbre" /></button>
<button alt="accordion"><lang en="Accordion" fr="Accordéon" /></button>
</div>
<div id="theme">
<p class="ui-widget-header ui-corner-all"><lang en="Theme" fr="Thème" /></p>
<button alt="ui-lightness"><lang en="Lightness" fr="Lumineux" /></button>
<button alt="ui-darkness"><lang en="Darkness" fr="Obscur" /></button>
</div>
</div>
<!-- Header -->
<div id="header">
<a href="index.pl"><lang en="Configuration management" fr="Gestion de la configuration"/></a>
<a href="sessions.pl"><lang en="Sessions explorer" fr="Explorateur de sessions"/></a>
<span id="css-switch-link"><lang en="Menu style" fr="Style de menu" /></span>
<!-- Header -->
</div>
<!-- Menu (tree) -->
<div id="menu" class="ui-corner-all ui-helper-clearfix ui-widget-content">
<!-- Query choice -->
<TMPL_VAR NAME="TREE">
</div>
<!-- Data -->
<div id="data" class="ui-corner-all ui-helper-clearfix ui-widget-content">
<!-- Container -->
</div>
</body>
</html>
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