From a7ef8845f8cb14d7f4a1e894ba9e811c1c1439b8 Mon Sep 17 00:00:00 2001 From: zenggang Date: Tue, 25 Jul 2023 07:35:03 +0000 Subject: [PATCH] * Finish task#98665,98667 --- module/common/lang/menu.php | 4 ++-- module/instance/lang/zh-cn.php | 2 +- module/instance/model.php | 7 +++--- module/job/js/create.ui.js | 6 ++++- module/pipeline/model.php | 2 +- module/space/config/dtable.php | 33 ++++++++++++++++++++++---- module/space/control.php | 27 ++++++++++++++++++--- module/space/js/browse.ui.js | 21 ++++++++++++++++ module/space/lang/en.php | 9 +++++++ module/space/lang/zh-cn.php | 10 ++++++++ module/space/ui/browse.html.php | 8 ++----- module/system/ui/browsebackup.html.php | 4 +--- module/system/ui/dblist.html.php | 2 -- module/system/ui/editdomain.html.php | 1 + module/system/ui/ossview.html.php | 2 -- 15 files changed, 110 insertions(+), 28 deletions(-) create mode 100644 module/space/js/browse.ui.js create mode 100644 module/space/lang/en.php diff --git a/module/common/lang/menu.php b/module/common/lang/menu.php index b1b52fc78d..b62752a791 100644 --- a/module/common/lang/menu.php +++ b/module/common/lang/menu.php @@ -486,7 +486,7 @@ $lang->devops->homeMenu = new stdclass(); //$lang->devops->homeMenu->dashboard = array('link' => "{$lang->dashboard}|system|dashboard"); $lang->devops->homeMenu->repos = array('link' => "{$lang->devops->repo}|repo|maintain", 'alias' => 'create,edit,import'); $lang->devops->homeMenu->compile = array('link' => "{$lang->devops->compile}|job|browse", 'subModule' => 'compile,job'); -//$lang->devops->homeMenu->WIPs = array('link' => "{$lang->devops->WIPs}|space|browse", 'subModule' => 'instance,store'); +$lang->devops->homeMenu->WIPs = array('link' => "{$lang->app->common}|space|browse", 'subModule' => 'instance,store'); //$lang->devops->homeMenu->environment = array('link' => "{$lang->devops->environment}|gitlab|browse", 'subModule' => 'gitlab,jenkins,sonarqube,gitea,gogs', 'alias' => 'setrules,create,edit,import'); //$lang->devops->homeMenu->app = array('link' => "{$lang->app->common}|app|serverlink|%s"); @@ -504,7 +504,7 @@ $lang->devops->menuOrder[30] = 'WIPs'; $lang->devops->menuOrder[35] = 'environment'; $lang->devops->menuOrder[40] = 'app'; -$lang->devops->dividerMenu = ',repos,app,'; +$lang->devops->dividerMenu = ',WIPs,'; $lang->devops->homeMenu->environment['subMenu'] = new stdclass(); $lang->devops->homeMenu->environment['subMenu']->gitlab = array('link' => 'GitLab|gitlab|browse', 'subModule' => 'gitlab'); diff --git a/module/instance/lang/zh-cn.php b/module/instance/lang/zh-cn.php index a67cac77f9..a91c7e3375 100644 --- a/module/instance/lang/zh-cn.php +++ b/module/instance/lang/zh-cn.php @@ -1,7 +1,7 @@ instance = new stdclass; $lang->instance->name = '名称'; -$lang->instance->appName = '应用模板'; +$lang->instance->appName = '应用类型'; $lang->instance->version = '版本'; $lang->instance->status = '状态'; $lang->instance->cpu = 'CPU'; diff --git a/module/instance/model.php b/module/instance/model.php index 11677c98db..fc2d9f1395 100644 --- a/module/instance/model.php +++ b/module/instance/model.php @@ -2031,11 +2031,12 @@ class InstanceModel extends model */ public function isClickable(object $instance, string $action): bool { - if($action == 'start') return $this->canDo('start', $instance); - if($action == 'stop') return $this->canDo('stop', $instance); + if($action == 'start') return empty($instance->type) ? $this->canDo('start', $instance) : false; + if($action == 'stop') return empty($instance->type) ? $this->canDo('stop', $instance) : false; if($action == 'uninstall') return empty($instance->solution) && $this->canDo('uninstall', $instance); - if($action == 'visit') return $instance->domain && $this->canDo('visit', $instance); + if($action == 'visit') return empty($instance->type) ? ($instance->domain && $this->canDo('visit', $instance)) : true; if($action == 'upgrade') return !empty($instance->latestVersion); + if($action == 'bindUser') return empty($instance->type) ? false : true; return true; } diff --git a/module/job/js/create.ui.js b/module/job/js/create.ui.js index 993ca0d0b5..a4ceb8818c 100644 --- a/module/job/js/create.ui.js +++ b/module/job/js/create.ui.js @@ -74,7 +74,10 @@ function changeRepo(event) { if(data.type.indexOf('git') != -1) { - $('.reference').removeClass('hidden'); + var engine = $('[name=engine]').val(); + if(engine == 'jenkins') $('.reference').removeClass('hidden'); + $('.reference').addClass('gitRepo'); + $('.svn-fields').addClass('hidden'); $('#reference option').remove(); @@ -88,6 +91,7 @@ function changeRepo(event) } else { + $('.reference').removeClass('gitRepo'); if($('#triggerType').val() == 'tag') $('.svn-fields').removeClass('hidden'); $('#svnDir').remove(); diff --git a/module/pipeline/model.php b/module/pipeline/model.php index 20bb674e4e..431987a4d7 100644 --- a/module/pipeline/model.php +++ b/module/pipeline/model.php @@ -42,7 +42,7 @@ class pipelineModel extends model { return $this->dao->select('*')->from(TABLE_PIPELINE) ->where('deleted')->eq('0') - ->AndWhere('type')->in($type) + ->beginIF($type)->AndWhere('type')->in($type)->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); diff --git a/module/space/config/dtable.php b/module/space/config/dtable.php index fc6a53637b..42ea19586d 100644 --- a/module/space/config/dtable.php +++ b/module/space/config/dtable.php @@ -2,6 +2,8 @@ global $lang, $app; $app->loadLang('instance'); $app->loadLang('store'); +$app->loadLang('task'); +$app->loadLang('gitlab'); $config->space->dtable = new stdclass(); @@ -12,16 +14,30 @@ $config->space->dtable->fieldList['name']['link'] = helper::createLink('instanc $config->space->dtable->fieldList['appName']['title'] = $lang->instance->appName; $config->space->dtable->fieldList['appName']['type'] = 'text'; $config->space->dtable->fieldList['appName']['link'] = helper::createLink('store', 'appview', "id={appID}"); +$config->space->dtable->fieldList['appName']['width'] = '90'; + +$config->space->dtable->fieldList['status']['name'] = 'status'; +$config->space->dtable->fieldList['status']['title'] = $lang->space->status; +$config->space->dtable->fieldList['status']['type'] = 'category'; +$config->space->dtable->fieldList['status']['map'] = $lang->instance->statusList; +$config->space->dtable->fieldList['status']['group'] = 'status'; +$config->space->dtable->fieldList['status']['width'] = '80'; $config->space->dtable->fieldList['appVersion']['title'] = $lang->store->appVersion; $config->space->dtable->fieldList['appVersion']['type'] = 'text'; +$config->space->dtable->fieldList['appVersion']['group'] = 'version'; +$config->space->dtable->fieldList['appVersion']['width'] = '136'; -$config->space->dtable->fieldList['status']['name'] = 'statusText'; -$config->space->dtable->fieldList['status']['title'] = $lang->space->status; -$config->space->dtable->fieldList['status']['type'] = 'html'; +$config->space->dtable->fieldList['createdBy']['title'] = $lang->space->createdBy; +$config->space->dtable->fieldList['createdBy']['type'] = 'user'; +$config->space->dtable->fieldList['createdBy']['group'] = 'created'; + +$config->space->dtable->fieldList['createdAt']['title'] = $lang->space->createdAt; +$config->space->dtable->fieldList['createdAt']['type'] = 'datetime'; +$config->space->dtable->fieldList['createdAt']['group'] = 'created'; $config->space->dtable->fieldList['actions']['type'] = 'actions'; -$config->space->dtable->fieldList['actions']['menu'] = array('start', 'stop', 'uninstall', 'visit', 'upgrade'); +$config->space->dtable->fieldList['actions']['menu'] = array('visit', 'start', 'stop', 'edit', 'bindUser', 'uninstall', 'upgrade'); $config->space->dtable->fieldList['actions']['list']['start']['icon'] = 'play'; $config->space->dtable->fieldList['actions']['list']['start']['hint'] = $lang->instance->start; @@ -34,7 +50,16 @@ $config->space->dtable->fieldList['actions']['list']['uninstall']['hint'] = $lan $config->space->dtable->fieldList['actions']['list']['visit']['icon'] = 'menu-my'; $config->space->dtable->fieldList['actions']['list']['visit']['hint'] = $lang->instance->visit; +$config->space->dtable->fieldList['actions']['list']['visit']['url'] = array('module' => 'instance', 'method' => 'visit', 'params' => 'id={id}&type={type}'); $config->space->dtable->fieldList['actions']['list']['upgrade']['icon'] = 'refresh'; $config->space->dtable->fieldList['actions']['list']['upgrade']['hint'] = $lang->space->upgrade; $config->space->dtable->fieldList['actions']['list']['upgrade']['url'] = helper::createLink('instance', 'upgrade', "id={id}"); + +$config->space->dtable->fieldList['actions']['list']['edit']['icon'] = 'edit'; +$config->space->dtable->fieldList['actions']['list']['edit']['hint'] = $lang->edit; +$config->space->dtable->fieldList['actions']['list']['edit']['url'] = array('module' => 'space', 'method' => 'edit', 'id={id}&type={type}'); + +$config->space->dtable->fieldList['actions']['list']['bindUser']['icon'] = 'lock'; +$config->space->dtable->fieldList['actions']['list']['bindUser']['hint'] = $lang->gitlab->bindUser; +$config->space->dtable->fieldList['actions']['list']['bindUser']['url'] = array('module' => 'space', 'method' => 'bindUser', 'id={id}'); diff --git a/module/space/control.php b/module/space/control.php index a6541ee60a..b4c8955f75 100644 --- a/module/space/control.php +++ b/module/space/control.php @@ -20,10 +20,10 @@ class space extends control * @param int $recTotal * @param int $recPerPage * @param int $pageID - @access public + @access public * @return void */ - public function browse($spaceID = null, $browseType = 'all', $recTotal = 0, $recPerPage = 24, $pageID = 1) + public function browse($spaceID = null, $browseType = 'all', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 24, $pageID = 1) { $this->app->loadLang('instance'); $this->loadModel('instance'); @@ -49,16 +49,37 @@ class space extends control $pager = pager::init($recTotal, $recPerPage, $pageID); $instances = $this->space->getSpaceInstances($space->id, $browseType, $search, $pager); + $pipelines = $this->loadModel('pipeline')->getList('', 'id_desc', $pager); + foreach($pipelines as $pipeline) + { + $pipeline->createdAt = $pipeline->createdDate; + $pipeline->appName = ucfirst($pipeline->type); + $pipeline->status = ''; + $pipeline->type = 'external'; + } + $allInstances = array_merge($instances, $pipelines); + + list($order, $sort) = explode('_', $orderBy); + $createdColumn = array_column((array)$allInstances, $order == 'id' ? 'createdAt' : $order); + array_multisort($createdColumn, $sort == 'desc' ? SORT_DESC : SORT_ASC, $allInstances); + $allInstances = array_slice($allInstances, 0, $recPerPage); $this->view->title = $this->lang->space->common; $this->view->position[] = $this->lang->space->common; $this->view->pager = $pager; $this->view->browseType = $browseType; $this->view->spaceType = $spaceType; - $this->view->instances = $instances; + $this->view->instances = $allInstances; $this->view->currentSpace = $space; $this->view->searchName = $search; $this->display(); } + + public function createApplication() + { + $this->app->loadLang('gitlab'); + + $this->display(); + } } diff --git a/module/space/js/browse.ui.js b/module/space/js/browse.ui.js new file mode 100644 index 0000000000..9e3df1cae6 --- /dev/null +++ b/module/space/js/browse.ui.js @@ -0,0 +1,21 @@ +window.renderInstanceList = function (result, {col, row, value}) +{ + if(col.name === 'status') + { + switch(value) + { + case 'running': + var statusClass = 'text-success'; + break; + case 'abnormal': + var statusClass = 'text-danger'; + break; + default: + var statusClass = ''; + } + result[0] = {html: '' + result[0] + ''}; + return result; + } + + return result; +} diff --git a/module/space/lang/en.php b/module/space/lang/en.php new file mode 100644 index 0000000000..c241b37134 --- /dev/null +++ b/module/space/lang/en.php @@ -0,0 +1,9 @@ +space->handConfig = 'Manual configuration'; +$lang->space->addType = 'Add method'; + +$lang->space->appType['Gitlab'] = 'Gitlab'; +$lang->space->appType['Gitea'] = 'Gitea'; +$lang->space->appType['Gogs'] = 'Gogs'; +$lang->space->appType['Jenkins'] = 'Jenkins'; +$lang->space->appType['Sonarqube'] = 'Sonarqube'; diff --git a/module/space/lang/zh-cn.php b/module/space/lang/zh-cn.php index 336255470b..f20704de4f 100644 --- a/module/space/lang/zh-cn.php +++ b/module/space/lang/zh-cn.php @@ -6,6 +6,10 @@ $lang->space->systemSpace = '系统空间'; $lang->space->searchInstance = '搜索服务'; $lang->space->upgrade = '升级'; $lang->space->install = '添加应用'; +$lang->space->createdBy = '创建者'; +$lang->space->createdAt = '创建时间'; +$lang->space->handConfig = '手工配置'; +$lang->space->addType = '添加方式'; $lang->space->notice = new stdclass; $lang->space->notice->toInstall = '请到应用市场安装'; @@ -18,3 +22,9 @@ $lang->space->featureBar['browse']['all'] = '全部'; $lang->space->featureBar['browse']['running'] = '运行中'; $lang->space->featureBar['browse']['stopped'] = '已停止'; $lang->space->featureBar['browse']['abnormal'] = '异常'; + +$lang->space->appType['Gitlab'] = 'Gitlab'; +$lang->space->appType['Gitea'] = 'Gitea'; +$lang->space->appType['Gogs'] = 'Gogs'; +$lang->space->appType['Jenkins'] = 'Jenkins'; +$lang->space->appType['Sonarqube'] = 'Sonarqube'; diff --git a/module/space/ui/browse.html.php b/module/space/ui/browse.html.php index a4a33461ad..8826bc6d01 100644 --- a/module/space/ui/browse.html.php +++ b/module/space/ui/browse.html.php @@ -10,11 +10,6 @@ declare(strict_types=1); */ namespace zin; -foreach($instances as $instance) -{ - $instance->statusText = $this->instance->printStatus($instance, false); -} - $instances = initTableData($instances, $config->space->dtable->fieldList, $this->instance); featureBar @@ -30,7 +25,7 @@ toolBar 'text' => $lang->space->install, 'icon' => 'plus', 'class' => 'btn primary', - 'url' => createLink('store', 'browse'), + 'url' => createLink('space', 'createApplication'), ))) : null, ); @@ -38,6 +33,7 @@ dtable ( set::cols($config->space->dtable->fieldList), set::data($instances), + set::onRenderCell(jsRaw('window.renderInstanceList')), set::footPager(usePager()), ); diff --git a/module/system/ui/browsebackup.html.php b/module/system/ui/browsebackup.html.php index 50a89dcf17..82279024de 100644 --- a/module/system/ui/browsebackup.html.php +++ b/module/system/ui/browsebackup.html.php @@ -17,9 +17,7 @@ foreach($backups as $backup) $backup->type = $backup->sqlSummary['backupType']; } $backups = initTableData($backups, $config->system->dtable->backup->fieldList, $this->system); - -detailHeader(); - +$backups = array(); panel ( set::size('lg'), diff --git a/module/system/ui/dblist.html.php b/module/system/ui/dblist.html.php index f3ebd05fb0..4869c58641 100644 --- a/module/system/ui/dblist.html.php +++ b/module/system/ui/dblist.html.php @@ -15,8 +15,6 @@ $config->system->dtable->dbList->fieldList['actions']['list']['management']['url $dbList = array((object)array('name' => 'qucheng-mysql', 'db_type' => 'mysql', 'status' => 'running')); $dbList = initTableData($dbList, $config->system->dtable->dbList->fieldList, $this->system); -detailHeader(); - panel ( set::size('lg'), diff --git a/module/system/ui/editdomain.html.php b/module/system/ui/editdomain.html.php index ca8533234c..09dbf9d75f 100644 --- a/module/system/ui/editdomain.html.php +++ b/module/system/ui/editdomain.html.php @@ -42,6 +42,7 @@ formPanel h::a ( setClass('leading-8'), + set::target('_blank'), set::href('https://www.qucheng.com/book/Installation-manual/47.html'), $lang->system->domain->dnsHelperLink ), diff --git a/module/system/ui/ossview.html.php b/module/system/ui/ossview.html.php index d7c0f11c8b..efe3855aee 100644 --- a/module/system/ui/ossview.html.php +++ b/module/system/ui/ossview.html.php @@ -14,8 +14,6 @@ jsVar('copySuccess', $lang->system->copySuccess); $apiURL = !empty($ossDomain->extra_hosts) ? zget($ossDomain->extra_hosts, 'api', '') : ''; -detailHeader(); - panel ( set::size('lg'),