* Code for task #77685.
This commit is contained in:
@@ -207,8 +207,8 @@ class zanode extends control
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
|
||||
}
|
||||
|
||||
// $task = '';
|
||||
$this->view->task = $task;
|
||||
$this->view->node = $node;
|
||||
$this->view->rate = !empty($task->rate) ? $task->rate : 0;
|
||||
$this->display();
|
||||
}
|
||||
@@ -302,4 +302,28 @@ class zanode extends control
|
||||
$result = $this->zanode->getTaskStatus($extranet, $taskID, $type, $status);
|
||||
return print(json_encode($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update image.
|
||||
*
|
||||
* @param int $imageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxUpdateImage($imageID = 0)
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$data = fixer::input('post')->get();
|
||||
$this->dao->update(TABLE_IMAGE)->data($data)->where('id')->eq($imageID)->autoCheck()->exec();
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
$response['result'] = 'fail';
|
||||
$response['message'] = dao::getError();
|
||||
return $this->send($response);
|
||||
}
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
.progress{height: 20px;}
|
||||
#mainContent{width: 50%; margin: 0 auto;}
|
||||
#mainContent{margin: 0 auto;}
|
||||
|
||||
@@ -52,6 +52,7 @@ $lang->zanode->empty = 'No Execution Node';
|
||||
$lang->zanode->createImaging = 'Creating';
|
||||
$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?';
|
||||
$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. <a href="%s">Created</a>';
|
||||
$lang->zanode->createImageFail = 'Failed to create';
|
||||
|
||||
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ $lang->zanode->empty = 'No Execution Node';
|
||||
$lang->zanode->createImaging = 'Creating';
|
||||
$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?';
|
||||
$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. <a href="%s">Created</a>';
|
||||
$lang->zanode->createImageFail = 'Failed to create';
|
||||
|
||||
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ $lang->zanode->empty = 'No Execution Node';
|
||||
$lang->zanode->createImaging = 'Creating';
|
||||
$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?';
|
||||
$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. <a href="%s">Created</a>';
|
||||
$lang->zanode->createImageFail = 'Failed to create';
|
||||
|
||||
$lang->zanode->apiError['-10100'] = 'Execution node not found.';
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ $lang->zanode->createImage = '创建镜像';
|
||||
$lang->zanode->createImaging = '正在创建镜像';
|
||||
$lang->zanode->createImageNotice = '系统将基于当前执行节点创建镜像,该过程需要关闭该执行节点,确定要继续么?';
|
||||
$lang->zanode->createImageSuccess = '镜像创建成功,您可以使用此镜像创建执行节点。<a href="%s">去创建</a>';
|
||||
$lang->zanode->createImageFail = '镜像创建失败';
|
||||
|
||||
$lang->zanode->apiError['-10100'] = '执行节点不存在';
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ class zanodemodel extends model
|
||||
/* Prepare create params. */
|
||||
$agnetUrl = 'http://' . $node->ip . ':' . $this->config->zanode->defaultPort;
|
||||
$param = array(
|
||||
'backing' => "'{$data->name}'",
|
||||
'backing' => $data->name,
|
||||
'task' => $newID,
|
||||
'vm' => $node->name
|
||||
);
|
||||
@@ -565,10 +565,10 @@ class zanodemodel extends model
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
if($type == $task->type and $taskID == $task->task) return $task;
|
||||
if($taskID == $task->task) return $task;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function buildOperateMenu($node)
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
common::printLink('zanode', 'suspend', "zanodeID={$node->id}", "<i class='icon icon-pause'></i> ", '', $suspendAttr);
|
||||
common::printLink('zanode', 'resume', "zanodeID={$node->id}", "<i class='icon icon-back'></i> ", '', $resumeAttr);
|
||||
common::printLink('zanode', 'reboot', "zanodeID={$node->id}", "<i class='icon icon-restart'></i> ", '', $rebootAttr);
|
||||
common::printLink('zanode', 'createImage', "zanodeID={$node->id}", "<i class='icon icon-plus'></i> ", '', "class='btn iframe' title='{$lang->zanode->createImage}'", '', true);
|
||||
common::printLink('zanode', 'createImage', "zanodeID={$node->id}", "<i class='icon icon-plus'></i> ", '', "class='btn iframe' title='{$lang->zanode->createImage}' data-width='50%'", '', true);
|
||||
common::printIcon('zanode', 'edit', "id={$node->id}", $node, 'list');
|
||||
common::printLink('zanode', 'delete', "zanodeID={$node->id}", "<i class='icon icon-trash'></i> ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==false) return false;'");
|
||||
?>
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php include '../../common/view/kindeditor.html.php';?>
|
||||
<?php if($task):?>
|
||||
<?php js::set('taskID', $task->task);?>
|
||||
<?php js::set('extranet', $node->ip);?>
|
||||
<style>.body-modal #mainContent{width:90%;}
|
||||
</style>
|
||||
<?php endif;?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
@@ -26,7 +32,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<?php $link = helper::createLink('zanode', 'create');?>
|
||||
<h6 class='hide text-center success'><?php echo sprintf($lang->zanode->createImageSuccess, $link)?></h6>
|
||||
<h6 class='hide text-center success'><?php echo sprintf($lang->zanode->createImageSuccess, $link);?></h6>
|
||||
<h6 class='hide text-center fail'><?php echo $lang->zanode->createImageFail;?></h6>
|
||||
<?php else:?>
|
||||
<form class="load-indicator main-form form-ajax" method='post' enctype='multipart/form-data' id='dataform'>
|
||||
<table class='table table-form'>
|
||||
@@ -48,30 +55,40 @@
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if($task):?>
|
||||
<script>
|
||||
var i = 1;
|
||||
var int = self.setInterval("refreshProgress()",100);
|
||||
function refreshProgress()
|
||||
{
|
||||
$('.rate').css('width', i + '%');
|
||||
if(i == 100)
|
||||
{
|
||||
console.log($('.rate').css);
|
||||
debugger;
|
||||
$('.success').removeClass('hide');
|
||||
clearInterval(int);
|
||||
}
|
||||
i ++ ;
|
||||
}
|
||||
var setProgress = self.setInterval("getTaskProgress()",500);
|
||||
|
||||
function getTaskProgress()
|
||||
{
|
||||
var url = createLink('zanode', 'ajaxGetTaskStatus', 'extranet=' + extranet + '&taskID=' + taskID + '&type=exportVm');
|
||||
$.get(url, function(data)
|
||||
{
|
||||
var rate = data.rate;
|
||||
var status = data.status;
|
||||
|
||||
});
|
||||
if(rate == 1 || status == 'completed') rate = 100;
|
||||
|
||||
$('.rate').css('width', rate + '%');
|
||||
if(rate == 100 || (status != 'inprogress' && status != 'created'))
|
||||
{
|
||||
updateStatus(data);
|
||||
clearInterval(setProgress);
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
function updateStatus(data)
|
||||
{
|
||||
var url = createLink('zanode', 'ajaxUpdateImage', 'taskID=' + taskID)
|
||||
var postData = {"status":data.status, "path":data.path}
|
||||
|
||||
$.post(url, postData, function(result)
|
||||
{
|
||||
if(data.status == 'completed') $('.success').removeClass('hide');
|
||||
else $('.fail').removeClass('hide');
|
||||
}, 'json');
|
||||
}
|
||||
</script>
|
||||
<?php endif;;?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user