* Finish task#47222
This commit is contained in:
@@ -3,3 +3,6 @@ $config->sonarqube = new stdclass();
|
||||
|
||||
$config->sonarqube->create = new stdclass();
|
||||
$config->sonarqube->create->requiredFields = 'name,url,account,password';
|
||||
|
||||
$config->sonarqube->edit = new stdclass();
|
||||
$config->sonarqube->edit->requiredFields = 'name,url,account,password';
|
||||
|
||||
@@ -80,19 +80,28 @@ class sonarqube extends control
|
||||
/**
|
||||
* Check post info.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function checkToken()
|
||||
protected function checkToken($sonarqubeID = 0)
|
||||
{
|
||||
$sonarqube = fixer::input('post')->get();
|
||||
$this->dao->update('sonarqube')->data($sonarqube)->batchCheck($this->config->sonarqube->create->requiredFields, 'notempty');
|
||||
$this->dao->update('sonarqube')->data($sonarqube)->batchCheck(empty($sonarqubeID) ? $this->config->sonarqube->create->requiredFields : $this->config->sonarqube->edit->requiredFields, 'notempty');
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
if(strpos($sonarqube->url, 'http') !== 0) return $this->send(array('result' => 'fail', 'message' => array('url' => array($this->lang->sonarqube->hostError))));
|
||||
|
||||
/* Check name and url unique. */
|
||||
$isExist = $this->dao->select('*')->from(TABLE_PIPELINE)->where("name='{$sonarqube->name}' or url='{$sonarqube->url}'")->fetch();
|
||||
if($isExist) return $this->send(array('result' => 'fail', 'message' => $this->lang->sonarqube->repeatError));
|
||||
if(empty($sonarqubeID))
|
||||
{
|
||||
$existSonarQube = $this->dao->select('*')->from(TABLE_PIPELINE)->where("type='sonarqube' and (name='{$sonarqube->name}' or url='{$sonarqube->url}')")->fetch();
|
||||
}
|
||||
else
|
||||
{
|
||||
$existSonarQube = $this->dao->select('*')->from(TABLE_PIPELINE)->where("id!={$sonarqubeID} and type='sonarqube' and (name='{$sonarqube->name}' or url='{$sonarqube->url}')")->fetch();
|
||||
}
|
||||
if(isset($existSonarQube->name) and $existSonarQube->name == $sonarqube->name) return $this->send(array('result' => 'fail', 'message' => $this->lang->sonarqube->nameRepeatError));
|
||||
if(isset($existSonarQube->url) and $existSonarQube->url== $sonarqube->url) return $this->send(array('result' => 'fail', 'message' => $this->lang->sonarqube->urlRepeatError));
|
||||
|
||||
$token = base64_encode("{$sonarqube->account}:{$sonarqube->password}");
|
||||
$result = $this->sonarqube->apiValidate($sonarqube->url, $token);
|
||||
@@ -101,6 +110,37 @@ class sonarqube extends control
|
||||
$this->post->set('token', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a sonarqube.
|
||||
*
|
||||
* @param int $sonarqubeID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function edit($sonarqubeID)
|
||||
{
|
||||
$oldSonarQube = $this->sonarqube->getByID($sonarqubeID);
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$this->checkToken($sonarqubeID);
|
||||
$this->loadModel('pipeline')->update($sonarqubeID);
|
||||
$sonarqube = $this->sonarqube->getByID($sonarqubeID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$this->loadModel('action');
|
||||
$actionID = $this->action->create('sonarqube', $sonarqubeID, 'edited');
|
||||
$changes = common::createChanges($oldSonarQube, $sonarqube);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->editServer;
|
||||
$this->view->sonarqube = $oldSonarQube;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a sonarqube.
|
||||
*
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
.table-form .c-name {width: 130px;}
|
||||
.table-form .c-input {width: 650px;}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.table-form .c-name {width: 130px;}
|
||||
.table-form .c-input {width: 650px;}
|
||||
@@ -15,8 +15,8 @@ $lang->sonarqube->placeholderSearch = 'Project name';
|
||||
$lang->sonarqube->execJob = "Exec SonarQube Job";
|
||||
|
||||
$lang->sonarqube->id = 'ID';
|
||||
$lang->sonarqube->name = "{$lang->sonarqube->common} Name";
|
||||
$lang->sonarqube->url = 'URL';
|
||||
$lang->sonarqube->name = "Server Name";
|
||||
$lang->sonarqube->url = 'Server Address';
|
||||
$lang->sonarqube->account = 'Username';
|
||||
$lang->sonarqube->password = 'Password';
|
||||
$lang->sonarqube->token = 'Token';
|
||||
@@ -24,6 +24,7 @@ $lang->sonarqube->defaultProject = 'Default Project';
|
||||
$lang->sonarqube->private = 'MD5 Verify';
|
||||
|
||||
$lang->sonarqube->createServer = 'Create SonarQube Server';
|
||||
$lang->sonarqube->editServer = 'Edit SonarQube Server';
|
||||
$lang->sonarqube->desc = 'Description';
|
||||
$lang->sonarqube->createSuccess = 'Create success';
|
||||
|
||||
@@ -31,9 +32,11 @@ $lang->sonarqube->placeholder = new stdclass;
|
||||
$lang->sonarqube->placeholder->name = '';
|
||||
$lang->sonarqube->placeholder->url = "Please fill in the access address of the SonarQube Server homepage, as: https://sonarqube.zentao.net.";
|
||||
|
||||
$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->nameRepeatError = "Server name already exists!";
|
||||
$lang->sonarqube->urlRepeatError = 'Server address already exists!';
|
||||
$lang->sonarqube->validError = 'Sonarqube user authority authentication failed!';
|
||||
$lang->sonarqube->hostError = "Invalid SonarQube server address.";
|
||||
|
||||
$lang->sonarqube->projectKey = 'Project Key';
|
||||
$lang->sonarqube->projectName = 'Project Name';
|
||||
$lang->sonarqube->projectlastAnalysis = 'Last analysis time';
|
||||
|
||||
@@ -15,8 +15,8 @@ $lang->sonarqube->placeholderSearch = '请输入项目名称';
|
||||
$lang->sonarqube->execJob = "执行SonarQube任务";
|
||||
|
||||
$lang->sonarqube->id = 'ID';
|
||||
$lang->sonarqube->name = "{$lang->sonarqube->common}名称";
|
||||
$lang->sonarqube->url = '服务地址';
|
||||
$lang->sonarqube->name = "服务器名称";
|
||||
$lang->sonarqube->url = '服务器地址';
|
||||
$lang->sonarqube->account = '用户名';
|
||||
$lang->sonarqube->password = '密码';
|
||||
$lang->sonarqube->token = 'Token';
|
||||
@@ -24,6 +24,7 @@ $lang->sonarqube->defaultProject = '默认项目';
|
||||
$lang->sonarqube->private = 'MD5验证';
|
||||
|
||||
$lang->sonarqube->createServer = '添加SonarQube服务器';
|
||||
$lang->sonarqube->editServer = '修改SonarQube服务器';
|
||||
$lang->sonarqube->desc = '描述';
|
||||
$lang->sonarqube->createSuccess = "创建成功";
|
||||
|
||||
@@ -31,9 +32,11 @@ $lang->sonarqube->placeholder = new stdclass;
|
||||
$lang->sonarqube->placeholder->name = '';
|
||||
$lang->sonarqube->placeholder->url = "请填写SonarQube Server首页的访问地址,如:https://sonarqube.zentao.net。";
|
||||
|
||||
$lang->sonarqube->repeatError = "服务器名称或服务器地址已存在!";
|
||||
$lang->sonarqube->validError = "SonarQube 用户权限认证失败!";
|
||||
$lang->sonarqube->hostError = "无效的SonarQube服务地址。";
|
||||
$lang->sonarqube->nameRepeatError = "服务器名称已存在!";
|
||||
$lang->sonarqube->urlRepeatError = "服务器地址已存在!";
|
||||
$lang->sonarqube->validError = "SonarQube 用户权限认证失败!";
|
||||
$lang->sonarqube->hostError = "无效的SonarQube服务器地址。";
|
||||
|
||||
$lang->sonarqube->projectKey = '项目标识';
|
||||
$lang->sonarqube->projectName = '项目名称';
|
||||
$lang->sonarqube->projectlastAnalysis = '最后执行时间';
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
<?php $vars = "sonarqubeID={$sonarqubeID}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='c-key text-left'><?php common::printOrderLink('key', $orderBy, $vars, $lang->sonarqube->projectKey);?></th>
|
||||
<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>
|
||||
@@ -54,6 +55,7 @@
|
||||
<tbody>
|
||||
<?php foreach ($sonarqubeProjectList as $id => $sonarqubeProject): ?>
|
||||
<tr class='text'>
|
||||
<td class='text' title='<?php echo $sonarqubeProject->key;?>'><?php echo $sonarqubeProject->key;?></td>
|
||||
<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'>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='c-name'><?php echo $lang->sonarqube->name;?></th>
|
||||
<td><?php echo html::input('name', '', "class='form-control' placeholder='{$lang->sonarqube->placeholder->name}'");?></td>
|
||||
<td class='c-input'><?php echo html::input('name', '', "class='form-control' placeholder='{$lang->sonarqube->placeholder->name}'");?></td>
|
||||
<td class="tips-git"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* The edit 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<zenggang@cnezsoft.com>
|
||||
* @package sonarqube
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-col main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->sonarqube->editServer;?></h2>
|
||||
</div>
|
||||
<form id='sonarqubeForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class="c-name"><?php echo $lang->sonarqube->name;?></th>
|
||||
<td class="c-input"><?php echo html::input('name', isset($sonarqube->name) ? $sonarqube->name : '', "class='form-control' placeholder='{$lang->sonarqube->placeholder->name}'");?></td>
|
||||
<td class="tips-git"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->url;?></th>
|
||||
<td><?php echo html::input('url', isset($sonarqube->url) ? $sonarqube->url : '', "class='form-control' placeholder='{$lang->sonarqube->placeholder->url}'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->account;?></th>
|
||||
<td><?php echo html::input('account', isset($sonarqube->account) ? $sonarqube->account : '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->sonarqube->password;?></th>
|
||||
<td><?php echo html::password('password', isset($sonarqube->password) ? $sonarqube->password : '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td class='text-center form-actions'>
|
||||
<?php echo html::submitButton();?>
|
||||
<?php if(!isonlybody()) echo html::a(inlink('browse', ""), $lang->goback, '', 'class="btn btn-wide"');?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
Reference in New Issue
Block a user