* Code for story#45936

This commit is contained in:
zenggang
2023-06-19 11:59:35 +00:00
parent 5af4fb60ad
commit 2e033a8f04
14 changed files with 138 additions and 51 deletions
+2 -2
View File
@@ -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) : '';
}
}
+1
View File
@@ -18,6 +18,7 @@ jsVar('branchPrivs', array());
formPanel
(
set::labelWidth('11em'),
formGroup
(
set::width('1/2'),
+13
View File
@@ -1,4 +1,6 @@
<?php
global $lang;
$config->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);
+24 -16
View File
@@ -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;
+5 -1
View File
@@ -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;
+2
View File
@@ -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';
+2
View File
@@ -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';
+2
View File
@@ -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';
+4
View File
@@ -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'] = '全部';
+7 -1
View File
@@ -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);
}
+28
View File
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
/**
* The tao file of repo 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 Zeng Gang<zenggang@easycorp.ltd>
* @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();
}
}
+13 -13
View File
@@ -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
)))
),
+1 -1
View File
@@ -28,7 +28,7 @@ featureBar
(
setClass('form-title'),
set::href($this->createLink('repo', 'import')),
$lang->repo->importAction,
$lang->repo->batchCreate,
),
inputGroup
(
+34 -17
View File
@@ -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