添加了元数据概况页面
This commit is contained in:
parent
044acaf849
commit
5e61c301b7
|
@ -3,6 +3,7 @@ use Helpers\View as view;
|
|||
use Helpers\dbh;
|
||||
use \Files\Files;
|
||||
use \Westdc\Visual;
|
||||
use \Westdc\Metadata;
|
||||
|
||||
class Admin_DataController extends Zend_Controller_Action
|
||||
{
|
||||
|
@ -21,8 +22,19 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
{
|
||||
$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));
|
||||
}
|
||||
//其他连接
|
||||
}
|
||||
|
||||
|
|
|
@ -2,17 +2,87 @@
|
|||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle('后台管理');
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headLink()->appendStylesheet('/css/admin.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/admin">后台首页</a>');
|
||||
$this->breadcrumb('数据管理');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
$Theme = new Theme;
|
||||
$Theme->AppendPlus($this,'highstock');
|
||||
?>
|
||||
<div id="divContent">
|
||||
<div id="leftPanel">
|
||||
<?= $this->partial('data/left.phtml'); ?>
|
||||
<div class="row-fluid">
|
||||
<div class="span2">
|
||||
<?= $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 id="rightPanel">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
Highcharts.setOptions({
|
||||
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>
|
|
@ -137,6 +137,12 @@ class Theme
|
|||
)
|
||||
),
|
||||
|
||||
'highcharts' => array(
|
||||
$this->ScriptKey => array(
|
||||
'/js/lib/highcharts/highcharts.js'
|
||||
)
|
||||
),
|
||||
|
||||
/*********谷歌地图*********/
|
||||
|
||||
//Google Map API v3
|
||||
|
|
|
@ -3,7 +3,8 @@ namespace Westdc\Metadata;
|
|||
|
||||
class Metadata
|
||||
{
|
||||
private $db; //传入PDO对象.
|
||||
public $db;
|
||||
public $config;
|
||||
|
||||
//使用到的公共变量
|
||||
public $tbl_metadata = "metadata";
|
||||
|
@ -11,9 +12,15 @@ class Metadata
|
|||
function __construct()
|
||||
{
|
||||
$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)
|
||||
{
|
||||
|
|
|
@ -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'];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue