Merge branch 'master' of https://gitlab.zcorp.cc/easycorp/zentaopms
This commit is contained in:
@@ -317,14 +317,14 @@ $lang->qa->dividerMenu = ',bug,testtask,caselib,';
|
||||
$lang->devops->menu = new stdclass();
|
||||
$lang->devops->menu->code = array('link' => "{$lang->repo->common}|repo|browse|repoID=%s", 'alias' => 'diff,view,revision,log,blame,showsynccommit');
|
||||
$lang->devops->menu->compile = array('link' => "{$lang->devops->compile}|job|browse", 'subModule' => 'compile,job');
|
||||
// $lang->devops->menu->gitlab = array('link' => "Gitlab|gitlab|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->gitlab = array('link' => "GitLab|gitlab|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->jenkins = array('link' => "Jenkins|jenkins|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->maintain = array('link' => "{$lang->devops->repo}|repo|maintain", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->rules = array('link' => "{$lang->devops->rules}|repo|setrules");
|
||||
|
||||
$lang->devops->menuOrder[5] = 'code';
|
||||
$lang->devops->menuOrder[10] = 'compile';
|
||||
// $lang->devops->menuOrder[15] = 'gitlab';
|
||||
$lang->devops->menuOrder[15] = 'gitlab';
|
||||
$lang->devops->menuOrder[20] = 'jenkins';
|
||||
$lang->devops->menuOrder[25] = 'maintain';
|
||||
$lang->devops->menuOrder[30] = 'rules';
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
$(function()
|
||||
{
|
||||
if($.cookie('isFullScreen') == 1) fullScreen();
|
||||
})
|
||||
|
||||
/**
|
||||
* Ajax delete doc.
|
||||
*
|
||||
@@ -45,25 +50,32 @@ function fullScreen()
|
||||
{
|
||||
$('#content .actions').addClass('hidden');
|
||||
requestMethod.call(element);
|
||||
$.cookie('isFullScreen', 1);
|
||||
}
|
||||
}
|
||||
|
||||
function exitFullScreen()
|
||||
{
|
||||
$('#content .actions').removeClass('hidden');
|
||||
$.cookie('isFullScreen', 0);
|
||||
}
|
||||
|
||||
document.addEventListener("fullscreenchange", function (e)
|
||||
{
|
||||
if(!document.fullscreenElement) $('#content .actions').removeClass('hidden');
|
||||
if(!document.fullscreenElement) exitFullScreen();
|
||||
})
|
||||
|
||||
document.addEventListener("webkitfullscreenchange", function (e)
|
||||
{
|
||||
if(!document.webkitFullscreenElement) $('#content .actions').removeClass('hidden');
|
||||
if(!document.webkitFullscreenElement) exitFullScreen();
|
||||
})
|
||||
|
||||
document.addEventListener("mozfullscreenchange", function (e)
|
||||
{
|
||||
if(!document.mozFullScreenElement) $('#content .actions').removeClass('hidden');
|
||||
if(!document.mozFullScreenElement) exitFullScreen();
|
||||
})
|
||||
|
||||
document.addEventListener("msfullscreenChange", function (e)
|
||||
{
|
||||
if(!document.msfullscreenElement) $('#content .actions').removeClass('hidden');
|
||||
if(!document.msfullscreenElement) exitFullScreen();
|
||||
})
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
/**
|
||||
* The model file of pipeline module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Chenqi <chenqi@cnezsoft.com>
|
||||
* @package product
|
||||
* @version $Id: $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
|
||||
class gitlabpipelineModel extends model
|
||||
{
|
||||
/**
|
||||
* Get single pipline by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $pipelineID
|
||||
* @access public
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipelines.html#get-a-single-pipeline
|
||||
*/
|
||||
|
||||
public function apiGetPiplineByID($projectID, $pipelineID)
|
||||
{
|
||||
//Priv 1
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipelines/{$piplinesID}");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get piplines list by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @access public
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipelines.html#list-project-pipelines
|
||||
*/
|
||||
|
||||
public function apiGetPiplines($projectID)
|
||||
{
|
||||
//Later
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipelines");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pipeline’s report by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $pipelineID
|
||||
* @access public
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipelines.html#get-a-pipelines-test-report
|
||||
*/
|
||||
public function apiGetPiplineReport($projectID, $pipelineID)
|
||||
{
|
||||
//Later
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipelines/{$pipelineID}/test_report");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new pipeline by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param string $reference
|
||||
* @access public
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipelines.html#create-a-new-pipeline
|
||||
*/
|
||||
public function apiCreatePipeline($projectID, $reference)
|
||||
{
|
||||
//Priv 1
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipeline");
|
||||
return json_decode(commonModel::http($url, $reference));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retry jobs in a pipeline by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $pipelineID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipelines.html#retry-jobs-in-a-pipeline
|
||||
*/
|
||||
public function apiRetryPipeline($projectID, $pipelineID)
|
||||
{
|
||||
//Priv 2
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipelines/{$piplineID}/retry");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a pipeline’s jobs by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $pipelineID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipelines.html#cancel-a-pipelines-jobs
|
||||
*/
|
||||
public function apiPipelineCancel($projectID, $piplineID)
|
||||
{
|
||||
//Priv 1
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipelines/{$pipelineID}/cancel");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a pipeline-·· by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $pipelineID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipelines.html#delete-a-pipeline
|
||||
*/
|
||||
public function apiDeletePipeline($projectID, $piplineID)
|
||||
{
|
||||
//Later
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipelines/{$piplineID}");
|
||||
return json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'DELETE')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all pipeline schedules by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipeline_schedules.html#get-all-pipeline-schedules
|
||||
*/
|
||||
public function apiGetPiplineSchedules($projectID)
|
||||
{
|
||||
//Later
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipeline_schedules");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a pipeline schedule by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $pipelineScheduleID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipeline_schedules.html#delete-a-pipeline-schedule
|
||||
*/
|
||||
public function apiDeletePiplineSchedules($projectID, $pipelineScheduleID)
|
||||
{
|
||||
//Later
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipeline_schedules/{$pipelineScheduleID}/play");
|
||||
return json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'DELETE')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a scheduled pipeline immediately by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $pipelineScheduleID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/pipeline_schedules.html#run-a-scheduled-pipeline-immediately
|
||||
*/
|
||||
public function apiRunPiplineSchedule()
|
||||
{
|
||||
//Later
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/jobs/{$jobID}/trace");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a log file by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $jobID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/jobs.html#get-a-log-file
|
||||
*/
|
||||
public function apiPipelineGetlog($projectID, $jobID)
|
||||
{
|
||||
//Priv 2
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/jobs/{$jobID}/trace");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* List pipeline jobs by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $pipelineID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/jobs.html#list-pipeline-jobs
|
||||
*/
|
||||
public function apiGetPipelineJobs($projectID, $pipelineID)
|
||||
{
|
||||
//Priv 2
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/pipelines/{$pipelineID}/jobs");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single job by api.
|
||||
*
|
||||
* @param integer $projectID
|
||||
* @param integer $jobID
|
||||
* @return object
|
||||
* @docment https://docs.gitlab.com/ee/api/jobs.html#get-a-single-job
|
||||
*/
|
||||
public function apiGetSingleJob($projectID, $jobID)
|
||||
{
|
||||
//Priv 2
|
||||
$url = sprintf($this->loadModel('gitlab')->getApiRoot($gitlabID), "/projects/{$projectID}/jobs/{$jobID}");
|
||||
return json_decode(commonModel::http($url));
|
||||
}
|
||||
}
|
||||
+10
-26
@@ -1,6 +1,12 @@
|
||||
$('#repo').change(function()
|
||||
{
|
||||
var repoID = $(this).val();
|
||||
$.getJSON(createLink('job', 'ajaxGetProductByRepo', 'repoID=' + repoID), function(product)
|
||||
{
|
||||
console.log(product);
|
||||
}
|
||||
);
|
||||
|
||||
var type = 'Git';
|
||||
if(typeof(repoTypes[repoID]) != 'undefined') type = repoTypes[repoID];
|
||||
|
||||
@@ -82,37 +88,15 @@ $('#triggerType').change(function()
|
||||
}
|
||||
});
|
||||
|
||||
$('#gitlabServer').change(function()
|
||||
{
|
||||
var repoID = $('#repo').val();
|
||||
$('#gitlabServerTR #pipeline').remove();
|
||||
$('#gitlabServerTR #pipeline_chosen').remove();
|
||||
$('#gitlabServerTR .input-group').append("<div class='load-indicator loading'></div>");
|
||||
$.getJSON(createLink('gitlab', 'ajaxGetGitlabPipeline', 'repoID=' + repoID), function(tasks)
|
||||
{
|
||||
html = "<select id='pipeline' name='pipeline' class='form-control'>";
|
||||
for(taskKey in tasks)
|
||||
{
|
||||
var task = tasks[taskKey];
|
||||
html += "<option value='" + taskKey + "'>" + task + "</option>";
|
||||
}
|
||||
html += '</select>';
|
||||
$('#gitlabServerTR .loading').remove();
|
||||
$('#gitlabServerTR .input-group').append(html);
|
||||
|
||||
$('#gitlabServerTR #pipeline').chosen({drop_direction: 'auto'});
|
||||
})
|
||||
})
|
||||
|
||||
$('#jkServer').change(function()
|
||||
{
|
||||
var jenkinsID = $(this).val();
|
||||
$('#jenkinsServerTR #JkTask').remove();
|
||||
$('#jenkinsServerTR #JkTask_chosen').remove();
|
||||
$('#jenkinsServerTR #jkTask').remove();
|
||||
$('#jenkinsServerTR #jkTask_chosen').remove();
|
||||
$('#jenkinsServerTR .input-group').append("<div class='load-indicator loading'></div>");
|
||||
$.getJSON(createLink('jenkins', 'ajaxGetJenkinsTasks', 'jenkinsID=' + jenkinsID), function(tasks)
|
||||
{
|
||||
html = "<select id='JkTask' name='JkTask' class='form-control'>";
|
||||
html = "<select id='jkTask' name='jkTask' class='form-control'>";
|
||||
for(taskKey in tasks)
|
||||
{
|
||||
var task = tasks[taskKey];
|
||||
@@ -122,7 +106,7 @@ $('#jkServer').change(function()
|
||||
$('#jenkinsServerTR .loading').remove();
|
||||
$('#jenkinsServerTR .input-group').append(html);
|
||||
|
||||
$('#jenkinsServerTR #JkTask').chosen({drop_direction: 'auto'});
|
||||
$('#jenkinsServerTR #jkTask').chosen({drop_direction: 'auto'});
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -76,6 +76,6 @@ $lang->job->engineList['gitlab'] = 'GitLab';
|
||||
$lang->job->engineList['jenkins'] = 'Jenkins';
|
||||
|
||||
$lang->job->engineTips = new stdclass;
|
||||
$lang->job->engineTips->success = '构建引擎将使用GitLab项目内置的流水线';
|
||||
$lang->job->engineTips->error = '当前GitLab项目内没有可用的流水线,请先前往GitLab配置';
|
||||
$lang->job->engineTips->success = '构建引擎将使用GitLab项目内置的流水线.';
|
||||
$lang->job->engineTips->error = '当前GitLab项目内没有可用的流水线,请先前往GitLab配置.';
|
||||
|
||||
|
||||
+14
-1
@@ -119,6 +119,20 @@ class jobModel extends model
|
||||
->add('createdDate', helper::now())
|
||||
->remove('repoType')
|
||||
->get();
|
||||
|
||||
if($job->engine == 'jenkins')
|
||||
{
|
||||
$job->server = $job->jkServer;
|
||||
$job->pipeline = $job->jkTask;
|
||||
unset($job->jkServer);
|
||||
unset($job->jkTask);
|
||||
}
|
||||
|
||||
if(strtolower($job->engine) == 'gitlab')
|
||||
{
|
||||
var_dump($job);exit;
|
||||
}
|
||||
|
||||
if($job->triggerType == 'schedule') $job->atDay = empty($_POST['atDay']) ? '' : join(',', $this->post->atDay);
|
||||
|
||||
$job->svnDir = '';
|
||||
@@ -158,7 +172,6 @@ class jobModel extends model
|
||||
->batchCheckIF($job->triggerType === 'schedule', "atDay,atTime", 'notempty')
|
||||
->batchCheckIF($job->triggerType === 'commit', "comment", 'notempty')
|
||||
->batchCheckIF(($this->post->repoType == 'Subversion' and $job->triggerType == 'tag'), "svnDir", 'notempty')
|
||||
|
||||
->autoCheck()
|
||||
->exec();
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<th class='text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->job->name);?></th>
|
||||
<th class='w-150px text-left'><?php common::printOrderLink('repo', $orderBy, $vars, $lang->job->repo);?></th>
|
||||
<th class='w-80px'><?php common::printOrderLink('frame', $orderBy, $vars, $lang->job->frame);?></th>
|
||||
<th class='w-80px'><?php common::printOrderLink('engine', $orderBy, $vars, $lang->job->engine);?></th>
|
||||
<th class='w-250px text-left'><?php common::printOrderLink('server', $orderBy, $vars, $lang->job->jenkins);?></th>
|
||||
<th class='text-left'><?php echo $lang->job->triggerType;?></th>
|
||||
<th class='w-100px text-center'><?php common::printOrderLink('lastStatus', $orderBy, $vars, $lang->job->lastStatus);?></th>
|
||||
@@ -44,6 +45,7 @@
|
||||
<td title='<?php echo $job->name; ?>'><?php echo common::hasPriv('job', 'view') ? html::a($this->createLink('job', 'view', "jobID={$job->id}", 'html', true), $job->name, '', "class='iframe' data-width='90%'") : $job->name;?></td>
|
||||
<td title='<?php echo $job->repoName; ?>'><?php echo $job->repoName; ?></td>
|
||||
<td><?php echo zget($lang->job->frameList, $job->frame);?></td>
|
||||
<td><?php echo $job->engine;?></td>
|
||||
<?php $jenkins = urldecode($job->pipeline) . '@' . $job->jenkinsName;?>
|
||||
<td title='<?php echo $jenkins; ?>'><?php echo $jenkins; ?></td>
|
||||
<?php $triggerConfig = $this->job->getTriggerConfig($job);?>
|
||||
|
||||
@@ -55,16 +55,16 @@
|
||||
<div class='table-col'>
|
||||
<div class='input-group'>
|
||||
<span class='input-group-addon'><?php echo $lang->job->pipeline; ?></span>
|
||||
<?php echo html::select('JkTask', array('' => ''), '', "class='form-control chosen'"); ?>
|
||||
<?php echo html::select('jkTask', array('' => ''), '', "class='form-control chosen'"); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="gitlabServerTR">
|
||||
<th><?php echo $lang->job->server; ?></th>
|
||||
<th></th>
|
||||
<td>
|
||||
<?php echo 'gitlabServer'; ?>
|
||||
<?php echo $lang->job->engineTips->success; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
+23
-21
@@ -129,11 +129,12 @@ class repo extends control
|
||||
|
||||
$this->app->loadLang('action');
|
||||
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->create;
|
||||
$this->view->position[] = $this->lang->repo->create;
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted');
|
||||
$this->view->products = $this->loadModel('product')->getProductPairsByProject($objectID);
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->create;
|
||||
$this->view->position[] = $this->lang->repo->create;
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted');
|
||||
$this->view->products = $this->loadModel('product')->getProductPairsByProject($objectID);
|
||||
$this->view->gitlabHosts = $this->loadModel('gitlab')->getPairs();
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -168,23 +169,24 @@ class repo extends control
|
||||
|
||||
if($repo->SCM == 'Gitlab')
|
||||
{
|
||||
$projects = $this->loadModel('gitlab')->apiGetProjects($repo->gitlab, $repo->password);
|
||||
|
||||
$projects = $this->repo->getGitlabProjects($repo->client, $repo->password);
|
||||
$options = array();
|
||||
foreach($projects as $project) $options[$project->id] = $project->name . ':' . $project->http_url_to_repo;
|
||||
foreach($projects as $project) $options[$project->id] = $project->name_with_namespace;
|
||||
|
||||
$this->view->projects = $options;
|
||||
}
|
||||
|
||||
$repo->repoType = $repo->id . '-' . $repo->SCM;
|
||||
$this->view->repo = $repo;
|
||||
$this->view->repoID = $repoID;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted');
|
||||
$this->view->products = $objectID ? $this->loadModel('product')->getProductPairsByProject($objectID) : $this->loadModel('product')->getPairs();
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->edit;
|
||||
$repo->repoType = $repo->id . '-' . $repo->SCM;
|
||||
$this->view->repo = $repo;
|
||||
$this->view->repoID = $repoID;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->groups = $this->loadModel('group')->getPairs();
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|noempty|nodeleted');
|
||||
$this->view->products = $objectID ? $this->loadModel('product')->getProductPairsByProject($objectID) : $this->loadModel('product')->getPairs();
|
||||
$this->view->gitlabHosts = $this->loadModel('gitlab')->getPairs();
|
||||
|
||||
$this->view->title = $this->lang->repo->common . $this->lang->colon . $this->lang->repo->edit;
|
||||
$this->view->position[] = html::a(inlink('maintain'), $this->lang->repo->common);
|
||||
$this->view->position[] = $this->lang->repo->edit;
|
||||
|
||||
@@ -1108,22 +1110,22 @@ class repo extends control
|
||||
/**
|
||||
* Ajax get gitlab projects.
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $gitlabID
|
||||
* @param string $token
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetGitlabProjects($host, $token)
|
||||
public function ajaxGetGitlabProjects($gitlabID, $projectIdList = '')
|
||||
{
|
||||
$host = helper::safe64decode($host);
|
||||
$projects = $this->repo->getgitlabprojects($host, $token);
|
||||
$projects = $this->loadModel('gitlab')->apiGetProjects($gitlabID);
|
||||
|
||||
if(!$projects) $this->send(array('message' => array()));
|
||||
|
||||
$projectIdList = $projectIdList ? explode(',', $projectIdList) : null;
|
||||
$options = "<option value=''></option>";
|
||||
foreach($projects as $project)
|
||||
{
|
||||
$options .= "<option value='{$project->id}' data-name='{$project->name}'>{$project->name}:{$project->http_url_to_repo}</option>";
|
||||
if(!empty($projectIdList) and $project and !in_array($project->id, $projectIdList)) continue;
|
||||
$options .= "<option value='{$project->id}' data-name='{$project->name}'>{$project->name_with_namespace}</option>";
|
||||
}
|
||||
|
||||
die($options);
|
||||
|
||||
@@ -7,12 +7,11 @@ $(function()
|
||||
$form.css('min-height', $form.height());
|
||||
})
|
||||
|
||||
$('#gitlabHost, #gitlabToken').change(function()
|
||||
$('#gitlabHost').change(function()
|
||||
{
|
||||
host = Base64.encode($('#gitlabHost').val());
|
||||
token = $('#gitlabToken').val();
|
||||
url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host + '&token=' + token);
|
||||
if(host == '' || token == '') return false;
|
||||
host = $('#gitlabHost').val();
|
||||
url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host);
|
||||
if(host == '') return false;
|
||||
|
||||
$.get(url, function(response)
|
||||
{
|
||||
|
||||
@@ -7,12 +7,11 @@ $(function()
|
||||
$form.css('min-height', $form.height());
|
||||
})
|
||||
|
||||
$('#gitlabHost, #gitlabToken').change(function()
|
||||
$('#gitlabHost').change(function()
|
||||
{
|
||||
host = Base64.encode($('#gitlabHost').val());
|
||||
token = $('#gitlabToken').val();
|
||||
url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host + '&token=' + token);
|
||||
if(host == '' || token == '') return false;
|
||||
host = $('#gitlabHost').val();
|
||||
if(host == '') return false;
|
||||
url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host);
|
||||
|
||||
$.get(url, function(response)
|
||||
{
|
||||
@@ -20,7 +19,7 @@ $(function()
|
||||
$('#gitlabProject').chosen().trigger("chosen:updated");;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#gitlabProject').change(function()
|
||||
{
|
||||
$option = $(this).find('option:selected');
|
||||
@@ -28,7 +27,6 @@ $(function()
|
||||
$('#name').val($option.data('name'));
|
||||
$(this).chosen().trigger("chosen:updated");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function scmChanged(scm)
|
||||
|
||||
@@ -153,6 +153,8 @@ class repoModel extends model
|
||||
if(!$hasPriv) unset($repos[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
if($repo->SCM == 'Gitlab') $repo = $this->processGitlab($repo);
|
||||
}
|
||||
|
||||
return $repos;
|
||||
@@ -197,6 +199,7 @@ class repoModel extends model
|
||||
|
||||
$data = fixer::input('post')
|
||||
->setIf($this->post->SCM == 'Gitlab', 'password', $this->post->gitlabToken)
|
||||
->setIf($this->post->SCM == 'Gitlab', 'path', $this->post->gitlabProject)
|
||||
->setIf($this->post->SCM == 'Gitlab', 'client', $this->post->gitlabHost)
|
||||
->setIf($this->post->SCM == 'Gitlab', 'extra', $this->post->gitlabProject)
|
||||
->skipSpecial('path,client,account,password')
|
||||
@@ -204,7 +207,7 @@ class repoModel extends model
|
||||
->join('product', ',')
|
||||
->get();
|
||||
|
||||
if($this->post->SCM == 'Gitlab') $data->path = sprintf($this->config->repo->gitlab->apiPath, $data->gitlabHost, $this->post->gitlabProject);
|
||||
if($this->post->SCM == 'Gitlab') $data->path = $this->post->gitlabProject;
|
||||
|
||||
$data->acl = empty($data->acl) ? '' : json_encode($data->acl);
|
||||
|
||||
@@ -243,6 +246,7 @@ class repoModel extends model
|
||||
|
||||
$data = fixer::input('post')
|
||||
->setIf($this->post->SCM == 'Gitlab', 'password', $this->post->gitlabToken)
|
||||
->setIf($this->post->SCM == 'Gitlab', 'path', $this->post->gitlabProject)
|
||||
->setIf($this->post->SCM == 'Gitlab', 'client', $this->post->gitlabHost)
|
||||
->setIf($this->post->SCM == 'Gitlab', 'extra', $this->post->gitlabProject)
|
||||
->setDefault('client', 'svn')
|
||||
@@ -252,7 +256,6 @@ class repoModel extends model
|
||||
->join('product', ',')
|
||||
->get();
|
||||
|
||||
if($this->post->SCM == 'Gitlab') $data->path = sprintf($this->config->repo->gitlab->apiPath, $data->gitlabHost, $this->post->gitlabProject);
|
||||
if($data->path != $repo->path) $data->synced = 0;
|
||||
|
||||
$data->acl = empty($data->acl) ? '' : json_encode($data->acl);
|
||||
@@ -622,7 +625,6 @@ class repoModel extends model
|
||||
{
|
||||
$commitID = $this->dao->lastInsertID();
|
||||
if($branch) $this->dao->replace(TABLE_REPOBRANCH)->set('repo')->eq($repoID)->set('revision')->eq($commitID)->set('branch')->eq($branch)->exec();
|
||||
$file = array();
|
||||
foreach($logs['files'][$i] as $file)
|
||||
{
|
||||
$parentPath = dirname($file->path);
|
||||
|
||||
@@ -34,15 +34,11 @@
|
||||
</tr>
|
||||
<tr class='gitlab hide'>
|
||||
<th><?php echo $lang->repo->gitlabHost;?></th>
|
||||
<td><?php echo html::input('gitlabHost', '', "class='form-control' placeholder='{$lang->repo->placeholder->gitlabHost}'");?>
|
||||
</tr>
|
||||
<tr class='gitlab hide'>
|
||||
<th><?php echo $lang->repo->gitlabToken;?></th>
|
||||
<td><?php echo html::input('gitlabToken', '', "class='form-control'");?>
|
||||
<td class='required'><?php echo html::select('gitlabHost', $gitlabHosts, '', "class='form-control' placeholder='{$lang->repo->placeholder->gitlabHost}'");?>
|
||||
</tr>
|
||||
<tr class='gitlab hide'>
|
||||
<th><?php echo $lang->repo->gitlabProject;?></th>
|
||||
<td><?php echo html::select('gitlabProject', array(''), '', "class='form-control chosen'");?>
|
||||
<td class='required'><?php echo html::select('gitlabProject', array(''), '', "class='form-control chosen'");?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->repo->name; ?></th>
|
||||
|
||||
@@ -34,21 +34,15 @@
|
||||
<tr>
|
||||
<th class='thWidth'><?php echo $lang->repo->type; ?></th>
|
||||
<td style="width:550px"><?php echo html::select('SCM', $lang->repo->scmList, $repo->SCM, "onchange='scmChanged(this.value)' class='form-control'"); ?></td>
|
||||
<td>
|
||||
<span class="tips-git"><?php echo $lang->repo->syncTips; ?></span>
|
||||
</td>
|
||||
<td><span class="tips-git"><?php echo $lang->repo->syncTips; ?></span></td>
|
||||
</tr>
|
||||
<tr class='gitlab hide'>
|
||||
<th><?php echo $lang->repo->gitlabHost;?></th>
|
||||
<td><?php echo html::input('gitlabHost', $repo->client, "class='form-control' placeholder='{$lang->repo->placeholder->gitlabHost}'");?>
|
||||
</tr>
|
||||
<tr class='gitlab hide'>
|
||||
<th><?php echo $lang->repo->gitlabToken;?></th>
|
||||
<td><?php echo html::input('gitlabToken', $repo->password, "class='form-control'");?>
|
||||
<td class='required'><?php echo html::select('gitlabHost', $gitlabHosts, $repo->gitlab, "class='form-control' placeholder='{$lang->repo->placeholder->gitlabHost}'");?>
|
||||
</tr>
|
||||
<tr class='gitlab hide'>
|
||||
<th><?php echo $lang->repo->gitlabProject;?></th>
|
||||
<td><?php echo html::select('gitlabProject', $projects, $repo->extra, "class='form-control chosen'");?>
|
||||
<td class='required'><?php echo html::select('gitlabProject', $projects, $repo->project, "class='form-control chosen'");?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->repo->name; ?></th>
|
||||
@@ -59,8 +53,8 @@
|
||||
<th><?php echo $lang->repo->path; ?></th>
|
||||
<td class='required'><?php echo html::input('path', $repo->path, "class='form-control'"); ?></td>
|
||||
<td class='muted'>
|
||||
<span class="tips-git"><?php echo $lang->repo->example->path->git;?></span>
|
||||
<span class="tips-svn"><?php echo $lang->repo->example->path->svn;?></span>
|
||||
<span class="tips-git"><?php echo $lang->repo->example->path->git;?></span>
|
||||
<span class="tips-svn"><?php echo $lang->repo->example->path->svn;?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -72,8 +66,8 @@
|
||||
<th><?php echo $lang->repo->client;?></th>
|
||||
<td class='required'><?php echo html::input('client', $repo->client, "class='form-control'")?></td>
|
||||
<td class='muted'>
|
||||
<span class="tips-git"><?php echo $lang->repo->example->client->git;?></span>
|
||||
<span class="tips-svn"><?php echo $lang->repo->example->client->svn;?></span>
|
||||
<span class="tips-git"><?php echo $lang->repo->example->client->git;?></span>
|
||||
<span class="tips-svn"><?php echo $lang->repo->example->client->svn;?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="account-fields hide-gitlab">
|
||||
@@ -112,7 +106,7 @@
|
||||
<th></th>
|
||||
<td colspan='2' class='text-center form-actions'>
|
||||
<?php echo html::submitButton(); ?>
|
||||
<?php echo html::backButton() ?>
|
||||
<?php if(!isonlybody()) echo html::a(inlink('maintain', ""), $lang->goback, '', 'class="btn btn-wide"'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user