* Refactor cacelDownload function.

This commit is contained in:
daitingting
2023-12-26 06:37:47 +00:00
parent 5a15fc9b1f
commit f5296acefe
2 changed files with 11 additions and 13 deletions
+5 -4
View File
@@ -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;
+6 -9
View File
@@ -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