From 17f4d37cfcff9f9f8eaadebd777b537b4b38cb7c Mon Sep 17 00:00:00 2001 From: zhaoke Date: Tue, 8 Aug 2023 14:38:15 +0800 Subject: [PATCH] * Fix bugs of devops. --- framework/helper.class.php | 2 +- module/account/control.php | 1 + module/account/ui/browse.html.php | 2 +- module/cne/model.php | 20 +++++++++++++++- module/host/control.php | 2 +- module/host/model.php | 3 +++ module/instance/config.php | 4 +++- module/instance/control.php | 5 ++-- module/instance/model.php | 6 +++++ module/instance/ui/view.html.php | 2 +- module/pipeline/model.php | 27 ++++++++++++++++++++++ module/repo/model.php | 2 +- module/space/control.php | 3 ++- module/space/js/createapplication.ui.js | 16 ++++++++----- module/space/ui/createapplication.html.php | 1 + 15 files changed, 79 insertions(+), 17 deletions(-) diff --git a/framework/helper.class.php b/framework/helper.class.php index 516a2a420e..ebe4cd6695 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -543,7 +543,7 @@ function initTableData(array $items, array &$fieldList, object $model = null): a } $item->actions[] = 'other:' . $otherAction; } - elseif($actionKey == 'more') + elseif($actionKey === 'more') { $moreAction = ''; foreach($actionMenu as $moreActionName) diff --git a/module/account/control.php b/module/account/control.php index dda72c1dce..37e0dbf6db 100644 --- a/module/account/control.php +++ b/module/account/control.php @@ -42,6 +42,7 @@ class account extends control $this->view->title = $this->lang->account->common; $this->view->accountList = $accountList; + $this->view->users = $this->loadModel('user')->getPairs('noletter,noempty,noclosed'); $this->view->pager = $pager; $this->view->param = $param; $this->view->orderBy = $orderBy; diff --git a/module/account/ui/browse.html.php b/module/account/ui/browse.html.php index 621402398b..166365cabf 100644 --- a/module/account/ui/browse.html.php +++ b/module/account/ui/browse.html.php @@ -31,7 +31,7 @@ jsVar('sortLink', helper::createLink('account', 'browse', "browseType=$browseTyp dtable ( - set::userMap($accountList), + set::userMap($users), set::cols(array_values($config->account->dtable->fieldList)), set::data($tableData), set::sortLink(jsRaw('createSortLink')), diff --git a/module/cne/model.php b/module/cne/model.php index 493286c8c1..0e36b35e16 100644 --- a/module/cne/model.php +++ b/module/cne/model.php @@ -823,8 +823,26 @@ class cneModel extends model * @access public * @return object|null */ - public function getSettingsMapping($instance, $mappings) + public function getSettingsMapping($instance, $mappings = array()) { + if(empty($mappings)) $mappings = array( + array( + "key" => "admin_username", + "type" => "helm", + "path" => "auth.username" + ), + array( + "key" => "admin_password", + "type" => "helm", + "path" => "auth.password" + ), + array( + "key" => "admin_token", + "type" => "secret", + "path" => "api_token" + ), + ); + $apiParams = new stdclass; $apiParams->cluster = ''; $apiParams->namespace = $instance->spaceData->k8space; diff --git a/module/host/control.php b/module/host/control.php index c8ee7f823a..863d644d91 100644 --- a/module/host/control.php +++ b/module/host/control.php @@ -36,7 +36,7 @@ class host extends control $hostList = $this->host->getList($browseType, $param, $orderBy, $pager); $rooms = $this->loadModel('serverroom')->getPairs(); - $accounts = $this->loadModel('account')->getPairs(); + $accounts = array(0 => '') + $this->loadModel('account')->getPairs(); $groups = array('', '') + $this->loadModel('tree')->getOptionMenu(0, 'host'); /* Build the search form. */ diff --git a/module/host/model.php b/module/host/model.php index f04d74093d..d28d159ef4 100644 --- a/module/host/model.php +++ b/module/host/model.php @@ -212,6 +212,9 @@ class hostModel extends model ->setDefault('cpuNumber,cpuCores,diskSize,memory', 0) ->get(); + $hostInfo->admin = intval($hostInfo->admin); + $hostInfo->serverRoom = intval($hostInfo->serverRoom); + $this->dao->update(TABLE_HOST)->data($hostInfo) ->batchCheck($this->config->host->create->requiredFields, 'notempty') ->batchCheck('diskSize,memory', 'float'); diff --git a/module/instance/config.php b/module/instance/config.php index 1b3ba07cb3..76bb387628 100644 --- a/module/instance/config.php +++ b/module/instance/config.php @@ -57,4 +57,6 @@ $config->instance->actionList['upgrade']['url'] = helper::createLink('in $config->instance->actions = new stdclass(); $config->instance->actions->view = array(); $config->instance->actions->view['mainActions'] = array('visit', 'start', 'stop', 'upgrade'); -$config->instance->actions->view['suffixActions'] = array('uninstall'); \ No newline at end of file +$config->instance->actions->view['suffixActions'] = array('uninstall'); + +$config->instance->devopsApps = array(89 => 'gitea', 58 => 'gitlab', 57 => 'gogs', 59 => 'jenkins', 60 => 'sonarqube'); \ No newline at end of file diff --git a/module/instance/control.php b/module/instance/control.php index 8d379d9e52..db26104d8a 100644 --- a/module/instance/control.php +++ b/module/instance/control.php @@ -77,13 +77,12 @@ class instance extends control } } - $dbList = new stdclass; - $currentResource = new stdclass; - $customItems = array(); $dbList = $this->cne->appDBList($instance); $currentResource = $this->cne->getAppConfig($instance); $customItems = $this->cne->getCustomItems($instance); + if($instance->status == 'running') $this->instanceZen->saveAuthInfo($instance); + $this->view->title = $instance->appName; $this->view->instance = $instance; $this->view->cloudApp = $this->loadModel('store')->getAppInfoByChart($instance->chart, $instance->channel, false); diff --git a/module/instance/model.php b/module/instance/model.php index 33e34b1f1a..2d3095e065 100644 --- a/module/instance/model.php +++ b/module/instance/model.php @@ -575,6 +575,12 @@ class InstanceModel extends model $settingsMap->global->ingress->host = $settingsMap->ingress->host; } + if(!empty($this->config->instance->devopsApps[$instance->appID])) + { + $settingsMap->ci = new stdclass(); + $settingsMap->ci->enabled = true; + } + if(empty($customData->dbType) || $customData->dbType == 'unsharedDB' || empty($customData->dbService)) return $settingsMap; /* Set DB settings. */ diff --git a/module/instance/ui/view.html.php b/module/instance/ui/view.html.php index dc361837b3..701c014132 100644 --- a/module/instance/ui/view.html.php +++ b/module/instance/ui/view.html.php @@ -197,7 +197,7 @@ div floatToolbar ( set::object($instance), - isAjaxRequest('modal') ? null : to::prefix(backBtn(set::icon('back'), set::class('ghost text-white'), $lang->goback)), + isAjaxRequest('modal') ? null : to::prefix(backBtn(set::icon('back'), set::class('ghost text-white'), $lang->goback, set::url(createLink('space', 'browse')))), set::main($actions['mainActions']), set::suffix($actions['suffixActions']) ), diff --git a/module/pipeline/model.php b/module/pipeline/model.php index a806f18a68..38ce9c7927 100644 --- a/module/pipeline/model.php +++ b/module/pipeline/model.php @@ -29,6 +29,33 @@ class pipelineModel extends model return $pipeline; } + /** + * 根据名称及类型获取一条流水线记录 + * Get a pipeline by name and type. + * + * @param string $name + * @param string $type + * @access public + * @return object + */ + public function getByNameAndType(string $name, string $type) + { + return $this->dao->select('id')->from(TABLE_PIPELINE)->where('name')->eq($name)->andWhere('type')->eq($type)->fetch(); + } + + /** + * 根据url获取渠成创建的代码库。 + * Get a pipeline by url which created by quickon. + * + * @param string $url + * @access public + * @return object + */ + public function getByUrl(string $url) + { + return $this->dao->select('id')->from(TABLE_PIPELINE)->where('url')->eq($url)->andWhere('createdBy')->eq('system')->fetch(); + } + /** * Get pipeline list. * diff --git a/module/repo/model.php b/module/repo/model.php index af5d12f73e..0eb759634d 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -2651,7 +2651,7 @@ class repoModel extends model foreach($files as $key => $file) { - if ($file['parent'] == $parent) + if ($file['parent'] === $parent) { $treeList[$key] = $file; $fileName[$key] = $file['name']; diff --git a/module/space/control.php b/module/space/control.php index 0c6d20762a..1125f56bdb 100644 --- a/module/space/control.php +++ b/module/space/control.php @@ -55,8 +55,9 @@ class space extends control $pipelines = $this->loadModel('pipeline')->getList('', 'id_desc'); $maxID = 0; if(!empty($instances)) $maxID = max(array_keys($instances)); - foreach($pipelines as $pipeline) + foreach($pipelines as $key => $pipeline) { + if($pipeline->createdBy == 'system') unset($pipelines[$key]); $pipeline->createdAt = $pipeline->createdDate; $pipeline->appName = ucfirst($pipeline->type); $pipeline->status = ''; diff --git a/module/space/js/createapplication.ui.js b/module/space/js/createapplication.ui.js index 78d1c23a90..40a6c20f98 100644 --- a/module/space/js/createapplication.ui.js +++ b/module/space/js/createapplication.ui.js @@ -72,13 +72,17 @@ function onChangeAppType(event) function onChangeStoreAppType(event) { - if(typeof(event) == 'undefined') + var storeApp = appID; + if(!storeApp) { - var storeApp = defaultApp; - } - else - { - var storeApp = $('[name=storeAppType]').val(); + if(typeof(event) == 'undefined') + { + storeApp = defaultApp; + } + else + { + storeApp = $('[name=storeAppType]').val(); + } } $('#createStoreAppForm').attr('action', $.createLink('instance', 'install', 'appID=' + storeApp)); diff --git a/module/space/ui/createapplication.html.php b/module/space/ui/createapplication.html.php index c2720c3a95..2829def9ca 100644 --- a/module/space/ui/createapplication.html.php +++ b/module/space/ui/createapplication.html.php @@ -20,6 +20,7 @@ jsVar('apps', $apps); jsVar('mysqlList', $mysqlList); jsVar('pgList', $pgList); jsVar('defaultApp', $defaultApp); +jsVar('appID', $appID); $showVersion = getenv('ALLOW_SELECT_VERSION') && (strtolower(getenv('ALLOW_SELECT_VERSION')) == 'true' || strtolower(getenv('ALLOW_SELECT_VERSION')) == '1'); $dbTypeItems = array();