添加了元数据概况页面

This commit is contained in:
Li Jianxuan 2014-06-12 08:39:57 +00:00
parent 044acaf849
commit 5e61c301b7
5 changed files with 196 additions and 11 deletions

View File

@ -3,6 +3,7 @@ use Helpers\View as view;
use Helpers\dbh; use Helpers\dbh;
use \Files\Files; use \Files\Files;
use \Westdc\Visual; use \Westdc\Visual;
use \Westdc\Metadata;
class Admin_DataController extends Zend_Controller_Action class Admin_DataController extends Zend_Controller_Action
{ {
@ -21,8 +22,19 @@ class Admin_DataController extends Zend_Controller_Action
{ {
$this->view->messages = $this->messenger->getMessages(); $this->view->messages = $this->messenger->getMessages();
} }
function indexAction()
public function indexAction()
{ {
$statistics = new Metadata\Statistics;
$this->view->total = $statistics->total();
$this->view->review_accept = $statistics->review("accept");
$this->view->review_finish = $statistics->review('finish');
$this->view->visual = $statistics->visual();
if(view::isXmlHttpRequest($this))
{
$this->jsonexit($statistics->getMetadataCountByDay(true));
}
//其他连接 //其他连接
} }

View File

@ -2,17 +2,87 @@
$this->headTitle($this->config->title->site); $this->headTitle($this->config->title->site);
$this->headTitle('后台管理'); $this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - '); $this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>'); $this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>'); $this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('数据管理'); $this->breadcrumb('数据管理');
$this->breadcrumb()->setSeparator(' > '); $this->breadcrumb()->setSeparator(' > ');
$Theme = new Theme;
$Theme->AppendPlus($this,'highstock');
?> ?>
<div id="divContent"> <div class="row-fluid">
<div id="leftPanel"> <div class="span2">
<?= $this->partial('data/left.phtml'); ?> <?= $this->partial('data/left.phtml'); ?>
</div>
<div class="span10">
<h2>元数据管理 <small>概况</small></h2>
<hr />
<ul class="unstyled">
<li>元数据总条数:<?= $this->total ?></li>
<li>待评审的元数据:<a href="/admin/review/accept"><?= $this->review_accept ?></a></li>
<li>已评审的元数据:<a href="/admin/review/reviewed"><?= $this->review_finish ?></a></li>
<li>可视化数据:<a href="/admin/data/visual"><?= $this->visual ?></a></li>
</ul>
<div id="container">
</div>
</div>
</div> </div>
<div id="rightPanel"> <script>
$(function () {
</div> Highcharts.setOptions({
</div> lang: {
months : [ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
//months : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
weekdays: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
}
});
$('#container').highcharts('StockChart', {
title : {
text : '元数据数量增加情况'
},
rangeSelector : {
selected : 1,
inputEnabled: $('#container').width() > 480
},
credits : {
enabled : false
},
tooltip : {
dateTimeLabelFormats :{
day:"%A, %b %e, %Y-%m-%d",
}
},
xAxis : {
dateTimeLabelFormats : {
day:"%Y/%m/%d",
}
}
});
var chart = $('#container').highcharts();
$.ajax({
'url': '?time=<?= time() ?>',
'data': '',
'method': 'GET',
'dataType': 'json',
'success': function(data){
chart.addSeries({
name: "元数据个数",
data: data,
type : 'line'
});
},
'timeout': 30000,
'global' : true
});
});
</script>

View File

@ -137,6 +137,12 @@ class Theme
) )
), ),
'highcharts' => array(
$this->ScriptKey => array(
'/js/lib/highcharts/highcharts.js'
)
),
/*********谷歌地图*********/ /*********谷歌地图*********/
//Google Map API v3 //Google Map API v3

View File

@ -3,7 +3,8 @@ namespace Westdc\Metadata;
class Metadata class Metadata
{ {
private $db; //传入PDO对象. public $db;
public $config;
//使用到的公共变量 //使用到的公共变量
public $tbl_metadata = "metadata"; public $tbl_metadata = "metadata";
@ -11,9 +12,15 @@ class Metadata
function __construct() function __construct()
{ {
$this->db = \Zend_Registry::get('db'); $this->db = \Zend_Registry::get('db');
$this->config = \Zend_Registry::get('config');
if(isset($this->config->sub->metadata) && !empty($this->config->sub->metadata))
{
$this->tbl_metadata = $this->config->sub->metadata;
}
} }
function view($uuid) public function view($uuid)
{ {
if(\Helpers\Uuid::test($uuid) !== true) if(\Helpers\Uuid::test($uuid) !== true)
{ {

View File

@ -0,0 +1,90 @@
<?php
namespace Westdc\Metadata;
class Statistics extends Metadata
{
function __construct()
{
parent::__construct();
}
public function total()
{
$sql = "SELECT count(id) as num FROM {$this->tbl_metadata}";
$rs = $this->db->query($sql);
$row = $rs->fetch();
return $row['num'];
}
public function getMetadataCountByDay($utcTimeReplace = false)
{
$sql = "SELECT
extract(YEAR from ts_created) as y ,
extract(MONTH from ts_created) as m ,
extract(DAY from ts_created) as d,
count(id) as value
FROM {$this->tbl_metadata}
GROUP BY
extract(YEAR from ts_created),
extract(MONTH from ts_created),
extract(DAY from ts_created)
ORDER BY
extract(YEAR from ts_created) ASC,
extract(MONTH from ts_created) ASC,
extract(DAY from ts_created) ASC";
$rs = $this->db->query($sql);
//输出highchart用得数据
if($utcTimeReplace !== false)
{
$data = [];
while($row = $rs->fetch())
{
$data[] = [mktime(0,0,0,$row['m'],$row['d'],$row['y'])*1000,$row['value']];
}
return $data;
}
//输出表格数据
else{
return $rs->fetchAll();
}
}
public function review($type = "accept")
{
switch($type){
case "accept":
$sql = "select count(m.uuid) as num from mdstatus m
right join {$this->tbl_metadata} md on md.uuid=m.uuid
where m.status in (1,2,3,4)";
break;
case "finish":
$sql = "select count(m.uuid) as num from mdstatus m
right join {$this->tbl_metadata} md on md.uuid=m.uuid
where m.status = 5";
break;
}
$rs = $this->db->query($sql);
$row = $rs->fetch();
return $row['num'];
}
public function visual()
{
$sql = "SELECT count(md.id) as num FROM {$this->tbl_metadata} md
LEFT JOIN datavisual v ON v.uuid = md.uuid
WHERE v.uuid IS NOT NULL";
$rs = $this->db->query($sql);
$row = $rs->fetch();
return $row['num'];
}
}