Merge branch 'devops19_47229' into devops19
This commit is contained in:
@@ -1389,6 +1389,8 @@ $lang->resource->sonarqube->create = 'create';
|
||||
$lang->resource->sonarqube->edit = 'edit';
|
||||
$lang->resource->sonarqube->delete = 'delete';
|
||||
$lang->resource->sonarqube->browseProject = 'browseProject';
|
||||
$lang->resource->sonarqube->createProject = 'createProject';
|
||||
$lang->resource->sonarqube->deleteProject = 'deleteProject';
|
||||
$lang->resource->sonarqube->execJob = 'execJob';
|
||||
|
||||
$lang->sonarqube->methodOrder[5] = 'browse';
|
||||
@@ -1396,7 +1398,9 @@ $lang->sonarqube->methodOrder[10] = 'create';
|
||||
$lang->sonarqube->methodOrder[15] = 'edit';
|
||||
$lang->sonarqube->methodOrder[20] = 'delete';
|
||||
$lang->sonarqube->methodOrder[25] = 'browseProject';
|
||||
$lang->sonarqube->methodOrder[30] = 'execJob';
|
||||
$lang->sonarqube->methodOrder[30] = 'createProject';
|
||||
$lang->sonarqube->methodOrder[35] = 'deleteProject';
|
||||
$lang->sonarqube->methodOrder[40] = 'execJob';
|
||||
|
||||
/* merge request. */
|
||||
$lang->resource->mr = new stdclass();
|
||||
|
||||
@@ -53,7 +53,7 @@ class sonarqube extends control
|
||||
}
|
||||
echo html::select('projectKey', $projectPairs, '', "class='form-control chosen' required");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* create a sonarqube.
|
||||
*
|
||||
@@ -101,18 +101,6 @@ class sonarqube extends control
|
||||
$this->post->set('token', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exec job.
|
||||
*
|
||||
* @param int $jobID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function execJob($jobID)
|
||||
{
|
||||
echo $this->fetch('job', 'exec', "jobID=$jobID");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a sonarqube.
|
||||
*
|
||||
@@ -134,4 +122,57 @@ class sonarqube extends control
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
echo js::reload('parent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Exec job.
|
||||
*
|
||||
* @param int $jobID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function execJob($jobID)
|
||||
{
|
||||
echo $this->fetch('job', 'exec', "jobID=$jobID");
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse sonarqube project.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param string $orderBy
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function browseProject($sonarqubeID, $orderBy = 'name_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
|
||||
{
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$keyword = fixer::input('post')->setDefault('keyword', '')->get('keyword');
|
||||
|
||||
$sonarqubeProjectList = $this->sonarqube->apiGetProjects($sonarqubeID, $keyword);
|
||||
foreach($sonarqubeProjectList as $key => $sonarqubeProject) !isset($sonarqubeProject->lastAnalysisDate) ? $sonarqubeProject->lastAnalysisDate = '' : '';
|
||||
|
||||
/* Data sort. */
|
||||
list($order, $sort) = explode('_', $orderBy);
|
||||
$orderList = array();
|
||||
foreach($sonarqubeProjectList as $sonarqubeProject) $orderList[] = $sonarqubeProject->$order;
|
||||
array_multisort($orderList, $sort == 'desc' ? SORT_DESC : SORT_ASC, $sonarqubeProjectList);
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$recTotal = count($sonarqubeProjectList);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$sonarqubeProjectList = array_chunk($sonarqubeProjectList, $pager->recPerPage);
|
||||
|
||||
$this->view->sonarqube = $this->sonarqube->getByID($sonarqubeID);
|
||||
$this->view->keyword = urldecode(urldecode($keyword));
|
||||
$this->view->pager = $pager;
|
||||
$this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->browseProject;
|
||||
$this->view->sonarqubeID = $sonarqubeID;
|
||||
$this->view->sonarqubeProjectList = empty($sonarqubeProjectList) ? $sonarqubeProjectList: $sonarqubeProjectList[$pageID - 1];
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.text-c-counts > span {margin-left: 5px;}
|
||||
#mainMenu .pull-left {margin-right: 15px;}
|
||||
@@ -0,0 +1,22 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#projectSearch').click(function()
|
||||
{
|
||||
triggerSearch();
|
||||
});
|
||||
$('#keyword').keypress(function(event)
|
||||
{
|
||||
if(event.which == 13) triggerSearch();
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* Trigger filtering function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function triggerSearch()
|
||||
{
|
||||
$("#sonarqubeProjectForm").submit();
|
||||
}
|
||||
@@ -1,15 +1,18 @@
|
||||
<?php
|
||||
$lang->sonarqube = new stdclass;
|
||||
$lang->sonarqube->common = 'SonarQube';
|
||||
$lang->sonarqube->browse = 'SonarQube Browse';
|
||||
$lang->sonarqube->search = 'Search';
|
||||
$lang->sonarqube->create = 'Create SonarQube';
|
||||
$lang->sonarqube->edit = 'Edit SonarQube';
|
||||
$lang->sonarqube->delete = 'Delete SonarQube';
|
||||
$lang->sonarqube->confirmDelete = 'Do you want to delete this SonarQube server?';
|
||||
$lang->sonarqube->serverFail = 'Connect to SonarQube server failed, please check the SonarQube server.';
|
||||
$lang->sonarqube->browseProject = "SonarQube Project List";
|
||||
$lang->sonarqube->execJob = "Exec SonarQube Job";
|
||||
$lang->sonarqube->common = 'SonarQube';
|
||||
$lang->sonarqube->browse = 'SonarQube Browse';
|
||||
$lang->sonarqube->search = 'Search';
|
||||
$lang->sonarqube->create = 'Create SonarQube';
|
||||
$lang->sonarqube->edit = 'Edit SonarQube';
|
||||
$lang->sonarqube->delete = 'Delete SonarQube';
|
||||
$lang->sonarqube->confirmDelete = 'Do you want to delete this SonarQube server?';
|
||||
$lang->sonarqube->serverFail = 'Connect to SonarQube server failed, please check the SonarQube server.';
|
||||
$lang->sonarqube->browseProject = "SonarQube Project List";
|
||||
$lang->sonarqube->createProject = "Create SonarQube Project";
|
||||
$lang->sonarqube->deleteProject = "Delete SonarQube Project";
|
||||
$lang->sonarqube->placeholderSearch = 'Project name';
|
||||
$lang->sonarqube->execJob = "Exec SonarQube Job";
|
||||
|
||||
$lang->sonarqube->id = 'ID';
|
||||
$lang->sonarqube->name = "{$lang->sonarqube->common} Name";
|
||||
@@ -31,3 +34,6 @@ $lang->sonarqube->placeholder->url = "Please fill in the access address of the
|
||||
$lang->sonarqube->repeatError = 'Server name or server address already exists!';
|
||||
$lang->sonarqube->validError = 'Sonarqube user authority authentication failed!';
|
||||
$lang->sonarqube->hostError = "Invalid SonarQube service address.";
|
||||
|
||||
$lang->sonarqube->projectName = 'Project Name';
|
||||
$lang->sonarqube->projectlastAnalysis = 'Last analysis time';
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
<?php
|
||||
$lang->sonarqube = new stdclass;
|
||||
$lang->sonarqube->common = 'SonarQube';
|
||||
$lang->sonarqube->browse = '浏览SonarQube';
|
||||
$lang->sonarqube->search = '搜索';
|
||||
$lang->sonarqube->create = '添加SonarQube';
|
||||
$lang->sonarqube->edit = '编辑SonarQube';
|
||||
$lang->sonarqube->delete = '删除SonarQube';
|
||||
$lang->sonarqube->confirmDelete = '确认删除该SonarQube吗?';
|
||||
$lang->sonarqube->serverFail = '连接SonarQube服务器异常,请检查SonarQube服务器。';
|
||||
$lang->sonarqube->browseProject = "SonarQube项目列表";
|
||||
$lang->sonarqube->execJob = "执行SonarQube任务";
|
||||
$lang->sonarqube->common = 'SonarQube';
|
||||
$lang->sonarqube->browse = '浏览SonarQube';
|
||||
$lang->sonarqube->search = '搜索';
|
||||
$lang->sonarqube->create = '添加SonarQube';
|
||||
$lang->sonarqube->edit = '编辑SonarQube';
|
||||
$lang->sonarqube->delete = '删除SonarQube';
|
||||
$lang->sonarqube->confirmDelete = '确认删除该SonarQube吗?';
|
||||
$lang->sonarqube->serverFail = '连接SonarQube服务器异常,请检查SonarQube服务器。';
|
||||
$lang->sonarqube->browseProject = "SonarQube项目列表";
|
||||
$lang->sonarqube->createProject = "创建SonarQube项目";
|
||||
$lang->sonarqube->deleteProject = "删除SonarQube项目";
|
||||
$lang->sonarqube->placeholderSearch = '请输入项目名称';
|
||||
$lang->sonarqube->execJob = "执行SonarQube任务";
|
||||
|
||||
$lang->sonarqube->id = 'ID';
|
||||
$lang->sonarqube->name = "{$lang->sonarqube->common}名称";
|
||||
@@ -31,3 +34,6 @@ $lang->sonarqube->placeholder->url = "请填写SonarQube Server首页的访问
|
||||
$lang->sonarqube->repeatError = "服务器名称或服务器地址已存在!";
|
||||
$lang->sonarqube->validError = "SonarQube 用户权限认证失败!";
|
||||
$lang->sonarqube->hostError = "无效的SonarQube服务地址。";
|
||||
|
||||
$lang->sonarqube->projectName = '项目名称';
|
||||
$lang->sonarqube->projectlastAnalysis = '最后执行时间';
|
||||
|
||||
@@ -12,6 +12,17 @@
|
||||
|
||||
class sonarqubeModel extends model
|
||||
{
|
||||
/**
|
||||
* Get a sonarqube by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getByID($id)
|
||||
{
|
||||
return $this->loadModel('pipeline')->getByID($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sonarqube list.
|
||||
@@ -48,7 +59,7 @@ class sonarqubeModel extends model
|
||||
*/
|
||||
public function getApiBase($sonarqubeID)
|
||||
{
|
||||
$sonarqube = $this->loadModel('pipeline')->getByID($sonarqubeID);
|
||||
$sonarqube = $this->getByID($sonarqubeID);
|
||||
if(!$sonarqube) return '';
|
||||
|
||||
$url = rtrim($sonarqube->url, '/') . '/api/%s';
|
||||
@@ -71,4 +82,31 @@ class sonarqubeModel extends model
|
||||
$header = 'Authorization: Basic ' . $token;
|
||||
return json_decode(commonModel::http($url, null, array(), $header));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projects of one sonarqube.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @param string $keyword
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function apiGetProjects($sonarqubeID, $keyword = '')
|
||||
{
|
||||
list($apiRoot, $header) = $this->getApiBase($sonarqubeID);
|
||||
if(!$apiRoot) return array();
|
||||
|
||||
$url = sprintf($apiRoot, "projects/search");
|
||||
|
||||
$allResults = array();
|
||||
for($page = 1; true; $page++)
|
||||
{
|
||||
$result = json_decode(commonModel::http($url. "?p={$page}&ps=500" . ($keyword ? "&q={$keyword}" : ''), null, array(), $header));
|
||||
if(!isset($result->components)) break;
|
||||
if(!empty($result->components)) $allResults = array_merge($allResults, $result->components);
|
||||
if(count($result->components) < 500) break;
|
||||
}
|
||||
|
||||
return $allResults;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* The browse view file of sonarqube module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Gang Zeng <liugang@cnezsoft.com>
|
||||
* @package sonarqube
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class='pull-left'>
|
||||
<?php echo html::a($this->createLink('sonarqube', 'browse'), "<i class='icon icon-back icon-sm'></i> " . $lang->goback, '', "class='btn btn-secondary'");?>
|
||||
</div>
|
||||
<div id="sidebarHeader">
|
||||
<div class="title"><?php echo $this->lang->sonarqube->common . ':' . $sonarqube->name; ?></div>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-left">
|
||||
<div>
|
||||
<form id='sonarqubeProjectForm' method='post'>
|
||||
<?php echo html::input('keyword', $keyword, "class='form-control' placeholder='{$lang->sonarqube->placeholderSearch}' style='display: inline-block;width:auto;margin:0 10px'");?>
|
||||
<a id="projectSearch" class="btn btn-primary"><?php echo $lang->sonarqube->search?></a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php if(common::hasPriv('sonarqube', 'createProject')) common::printLink('sonarqube', 'createProject', "sonarqubeID=$sonarqubeID", "<i class='icon icon-plus'></i> " . $lang->sonarqube->createProject, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($sonarqubeProjectList)):?>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->noData;?></span>
|
||||
<?php if(empty($keyword) and common::hasPriv('sonarqube', 'createProject')):?>
|
||||
<?php echo html::a($this->createLink('sonarqube', 'createProject', "sonarqubeID=$sonarqubeID"), "<i class='icon icon-plus'></i> " . $lang->sonarqube->createProject, '', "class='btn btn-info'");?>
|
||||
<?php endif;?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<form class='main-table' id='ajaxForm' method='post'>
|
||||
<table id='sonarqubeProjectList' class='table has-sort-head table-fixed'>
|
||||
<?php $vars = "sonarqubeID={$sonarqubeID}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->sonarqube->projectName);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('lastAnalysisDate', $orderBy, $vars, $lang->sonarqube->projectlastAnalysis);?></th>
|
||||
<th class='c-actions-2'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($sonarqubeProjectList as $id => $sonarqubeProject): ?>
|
||||
<tr class='text'>
|
||||
<td class='text-c-name' title='<?php echo $sonarqubeProject->name;?>'><?php echo $sonarqubeProject->name;?></td>
|
||||
<td class='text' title='<?php echo substr($sonarqubeProject->lastAnalysisDate, 0, 10);?>'><?php echo substr($sonarqubeProject->lastAnalysisDate, 0, 10);?></td>
|
||||
<td class='c-actions text-left'>
|
||||
<?php
|
||||
if(common::hasPriv('sonarqube', 'deleteProject')) echo html::a($this->createLink('sonarqube', 'deleteProject', "sonarqubeID=$sonarqubeID&project=$sonarqubeProject->key"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->sonarqube->deleteProject}' class='btn'");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if($sonarqubeProjectList):?>
|
||||
<div class='table-footer'><?php $pager->show('right', 'pagerjs');?></div>
|
||||
<?php endif;?>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
Reference in New Issue
Block a user