*Finish 44403,44406,44406,44401
This commit is contained in:
@@ -373,4 +373,45 @@ class job extends control
|
||||
$refList = $this->loadModel('gitlab')->getReferenceOptions($repo->gitlab, $repo->project);
|
||||
$this->send(array('result' => 'success', 'refList' => $refList));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get repo list.
|
||||
*
|
||||
* @param int $engine
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetRepoList($engine)
|
||||
{
|
||||
$repoList = $this->loadModel('repo')->getList($this->projectID);
|
||||
$repoPairs = array(0 => '');
|
||||
foreach($repoList as $repo)
|
||||
{
|
||||
if(empty($repo->synced)) continue;
|
||||
if($engine == 'gitlab')
|
||||
{
|
||||
if(strtolower($repo->SCM) == 'gitlab') $repoPairs[$repo->id] = $repo->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$repoPairs[$repo->id] = $repo->name;
|
||||
}
|
||||
}
|
||||
echo html::select('repo', $repoPairs, '', "class='form-control chosen'");
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get an repo type.
|
||||
*
|
||||
* @param int $repoID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetRepoType($repoID)
|
||||
{
|
||||
$repo = $this->loadModel('repo')->getRepoByID($repoID);
|
||||
$this->send(array('result' => 'success', 'type' => strtolower($repo->SCM)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,3 +64,17 @@ function setValueInput(obj)
|
||||
$(obj).closest('.input-group').find('select').removeAttr('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
function loadRepoList(engine = '')
|
||||
{
|
||||
var link = createLink('job', 'ajaxGetRepoList', 'engine=' + engine);
|
||||
$.get(link, function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
$('#repo').replaceWith(data)
|
||||
$('#repo_chosen').remove();
|
||||
$('#repo').chosen();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#gitlabRepo').change(function()
|
||||
{
|
||||
$('#repo').val($(this).val()).change();
|
||||
})
|
||||
|
||||
$('#repo').change(function()
|
||||
$(document).on('change', '#repo', function()
|
||||
{
|
||||
var _this = this;
|
||||
var repoID = $(this).val();
|
||||
if(repoID <= 0) return;
|
||||
|
||||
var link = createLink('repo', 'ajaxLoadProducts', 'repoID=' + repoID);
|
||||
$.get(link, function(data)
|
||||
{
|
||||
@@ -19,33 +17,54 @@ $(document).ready(function()
|
||||
}
|
||||
});
|
||||
|
||||
var type = 'Git';
|
||||
if(typeof(repoTypes[repoID]) != 'undefined') type = repoTypes[repoID];
|
||||
|
||||
$('.svn-fields').addClass('hidden');
|
||||
if(type == 'Subversion' && $('#triggerType').val() == 'tag') $('.svn-fields').removeClass('hidden');
|
||||
|
||||
$('#repoType').val(type);
|
||||
$('#triggerType option[value=tag]').html(type == 'Subversion' ? dirChange : buildTag).trigger('chosen:updated');
|
||||
if(type == 'Subversion')
|
||||
/* Add new way get repo type. */
|
||||
var link = createLink('job', 'ajaxGetRepoType', 'repoID=' + repoID);
|
||||
$.getJSON(link, function(data)
|
||||
{
|
||||
$('#svnDirBox .input-group').empty();
|
||||
$('#svnDirBox .input-group').append("<div class='load-indicator loading'></div>");
|
||||
$.getJSON(createLink('repo', 'ajaxGetSVNDirs', 'repoID=' + repoID), function(tags)
|
||||
if(data.result == 'success')
|
||||
{
|
||||
html = "<select id='svnDir' name='svnDir[]' class='form-control'>";
|
||||
for(path in tags)
|
||||
if(data.type == 'gitlab')
|
||||
{
|
||||
var encodePath = tags[path];
|
||||
html += "<option value='" + path + "' data-encodePath='" + encodePath + "'>" + path + "</option>";
|
||||
$('.reference').show();
|
||||
$('.svn-fields').addClass('hidden');
|
||||
$('#reference option').remove();
|
||||
|
||||
$.getJSON(createLink('job', 'ajaxGetRefList', "repoID=" + repoID), function(response)
|
||||
{
|
||||
if(response.result == 'success')
|
||||
{
|
||||
$.each(response.refList, function(reference, name)
|
||||
{
|
||||
$('#reference').append("<option value='" + reference + "'>" + name + "</option>");
|
||||
});
|
||||
}
|
||||
$('#reference').trigger('chosen:updated');
|
||||
});
|
||||
}
|
||||
html += '</select>';
|
||||
$('#svnDirBox .loading').remove();
|
||||
$('#svnDirBox .input-group').append(html);
|
||||
$('#svnDirBox #svnDir').chosen();
|
||||
})
|
||||
}
|
||||
})
|
||||
else
|
||||
{
|
||||
if($('#triggerType').val() == 'tag') $('.svn-fields').removeClass('hidden');
|
||||
|
||||
$('#svnDirBox .input-group').empty();
|
||||
$('#svnDirBox .input-group').append("<div class='load-indicator loading'></div>");
|
||||
$.getJSON(createLink('repo', 'ajaxGetSVNDirs', 'repoID=' + repoID), function(tags)
|
||||
{
|
||||
html = "<select id='svnDir' name='svnDir[]' class='form-control'>";
|
||||
for(path in tags)
|
||||
{
|
||||
var encodePath = tags[path];
|
||||
html += "<option value='" + path + "' data-encodePath='" + encodePath + "'>" + path + "</option>";
|
||||
}
|
||||
html += '</select>';
|
||||
$('#svnDirBox .loading').remove();
|
||||
$('#svnDirBox .input-group').append(html);
|
||||
$('#svnDirBox #svnDir').chosen();
|
||||
})
|
||||
}
|
||||
$('#triggerggerType option[value=tag]').html(data.type == 'gitlab' ? buildTag : dirChange).trigger('chosen:updated');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('change', '[name^=svnDir]', function()
|
||||
{
|
||||
@@ -124,15 +143,19 @@ $(document).ready(function()
|
||||
var scheduleOption = "<option value='schedule'>" + $('#triggerType').find('[value=schedule]').text() + "</option>";
|
||||
$('#engine').change(function()
|
||||
{
|
||||
$('#jenkinsServerTR').toggle($('#engine').val() == 'jenkins');
|
||||
$('#gitlabServerTR').toggle($('#engine').val() == 'gitlab');
|
||||
var engine = $(this).val();
|
||||
$('.reference').hide();
|
||||
loadRepoList(engine);
|
||||
$('#jenkinsServerTR').toggle(engine == 'jenkins');
|
||||
$('#gitlabServerTR').toggle(engine == 'gitlab');
|
||||
|
||||
if($(this).val() == 'gitlab')
|
||||
if(engine == 'gitlab')
|
||||
{
|
||||
$('tr.gitlabRepo').show();
|
||||
$('tr.commonRepo').hide();
|
||||
}
|
||||
else if($('#triggerType').find('[value=schedule]').size() == 0 )
|
||||
//else if($('#triggerType').find('[value=schedule]').size() == 0)
|
||||
else
|
||||
{
|
||||
$('tr.gitlabRepo').hide();
|
||||
$('tr.commonRepo').show();
|
||||
@@ -140,26 +163,6 @@ $(document).ready(function()
|
||||
});
|
||||
|
||||
$('#engine').change();
|
||||
$('#gitlabRepo').change(function()
|
||||
{
|
||||
$('#reference option').remove();
|
||||
|
||||
var repoID = $(this).val();
|
||||
if(repoID > 0)
|
||||
{
|
||||
$.getJSON(createLink('job', 'ajaxGetRefList', "repoID=" + repoID), function(response)
|
||||
{
|
||||
if(response.result == 'success')
|
||||
{
|
||||
$.each(response.refList, function(reference, name)
|
||||
{
|
||||
$('#reference').append("<option value='" + reference + "'>" + name + "</option>");
|
||||
});
|
||||
}
|
||||
$('#reference').trigger('chosen:updated');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#triggerType').change();
|
||||
});
|
||||
|
||||
@@ -152,10 +152,9 @@ class jobModel extends model
|
||||
|
||||
if(strtolower($job->engine) == 'gitlab')
|
||||
{
|
||||
$repo = $this->loadModel('repo')->getRepoByID($job->gitlabRepo);
|
||||
$repo = $this->loadModel('repo')->getRepoByID($job->repo);
|
||||
$project = zget($repo, 'project');
|
||||
|
||||
$job->repo = $job->gitlabRepo;
|
||||
$job->server = (int)zget($repo, 'gitlab', 0);
|
||||
$job->pipeline = json_encode(array('project' => $project, 'reference' => $this->post->reference));
|
||||
}
|
||||
|
||||
@@ -42,14 +42,10 @@
|
||||
<span id="gitlabServerTR"><?php echo $lang->job->engineTips->success;?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class='commonRepo'>
|
||||
<tr>
|
||||
<th><?php echo $lang->job->repo; ?></th>
|
||||
<td><?php echo html::select('repo', $repoPairs, '', "class='form-control'"); ?></td>
|
||||
</tr>
|
||||
<tr class='gitlabRepo hide'>
|
||||
<th><?php echo $lang->job->repo; ?></th>
|
||||
<td> <?php echo html::select('gitlabRepo', $gitlabRepos, '', "class='chosen form-control'");?> </td>
|
||||
<td> <?php echo html::select('reference', array(), '', "class='chosen form-control'");?> </td>
|
||||
<td><?php echo html::select('repo', $repoPairs, '', "class='form-control chosen'"); ?></td>
|
||||
<td class='reference hide'><?php echo html::select('reference', array(), '', "class='chosen form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->job->product; ?></th>
|
||||
|
||||
Reference in New Issue
Block a user