* Refactor browse page of job.
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
global $lang, $app;
|
||||
$app->loadLang('job');
|
||||
$app->loadLang('compile');
|
||||
|
||||
$config->job->dtable = new stdclass();
|
||||
|
||||
$config->job->dtable->fieldList['id']['title'] = 'ID';
|
||||
$config->job->dtable->fieldList['id']['name'] = 'id';
|
||||
$config->job->dtable->fieldList['id']['fixed'] = 'left';
|
||||
$config->job->dtable->fieldList['id']['type'] = 'id';
|
||||
$config->job->dtable->fieldList['id']['sortType'] = 'text';
|
||||
$config->job->dtable->fieldList['id']['checkbox'] = false;
|
||||
$config->job->dtable->fieldList['id']['width'] = '80';
|
||||
|
||||
$config->job->dtable->fieldList['name']['title'] = $lang->job->name;
|
||||
$config->job->dtable->fieldList['name']['name'] = 'name';
|
||||
$config->job->dtable->fieldList['name']['fixed'] = 'left';
|
||||
$config->job->dtable->fieldList['name']['type'] = 'title';
|
||||
$config->job->dtable->fieldList['name']['sortType'] = true;
|
||||
$config->job->dtable->fieldList['name']['hint'] = true;
|
||||
$config->job->dtable->fieldList['name']['minWidth'] = '356';
|
||||
|
||||
$config->job->dtable->fieldList['repo']['title'] = $lang->job->repo;
|
||||
$config->job->dtable->fieldList['repo']['name'] = 'repoName';
|
||||
$config->job->dtable->fieldList['repo']['type'] = 'title';
|
||||
$config->job->dtable->fieldList['repo']['sortType'] = true;
|
||||
$config->job->dtable->fieldList['repo']['width'] = '100';
|
||||
|
||||
$config->job->dtable->fieldList['engine']['title'] = $lang->job->engine;
|
||||
$config->job->dtable->fieldList['engine']['name'] = 'engineName';
|
||||
$config->job->dtable->fieldList['engine']['type'] = 'text';
|
||||
$config->job->dtable->fieldList['engine']['sortType'] = true;
|
||||
$config->job->dtable->fieldList['engine']['width'] = '80';
|
||||
|
||||
$config->job->dtable->fieldList['frame']['title'] = $lang->job->frame;
|
||||
$config->job->dtable->fieldList['frame']['name'] = 'frameName';
|
||||
$config->job->dtable->fieldList['frame']['type'] = 'text';
|
||||
$config->job->dtable->fieldList['frame']['sortType'] = true;
|
||||
$config->job->dtable->fieldList['frame']['show'] = true;
|
||||
$config->job->dtable->fieldList['frame']['width'] = '120';
|
||||
|
||||
$config->job->dtable->fieldList['buildSpec']['title'] = $lang->job->buildSpec;
|
||||
$config->job->dtable->fieldList['buildSpec']['name'] = 'buildSpec';
|
||||
$config->job->dtable->fieldList['buildSpec']['type'] = 'text';
|
||||
$config->job->dtable->fieldList['buildSpec']['sortType'] = true;
|
||||
$config->job->dtable->fieldList['buildSpec']['width'] = '160';
|
||||
|
||||
$config->job->dtable->fieldList['triggerType']['title'] = $lang->job->triggerType;
|
||||
$config->job->dtable->fieldList['triggerType']['name'] = 'triggerConfig';
|
||||
$config->job->dtable->fieldList['triggerType']['type'] = 'text';
|
||||
$config->job->dtable->fieldList['triggerType']['sortType'] = false;
|
||||
$config->job->dtable->fieldList['triggerType']['width'] = '120';
|
||||
|
||||
$config->job->dtable->fieldList['lastStatus']['title'] = $lang->job->lastStatus;
|
||||
$config->job->dtable->fieldList['lastStatus']['name'] = 'lastStatusName';
|
||||
$config->job->dtable->fieldList['lastStatus']['type'] = 'status';
|
||||
$config->job->dtable->fieldList['lastStatus']['sortType'] = true;
|
||||
$config->job->dtable->fieldList['lastStatus']['width'] = '120';
|
||||
|
||||
$config->job->dtable->fieldList['lastExec']['title'] = $lang->job->lastExec;
|
||||
$config->job->dtable->fieldList['lastExec']['name'] = 'lastExec';
|
||||
$config->job->dtable->fieldList['lastExec']['type'] = 'date';
|
||||
$config->job->dtable->fieldList['lastExec']['sortType'] = true;
|
||||
$config->job->dtable->fieldList['lastExec']['width'] = '120';
|
||||
|
||||
$config->job->actionList = array();
|
||||
$config->job->actionList['compile']['icon'] = 'history';
|
||||
$config->job->actionList['compile']['text'] = $lang->compile->browse;
|
||||
$config->job->actionList['compile']['hint'] = $lang->compile->browse;
|
||||
$config->job->actionList['compile']['url'] = helper::createLink('compile', 'browse',"repoID={repo}&jobID={id}");
|
||||
|
||||
$config->job->actionList['edit']['icon'] = 'edit';
|
||||
$config->job->actionList['edit']['text'] = $lang->job->edit;
|
||||
$config->job->actionList['edit']['hint'] = $lang->job->edit;
|
||||
$config->job->actionList['edit']['url'] = helper::createLink('job', 'edit',"jobID={id}");
|
||||
|
||||
$config->job->actionList['exec']['icon'] = 'play';
|
||||
$config->job->actionList['exec']['text'] = $lang->job->exec;
|
||||
$config->job->actionList['exec']['hint'] = $lang->job->exec;
|
||||
$config->job->actionList['exec']['url'] = helper::createLink('job', 'exec',"jobID={id}");
|
||||
|
||||
$config->job->actionList['delete']['icon'] = 'trash';
|
||||
$config->job->actionList['delete']['text'] = $lang->job->delete;
|
||||
$config->job->actionList['delete']['hint'] = $lang->job->delete;
|
||||
$config->job->actionList['delete']['url'] = 'javascript:confirmDelete("{id}")';
|
||||
|
||||
$config->job->dtable->fieldList['actions']['name'] = 'actions';
|
||||
$config->job->dtable->fieldList['actions']['title'] = $lang->actions;
|
||||
$config->job->dtable->fieldList['actions']['type'] = 'actions';
|
||||
$config->job->dtable->fieldList['actions']['width'] = '160';
|
||||
$config->job->dtable->fieldList['actions']['sortType'] = false;
|
||||
$config->job->dtable->fieldList['actions']['fixed'] = 'right';
|
||||
$config->job->dtable->fieldList['actions']['menu'] = array('compile', 'edit', 'exec', 'delete');
|
||||
$config->job->dtable->fieldList['actions']['list'] = $config->job->actionList;
|
||||
+12
-1
@@ -53,17 +53,28 @@ class job extends control
|
||||
$this->loadModel('gitlab');
|
||||
foreach($jobList as $job)
|
||||
{
|
||||
$job->canExec = true;
|
||||
$job->canExec = true;
|
||||
$job->engineName = zget($this->lang->job->engineList, $job->engine);
|
||||
$job->frameName = zget($this->lang->job->frameList, $job->frame);
|
||||
|
||||
if($job->engine == 'gitlab')
|
||||
{
|
||||
$pipeline = json_decode($job->pipeline);
|
||||
$branch = $this->gitlab->apiGetSingleBranch($job->server, $pipeline->project, $pipeline->reference);
|
||||
if($branch and isset($branch->can_push) and !$branch->can_push) $job->canExec = false;
|
||||
/* query buildSpec */
|
||||
if(is_numeric($job->pipeline)) $job->pipeline = $this->loadModel('gitlab')->getProjectName($job->server, $job->pipeline);
|
||||
if(isset($pipeline->reference)) $job->pipeline = $this->loadModel('gitlab')->getProjectName($job->server, $pipeline->project);
|
||||
}
|
||||
elseif($job->engine == 'jenkins')
|
||||
{
|
||||
if(strpos($job->pipeline, '/job/') !== false) $job->pipeline = trim(str_replace('/job/', '/', $job->pipeline), '/');
|
||||
}
|
||||
|
||||
$job->lastStatusName = zget($this->lang->compile->statusList, $job->lastStatus, '');
|
||||
$job->lastExec = $job->lastExec ? $job->lastExec : '';
|
||||
$job->triggerConfig = $this->job->getTriggerConfig($job);
|
||||
$job->buildSpec = urldecode($job->pipeline) . '@' . $job->jenkinsName;
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->ci->job . $this->lang->colon . $this->lang->job->browse;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
window.createSortLink = function(col)
|
||||
{
|
||||
var sort = col.name + '_asc';
|
||||
if(sort == orderBy) sort = col.name + '_desc';
|
||||
|
||||
return sortLink.replace('{orderBy}', sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提示并删除版本。
|
||||
* Delete release with tips.
|
||||
*
|
||||
* @param int gogsID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
window.confirmDelete = function(gogsID)
|
||||
{
|
||||
if(window.confirm(confirmDelete))
|
||||
{
|
||||
$.ajaxSubmit({url: $.createLink('gogs', 'delete', 'gogsID=' + gogsID)});
|
||||
}
|
||||
}
|
||||
@@ -672,4 +672,23 @@ class jobModel extends model
|
||||
->beginIF(!empty($projectKeys) or !$emptyShowAll)->andWhere('projectKey')->in($projectKeys)->fi()
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断按钮是否可点击。
|
||||
* Adjust the action is clickable.
|
||||
*
|
||||
* @param object $object
|
||||
* @param string $action
|
||||
* @param string $module
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public static function isClickable($object, $action, $module = 'job')
|
||||
{
|
||||
$action = strtolower($action);
|
||||
|
||||
if($module == 'job' && $action == 'exec') return $object->canExec;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The browse view file of job module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Ke Zhao<zhaoke@easycorp.ltd>
|
||||
* @package job
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
|
||||
namespace zin;
|
||||
|
||||
featureBar();
|
||||
|
||||
/* zin: Define the toolbar on main menu. */
|
||||
$canCreate = hasPriv('job', 'create');
|
||||
$createLink = $this->createLink('job', 'create');
|
||||
$createItem = array('text' => $lang->job->create, 'url' => $createLink, 'class' => 'primary', 'icon' => 'plus');
|
||||
|
||||
$tableData = initTableData($jobList, $config->job->dtable->fieldList, $this->job);
|
||||
|
||||
toolbar
|
||||
(
|
||||
$canCreate ? item(set($createItem)) : null,
|
||||
);
|
||||
|
||||
jsVar('confirmDelete', $lang->job->confirmDelete);
|
||||
jsVar('orderBy', $orderBy);
|
||||
jsVar('canBrowseProject', common::hasPriv('job', 'browseProject'));
|
||||
jsVar('sortLink', helper::createLink('job', 'browse', "orderBy={orderBy}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}"));
|
||||
|
||||
dtable
|
||||
(
|
||||
set::cols($config->job->dtable->fieldList),
|
||||
set::data($tableData),
|
||||
set::sortLink(jsRaw('createSortLink')),
|
||||
set::footPager(usePager()),
|
||||
);
|
||||
|
||||
render();
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The activate view file of gogs module of ZenTaoPMS.
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Ke Zhao<zhaoke@easycorp.ltd>
|
||||
* @package gogs
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
namespace zin;
|
||||
global $lang;
|
||||
|
||||
detailHeader
|
||||
(
|
||||
to::title(entityLabel(set(array('entityID' => $gogs->id, 'level' => 1, 'text' => $gogs->name)))),
|
||||
);
|
||||
|
||||
detailBody
|
||||
(
|
||||
sectionList
|
||||
(
|
||||
section
|
||||
(
|
||||
set::title($lang->gogs->url),
|
||||
set::content("<a href='{$gogs->url}' target='_blank'>{$gogs->url}</a>"),
|
||||
set::useHtml(true)
|
||||
),
|
||||
),
|
||||
history(),
|
||||
);
|
||||
|
||||
render(isonlybody() ? 'modalDialog' : 'page');
|
||||
Reference in New Issue
Block a user