* Add Gitlab MR List Function.
This commit is contained in:
+12
-17
@@ -3,37 +3,32 @@ class mr extends control
|
||||
{
|
||||
public function browse($objectID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
$this->loadModel('repo');
|
||||
$this->loadModel('mr');
|
||||
|
||||
$repoList = $this->repo->getList(0, $orderBy);
|
||||
foreach($repoList as $id => $repo)
|
||||
{
|
||||
if(strtolower($repo->SCM) != 'gitlab') unset($repoList[$id]);
|
||||
}
|
||||
$mrList = $this->mr->getList(0, $orderBy);
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$recTotal = count($repoList);
|
||||
$recTotal = count($mrList);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$repoList = array_chunk($repoList, $pager->recPerPage);
|
||||
$mrList = array_chunk($mrList, $pager->recPerPage);
|
||||
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->browse;
|
||||
$this->view->position[] = $this->lang->repo->common;
|
||||
$this->view->position[] = $this->lang->repo->browse;
|
||||
$this->view->title = $this->lang->mr->common . $this->lang->colon . $this->lang->mr->browse;
|
||||
$this->view->position[] = $this->lang->mr->common;
|
||||
$this->view->position[] = $this->lang->mr->browse;
|
||||
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->pager = $pager;
|
||||
$this->view->repoList = empty($repoList) ? $repoList: $repoList[$pageID - 1];;
|
||||
$this->view->products = $this->loadModel('product')->getPairs();
|
||||
$this->view->mrList = empty($mrList) ? $mrList: $mrList[$pageID - 1];;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
public function list($repoID, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
public function list($mrID, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
$this->loadModel('gitlab');
|
||||
$gitlab = $this->mr->getGitlabProjectByRepo($repoID);
|
||||
$gitlab = $this->mr->getGitlabProjectByRepo($mrID);
|
||||
$mrList = $this->mr->apiGetMRList($gitlab->gitlabID, $gitlab->projectID);
|
||||
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -51,14 +46,14 @@ class mr extends control
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->loadModel('repo');
|
||||
$this->loadModel('mr');
|
||||
if($_POST)
|
||||
{
|
||||
$mrID = $this->mr->create();
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $repoID));
|
||||
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $mrID));
|
||||
$link = helper::createLink('mr', 'browse', '', '', false);
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link));
|
||||
}
|
||||
|
||||
@@ -9,15 +9,18 @@ $lang->mr->detail = "详情";
|
||||
|
||||
$lang->mr->addGitlab = "添加GitLab项目";
|
||||
|
||||
$lang->mr->id = 'ID';
|
||||
$lang->mr->iid = "{$lang->mr->common}ID";
|
||||
$lang->mr->name = '名称';
|
||||
$lang->mr->title = $lang->mr->name;
|
||||
$lang->mr->status = '状态';
|
||||
$lang->mr->author = '创建人';
|
||||
$lang->mr->assignee = '指派给';
|
||||
$lang->mr->reviewer = '评审人';
|
||||
$lang->mr->link = 'GitLab链接';
|
||||
$lang->mr->id = 'ID';
|
||||
$lang->mr->iid = "{$lang->mr->common}ID";
|
||||
$lang->mr->name = '名称';
|
||||
$lang->mr->title = $lang->mr->name;
|
||||
$lang->mr->status = '状态';
|
||||
$lang->mr->author = '创建人';
|
||||
$lang->mr->assignee = '指派给';
|
||||
$lang->mr->reviewer = '评审人';
|
||||
$lang->mr->link = 'GitLab链接';
|
||||
$lang->mr->pipeline = '流水线';
|
||||
$lang->mr->auditStatus = '审核状态';
|
||||
$lang->mr->lastExec = '执行状态';
|
||||
|
||||
$lang->mr->sourceProject = '源项目';
|
||||
$lang->mr->sourceBranch = '源分支';
|
||||
|
||||
+25
-3
@@ -55,15 +55,37 @@ class mrModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getList($repoID, $orderBy = 'id_desc', $pager = null)
|
||||
public function getList($orderBy = 'id_desc', $pager = null)
|
||||
{
|
||||
return $this->dao->select('*')
|
||||
$mrList = $this->dao->select('*')
|
||||
->from(TABLE_MR)
|
||||
->where('deleted')->eq('0')
|
||||
->AndWhere('repoID')->eq($repoID)
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll('id');
|
||||
|
||||
if(!empty($mrList))
|
||||
{
|
||||
$lists = array();
|
||||
foreach($mrList as $mr)
|
||||
{
|
||||
foreach($this->apiGetMRList($mr->gitlabID, $mr->projectID) as $subMR)
|
||||
{
|
||||
$list = new stdclass;
|
||||
|
||||
$list->id = $subMR->id;
|
||||
$list->name = $subMR->title;
|
||||
$list->target_branch = $subMR->target_branch;
|
||||
$list->source_branch = $subMR->source_branch;
|
||||
$list->pipeline = $subMR->merge_when_pipeline_succeeds;
|
||||
$list->auditStatus = $subMR->state;
|
||||
$list->lastExec = $subMR->merge_status;
|
||||
|
||||
$lists[] = $list;
|
||||
}
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class='pull-right'>
|
||||
<?php if(common::hasPriv('repo', 'create')) echo html::a(helper::createLink('repo', 'create'), "<i class='icon icon-plus'></i> " . $lang->mr->addGitlab, '', "class='btn btn-primary'");?>
|
||||
<?php if(common::hasPriv('mr', 'create')) echo html::a(helper::createLink('mr', 'create'), "<i class='icon icon-plus'></i> " . $lang->mr->addGitlab, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<div id='mainContent'>
|
||||
@@ -10,45 +10,39 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<?php $vars = "objectID=$objectID&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}"; ?>
|
||||
<th class='w-60px text-left'><?php common::printOrderLink('id', $orderBy, $vars, $lang->repo->id); ?></th>
|
||||
<th class='w-120px'><?php common::printOrderLink('SCM', $orderBy, $vars, $lang->repo->type); ?></th>
|
||||
<th class='w-200px text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->repo->name); ?></th>
|
||||
<th class='w-400px text-left'><?php common::printOrderLink('product', $orderBy, $vars, $lang->repo->product); ?></th>
|
||||
<th class='w-60px text-left'><?php common::printOrderLink('id', $orderBy, $vars, $lang->mr->id); ?></th>
|
||||
<th class='w-100px text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->mr->name); ?></th>
|
||||
<th class='w-100px text-left'><?php common::printOrderLink('sourceBranch', $orderBy, $vars, $lang->mr->sourceBranch); ?></th>
|
||||
<th class='w-100px text-left'><?php common::printOrderLink('targetBranch', $orderBy, $vars, $lang->mr->targetBranch); ?></th>
|
||||
<th class='w-100px text-left'><?php common::printOrderLink('pipeline', $orderBy, $vars, $lang->mr->pipeline); ?></th>
|
||||
<th class='w-100px text-left'><?php common::printOrderLink('auditStatus', $orderBy, $vars, $lang->mr->auditStatus); ?></th>
|
||||
<th class='w-100px text-left'><?php common::printOrderLink('lastExec', $orderBy, $vars, $lang->mr->lastExec); ?></th>
|
||||
<th class='w-100px c-actions-4'><?php echo $lang->actions; ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($repoList as $repo):?>
|
||||
<?php foreach($mrList as $mr):?>
|
||||
<tr>
|
||||
<td class='text'><?php echo $repo->id; ?></td>
|
||||
<td class='text'><?php echo zget($lang->repo->scmList, $repo->SCM); ?></td>
|
||||
<td class='text' title='<?php echo $repo->name; ?>'><?php echo html::a($this->createLink('repo', 'browse', "repoID={$repo->id}&branchID=&objectID=$objectID"), $repo->name);?></td>
|
||||
<td class='text'>
|
||||
<?php
|
||||
$productList = explode(',', str_replace(' ', '', $repo->product));
|
||||
if(isset($productList) and $productList[0])
|
||||
{
|
||||
foreach($productList as $productID)
|
||||
{
|
||||
if(!isset($products[$productID])) continue;
|
||||
echo ' ' . html::a($this->createLink('product', 'browse', "productID=$productID"), zget($products, $productID, $productID));
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td class='text'><?php echo $mr->id; ?></td>
|
||||
<td class='text'><?php echo $mr->name; ?></td>
|
||||
<td class='text'><?php echo $mr->target_branch; ?></td>
|
||||
<td class='text'><?php echo $mr->source_branch; ?></td>
|
||||
<td class='text'><?php echo $mr->pipeline; ?></td>
|
||||
<td class='text'><?php echo $mr->auditStatus; ?></td>
|
||||
<td class='text'><?php echo $mr->lastExec; ?></td>
|
||||
<td class='text-left c-actions'>
|
||||
<?php
|
||||
common::printLink('mr', 'list', "repo={$repo->id}", '<i class="icon icon-review"></i>', '', "title='{$lang->mr->list}' class='btn btn-info'");
|
||||
common::printLink('mr', 'create', "repo={$repo->id}", '<i class="icon icon-plus"></i>', '', "title='{$lang->mr->create}' class='btn btn-info'");
|
||||
common::printLink('repo', 'edit', "repoID=$repo->id&objectID=$objectID", '<i class="icon icon-edit"></i>', '', "title='{$lang->mr->edit}' class='btn btn-info'");
|
||||
if(common::hasPriv('repo', 'delete')) echo html::a($this->createLink('repo', 'delete', "repoID=$repo->id&objectID=$objectID"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->mr->delete}' class='btn'");
|
||||
common::printLink('mr', 'list', "mr={$mr->id}", '<i class="icon icon-review"></i>', '', "title='{$lang->mr->list}' class='btn btn-info'");
|
||||
common::printLink('mr', 'create', "mr={$mr->id}", '<i class="icon icon-plus"></i>', '', "title='{$lang->mr->create}' class='btn btn-info'");
|
||||
common::printLink('mr', 'edit', "mrID=$mr->id&objectID=$objectID", '<i class="icon icon-edit"></i>', '', "title='{$lang->mr->edit}' class='btn btn-info'");
|
||||
if(common::hasPriv('mr', 'delete')) echo html::a($this->createLink('mr', 'delete', "mrID=$mr->id&objectID=$objectID"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->mr->delete}' class='btn'");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if($repoList):?>
|
||||
<?php if($mrList):?>
|
||||
<div class='table-footer'><?php $pager->show('rignt', 'pagerjs');?></div>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user