From: Michal Vaner Date: Mon, 1 Sep 2008 17:49:36 +0000 (+0200) Subject: New admin interface X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=d1d9c665726be3f76f35d5c630d8f43ea04b9d32;p=pciids.git New admin interface Takes less space now --- diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index 40ab218..20941c0 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -31,8 +31,8 @@ sub new( $ ) { 'newhistory' => 'INSERT INTO history (location, owner, discussion, nodename, nodenote) VALUES(?, ?, ?, ?, ?)', 'history' => 'SELECT history.id, history.discussion, history.time, history.nodename, history.nodenote, history.seen, users.login, users.email FROM history LEFT OUTER JOIN users ON history.owner = users.id WHERE history.location = ? ORDER BY history.time', 'admindump' => 'SELECT - locations.id, locations.name, locations.note, locations.mainhistory, musers.login, main.discussion, - history.id, history.discussion, history.nodename, history.nodenote, users.login + locations.id, locations.name, locations.note, locations.mainhistory, musers.email, main.discussion, + history.id, history.discussion, history.nodename, history.nodenote, users.email FROM locations INNER JOIN history ON history.location = locations.id LEFT OUTER JOIN users ON history.owner = users.id @@ -40,7 +40,7 @@ sub new( $ ) { LEFT OUTER JOIN users AS musers ON main.owner = musers.id WHERE history.seen = "0" AND locations.id LIKE ? ORDER BY locations.id, history.id - LIMIT 1000',#Dumps new discussion submits with their senders and corresponding main history and names + LIMIT 100',#Dumps new discussion submits with their senders and corresponding main history and names 'delete-hist' => 'DELETE FROM history WHERE id = ?', 'mark-checked' => 'UPDATE history SET seen = 1 WHERE id = ?', 'delete-item' => 'DELETE FROM locations WHERE id = ?', @@ -94,12 +94,18 @@ sub new( $ ) { 'dropnotifsmail' => 'DELETE FROM pending WHERE notification = 0 AND EXISTS ( SELECT 1 FROM users WHERE users.id = pending.user AND nextmail <= ? )', 'time' => 'SELECT NOW()', 'searchname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? ORDER BY l.id', - 'searchlocalname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? AND l.id LIKE ? ORDER BY l.id' + 'searchlocalname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? AND l.id LIKE ? ORDER BY l.id', + 'hasChildren' => 'SELECT 1 FROM locations WHERE parent = ?' } ); } my %sorts = ( 'id' => 1, 'rid' => 1, 'name' => 1, 'rname' => 1 ); +sub hasChildren( $$ ) { + my( $self, $parent ) = @_; + return scalar @{$self->query( 'hasChildren', [ $parent ] )}; +} + sub nodes( $$$$ ) { my( $self, $parent, $args, $restrict ) = @_; my $q = 'id'; diff --git a/PciIds/Html/Admin.pm b/PciIds/Html/Admin.pm index a8aa592..1307b55 100644 --- a/PciIds/Html/Admin.pm +++ b/PciIds/Html/Admin.pm @@ -10,12 +10,24 @@ use PciIds::Address; use PciIds::Log; use Apache2::Const qw(:common :http); -sub genNewAdminForm( $$$$ ) { - my( $req, $args, $tables, $error ) = @_; +sub safeEncode( $ ) { + my( $text ) = @_; + return encode( $text ) if defined $text; + return ''; +} + +sub mailEncode( $ ) { + my( $email ) = @_; + return '' unless defined $email; + return "".encode( $email ).""; +} + +sub genNewAdminForm( $$$$$ ) { + my( $req, $args, $tables, $error, $auth ) = @_; my $address = PciIds::Address::new( $req->uri() ); my $prefix = $address->get(); $prefix = '' if( $args->{'global'} ); - my $caption = 'Administration ‒ pending events '.( $args->{'global'} ? '(Global)' : '('.encode( $address->pretty() ).')' ); + my $caption = 'Administration '.( $args->{'global'} ? '(Global)' : '('.encode( $address->pretty() ).')' ); genHtmlHead( $req, $caption, undef ); genCustomHead( $req, $args, $address, $caption, [ $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Help', 'help', 'admin' ], [ '', 'jump' ] ], [ [ 'Log out', 'logout' ] ] ); print "
$error
\n" if( defined $error ); @@ -25,52 +37,54 @@ sub genNewAdminForm( $$$$ ) { my $cnt = 0; my $hiscnt = 0; my $subcnt; + print "\n"; + print "\n"; + print ""; + } else { + print ""; + } + print "
IDNameNoteDiscussionAuthorOkSelDel\n"; foreach( @{$tables->adminDump( $prefix )} ) { my( $locId, $actName, $actNote, $actHist, $actUser, $actDisc, $hist, $disc, $name, $note, $user ) = @{$_}; if( !defined( $lastId ) || ( $lastId ne $locId ) ) { + last if( $hiscnt > 80 ); $lastId = $locId; - print "\n" if( $started ); $started = 1; - print "
\n"; my $addr = PciIds::Address::new( $locId ); - print "

".encode( $addr->pretty() )."

\n"; - print htmlDiv( 'name', '

'.encode( $actName ) ) if( defined( $actName ) ); - print htmlDiv( 'note', '

'.encode( $actNote ) ) if( defined( $actNote ) ); - print '

'.encode( $actDisc ) if( defined( $actDisc ) ); - print '

'.encode( $addr->parent()->pretty() )."" if( defined( $addr->parent() ) ); - print htmlDiv( 'author', '

'.encode( $actUser ) ) if( defined( $actUser ) ); - print "\n" if( defined( $subcnt ) ); + if( defined( $actHist ) ) { + print "

".encode( $addr->pretty() )."".safeEncode( $actName )."".safeEncode( $actNote )."".safeEncode( $actDisc )."".mailEncode( $actUser ); + $subcnt = 0; $cnt++; print "\n"; - print "

I will decide later.\n"; - if( defined( $actHist ) ) { - print "
Keep current name.\n"; + print "

"; + print ""; + if( hasRight( $auth->{'accrights'}, 'prune' ) || ( !defined $actHist && !$tables->hasChildren( $addr->get() ) ) ) { + print "\n"; + } else { + print ""; } - print "
Delete item.\n"; - print "
Add discussion:\n"; - print "
\n"; - print "
Set name:\n"; - print "
Set note:\n"; - print "
Discussion:\n"; - print "
\n"; + print "
New:\n"; + print ""; + genPathBare( $req, $addr, 0, 0 ); + print "\n"; } - print "
\n"; - print "

".encode( $name ) if( defined( $name ) ); - print "

".encode( $note ) if( defined( $note ) ); - print '

'.encode( $disc ) if( defined( $disc ) ); - print "

".encode( $user ) if( defined( $user ) ); - print "

Use this one.\n" if( defined( $name ) && ( $name ne "" ) ); + print "

".safeEncode( ( defined $name && $name eq '' ) ? 'Deletion request' : $name )."".safeEncode( $note )."".safeEncode( $disc )."".mailEncode( $user ); $hiscnt ++; - print "
Delete history.\n"; - print "\n"; $subcnt ++; - print "\n"; + print "
"; + if( defined $name ) { + print ""; + } else { + print ""; + } + print ""; + print "\n"; } + print "
\n"; print "\n" if( defined( $subcnt ) ); if( $started ) { - print "\n" if( $started ); print "

\n"; print "\n"; } else { @@ -84,7 +98,7 @@ sub genNewAdminForm( $$$$ ) { sub adminForm( $$$$ ) { my( $req, $args, $tables, $auth ) = @_; if( defined( $auth->{'authid'} ) && hasRight( $auth->{'accrights'}, 'validate' ) ) { - return genNewAdminForm( $req, $args, $tables, undef ); + return genNewAdminForm( $req, $args, $tables, undef, $auth ); } else { return notLoggedComplaint( $req, $args, $auth ); } @@ -166,7 +180,7 @@ sub submitAdminForm( $$$$ ) { markAllChecked( $tables, $i, \%deleted, $authid ); } } - return genNewAdminForm( $req, $args, $tables, $errors ); + return genNewAdminForm( $req, $args, $tables, $errors, $auth ); } else { return notLoggedComplaint( $req, $args, $auth ); } diff --git a/PciIds/Html/Util.pm b/PciIds/Html/Util.pm index 060dff1..cb9a0c3 100644 --- a/PciIds/Html/Util.pm +++ b/PciIds/Html/Util.pm @@ -7,7 +7,7 @@ use PciIds::Users; use Apache2::Const qw(:common :http); use APR::Table; -our @EXPORT = qw(&genHtmlHead &htmlDiv &genHtmlTail &genTableHead &genTableTail &parseArgs &buildExcept &buildArgs &genMenu &genCustomMenu &encode &setAddrPrefix &HTTPRedirect &genPath &logItem &genLocMenu &genCustomHead); +our @EXPORT = qw(&genHtmlHead &htmlDiv &genHtmlTail &genTableHead &genTableTail &parseArgs &buildExcept &buildArgs &genMenu &genCustomMenu &encode &setAddrPrefix &HTTPRedirect &genPath &logItem &genLocMenu &genCustomHead &genPathBare); sub encode( $ ) { return encode_entities( shift, "\"'&<>" ); @@ -150,8 +150,8 @@ sub HTTPRedirect( $$ ) { return HTTP_SEE_OTHER; } -sub genPath( $$$ ) { - my( $req, $address, $printAddr ) = @_; +sub genPathBare( $$$$ ) { + my( $req, $address, $printAddr, $started ) = @_; my $path; if( defined $address ) { $path = $address->path(); @@ -159,11 +159,21 @@ sub genPath( $$$ ) { } else { $path = []; } - print "

\n"; - print "

Main page"; foreach my $addr ( reverse @{$path} ) { - print " -> ".encode( $addr->pretty() ).""; + if( $started ) { + print " -> "; + } else { + $started = 1; + } + print "".encode( $addr->pretty() ).""; } +} + +sub genPath( $$$ ) { + my( $req, $address, $printAddr ) = @_; + print "

\n"; + print "

Main page"; + genPathBare( $req, $address, $printAddr, 1 ); print "

\n"; } diff --git a/static/screen.css b/static/screen.css index c41a7f7..b1c0d30 100644 --- a/static/screen.css +++ b/static/screen.css @@ -7,14 +7,27 @@ body { background: #D5D5D5; } -.item, .history +.item, .history, +table.admin .unseen-history { background: #F0F0F0; } -.main-history +.main-history, +table.admin .item, +table.admin .new { background: #DDFFDD; } +table.admin .empty +{ + background: #DDDDFF; +} +table.admin .unnamedItem td, +table.admin .item td +{ + padding-top: 1ex; + padding-bottom: 1ex; +} .help-example { background: #BBBBFF; @@ -112,3 +125,18 @@ form.jump p { margin-top: 0px; } +table.admin col.id-col, +table.admin col.name-col, +table.admin col.note-col, +table.admin col.disc-col, +table.admin col.auth-col +{ + width: 18%; +} +table.admin col.control-col +{ + width: 3%; +} +{ + background: #DDFFDD; +}