diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 9c0e529751..11998aba2c 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -1050,10 +1050,10 @@ class gitlabModel extends model $requests[$id]['url'] = sprintf($this->getApiRoot($repo->serviceHost, false), "/projects/{$repo->serviceProject}"); } $this->app->loadClass('requests', true); - $results = requests::request_multiple($requests); + $results = requests::request_multiple($requests, array('timeout' => 2)); foreach($results as $id => $result) { - if(!empty($result->body) and substr($result->body, 0, 1) == '{') $this->projects[$repos[$id]->serviceHost][$repos[$id]->serviceProject] = json_decode($result->body); + $this->projects[$repos[$id]->serviceHost][$repos[$id]->serviceProject] = (!empty($result->body) and substr($result->body, 0, 1) == '{') ? json_decode($result->body) : ''; } } diff --git a/module/mr/ui/create.html.php b/module/mr/ui/create.html.php index 6385c77a4e..241c0e6b73 100644 --- a/module/mr/ui/create.html.php +++ b/module/mr/ui/create.html.php @@ -18,6 +18,7 @@ jsVar('branchPrivs', array()); formPanel ( + set::labelWidth('11em'), formGroup ( set::width('1/2'), diff --git a/module/repo/config.php b/module/repo/config.php index b61e8dbf4a..cecbcff29e 100644 --- a/module/repo/config.php +++ b/module/repo/config.php @@ -1,4 +1,6 @@ program = new stdclass(); $config->program->suffix['c'] = "cpp"; $config->program->suffix['cpp'] = "cpp"; @@ -138,3 +140,14 @@ $config->repo->fileExt["vb"] = array('.vb'); $config->repo->fileExt["verilog"] = array('.v', '.vh'); $config->repo->fileExt["xml"] = array('.xml', '.dtd', '.ascx', '.csproj', '.config', '.wxi', '.wxl', '.wxs', '.xaml', '.svg', '.svgz', '.opf', '.xsl'); $config->repo->fileExt["yaml"] = array('.yaml', '.yml'); + +$config->repo->search['module'] = 'repo'; +$config->repo->search['fields']['name'] = $lang->repo->name; +$config->repo->search['fields']['product'] = $lang->repo->product; +$config->repo->search['fields']['projects'] = $lang->repo->projects; +$config->repo->search['fields']['SCM'] = $lang->repo->SCM; + +$config->repo->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => array()); +$config->repo->search['params']['product'] = array('operator' => 'include', 'control' => 'select', 'values' => array()); +$config->repo->search['params']['projects'] = array('operator' => 'include', 'control' => 'select', 'values' => array()); +$config->repo->search['params']['SCM'] = array('operator' => 'include', 'control' => 'select', 'values' => $lang->repo->scmList); diff --git a/module/repo/config/dtable.php b/module/repo/config/dtable.php index 335024e3dc..6c0118bd45 100644 --- a/module/repo/config/dtable.php +++ b/module/repo/config/dtable.php @@ -4,10 +4,22 @@ $app->loadLang('sonarqube'); $config->repo->dtable = new stdclass(); -$config->repo->dtable->fieldList['id']['name'] = 'id'; -$config->repo->dtable->fieldList['id']['title'] = $lang->idAB; -$config->repo->dtable->fieldList['id']['type'] = 'id'; -$config->repo->dtable->fieldList['id']['group'] = 1; +$config->repo->dtable->fieldList['name']['name'] = 'name'; +$config->repo->dtable->fieldList['name']['title'] = $lang->repo->name; +$config->repo->dtable->fieldList['name']['type'] = 'title'; +$config->repo->dtable->fieldList['name']['width'] = '0.2'; + +$config->repo->dtable->fieldList['product']['name'] = 'productNames'; +$config->repo->dtable->fieldList['product']['title'] = $lang->repo->product; +$config->repo->dtable->fieldList['product']['type'] = 'text'; +$config->repo->dtable->fieldList['product']['sortType'] = true; +$config->repo->dtable->fieldList['product']['width'] = '136'; + +$config->repo->dtable->fieldList['project']['name'] = 'projectNames'; +$config->repo->dtable->fieldList['project']['title'] = $lang->repo->projects; +$config->repo->dtable->fieldList['project']['type'] = 'text'; +$config->repo->dtable->fieldList['project']['sortType'] = true; +$config->repo->dtable->fieldList['project']['width'] = '136'; $config->repo->dtable->fieldList['scm']['name'] = 'SCM'; $config->repo->dtable->fieldList['scm']['title'] = $lang->repo->type; @@ -15,20 +27,15 @@ $config->repo->dtable->fieldList['scm']['type'] = 'status'; $config->repo->dtable->fieldList['scm']['map'] = $lang->repo->scmList; $config->repo->dtable->fieldList['scm']['group'] = 1; -$config->repo->dtable->fieldList['name']['name'] = 'name'; -$config->repo->dtable->fieldList['name']['title'] = $lang->repo->name; -$config->repo->dtable->fieldList['name']['type'] = 'text'; -$config->repo->dtable->fieldList['name']['sortType'] = true; -$config->repo->dtable->fieldList['name']['group'] = 2; - -$config->repo->dtable->fieldList['product']['name'] = 'productNames'; -$config->repo->dtable->fieldList['product']['title'] = $lang->repo->product; -$config->repo->dtable->fieldList['product']['type'] = 'text'; -$config->repo->dtable->fieldList['product']['sortType'] = true; - $config->repo->dtable->fieldList['path']['name'] = 'codePath'; $config->repo->dtable->fieldList['path']['title'] = $lang->repo->path; $config->repo->dtable->fieldList['path']['type'] = 'text'; +$config->repo->dtable->fieldList['path']['width'] = '260'; + +$config->repo->dtable->fieldList['lastSubmit']['name'] = 'lastSubmitTime'; +$config->repo->dtable->fieldList['lastSubmit']['title'] = $lang->repo->lastSubmitTime; +$config->repo->dtable->fieldList['lastSubmit']['type'] = 'datetime'; +$config->repo->dtable->fieldList['lastSubmit']['width'] = '128'; $config->repo->dtable->fieldList['job']['name'] = 'job'; $config->repo->dtable->fieldList['job']['hidden'] = true; @@ -36,7 +43,8 @@ $config->repo->dtable->fieldList['job']['hidden'] = true; $config->repo->dtable->fieldList['actions']['name'] = 'actions'; $config->repo->dtable->fieldList['actions']['title'] = $lang->actions; $config->repo->dtable->fieldList['actions']['type'] = 'actions'; -$config->repo->dtable->fieldList['actions']['menu'] = array('edit', 'execJob', 'reportView', 'delete'); +$config->repo->dtable->fieldList['actions']['width'] = '132'; +$config->repo->dtable->fieldList['actions']['menu'] = array('execJob', 'reportView', 'edit', 'delete'); $config->repo->dtable->fieldList['actions']['list']['edit']['icon'] = 'edit'; $config->repo->dtable->fieldList['actions']['list']['edit']['hint'] = $lang->repo->edit; diff --git a/module/repo/control.php b/module/repo/control.php index 6df25b75f1..a599e05110 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -79,7 +79,7 @@ class repo extends control $repoID = $this->repo->saveState(0, $objectID); if($this->viewType !== 'json') $this->commonAction($repoID, $objectID); - $repoList = $this->repo->getList(0, '', $orderBy, null, true); + $repoList = $this->repo->getList(0, '', $orderBy, null, true, true); $sonarRepoList = $this->loadModel('job')->getSonarqubeByRepo(array_keys($repoList)); /* Pager. */ @@ -97,6 +97,9 @@ class repo extends control } $successJobs = $this->loadModel('compile')->getSuccessJobs($jobIDList); + $this->config->repo->search['actionURL'] = $this->createLink('repo', 'maintain'); + $this->loadModel('search')->setSearchParams($this->config->repo->search); + $this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->browse; $this->view->orderBy = $orderBy; @@ -104,6 +107,7 @@ class repo extends control $this->view->pager = $pager; $this->view->repoList = $repoList; $this->view->products = $this->loadModel('product')->getPairs('', 0, '', 'all'); + $this->view->projects = $this->loadModel('project')->getPairs(); $this->view->sonarRepoList = $sonarRepoList; $this->view->successJobs = $successJobs; diff --git a/module/repo/lang/de.php b/module/repo/lang/de.php index ea299f7a14..72c44fe7ae 100644 --- a/module/repo/lang/de.php +++ b/module/repo/lang/de.php @@ -51,6 +51,7 @@ $lang->repo->import = 'Import'; $lang->repo->importName = 'Name after import'; $lang->repo->importServer = 'Please select a server'; $lang->repo->gitlabList = 'Gitlab Repo'; +$lang->repo->batchCreate = 'Batch create repo'; $lang->repo->submit = 'Submit'; $lang->repo->cancel = 'Cancel'; @@ -120,6 +121,7 @@ $lang->repo->linkBug = 'Link Bug'; $lang->repo->linkTask = 'Link Task'; $lang->repo->unlink = 'Unlink'; $lang->repo->viewBugs = 'View Bugs'; +$lang->repo->lastSubmitTime = 'Final submission time'; $lang->repo->title = 'Title'; $lang->repo->status = 'Status'; diff --git a/module/repo/lang/en.php b/module/repo/lang/en.php index 9175adab27..0326b201e3 100644 --- a/module/repo/lang/en.php +++ b/module/repo/lang/en.php @@ -51,6 +51,7 @@ $lang->repo->import = 'Import'; $lang->repo->importName = 'Name after import'; $lang->repo->importServer = 'Please select a server'; $lang->repo->gitlabList = 'Gitlab Repo'; +$lang->repo->batchCreate = 'Batch create repo'; $lang->repo->submit = 'Submit'; $lang->repo->cancel = 'Cancel'; @@ -120,6 +121,7 @@ $lang->repo->linkBug = 'Link Bug'; $lang->repo->linkTask = 'Link Task'; $lang->repo->unlink = 'Unlink'; $lang->repo->viewBugs = 'View Bugs'; +$lang->repo->lastSubmitTime = 'Final submission time'; $lang->repo->title = 'Title'; $lang->repo->status = 'Status'; diff --git a/module/repo/lang/fr.php b/module/repo/lang/fr.php index 78d78b2aaf..5fdd7eaf38 100644 --- a/module/repo/lang/fr.php +++ b/module/repo/lang/fr.php @@ -51,6 +51,7 @@ $lang->repo->import = 'Import'; $lang->repo->importName = 'Name after import'; $lang->repo->importServer = 'Please select a server'; $lang->repo->gitlabList = 'Gitlab Repo'; +$lang->repo->batchCreate = 'Batch create repo'; $lang->repo->submit = 'Soumettre'; $lang->repo->cancel = 'Annuler'; @@ -120,6 +121,7 @@ $lang->repo->linkBug = 'Link Bug'; $lang->repo->linkTask = 'Link Task'; $lang->repo->unlink = 'Unlink'; $lang->repo->viewBugs = 'View Bugs'; +$lang->repo->lastSubmitTime = 'Final submission time'; $lang->repo->title = 'Titre'; $lang->repo->status = 'Statut'; diff --git a/module/repo/lang/zh-cn.php b/module/repo/lang/zh-cn.php index 46fccc9209..08c669c968 100644 --- a/module/repo/lang/zh-cn.php +++ b/module/repo/lang/zh-cn.php @@ -51,6 +51,7 @@ $lang->repo->import = '导入'; $lang->repo->importName = '导入后的名称'; $lang->repo->importServer = '请选择服务器'; $lang->repo->gitlabList = 'Gitlab代码库'; +$lang->repo->batchCreate = '批量添加代码库'; $lang->repo->submit = '提交'; $lang->repo->cancel = '取消'; @@ -120,6 +121,7 @@ $lang->repo->linkBug = '关联Bug'; $lang->repo->linkTask = '关联任务'; $lang->repo->unlink = '取消关联'; $lang->repo->viewBugs = '查看Bug'; +$lang->repo->lastSubmitTime = '最后提交时间'; $lang->repo->title = '标题'; $lang->repo->status = '状态'; @@ -238,3 +240,5 @@ $lang->repo->typeList['performance'] = '性能'; $lang->repo->typeList['security'] = '安全'; $lang->repo->typeList['redundancy'] = '冗余'; $lang->repo->typeList['logicError'] = '逻辑错误'; + +$lang->repo->featureBar['maintain']['all'] = '全部'; diff --git a/module/repo/model.php b/module/repo/model.php index 8384a9781d..4c64e62778 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -111,7 +111,7 @@ class repoModel extends model * @access public * @return array */ - public function getList($projectID = 0, $SCM = '', $orderBy = 'id_desc', $pager = null, $getCodePath = false) + public function getList($projectID = 0, $SCM = '', $orderBy = 'id_desc', $pager = null, $getCodePath = false, $lastSubmitTime = false) { $repos = $this->dao->select('*')->from(TABLE_REPO) ->where('deleted')->eq('0') @@ -154,6 +154,12 @@ class repoModel extends model } } + if($lastSubmitTime) + { + $lastRevision = $this->repoTao->getLastRevision($repo->id); + $repo->lastSubmitTime = isset($lastRevision->time) ? $lastRevision->time : ''; + } + if(in_array(strtolower($repo->SCM), $this->config->repo->gitServiceList)) $repo = $this->processGitService($repo, $getCodePath); } diff --git a/module/repo/tao.php b/module/repo/tao.php new file mode 100644 index 0000000000..5a2c84a56b --- /dev/null +++ b/module/repo/tao.php @@ -0,0 +1,28 @@ + + * @package repo + * @link https://www.zentao.net + */ + +class repoTao extends repoModel +{ + /** + * 获取最后一次提交信息。 + * Get last revision. + * + * @param int $repoID + * @access protected + * @return object|false + */ + protected function getLastRevision(int $repoID): object|false + { + return $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('repo')->eq($repoID)->orderBy('time_desc')->fetch(); + } +} + diff --git a/module/repo/ui/create.html.php b/module/repo/ui/create.html.php index 893caff810..03638fabdb 100644 --- a/module/repo/ui/create.html.php +++ b/module/repo/ui/create.html.php @@ -19,7 +19,7 @@ formPanel set::title($lang->repo->createAction), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("product[]"), set::label($lang->story->product), set::required(true), @@ -30,7 +30,7 @@ formPanel ), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("projects[]"), set::label($lang->repo->projects), set::control(array("type" => "picker","multiple" => true)), @@ -40,7 +40,7 @@ formPanel ), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("SCM"), set::label($lang->product->typeAB), set::required(true), @@ -53,7 +53,7 @@ formPanel setClass('service hide'), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("serviceHost"), set::label($lang->repo->serviceHost), set::required(true), @@ -67,7 +67,7 @@ formPanel setClass('service hide'), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("serviceProject"), set::label($lang->repo->serviceProject), set::required(true), @@ -76,7 +76,7 @@ formPanel ), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("name"), set::label($lang->user->name), set::required(true), @@ -87,7 +87,7 @@ formPanel setClass('hide-service hide-git'), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("path"), set::label($lang->repo->path), set::required(true), @@ -96,7 +96,7 @@ formPanel ), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("encoding"), set::label($lang->repo->encoding), set::required(true), @@ -108,7 +108,7 @@ formPanel setClass('hide-service'), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("client"), set::label($lang->repo->client), set::required(true), @@ -120,7 +120,7 @@ formPanel setClass('account-fields hide-service'), formGroup ( - set::width("1/3"), + set::width("1/2"), set::name("account"), set::label($lang->user->account), set::control("text") @@ -131,7 +131,7 @@ formPanel setClass('account-fields hide-service'), formGroup ( - set::width("1/3"), + set::width("1/2"), set::label($lang->user->password), inputGroup ( @@ -155,7 +155,7 @@ formPanel ), formGroup ( - set::width("1/3"), + set::width("1/2"), set::label($lang->repo->acl), inputGroup ( @@ -166,7 +166,7 @@ formPanel 'id' => "aclgroups", 'value' => NULL, 'type' => "picker", - 'items' => $acl['groups']['Options'], + 'items' => $groups, 'multiple' => true ))) ), diff --git a/module/repo/ui/import.html.php b/module/repo/ui/import.html.php index 5b90eedcc6..f9f0dd9661 100644 --- a/module/repo/ui/import.html.php +++ b/module/repo/ui/import.html.php @@ -28,7 +28,7 @@ featureBar ( setClass('form-title'), set::href($this->createLink('repo', 'import')), - $lang->repo->importAction, + $lang->repo->batchCreate, ), inputGroup ( diff --git a/module/repo/ui/maintain.html.php b/module/repo/ui/maintain.html.php index ee52eb422b..b34bb3bffd 100644 --- a/module/repo/ui/maintain.html.php +++ b/module/repo/ui/maintain.html.php @@ -10,6 +10,9 @@ declare(strict_types=1); */ namespace zin; +$createItem = array('text' => $lang->repo->createAction, 'url' => createLink('repo', 'create')); +$batchCreateItem = array('text' => $lang->repo->batchCreate, 'url' => createLink('repo', 'import')); + foreach($repoList as $repo) { $jobID = 0; @@ -24,7 +27,7 @@ foreach($repoList as $repo) $repo->productNames = ''; $productList = explode(',', str_replace(' ', '', $repo->product)); - if(isset($productList) and $productList[0]) + if($productList) { foreach($productList as $productID) { @@ -32,6 +35,17 @@ foreach($repoList as $repo) $repo->productNames .= ' ' . zget($products, $productID, $productID); } } + + $repo->projectNames = ''; + $projectList = explode(',', str_replace(' ', '', $repo->projects)); + if($projectList) + { + foreach($projectList as $projectID) + { + if(!isset($projects[$projectID])) continue; + $repo->projectNames .= ' ' . zget($projects, $projectID, $projectID); + } + } } $config->repo->dtable->fieldList['name']['link'] = $this->createLink('repo', 'browse', "repoID={id}&branchID=&objectID={$objectID}"); @@ -42,30 +56,33 @@ $repos = initTableData($repoList, $config->repo->dtable->fieldList, $this->repo) featureBar ( - h::a - ( - setClass('btn btn-active-text'), - $lang->repo->maintain, - set::href(createLink('repo', 'maintain')), - ), + set::current('all'), + li(searchToggle(set::module('repo'))) ); toolBar ( - hasPriv('repo', 'import') ? item(set(array + !hasPriv('repo', 'create') && hasPriv('repo', 'import') ? item(set($batchCreateItem + array ( - 'text' => $lang->repo->importAction, - 'icon' => 'import', - 'class' => 'toolbar-item ghost btn btn-default', - 'url' => createLink('repo', 'import'), - ))) : null, - hasPriv('repo', 'create') ? item(set(array - ( - 'text' => $lang->repo->createAction, 'icon' => 'plus', 'class' => 'btn primary', - 'url' => createLink('repo', 'create'), ))) : null, + !hasPriv('repo', 'import') && hasPriv('repo', 'create') ? item(set($createItem + array + ( + 'icon' => 'plus', + 'class' => 'btn primary', + ))) : null, + hasPriv('repo', 'import') && hasPriv('repo', 'create') ? btnGroup + ( + btn(setClass('btn primary'), set::icon('plus'), set::url(createLink('repo', 'create')), $lang->repo->createAction), + dropDown + ( + btn(setClass('btn primary dropdown-toggle'), + setStyle(array('padding' => '6px', 'border-radius' => '0 2px 2px 0'))), + set::placement('bottom-end'), + set::items(array($createItem, $batchCreateItem)), + ), + ) : null, ); dtable