- [refactor] remove solution module
This commit is contained in:
@@ -455,133 +455,6 @@ class install extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示应用安装进度。
|
||||
* Show installation progress of solution.
|
||||
*
|
||||
* @param int $id
|
||||
* @param bool $startInstall
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function progress(int $id, bool $startInstall = false)
|
||||
{
|
||||
$solution = $this->loadModel('solution')->getByID($id);
|
||||
|
||||
$this->view->title = $this->lang->solution->progress;
|
||||
$this->view->solution = $solution;
|
||||
$this->view->startInstall = $startInstall;
|
||||
|
||||
$this->app->loadConfig('message');
|
||||
$this->config->message->browser->turnon = 0;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取安装进度。
|
||||
* AJAX: Get installing progress of solution.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxProgress(int $id)
|
||||
{
|
||||
$this->loadModel('common');
|
||||
$solution = $this->loadModel('solution')->getByID($id);
|
||||
$result = 'success';
|
||||
$message = '';
|
||||
$logs = array();
|
||||
|
||||
if($solution->status == 'installed') return $this->send(array('result' => $result, 'message' => $message, 'data' => json_decode($solution->components), 'logs' => $logs));
|
||||
|
||||
if($solution->status != 'installing')
|
||||
{
|
||||
$result = 'fail';
|
||||
$message = zget($this->lang->solution->installationErrors, $solution->status, $this->lang->solution->errors->hasInstallationError);
|
||||
return $this->send(array('result' => $result, 'message' => $message, 'data' => json_decode($solution->components), 'logs' => $logs));
|
||||
}
|
||||
|
||||
if((time() - strtotime($solution->updatedDate)) > 60 * 20)
|
||||
{
|
||||
$this->solution->saveStatus($id, 'timeout');
|
||||
$result = 'fail';
|
||||
$message = $this->lang->solution->errors->timeout;
|
||||
return $this->send(array('result' => $result, 'message' => $message, 'data' => json_decode($solution->components), 'logs' => $logs));
|
||||
}
|
||||
|
||||
$components = json_decode($solution->components);
|
||||
foreach($components as $componentApp)
|
||||
{
|
||||
if($componentApp->status != 'installing') continue;
|
||||
|
||||
$instance = $this->loadModel('instance')->instanceOfSolution($solution, $componentApp->chart);
|
||||
if(!$instance) continue;
|
||||
|
||||
$chartLogs = $this->loadModel('cne')->getAppLogs($instance);
|
||||
$logs[$componentApp->chart] = !empty($chartLogs->data) ? $chartLogs->data : array();
|
||||
}
|
||||
return $this->send(array('result' => $result, 'message' => $message, 'data' => json_decode($solution->components), 'logs' => $logs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装应用。
|
||||
* AJAX: Start install.
|
||||
*
|
||||
* @param int $solutionID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxInstall(int $solutionID)
|
||||
{
|
||||
$this->loadModel('solution')->install($solutionID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
return $this->send(array('result' => 'success', 'message' => '', 'locate' => $this->inLink('step6')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消安装时卸载应用。
|
||||
* AJAX: Uninstall app.
|
||||
*
|
||||
* @param int $solutionID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxUninstall(int $solutionID)
|
||||
{
|
||||
$this->loadModel('common');
|
||||
$this->loadModel('solution')->uninstall($solutionID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
return $this->send(array('result' => 'success', 'message' => '', 'load' => $this->inLink('app')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查内存与CPU是否满足安装所需。
|
||||
* AJAX: Check memory and cpu.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxCheck()
|
||||
{
|
||||
$this->loadModel('common');
|
||||
|
||||
$apps = (array)$this->post->apps;
|
||||
foreach($apps as $index => $app)
|
||||
{
|
||||
if($app == $this->lang->install->solution->skipInstall) unset($apps[$index]);
|
||||
}
|
||||
|
||||
$appMap = $this->loadModel('store')->getAppMapByNames($apps);
|
||||
$resources = array();
|
||||
foreach($apps as $app) $resources[] = array('cpu' => $appMap->$app->cpu, 'memory' => $appMap->$app->memory);
|
||||
|
||||
$result = $this->loadModel('cne')->tryAllocate($resources);
|
||||
return $this->send(array('result' => 'success', 'message' => '', 'code' => $result->code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 安装DuckDB引擎界面。
|
||||
* Install duckdb.
|
||||
|
||||
Reference in New Issue
Block a user