* Add gitlab projects orderby
This commit is contained in:
@@ -583,13 +583,13 @@ class gitlab extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function browseProject($gitlabID, $keyword = '',$recTotal = 0, $recPerPage = 15, $pageID = 1)
|
||||
public function browseProject($gitlabID, $keyword = '', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 15, $pageID = 1)
|
||||
{
|
||||
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$result = $this->gitlab->apiGetProjects($gitlabID, $keyword, $pager);
|
||||
$result = $this->gitlab->apiGetProjects($gitlabID, $keyword, $orderBy, $pager);
|
||||
|
||||
$gitlab = $this->gitlab->getByID($gitlabID);
|
||||
|
||||
@@ -599,6 +599,7 @@ class gitlab extends control
|
||||
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browseProject;
|
||||
$this->view->gitlabID = $gitlabID;
|
||||
$this->view->gitlabProjectList = $result['projects'];
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
@@ -574,11 +574,12 @@ class gitlabModel extends model
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param string $keyword
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function apiGetProjects($gitlabID, $keyword = '', $pager)
|
||||
public function apiGetProjects($gitlabID, $keyword = '', $orderBy, $pager)
|
||||
{
|
||||
$gitlab = $this->getByID($gitlabID);
|
||||
if(!$gitlab) return array();
|
||||
@@ -586,7 +587,10 @@ class gitlabModel extends model
|
||||
$host = rtrim($gitlab->url, '/');
|
||||
$host .= '/api/v4/projects';
|
||||
|
||||
$result = commonModel::httpWithHeader($host . "?private_token={$gitlab->token}&simple=true&&per_page={$pager->recPerPage}&order_by=id&page={$pager->pageID}&search={$keyword}");
|
||||
/* Parse order string. */
|
||||
$order = explode('_', $orderBy);
|
||||
|
||||
$result = commonModel::httpWithHeader($host . "?private_token={$gitlab->token}&simple=true&&per_page={$pager->recPerPage}&order_by={$order[0]}&sort={$order[1]}&page={$pager->pageID}&search={$keyword}");
|
||||
|
||||
$header = $result['header'];
|
||||
$recTotal = $header['X-Total'];
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<?php js::set('vars', "keyword=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID=1")?>
|
||||
<?php js::set('vars', "keyword=%s&orderBy=id_desc&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID=1")?>
|
||||
<?php js::set('gitlabID', $gitlabID)?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div id="sidebarHeader">
|
||||
@@ -40,10 +40,11 @@
|
||||
<div id='mainContent' class='main-row'>
|
||||
<form class='main-table' id='ajaxForm' method='post'>
|
||||
<table id='gitlabProjectList' class='table has-sort-head table-fixed'>
|
||||
<?php $vars = "gitlabID={$gitlabID}&keyword={$keyword}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='c-id'><?php echo $lang->gitlab->project->id;?></th>
|
||||
<th class='c-name text-left'><?php echo $lang->gitlab->project->name;?></th>
|
||||
<th class='c-id'><?php common::printOrderLink('id', $orderBy, $vars, $lang->gitlab->id);?></th>
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->gitlab->project->name);?></th>
|
||||
<th class='text-left'></th>
|
||||
<th class='text-left'><?php echo $lang->gitlab->lastUpdate;?></th>
|
||||
<th class='c-actions-4'><?php echo $lang->actions;?></th>
|
||||
|
||||
Reference in New Issue
Block a user