From ef650485ee3c2085d9eb30fa8b38fee5bfc76811 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Thu, 12 Jan 2023 02:59:08 +0000 Subject: [PATCH] * Fix bug #31493 --- module/zahost/js/browseimage.js | 2 +- module/zahost/lang/de.php | 1 + module/zahost/lang/en.php | 1 + module/zahost/lang/fr.php | 1 + module/zahost/lang/vi.php | 1 + module/zahost/lang/zh-cn.php | 1 + module/zahost/model.php | 12 +++++++++++- module/zahost/view/view.html.php | 7 ++++--- module/zanode/lang/de.php | 1 + module/zanode/lang/en.php | 1 + module/zanode/lang/fr.php | 1 + module/zanode/lang/zh-cn.php | 1 + module/zanode/model.php | 1 + module/zanode/view/createimage.html.php | 16 +++++++++++++--- 14 files changed, 39 insertions(+), 8 deletions(-) diff --git a/module/zahost/js/browseimage.js b/module/zahost/js/browseimage.js index c0c7f8f0cd..d142876596 100644 --- a/module/zahost/js/browseimage.js +++ b/module/zahost/js/browseimage.js @@ -21,7 +21,7 @@ function updateProgress() { var hasInprogress = false; for (var imageID in statusList) { if (statusList[imageID].statusCode) { - if (statusList[imageID].statusCode == 'inprogress' || statusList[imageID].statusCode == 'created') + if (statusList[imageID].statusCode == 'inprogress' || statusList[imageID].statusCode == 'created' || statusList[imageID].statusCode == 'pending') { hasInprogress = true; $('.image-download-' + imageID).addClass('disabled'); diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index db5a2d8846..e4cf451830 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -91,6 +91,7 @@ $lang->zahost->image->statusList['notDownloaded'] = 'Not Downloaded'; $lang->zahost->image->statusList['created'] = 'Inprogress'; $lang->zahost->image->statusList['canceled'] = 'Not Downloaded'; $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['pending'] = 'Waiting for download'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index db5a2d8846..e4cf451830 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -91,6 +91,7 @@ $lang->zahost->image->statusList['notDownloaded'] = 'Not Downloaded'; $lang->zahost->image->statusList['created'] = 'Inprogress'; $lang->zahost->image->statusList['canceled'] = 'Not Downloaded'; $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['pending'] = 'Waiting for download'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index db5a2d8846..e4cf451830 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -91,6 +91,7 @@ $lang->zahost->image->statusList['notDownloaded'] = 'Not Downloaded'; $lang->zahost->image->statusList['created'] = 'Inprogress'; $lang->zahost->image->statusList['canceled'] = 'Not Downloaded'; $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['pending'] = 'Waiting for download'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 7c252fd147..3db09c4781 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -90,6 +90,7 @@ $lang->zahost->image->statusList['notDownloaded'] = 'Not Downloaded'; $lang->zahost->image->statusList['created'] = 'Inprogress'; $lang->zahost->image->statusList['canceled'] = 'Not Downloaded'; $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; +$lang->zahost->image->statusList['pending'] = 'Waiting for download'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index a4771a9fc4..60804004a3 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -91,6 +91,7 @@ $lang->zahost->image->statusList['notDownloaded'] = '可下载'; $lang->zahost->image->statusList['created'] = '下载中'; $lang->zahost->image->statusList['canceled'] = '可下载'; $lang->zahost->image->statusList['inprogress'] = '下载中'; +$lang->zahost->image->statusList['pending'] = '排队下载中'; $lang->zahost->image->statusList['completed'] = '可使用'; $lang->zahost->image->statusList['failed'] = '下载失败'; diff --git a/module/zahost/model.php b/module/zahost/model.php index 0751265257..b7f37b3e74 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -323,10 +323,13 @@ class zahostModel extends model } $currentTask = null; + $is_finish = false; foreach($result->data as $status => $group) { + if($is_finish) break; foreach($group as $task) { + if($is_finish) break; if($task->task == $image->id) { $task->endDate = substr($task->endDate, 0, 19); @@ -334,6 +337,12 @@ class zahostModel extends model { $currentTask = $task; } + if($task->status == 'inprogress') + { + $currentTask = $task; + $is_finish = true; + break; + } } } } @@ -343,6 +352,8 @@ class zahostModel extends model $image->rate = $currentTask->rate; $image->status = $currentTask->status; + if(!empty($result->data->inprogress) && $currentTask->task != $result->data->inprogress[0]->task && $currentTask->status == 'created') $image->status = 'pending'; + $this->dao->update(TABLE_IMAGE) ->set('status')->eq($image->status) ->set('path')->eq(!empty($currentTask->path) ? $currentTask->path : '') @@ -372,7 +383,6 @@ class zahostModel extends model $response = json_decode(commonModel::http($statusApi, array(), array(CURLOPT_CUSTOMREQUEST => 'GET'), array("Authorization:$host->tokenSN"), 'json')); - a($response); if($response->code == 200) return true; dao::$errors[] = $response->msg; diff --git a/module/zahost/view/view.html.php b/module/zahost/view/view.html.php index 3a3f9b9db0..5670c7b3ca 100644 --- a/module/zahost/view/view.html.php +++ b/module/zahost/view/view.html.php @@ -134,8 +134,9 @@
zahost->browseNode;?>
-
- +
+ createLink('zanode', 'browse', "id=$zahost->id", '', true) . "' frameborder='no' allowfullscreen='true' mozallowfullscreen='true' webkitallowfullscreen='true' allowtransparency='true' scrolling='auto' style='width: 100%; height: 100%; left: 0px;'>";?> +
diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php index 703d1fe112..f32d767fbc 100644 --- a/module/zanode/lang/de.php +++ b/module/zanode/lang/de.php @@ -73,6 +73,7 @@ $lang->zanode->runCaseConfirm = 'The system detects the presence of an automatio $lang->zanode->createImage = 'Create Image'; $lang->zanode->createImaging = 'Creating'; +$lang->zanode->pending = 'Waiting for create'; $lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the ZenAgent Node to be shut down. Do you want to continue?'; $lang->zanode->createImageSuccess = 'Successed, You can use this image to create node.'; $lang->zanode->createImageFail = 'Failed to create'; diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php index 703d1fe112..f32d767fbc 100644 --- a/module/zanode/lang/en.php +++ b/module/zanode/lang/en.php @@ -73,6 +73,7 @@ $lang->zanode->runCaseConfirm = 'The system detects the presence of an automatio $lang->zanode->createImage = 'Create Image'; $lang->zanode->createImaging = 'Creating'; +$lang->zanode->pending = 'Waiting for create'; $lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the ZenAgent Node to be shut down. Do you want to continue?'; $lang->zanode->createImageSuccess = 'Successed, You can use this image to create node.'; $lang->zanode->createImageFail = 'Failed to create'; diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php index 703d1fe112..f32d767fbc 100644 --- a/module/zanode/lang/fr.php +++ b/module/zanode/lang/fr.php @@ -73,6 +73,7 @@ $lang->zanode->runCaseConfirm = 'The system detects the presence of an automatio $lang->zanode->createImage = 'Create Image'; $lang->zanode->createImaging = 'Creating'; +$lang->zanode->pending = 'Waiting for create'; $lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the ZenAgent Node to be shut down. Do you want to continue?'; $lang->zanode->createImageSuccess = 'Successed, You can use this image to create node.'; $lang->zanode->createImageFail = 'Failed to create'; diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php index dacdf4b979..30bb81be88 100644 --- a/module/zanode/lang/zh-cn.php +++ b/module/zanode/lang/zh-cn.php @@ -73,6 +73,7 @@ $lang->zanode->runCaseConfirm = '系统检测到选择的用例存在自动化 $lang->zanode->createImage = '导出镜像'; $lang->zanode->createImaging = '正在导出镜像'; +$lang->zanode->pending = '等待导出镜像'; $lang->zanode->createImageNotice = '系统将基于当前执行节点导出镜像,该过程需要关闭该执行节点,确定要继续么?'; $lang->zanode->createImageSuccess = '镜像导出成功,您可以使用此镜像创建执行节点。'; $lang->zanode->createImageFail = '镜像导出失败'; diff --git a/module/zanode/model.php b/module/zanode/model.php index 217a586c2e..591d14fed0 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -675,6 +675,7 @@ class zanodemodel extends model foreach($tasks as $task) { + if(!empty($tasks['inprogress']) && $task->task != $tasks['inprogress'][0]->task && $task->status == 'created') $task->status = 'pending'; if($type == $task->type and $taskID == $task->task) return $task; } } diff --git a/module/zanode/view/createimage.html.php b/module/zanode/view/createimage.html.php index 934514162f..d718562fdc 100644 --- a/module/zanode/view/createimage.html.php +++ b/module/zanode/view/createimage.html.php @@ -15,6 +15,7 @@ task);?> id);?> +zanode); ?> @@ -26,7 +27,7 @@ -
zanode->createImaging;?>
+
zanode->pending;?>
@@ -82,8 +83,17 @@ function getTaskProgress() if(rate == 1 || status == 'completed') rate = 1; if(status == 'inprogress' && rate >= 1) rate = 0.97; + if(status == 'pending') + { + $('.status-title').text(zanodeLang.pending) + } + else + { + $('.status-title').text(zanodeLang.createImaging) + } + $('.rate').css('width', rate*100 + '%'); - if(rate == 1 || (status != 'inprogress' && status != 'created')) + if(rate == 1 || (status != 'inprogress' && status != 'created' && status != 'pending')) { updateStatus(data); clearInterval(setProgress); @@ -99,7 +109,7 @@ function updateStatus(data) $.post(url, postData, function(result) { if(data.status == 'completed') $('.success').removeClass('hide'); - else $('.fail').removeClass('hide'); + else $('.status-title').text(zanodeLang.createImageFail) }, 'json'); }