* Modify common function.

This commit is contained in:
caoyanyi
2022-01-17 06:53:53 +00:00
parent 03683c4119
commit f82a59604b
5 changed files with 17 additions and 54 deletions
+2 -2
View File
@@ -123,7 +123,7 @@ class job extends control
$this->view->products = array(0 => '') + $this->loadModel('product')->getProductPairsByProject($this->projectID);
$this->view->jenkinsServerList = array('' => '') + $this->loadModel('jenkins')->getPairs();
$this->view->sonarqubeServerList = array('') + $this->loadModel('sonarqube')->getPairs();
$this->view->sonarqubeServerList = array('') + $this->loadModel('pipeline')->getPairs('sonarqube');
$this->display();
}
@@ -204,7 +204,7 @@ class job extends control
$this->view->job = $job;
$this->view->products = array('') + $products;
$this->view->jenkinsServerList = $this->loadModel('jenkins')->getPairs();
$this->view->sonarqubeServerList = array('') + $this->loadModel('sonarqube')->getPairs();
$this->view->sonarqubeServerList = array('') + $this->loadModel('pipeline')->getPairs('sonarqube');
$this->view->pipelines = $this->jenkins->getTasks($job->server);
$this->display();
+4 -3
View File
@@ -624,15 +624,16 @@ class jobModel extends model
* @param int $sonarqubeID
* @param array $projectKeys
* @param bool $emptyShowAll
* @param bool $showDeleted
* @access public
* @return array
*/
public function getJobBySonarqubeProject($sonarqubeID, $projectKeys = array(), $emptyShowAll = false)
public function getJobBySonarqubeProject($sonarqubeID, $projectKeys = array(), $emptyShowAll = false, $showDeleted = false)
{
return $this->dao->select('projectKey,id')->from(TABLE_JOB)
->where('deleted')->eq(0)
->andWhere('frame')->eq('sonarqube')
->where('frame')->eq('sonarqube')
->andWhere('sonarqubeServer')->eq($sonarqubeID)
->beginIF(!$showDeleted)->andWhere('deleted')->eq('0')->fi()
->beginIF(!empty($projectKeys) or !$emptyShowAll)->andWhere('projectKey')->in($projectKeys)->fi()
->fetchPairs();
}
+9 -9
View File
@@ -40,7 +40,7 @@ class sonarqube extends control
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$sonarqubeList = $this->sonarqube->getList($orderBy, $pager);
$sonarqubeList = $this->loadModel('pipeline')->getList('sonarqube', $orderBy, $pager);
$this->view->title = $this->lang->sonarqube->common . $this->lang->colon . $this->lang->sonarqube->browse;
$this->view->sonarqubeList = $sonarqubeList;
@@ -60,7 +60,7 @@ class sonarqube extends control
*/
public function ajaxGetProjectList($sonarqubeID, $projectKey = '')
{
$jobPairs = $this->loadModel('job')->getJobBySonarqubeProject($sonarqubeID, array(), true);
$jobPairs = $this->loadModel('job')->getJobBySonarqubeProject($sonarqubeID, array(), true, true);
$existsProject = array_diff(array_keys($jobPairs), array($projectKey));
$projectList = $this->sonarqube->apiGetProjects($sonarqubeID);
@@ -138,13 +138,13 @@ class sonarqube extends control
*/
public function edit($sonarqubeID)
{
$oldSonarQube = $this->sonarqube->getByID($sonarqubeID);
$oldSonarQube = $this->loadModel('pipeline')->getByID($sonarqubeID);
if($_POST)
{
$this->checkToken($sonarqubeID);
$this->loadModel('pipeline')->update($sonarqubeID);
$sonarqube = $this->sonarqube->getByID($sonarqubeID);
$this->pipeline->update($sonarqubeID);
$sonarqube = $this->pipeline->getByID($sonarqubeID);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->loadModel('action');
@@ -171,11 +171,11 @@ class sonarqube extends control
{
if($confirm != 'yes') die(js::confirm($this->lang->sonarqube->confirmDelete, inlink('delete', "sonarqubeID=$sonarqubeID&confirm=yes")));
$oldSonarQube = $this->sonarqube->getByID($sonarqubeID);
$oldSonarQube = $this->loadModel('pipeline')->getByID($sonarqubeID);
$this->loadModel('action');
$actionID = $this->loadModel('pipeline')->delete($sonarqubeID, 'sonarqube');
$actionID = $this->pipeline->delete($sonarqubeID, 'sonarqube');
$sonarQube = $this->sonarqube->getByID($sonarqubeID);
$sonarQube = $this->pipeline->getByID($sonarqubeID);
$changes = common::createChanges($oldSonarQube, $sonarQube);
$this->action->logHistory($actionID, $changes);
echo js::reload('parent');
@@ -229,7 +229,7 @@ class sonarqube extends control
$pager = new pager($recTotal, $recPerPage, $pageID);
$sonarqubeProjectList = array_chunk($sonarqubeProjectList, $pager->recPerPage);
$this->view->sonarqube = $this->sonarqube->getByID($sonarqubeID);
$this->view->sonarqube = $this->loadModel('pipeline')->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;
+1 -39
View File
@@ -12,44 +12,6 @@
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.
*
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getList($orderBy = 'id_desc', $pager = null)
{
$sonarqubeList = $this->loadModel('pipeline')->getList('sonarqube', $orderBy, $pager);
return $sonarqubeList;
}
/**
* Get sonarqube pairs.
*
* @access public
* @return array
*/
public function getPairs()
{
return $this->loadModel('pipeline')->getPairs('sonarqube');
}
/**
* Get sonarqube api base url and header by id.
*
@@ -59,7 +21,7 @@ class sonarqubeModel extends model
*/
public function getApiBase($sonarqubeID)
{
$sonarqube = $this->getByID($sonarqubeID);
$sonarqube = $this->loadModel('pipeline')->getByID($sonarqubeID);
if(!$sonarqube) return array('', array());
$url = rtrim($sonarqube->url, '/') . '/api/%s';
+1 -1
View File
@@ -5,7 +5,7 @@ fields:
- field: id
range: 1-2
- field: type
range: gitlabi,sonarqube
range: gitlab,sonarqube
- field: name
range: gitlab服务器,sonarqube服务器
- field: url