* Finish task #98678.
This commit is contained in:
@@ -10,10 +10,38 @@ $config->instance->seniorChartList = array();
|
||||
$config->instance->seniorChartList['zentao'] = ['zentao-biz', 'zentao-max'];
|
||||
$config->instance->seniorChartList['zentao-biz'] = ['zentao-max'];
|
||||
|
||||
$config->instance->adminer = new stdclass;
|
||||
$config->instance->adminer = new stdclass();
|
||||
$config->instance->adminer->dbTypes = array();
|
||||
$config->instance->adminer->dbTypes['mysql'] = 'mysql';
|
||||
$config->instance->adminer->dbTypes['postgresql'] = 'pgsql';
|
||||
|
||||
$features = explode(',', getenv('QUICKON_FEATURES', ''));
|
||||
$config->instance->enableAutoRestore = in_array('auto-rollback', $features);
|
||||
|
||||
global $lang, $app;
|
||||
$app->loadLang('space');
|
||||
|
||||
$config->instance->actionList['start']['icon'] = 'play';
|
||||
$config->instance->actionList['start']['hint'] = $lang->instance->start;
|
||||
$config->instance->actionList['start']['url'] = array('module' => 'instance', 'method' => 'visit', 'params' => 'id={id}&type={type}');
|
||||
|
||||
$config->instance->actionList['stop']['icon'] = 'off';
|
||||
$config->instance->actionList['stop']['hint'] = $lang->instance->stop;
|
||||
$config->instance->actionList['stop']['url'] = array('module' => 'instance', 'method' => 'visit', 'params' => 'id={id}&type={type}');
|
||||
|
||||
$config->instance->actionList['uninstall']['icon'] = 'trash';
|
||||
$config->instance->actionList['uninstall']['hint'] = $lang->instance->uninstall;
|
||||
$config->instance->actionList['uninstall']['url'] = array('module' => 'instance', 'method' => 'visit', 'params' => 'id={id}&type={type}');
|
||||
|
||||
$config->instance->actionList['visit']['icon'] = 'menu-my';
|
||||
$config->instance->actionList['visit']['hint'] = $lang->instance->visit;
|
||||
$config->instance->actionList['visit']['url'] = array('module' => 'instance', 'method' => 'visit', 'params' => 'id={id}&type={type}');
|
||||
|
||||
$config->instance->actionList['upgrade']['icon'] = 'refresh';
|
||||
$config->instance->actionList['upgrade']['hint'] = $lang->instance->upgrade;
|
||||
$config->instance->actionList['upgrade']['url'] = helper::createLink('instance', 'upgrade', "id={id}");
|
||||
|
||||
$config->instance->actions = new stdclass();
|
||||
$config->instance->actions->view = array();
|
||||
$config->instance->actions->view['mainActions'] = array('start');
|
||||
$config->instance->actions->view['suffixActions'] = array('uninstall');
|
||||
+33
-20
@@ -78,12 +78,9 @@ class instance extends control
|
||||
$dbList = new stdclass;
|
||||
$currentResource = new stdclass;
|
||||
$customItems = array();
|
||||
if($tab == 'advance')
|
||||
{
|
||||
$dbList = $this->cne->appDBList($instance);
|
||||
$currentResource = $this->cne->getAppConfig($instance);
|
||||
$customItems = $this->cne->getCustomItems($instance);
|
||||
}
|
||||
$dbList = $this->cne->appDBList($instance);
|
||||
$currentResource = $this->cne->getAppConfig($instance);
|
||||
$customItems = $this->cne->getCustomItems($instance);
|
||||
|
||||
$this->view->title = $instance->appName;
|
||||
$this->view->instance = $instance;
|
||||
@@ -225,26 +222,42 @@ class instance extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function editName($id)
|
||||
public function setting($id)
|
||||
{
|
||||
$instance = $this->instance->getByID($id);
|
||||
|
||||
$currentResource = new stdclass;
|
||||
$instance = $this->instance->getByID($id);
|
||||
$currentResource = $this->cne->getAppConfig($instance);
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$newInstance = fixer::input('post')->trim('name')->get();
|
||||
$this->instance->updateByID($id, $newInstance);
|
||||
if(dao::isError())
|
||||
$memoryKb = $newInstance->memory_kb;
|
||||
unset($newInstance->memory_kb);
|
||||
|
||||
if(intval($currentResource->max->memory / 1024) != $memoryKb)
|
||||
{
|
||||
$this->action->create('instance', $instance->id, 'editname', '', json_encode(array('result' => array('result' => 'fail'), 'data' => array('oldName' => $instance->name, 'newName' => $newInstance->name))));
|
||||
return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
/* Check free memory size is enough or not. */
|
||||
$clusterResource = $this->cne->cneMetrics();
|
||||
$freeMemory = intval($clusterResource->metrics->memory->allocatable * 0.9); // Remain 10% memory for system.
|
||||
if($memoryKb * 1024 > $freeMemory) $this->send(array('result' => 'fail', 'message' => $this->lang->instance->errors->notEnoughResource));
|
||||
|
||||
/* Request CNE to adjust memory size. */
|
||||
if(!$this->instance->updateMemorySize($instance, $memoryKb * 1024))
|
||||
{
|
||||
$this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
}
|
||||
}
|
||||
|
||||
$this->action->create('instance', $instance->id, 'editname', '', json_encode(array('result' => array('result' => 'success'), 'data' => array('oldName' => $instance->name, 'newName' => $newInstance->name))));
|
||||
return print(js::closeModal('parent.parent', 'this', "function(){parent.parent.location.reload();}"));
|
||||
$this->instance->updateByID($id, $newInstance);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
if($newInstance->name != $instance->name)
|
||||
{
|
||||
$this->action->create('instance', $instance->id, 'editname', '', json_encode(array('result' => array('result' => 'success'), 'data' => array('oldName' => $instance->name, 'newName' => $newInstance->name))));
|
||||
}
|
||||
return $this->send(array('result' => 'success', 'load' => true, 'closeModal' => true));
|
||||
}
|
||||
|
||||
$this->view->title = $instance->name;
|
||||
$this->view->instance = $instance;
|
||||
$this->view->currentResource = $currentResource;
|
||||
$this->view->instance = $instance;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -350,9 +363,9 @@ class instance extends control
|
||||
if($cloudApp->memory > $freeMemory)
|
||||
{
|
||||
$this->view->cloudApp = $cloudApp;
|
||||
$this->view->gapMemory = helper::formatKB(intval(($cloudApp->memory - $freeMemory) / 1024));
|
||||
$this->view->requiredMemory = helper::formatKB(intval($cloudApp->memory / 1024));
|
||||
$this->view->freeMemory = helper::formatKB(intval($freeMemory / 1024));
|
||||
$this->view->gapMemory = helper::formatKB(intval(($cloudApp->memory - $freeMemory)));
|
||||
$this->view->requiredMemory = helper::formatKB(intval($cloudApp->memory));
|
||||
$this->view->freeMemory = helper::formatKB(intval($freeMemory));
|
||||
|
||||
return $this->display('instance','resourceerror');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The setting view file of instance module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Ke Zhao<zhaoke@easycorp.ltd>
|
||||
* @package instance
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
|
||||
namespace zin;
|
||||
|
||||
formPanel
|
||||
(
|
||||
set::id('instanceSettingForm'),
|
||||
set::title($lang->instance->setting),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::name('name'),
|
||||
set::width('500px'),
|
||||
set::label($lang->instance->name),
|
||||
set::value($instance->name),
|
||||
)
|
||||
),
|
||||
formRow
|
||||
(
|
||||
formGroup
|
||||
(
|
||||
set::name('memory_kb'),
|
||||
set::width('250px'),
|
||||
set::control('picker'),
|
||||
set::label($lang->instance->adjustMem),
|
||||
set::value(intval($currentResource->max->memory / 1024)),
|
||||
set::items($this->instance->filterMemOptions($currentResource)),
|
||||
)
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user