增加了三江源自平台的数据可是化管理功能和展示功能
This commit is contained in:
parent
0eeba0747c
commit
97402e262d
File diff suppressed because it is too large
Load Diff
|
@ -16,21 +16,72 @@
|
|||
<div class="span9">
|
||||
<h3>添加可视化要素</h3>
|
||||
<hr />
|
||||
<form class="form-horizontal">
|
||||
<?php if(!empty($this->error)) {?>
|
||||
<div class="alert alert-error">
|
||||
<?= $this->error ?>
|
||||
</div>
|
||||
<?php }?>
|
||||
<form class="form-horizontal" method="post" action="">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputUUID">UUID</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="inputUUID" placeholder="UUID" value="<?= $this->data['uuid'] ?>" class="input-block-level">
|
||||
<input type="text" id="inputUUID" placeholder="UUID" value="<?= $this->data['uuid'] ?>" class="input-block-level" name="uuid">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputVariable">可视化要素</label>
|
||||
<label class="control-label">状态</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="inputVariable" placeholder="Variable" class="input-block-level">
|
||||
<label class="radio inline">
|
||||
<?php $checked = function(){
|
||||
if(isset($this->info['status']))
|
||||
{
|
||||
if($this->info['status'] == 1)
|
||||
{
|
||||
return 'checked="checked"';
|
||||
}
|
||||
}else{
|
||||
return 'checked="checked"';
|
||||
}
|
||||
}; ?>
|
||||
<input type="radio" name="status" id="optionsRadios1" value="1" <?= $checked() ?>>
|
||||
启用
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<input type="radio" name="status" id="optionsRadios2" value="0"
|
||||
<?= isset($this->info['status']) && $this->info['status'] == 0 ? 'checked="checked"':"" ?>>
|
||||
禁用
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputData">数据读取SQL或表名</label>
|
||||
<div class="controls">
|
||||
<textarea name="data" rows="4" class="input-block-level" id="inputData"><?= !isset($this->info['data']) ? "":$this->info['data']?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($this->info['vars'])) { ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputVariable">可视化要素</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="inputVariable" placeholder="Variable" class="input-block-level" name="var[]">
|
||||
</div>
|
||||
</div>
|
||||
<?php }else{ ?>
|
||||
<?php $vars = array() ?>
|
||||
<?php $encoder = new \Westdc\Visual\VariableEncoder; ?>
|
||||
<?php $vars = $encoder->decode($this->info['vars']);?>
|
||||
<?php foreach($vars as $k=>$v) { ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputVariable">可视化要素 <small><a href="javascript:void(0);" onclick="delVar(this)">删除</a></small></label>
|
||||
<div class="controls">
|
||||
<input type="text" id="inputVariable" placeholder="Variable" class="input-block-level" name="var[]" value="<?= $v ?>">
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<div class="control-group" id="last-control-group">
|
||||
<div class="controls">
|
||||
<input type="hidden" name="submit" value="1" />
|
||||
<button type="button" class="btn btn-defualt" id="addVariable">添加要素</button>
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
|
@ -40,12 +91,15 @@
|
|||
</div>
|
||||
<script type="text/javascript">
|
||||
$('#addVariable').click(function(e) {
|
||||
html = '<div class="control-group">
|
||||
<label class="control-label" for="inputVariable">可视化要素</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="inputVariable" placeholder="Variable" class="input-block-level">
|
||||
</div>
|
||||
</div>';
|
||||
$('#last-control-group').prepend();
|
||||
html = '<div class="control-group">'
|
||||
+ '<label class="control-label" for="inputVariable">可视化要素 <small><a href="javascript:void(0);" onclick="delVar(this)">删除</a></small></label>'
|
||||
+ '<div class="controls">'
|
||||
+ '<input type="text" id="inputVariable" placeholder="Variable" class="input-block-level" name="var[]">'
|
||||
+ '</div>'
|
||||
+'</div>';
|
||||
$('#last-control-group').prepend(html);
|
||||
});
|
||||
function delVar(dom){
|
||||
$(dom).parent().parent().parent('.control-group').remove();
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -598,6 +598,9 @@ class DataController extends Zend_Controller_Action
|
|||
$fund = new Fund($this->db);
|
||||
$this->view->fund = $fund->fetch($uuid);
|
||||
|
||||
$visual = new \Westdc\Visual\Visual;
|
||||
$this->view->visual = $visual->getVisualVars($uuid);
|
||||
|
||||
//判断特殊数据服务
|
||||
$this->view->dataService= $this->checkDataService($uuid);
|
||||
|
||||
|
@ -2227,5 +2230,13 @@ order by m.title";
|
|||
$this->view->westee=$this->db->fetchAll($sql);
|
||||
|
||||
}
|
||||
|
||||
//可视化数据
|
||||
public function visualAction()
|
||||
{
|
||||
$visual = new \Westdc\Visual\Visual;
|
||||
view::addPaginator($visual->getVisualMetadata(),$this,10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
use Westdc\Visual\Factory;
|
||||
use Westdc\Visual;
|
||||
use Westdc\Metadata;
|
||||
use Helpers\View as view;
|
||||
|
||||
class VisualController extends Zend_Controller_Action
|
||||
{
|
||||
|
@ -26,7 +28,7 @@ class VisualController extends Zend_Controller_Action
|
|||
if(empty($record_type))
|
||||
return true;
|
||||
|
||||
$sc = Factory::Bootstrap($record_type);
|
||||
$sc = Factory::Bootstrap($record_type);
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,25 +47,56 @@ class VisualController extends Zend_Controller_Action
|
|||
$this->_helper->viewRenderer->setNoRender();
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
||||
$uuid = $this->_getParam("uuid");
|
||||
$record_type = $this->_getParam("dataset");
|
||||
$record_subset = $this->_getParam("subdataset");
|
||||
|
||||
if(empty($record_type))
|
||||
return true;
|
||||
|
||||
$record = Factory::Bootstrap($record_type);
|
||||
$record = new Visual\Record($uuid,$record_subset);
|
||||
//$record = Visual\Factory::Bootstrap($record_type);
|
||||
|
||||
if(!empty($record_subset))
|
||||
{
|
||||
$record->subset = $record_subset;
|
||||
}
|
||||
$data = $record->outPut();
|
||||
|
||||
$data = $record();
|
||||
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
|
||||
}//dataAction() Ajax获取数据
|
||||
|
||||
//viewAction
|
||||
public function viewAction()
|
||||
{
|
||||
$uuid = $this->_getParam('uuid');
|
||||
|
||||
if(empty($uuid) || \Helpers\Uuid::test($uuid) == false)
|
||||
{
|
||||
view::Post($this,"参数错误",-1);
|
||||
return;
|
||||
}
|
||||
|
||||
$visual = new Visual\Visual;
|
||||
|
||||
$this->view->data = $visual->getVisualVars($uuid);
|
||||
|
||||
if(empty($this->view->data))
|
||||
{
|
||||
view::Post($this,"此数据不支持可视化",-1);
|
||||
return;
|
||||
}
|
||||
|
||||
$metadata = new Metadata\Metadata;
|
||||
|
||||
$this->view->info = $metadata->view($uuid);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* jsonexit() 退出并返回json数据
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->data);
|
||||
if (!empty($this->codename)) $this->headTitle($this->codename);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$this->headLink()->appendStylesheet('/css/metadata.css');
|
||||
$this->nav[] = array('link'=>"/data/visual",'title'=>'可视化数据列表');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
?>
|
||||
<div class="row-fluid">
|
||||
<?= $this->render('breadcrumbs.phtml') ?>
|
||||
<?= $this->partial('data/tools.phtml'); ?>
|
||||
</div>
|
||||
<?php if (!empty($this->paginator)) : ?>
|
||||
<div id='metacontent'>
|
||||
<?php echo $this->paginator; ?>
|
||||
<hr />
|
||||
<?php foreach($this->paginator as $md) : ?>
|
||||
<div class="mditem">
|
||||
<div class="thumb">
|
||||
<a href="/service/bigthumb/uuid/<?= $md['uuid'] ?>" class="colorbox">
|
||||
<img src="/service/thumb/id/<?php echo $md['id'];?>" />
|
||||
</a>
|
||||
</div>
|
||||
<h2><a href="/data/<?php echo $md['uuid']; ?>"><?php echo $this->escape($md['title']);?></a></h2>
|
||||
<span><?php echo mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']);?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php echo $this->paginator; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".colorbox").colorbox({rel:"colorbox",photo:"true",transition:"fade"});
|
||||
$(".colorbox").colorbox({photo:"true"});
|
||||
});
|
||||
</script>
|
|
@ -1,46 +1,51 @@
|
|||
<!-- header -->
|
||||
<link href="/sjyportal/css/style.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
|
||||
<header>
|
||||
<div class="container">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="span4">
|
||||
<img src="/sjyportal/img/logo.png" />
|
||||
</div>
|
||||
<div class="span8 inline">
|
||||
<p class="pull-right" style="color:#000000; font-size:9px;">
|
||||
<?php
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if($auth->hasIdentity())
|
||||
{
|
||||
$user = $auth->getIdentity();
|
||||
echo '<a href="/account"><i class="icon-user"></i> '.$user->username.'</a> ';
|
||||
if ($user->usertype=="administrator") echo '<a href="/admin"><i class="icon-cog"></i> 后台 </a><a href="/data/order"><i class="icon-shopping-cart"></i> 数据篮 </a> <a href="/account/logout">退出</a> ';
|
||||
} else {
|
||||
echo '<a href="/account/login">登 录</a> | <a href="/account/register">注 册</a>';
|
||||
} ?>
|
||||
|
||||
</p>
|
||||
<?php $current_url =$_SERVER["REQUEST_URI"]?>
|
||||
<p>
|
||||
<ul class="nav nav-pills pull-right">
|
||||
<li style="padding-right:20px"<?php if($current_url=='/') echo " class='active'";?> ><a href="/">首 页</a></li>
|
||||
<li style="padding-right:20px"<?php if($current_url=='/archives/news/localnews') echo " class='active'";?> ><a href="/archives/news/localnews">新 闻</a></li>
|
||||
<li style="padding-right:20px"<?php if($current_url=='/data') echo " class='active'";?> ><a href="/data">数 据</a></li>
|
||||
<li style="padding-right:20px"<?php if($current_url=='/about') echo " class='active'";?> ><a href="/about">关于我们</a></li>
|
||||
<li style="padding-right:20px" class="input-append ">
|
||||
<form action="/search" method="get"><input class="input-medium" placeholder="关键字" type="text" name="q"><button class="btn" type="submit">搜索</button></form>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<?= $this->render('breadcrumbs.phtml'); ?>
|
||||
<!-- header -->
|
||||
<link href="/sjyportal/css/style.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
|
||||
<header>
|
||||
<div class="container">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="span4">
|
||||
<img src="/sjyportal/img/logo.png" />
|
||||
</div>
|
||||
<div class="span8 inline">
|
||||
<p class="pull-right" style="color:#000000; font-size:9px;">
|
||||
<?php
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if($auth->hasIdentity())
|
||||
{
|
||||
$user = $auth->getIdentity();
|
||||
echo '<a href="/account"><i class="icon-user"></i> '.$user->username.'</a> ';
|
||||
if ($user->usertype=="administrator")
|
||||
{
|
||||
echo '<a href="/admin"><i class="icon-cog"></i> 后台 </a>';
|
||||
}
|
||||
echo '<a href="/data/order"><i class="icon-shopping-cart"></i> 数据篮 </a>';
|
||||
echo '<a href="/account/logout">退出</a>';
|
||||
} else {
|
||||
echo '<a href="/account/login">登 录</a> | <a href="/account/register">注 册</a>';
|
||||
} ?>
|
||||
|
||||
</p>
|
||||
<?php $current_url =$_SERVER["REQUEST_URI"]?>
|
||||
<p>
|
||||
<ul class="nav nav-pills pull-right">
|
||||
<li style="padding-right:20px"<?php if($current_url=='/') echo " class='active'";?> ><a href="/">首 页</a></li>
|
||||
<li style="padding-right:20px"<?php if($current_url=='/archives/news/localnews') echo " class='active'";?> ><a href="/archives/news/localnews">新 闻</a></li>
|
||||
<li style="padding-right:20px"<?php if($current_url=='/data') echo " class='active'";?> ><a href="/data">数 据</a></li>
|
||||
<li style="padding-right:20px"<?php if($current_url=='/about') echo " class='active'";?> ><a href="/about">关于我们</a></li>
|
||||
<li style="padding-right:20px" class="input-append ">
|
||||
<form action="/search" method="get"><input class="input-medium" placeholder="关键字" type="text" name="q"><button class="btn" type="submit">搜索</button></form>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<?= $this->render('breadcrumbs.phtml'); ?>
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
$this->headTitle($this->config->title->site);
|
||||
$this->headTitle($this->config->title->data);
|
||||
$this->headTitle()->setSeparator(' - ');
|
||||
$theme = new Theme;
|
||||
$theme->appendPlus($this,'highstock');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
$this->breadcrumb('<a href="/data">数据与服务</a>');
|
||||
$this->breadcrumb('数据可视化');
|
||||
$this->breadcrumb()->setSeparator(' > ');
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h3><?= $this->info['title'] ?> <small>数据可视化查看</small></h3>
|
||||
<h4><small>请在需要查看的可视化要素上点击以描绘图表,再次点击可取消显示</small></h4>
|
||||
<hr />
|
||||
|
||||
<?php $vars = (new \Westdc\Visual\VariableEncoder)->normaldecode($this->data['vars']);?>
|
||||
<?php foreach($vars as $k=>$v) { ?>
|
||||
<a class="btn btn-default control-btn" href="javascript:void(0);" data-dataset="<?= $v['dataset'] ?>" data-subdataset="<?= $v['subdataset'] ?>" data-seriename="<?= $v['seriename'] ?>">
|
||||
<?= $v['seriename'] ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 页面内容 -->
|
||||
<div class="span12">
|
||||
<div id="datachart" style="width:100%;height:500px;"></div>
|
||||
<a class="btn btn-primary control-btn-cls" href="javascript:void(0);">
|
||||
清除图像
|
||||
</a>
|
||||
</div>
|
||||
<!-- //页面内容 -->
|
||||
</div>
|
||||
<script>
|
||||
_this = {};
|
||||
$(function() {
|
||||
|
||||
$('#datachart').highcharts('StockChart', {
|
||||
|
||||
rangeSelector : {
|
||||
selected : 1,
|
||||
inputEnabled: $('#container').width() > 480
|
||||
},
|
||||
|
||||
credits : {
|
||||
enabled : false
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var chart = $('#datachart').highcharts();
|
||||
|
||||
$(".control-btn").click(function(){
|
||||
|
||||
uuid = '<?= $this->info['uuid'] ?>';
|
||||
dataset = $(this).data('dataset');
|
||||
subdataset = $(this).data('subdataset');
|
||||
seriename = $(this).data('seriename');
|
||||
|
||||
for(i in chart.series)
|
||||
{
|
||||
if(chart.series[i].name == seriename)
|
||||
{
|
||||
chart.series[i].remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
'url': '/visual/data',
|
||||
'data': 'uuid=' + uuid + '&dataset=' + dataset + '&subdataset=' + subdataset,
|
||||
'method': 'GET',
|
||||
'dataType': 'json',
|
||||
'success': function(data){
|
||||
chart.addSeries({
|
||||
name: seriename,
|
||||
data: data,
|
||||
type : 'column'
|
||||
});
|
||||
},
|
||||
'timeout': 30000,
|
||||
'global' : true
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(".control-btn-cls").click(function(e) {
|
||||
for(i in chart.series)
|
||||
{
|
||||
chart.series[i].remove();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
$( document ).ajaxSend(function() {
|
||||
$('#loading').css('display','none');
|
||||
});
|
||||
$( document ).ajaxSend(function() {
|
||||
$('#loading').css('display','block');
|
||||
});
|
||||
$( document ).ajaxSend(function() {
|
||||
$('#loading').css('display','none');
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
namespace Helpers;
|
||||
// 三段
|
||||
// 一段是微秒 一段是地址 一段是随机数
|
||||
class Uuid
|
||||
{
|
||||
private $valueBeforeMD5;
|
||||
private $valueAfterMD5;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$address = $this->getLocalHost();
|
||||
$this->valueBeforeMD5 = $address.':'.$this->currentTimeMillis().':'.$this->nextLong();
|
||||
$this->valueAfterMD5 = md5($this->valueBeforeMD5);
|
||||
}
|
||||
function toString()
|
||||
{
|
||||
$raw = strtoupper($this->valueAfterMD5);
|
||||
return substr($raw,0,8).'-'.substr($raw,8,4).'-'.substr($raw,12,4).'-'.substr($raw,16,4).'-'.substr($raw,20);
|
||||
}
|
||||
|
||||
private function nextLong()
|
||||
{
|
||||
$tmp = rand(0,1)?'-':'';
|
||||
return $tmp.rand(1000, 9999).rand(1000, 9999).rand(1000, 9999).rand(100, 999).rand(100, 999);
|
||||
}
|
||||
private function currentTimeMillis()
|
||||
{
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return $sec.substr($usec, 2, 3);
|
||||
}
|
||||
private function getLocalHost()
|
||||
{
|
||||
$address = isset($_ENV["COMPUTERNAME"]) ? $_ENV["COMPUTERNAME"]."/":"".'/';
|
||||
$address.= $_SERVER["SERVER_ADDR"];
|
||||
return strtolower($address);
|
||||
}
|
||||
|
||||
static function test($uuid)
|
||||
{
|
||||
if(!preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
||||
{
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
namespace Westdc\Metadata;
|
||||
|
||||
class Metadata
|
||||
{
|
||||
private $db; //传入PDO对象.
|
||||
|
||||
//使用到的公共变量
|
||||
public $tbl_metadata = "metadata";
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->db = \Zend_Registry::get('db');
|
||||
}
|
||||
|
||||
function view($uuid)
|
||||
{
|
||||
if(\Helpers\Uuid::test($uuid) !== true)
|
||||
{
|
||||
return "参数错误";
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM ".$this->tbl_metadata." WHERE uuid='$uuid'";
|
||||
$rs = $this->db->query($sql);
|
||||
return $rs->fetch();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue