From f5296acefe127bb789fd3d0503a0194cb4ff30f8 Mon Sep 17 00:00:00 2001 From: daitingting Date: Tue, 26 Dec 2023 06:37:47 +0000 Subject: [PATCH] * Refactor cacelDownload function. --- module/zahost/config/dtable.php | 9 +++++---- module/zahost/control.php | 15 ++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/module/zahost/config/dtable.php b/module/zahost/config/dtable.php index 122f1c9778..e02817c1a7 100644 --- a/module/zahost/config/dtable.php +++ b/module/zahost/config/dtable.php @@ -81,7 +81,8 @@ $config->zahost->imageDtable->fieldList['actions']['list']['downloadImage']['hin $config->zahost->imageDtable->fieldList['actions']['list']['downloadImage']['url'] = array('module' => 'zahost', 'method' => 'downloadImage', 'params' => 'hostID={hostID}&imageID={id}'); $config->zahost->imageDtable->fieldList['actions']['list']['downloadImage']['className'] = 'ajax-submit'; -$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['icon'] = 'ban-circle'; -$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['hint'] = $lang->zahost->cancel; -$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['url'] = array('module' => 'zahost', 'method' => 'cancelDownload', 'params' => 'imageID={id}'); -$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['className'] = 'ajax-submit'; +$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['icon'] = 'ban-circle'; +$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['hint'] = $lang->zahost->cancel; +$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['url'] = array('module' => 'zahost', 'method' => 'cancelDownload', 'params' => 'imageID={id}'); +$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['className'] = 'ajax-submit'; +$config->zahost->imageDtable->fieldList['actions']['list']['cancelDownload']['data-confirm'] = $lang->zahost->cancelDelete; diff --git a/module/zahost/control.php b/module/zahost/control.php index c904ae4201..1f041c6867 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -269,29 +269,26 @@ class zahost extends control } /** + * 取消镜像下载。 * Sent cancel download image request to Host. * - * @param int $hostID - * @param string $imageName + * @param int $imageID * @access public * @return object */ - public function cancelDownload($imageID, $confirm = 'no') + public function cancelDownload(int $imageID) { - if($confirm == 'no') - { - return print(js::confirm($this->lang->zahost->cancelDelete, inlink('cancelDownload', "id=$imageID&confirm=yes"))); - } $image = $this->zahost->getImageByID($imageID); $this->zahost->cancelDownload($image); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => $this->lang->zahost->image->downloadImageFail)); - if(isInModal()) return print(js::reload('parent')); - return print(js::locate($this->createLink('zahost', 'browseImage', array("hostID" => $image->host)), 'parent')); + if(isInModal()) return $this->send(array('result' => 'success', 'reload' => true)); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => $this->createLink('zahost', 'browseImage', array("hostID" => $image->host)))); } /** + * Ajax 方式获取镜像列表。 * Get image list by ajax. * * @param int $hostID