为没有存档信息的元数据添加了存档添加的功能

This commit is contained in:
Li Jianxuan 2012-06-14 02:00:33 +00:00
parent 62143e2438
commit 35c06c9222
3 changed files with 72 additions and 5 deletions

View File

@ -494,6 +494,7 @@ class Admin_DataController extends Zend_Controller_Action
$row = $sth->fetch();
$this->view->dataset = $row;
$this->view->uuid = $uuid;
}
if($ac == "update")
@ -519,8 +520,42 @@ class Admin_DataController extends Zend_Controller_Action
$this->jsonexit($data);
return true;
}
}
if($ac == "add")
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$uuid = $this->_request->getParam('uuid');
$host = $this->_getParam('host');
$path = $this->_getParam('path');
$sql = "SELECT * FROM dataset WHERE uuid=?";
$sth = $this->db->prepare($sql);
$sth ->execute(array($uuid));
$row = $sth->fetch();
if(!empty($row['id']))
{
$data = array("error"=>"该数据已经有存档信息,不能重复添加");
$this->jsonexit($data);
return true;
}
$sql = "INSERT INTO dataset (uuid,host,path) VALUES (?,?,?)";
$sth = $this->db->prepare($sql);
$ds = $sth ->execute(array($uuid,$host,$path));
if($ds)
{
$data = array("ok"=>1);
$this->jsonexit($data);
return true;
}else{
$data = array("error"=>"处理中出现错误");
$this->jsonexit($data);
return true;
}
}
}//datasetAction存档管理

View File

@ -20,12 +20,16 @@
<div id="loading" class="info info-box"></div>
<div id="datalist">
<?php
if(isset($this->dataset))
if(!empty($this->dataset))
{?>
<p>主机:<br /><input type="text" id="host" name="host" value="<?= $this->dataset['host']?>" class="full" /></p>
<p>路径:<br /><input type="text" id="path" name="path" value="<?= $this->dataset['path']?>" class="full" /></p>
<p><button type="button" class="btn btn-green" onclick="updateDataSet()">修改</button></p>
<?php } ?>
<?php }else{ ?>
<p>主机:<br /><input type="text" id="host" name="host" value="" class="full" /></p>
<p>路径:<br /><input type="text" id="path" name="path" value="" class="full" /></p>
<p><button type="button" class="btn btn-green" onclick="addDataSet()">添加</button></p>
<?php } ?>
</div>
</div>
<!-- //页面内容 -->
@ -36,7 +40,7 @@ function updateDataSet(){
$.ajax({
'type':"POST",
'url':'/admin/data/dataset',
'data':'ac=update&uuid=<?= $this->dataset['uuid']?>&host='+$('#host').val()+'&path='+$('#path').val(),
'data':'ac=update&uuid=<?= $this->uuid ?>&host='+$('#host').val()+'&path='+$('#path').val(),
'success':function(data){
if (typeof(data)=='object')
{
@ -45,6 +49,32 @@ function updateDataSet(){
if(data.ok != null)
{
Alert('修改成功!');
setTimeout("parent.$.fn.colorbox.close();",2000);
}
}
else{
Alert('出现错误,请稍后再试');
}
},
'timeout': 30000,
'error': function(){
Alert('出现错误,请稍后再试');
}
});
}
function addDataSet(){
$.ajax({
'type':"POST",
'url':'/admin/data/dataset',
'data':'ac=add&uuid=<?= $this->uuid ?>&host='+$('#host').val()+'&path='+$('#path').val(),
'success':function(data){
if (typeof(data)=='object')
{
if(typeof(data.error)!='undefined')
{Alert(data.error);return false;}
if(data.ok != null)
{
Alert('添加成功!');
setTimeout("parent.$.fn.colorbox.close();parent.window.location.href=parent.window.location.href;",2000);
}
}
@ -54,7 +84,7 @@ function updateDataSet(){
},
'timeout': 30000,
'error': function(){
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
Alert('出现错误,请稍后再试');
}
});
}

View File

@ -58,8 +58,10 @@
<a href="/admin/review/addon/uuid/<?php echo $item['uuid'];?>">放入元数据评审</a> |
<?php endif; ?>
<a href="/admin/data/source/do/datasource/uuid/<?php echo $item['uuid'];?>">编辑数据来源</a> |
<?php if($item['datasetid']):?>
<?php if(!empty($item['datasetid'])):?>
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">存档</a>
<?php else: ?>
<a href="/admin/data/dataset/ac/getdataset/uuid/<?php echo $item['uuid'];?>" class="iframe">添加存档</a>
<?php endif;?>
</p>
<?php if($item['author']) :?>