]> git.andy128k.dev Git - ipf.git/commitdiff
admin log page
authorAndrey Kutejko <andy128k@gmail.com>
Thu, 8 Jan 2015 22:23:49 +0000 (00:23 +0200)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 10 Jan 2015 22:51:34 +0000 (00:51 +0200)
ipf/admin/app.php
ipf/admin/assets/css/base.css
ipf/admin/controllers/dashboard.php
ipf/admin/log.php
ipf/admin/templates/admin/index.html
ipf/admin/templates/admin/log.html [new file with mode: 0644]

index 623de435822d9f436251a2f37eb389efa2c3c289..1ebf0dcf0f81ad14ef932abc483af005942732bc 100644 (file)
@@ -10,6 +10,7 @@ class IPF_Admin_App extends IPF_Application
         return array('prefix' => '#^/'.$prefix.'/', 'urls' => array(
             array('controller' => 'IPF_Admin_Dashboard_Controller', 'urls' => array(
                 array('regex' => '$#', 'func' => 'index'),
+                array('regex' => 'log/$#', 'func' => 'log'),
             )),
             array('controller' => 'IPF_Admin_FileBrowser_Controller', 'urls' => array(
                 array('regex' => 'filebrowser/rename/$#', 'method' => 'POST', 'func' => 'rename'),
index e0ff9ce778c251f38a167fb958ef92ba5a51855d..628d4f118fad6ea216143c459cad62d9e147ea51 100644 (file)
@@ -174,9 +174,8 @@ table#change-history tbody th { width:16em; }
 #user-tools span {font-size:9px}
 
 /* SIDEBAR */
-#content-related h3 { font-size:12px; color:#666; margin-bottom:3px; }
-#content-related h4 { font-size:11px; }
 #content-related .module h2 { background: linear-gradient(to top, #e1e1e1, #fff 16px); color:#666 }
+#content-related a.all { display: block; text-align: center; margin: 10px 0; }
 
 /*
  * Dashboard
@@ -187,7 +186,7 @@ table#change-history tbody th { width:16em; }
 .dashboard .module table td { white-space:nowrap; }
 .dashboard .module table td a { display:block; padding-right:.6em; }
 /* RECENT ACTIONS MODULE  */
-.dashboard ul.actionlist { margin-left:0; }
+.dashboard ul.actionlist { margin: 10px 0; }
 .dashboard ul.actionlist li { list-style-type:none; }
 
 /*
index e751c2006be440e3d828c0305673b77f9b47f6d5..277b4e37f537e1aa73585af440c8be3fd605391b 100644 (file)
@@ -12,5 +12,27 @@ class IPF_Admin_Dashboard_Controller extends IPF_Admin_Base_Controller
         );
         return $this->render('admin/index.html', $context);
     }
+
+    function log()
+    {
+        $currentPage = (int)@$this->request->GET['page'];
+        if (!$currentPage)
+            $currentPage = 1;
+
+        $count = IPF_Admin_Log::count();
+
+        $perPage = 20;
+        $pagerLayout = new IPF_Pager_Layout;
+        $pages = $pagerLayout->layout($currentPage, ceil($count / $perPage));
+
+        $context = array(
+            'page_title' => __('Recent Actions'),
+            'admin_log' => IPF_Admin_Log::recent($perPage, ($currentPage - 1) * $perPage),
+            'count' => $count,
+            'current_page' => $currentPage,
+            'pages' => $pages,
+        );
+        return $this->render('admin/log.html', $context);
+    }
 }
 
index 22dbdce3def1b64c7349424972b78514557442b1..a5100c1ce5d8332a1034ba0fd39bc0f6c6209305 100644 (file)
@@ -2,12 +2,21 @@
 
 class IPF_Admin_Log
 {
-    public static function recent()
+    public static function count()
+    {
+        return \PFF\Container::databaseQuery()
+            ->from('admin_log')
+            ->select('COUNT(1) AS cnt')
+            ->fetch('cnt');
+    }
+
+    public static function recent($limit=10, $offset=0)
     {
         return \PFF\Container::databaseQuery()
             ->from('admin_log')
             ->orderBy('created_at DESC')
-            ->limit(10)
+            ->limit($limit)
+            ->offset($offset)
             ->asObject(true)
             ->fetchAll();
     }
index 5d77d45a0ccf32648cc485fe0ba32327360738b7..95b300b077cb20fded71abf5ba411f16ce39a125 100644 (file)
@@ -25,9 +25,8 @@
         {/foreach}
     </div>
     <div id="content-related">
-        <div class="module" id="recent-actions-module">
+        <div class="module">
             <h2>{trans 'Recent Actions'}</h2>
-            <h3>{trans 'My Actions'}</h3>
             <ul class="actionlist">
             {foreach $admin_log as $log}
             <li class="{$log.action}link">
@@ -40,8 +39,9 @@
             </li>
             {/foreach}
             </ul>
+            <a class="all" href="{url array('IPF_Admin_Dashboard_Controller', 'log')}">{trans 'View all'}</a>
         </div>
-    </div-->
+    </div>
     <br class="clear" />
 </div>
 {/block}
diff --git a/ipf/admin/templates/admin/log.html b/ipf/admin/templates/admin/log.html
new file mode 100644 (file)
index 0000000..74f7413
--- /dev/null
@@ -0,0 +1,60 @@
+{extends "admin/base.html"}
+
+{block breadcrumbs}<div class="breadcrumbs"><a href="{url array('IPF_Admin_Dashboard_Controller', 'index')}">{trans 'Home'}</a> &raquo; {$page_title}</div>{/block}
+
+{block content}
+<div id="content" class="flex">
+  <h1>{$page_title}</h1>
+  <div id="content-main">
+    <div id="changelist" class="module">
+
+      <div id="items-grid-container">
+        <table id="items-grid">
+          <thead>
+            <tr class="nodrop">
+              <th>{trans 'Action'}</th>
+              <th>{trans 'Type'}</th>
+              <th>{trans 'When'}</th>
+              <th>{trans 'Who'}</th>
+            </tr>
+          </thead>
+          <tbody>
+            {foreach $admin_log as $log}
+            <tr>
+              <td class="{$log.action}link">
+                {if $log.object_url}
+                  <a href="{$log.object_url}">{$log.object_repr}</a>
+                {else}
+                  {$log.object_repr}
+                {/if}
+              </td>
+              <td>{$log.object_class}</td>
+              <td>{$log.created_at|datetime:'%b %e, %Y %H:%M:%S'}</td>
+              <td>{$log.username}</td>
+            </tr>
+            {/foreach}
+          </tbody>
+        </table>
+
+        <p class="paginator">
+          {foreach $pages as $p}
+            {if $p}
+              {if $p == $current_page}
+                <span class="this-page">{$p}</span>
+              {else}
+                <a href="?{params $request->GET, 'page', $p}">{$p}</a>
+              {/if}
+            {else}
+              &hellip;
+            {/if}
+          {/foreach}
+          {$count} log records
+        </p>
+      </div>
+
+    </div>
+  </div>
+  <br class="clear" />
+</div>
+{/block}
+