chg: [galaxyCluster:index] Migrated to use the genericElement factory +

added sparkline and icon genericIndex fields
pull/5699/head
mokaddem 2020-03-12 13:39:50 +01:00
parent 93f5a64c97
commit 9cfd426c8b
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
5 changed files with 119 additions and 106 deletions

View File

@ -33,14 +33,21 @@ class GalaxyClustersController extends AppController
public function index($id)
{
$filters = $this->IndexFilter->harvestParameters(array('context', 'searchall'));
$contextConditions = array();
if (empty($filters['context'])) {
$filters['context'] = 'all';
}
$this->set('context', $filters['context']);
$this->set('searchall', isset($filters['searchall']) ? $filters['searchall'] : '');
$this->paginate['conditions'] = array('GalaxyCluster.galaxy_id' => $id);
if (isset($this->params['named']['searchall']) && strlen($this->params['named']['searchall']) > 0) {
if (isset($filters['searchall']) && strlen($filters['searchall']) > 0) {
$synonym_hits = $this->GalaxyCluster->GalaxyElement->find(
'list',
array(
'recursive' => -1,
'conditions' => array(
'LOWER(GalaxyElement.value) LIKE' => '%' . strtolower($this->params['named']['searchall']) . '%',
'LOWER(GalaxyElement.value) LIKE' => '%' . strtolower($filters['searchall']) . '%',
'GalaxyElement.key' => 'synonyms' ),
'fields' => array(
'GalaxyElement.galaxy_cluster_id')
@ -49,19 +56,21 @@ class GalaxyClustersController extends AppController
$this->paginate['conditions'] =
array("AND" => array(
'OR' => array(
"LOWER(GalaxyCluster.value) LIKE" => '%'. strtolower($this->params['named']['searchall']) .'%',
"LOWER(GalaxyCluster.description) LIKE" => '%'. strtolower($this->params['named']['searchall']) .'%',
"LOWER(GalaxyCluster.value) LIKE" => '%'. strtolower($filters['searchall']) .'%',
"LOWER(GalaxyCluster.description) LIKE" => '%'. strtolower($filters['searchall']) .'%',
"GalaxyCluster.id" => array_values($synonym_hits)
),
"GalaxyCluster.galaxy_id" => $id
));
$this->set('passedArgsArray', array('all'=>$this->params['named']['searchall']));
$this->set('passedArgsArray', array('all'=>$filters['searchall']));
}
$clusters = $this->paginate();
$sgs = $this->GalaxyCluster->Tag->EventTag->Event->SharingGroup->fetchAllAuthorised($this->Auth->user());
foreach ($clusters as $k => $cluster) {
if (!empty($cluster['Tag']['id'])) {
$clusters[$k]['GalaxyCluster']['event_count'] = $this->GalaxyCluster->Tag->EventTag->countForTag($cluster['Tag']['id'], $this->Auth->user(), $sgs);
} else {
$clusters[$k]['GalaxyCluster']['event_count'] = 0;
}
}
$tagIds = array();

View File

@ -0,0 +1,5 @@
<?php
echo sprintf(
'<i class="black %s"></i>',
$this->FontAwesome->getClass(Hash::extract($row, $field['data_path'])[0])
);

View File

@ -0,0 +1,4 @@
<?php
$elementId = Hash::extract($row, $field['data_path'])[0];
echo $this->element('sparkline', array('scope' => $field['csv']['scope'], 'id' => $elementId, 'csv' => $field['csv']['data'][$k]));
?>

View File

@ -1,6 +1,7 @@
<?php
$rowHtml = '';
foreach ($fields as $column => $field) {
$field['data_path'] = empty($field['data_path']) ? '' : $field['data_path'];
if (isset($field['requirement']) && $field['requirement'] === false) {
continue;
}
@ -13,7 +14,7 @@
'field' => $field,
'row' => $row,
'column' => $column,
'data_path' => empty($field['data_path']) ? '' : $field['data_path'],
'data_path' => $field['data_path'],
'k' => $k
)
);

View File

@ -1,105 +1,99 @@
<div class="pagination">
<ul>
<?php
$this->Paginator->options(array(
'update' => '#clusters_div',
'evalScripts' => true,
'before' => '$(".progress").show()',
'complete' => '$(".progress").hide()',
));
echo $this->Paginator->prev('&laquo; ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
echo $this->Paginator->next(__('next') . ' &raquo;', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
?>
</ul>
</div>
<?php
$tab = "Center";
$filtered = false;
if(isset($passedArgsArray)){
if (count($passedArgsArray) > 0) {
$tab = "Left";
$filtered = true;
}
}
echo $this->element('/genericElements/IndexTable/index_table', array(
'data' => array(
'data' => $list,
'top_bar' => array(
'children' => array(
array(
'type' => 'simple',
'children' => array(
array(
'active' => $context === 'all',
'url' => sprintf('%s/galaxy_clusters/index/%s/context:all', $baseurl, $galaxy_id),
'text' => __('All'),
),
array(
'active' => $context === 'altered',
'url' => sprintf('%s/galaxy_clusters/index/%s/context:altered', $baseurl, $galaxy_id),
'text' => __('Altered Galaxy Clusters'),
)
)
),
array(
'type' => 'search',
'button' => __('Filter'),
'placeholder' => __('Enter value to search'),
'data' => '',
'searchKey' => 'value',
'value' => $searchall
)
)
),
'fields' => array(
array(
'name' => __('Value'),
'sort' => 'GalaxyCluster.value',
'element' => 'links',
'class' => 'short',
'data_path' => 'GalaxyCluster.value',
'url' => $baseurl . '/galaxy_clusters/view/%s'
),
array(
'name' => __('Synonyms'),
'sort' => 'name',
'class' => 'short',
'data_path' => 'GalaxyCluster.synonyms',
),
array(
'name' => __('Activity'),
'class' => 'short',
'data_path' => 'GalaxyCluster.id',
'csv' => array('scope' => 'cluster', 'data' => $csv),
'element' => 'sparkline'
),
array(
'name' => __('#Events'),
'class' => 'short',
'data_path' => 'GalaxyCluster.event_count',
),
array(
'name' => __('Description'),
'sort' => 'description',
'data_path' => 'GalaxyCluster.description',
),
),
'actions' => array(
array(
'title' => 'View graph',
'url' => '/galaxies/viewGraph',
'url_params_data_paths' => array(
'GalaxyCluster.id'
),
'icon' => 'share-alt',
),
array(
'title' => 'View',
'url' => '/galaxy_clusters/view',
'url_params_data_paths' => array(
'GalaxyCluster.id'
),
'icon' => 'eye',
'dbclickAction' => true
),
array(
'title' => 'Delete',
'url' => '/galaxy_clusters/delete',
'url_params_data_paths' => array(
'GalaxyCluster.id'
),
'postLink' => true,
'postLinkConfirm' => __('Are you sure you want to delete the Galaxy Cluster?'),
'icon' => 'trash'
),
)
)
));
?>
<div class="tabMenuFixedContainer" style="display:inline-block;">
<?php if ($filtered):
foreach ($passedArgsArray as $k => $v):?>
<span class="tabMenuFixed tabMenuFixedElement">
<?php echo h(ucfirst($k)) . " : " . h($v); ?>
</span>
<?php endforeach; ?>
<span class="tabMenuFixed tabMenuFixedRight tabMenuSides">
<?php echo $this->Html->link('', array('controller' => 'galaxies', 'action' => 'view/'. $galaxy_id), array('class' => 'icon-remove', 'title' => __('Remove filters')));?>
</span>
<?php endif;?>
<span style="border-right:0px !important;">
<span id="quickFilterButton" role="button" tabindex="0" aria-label="Filter value galaxie cluster" class="tabMenuFilterFieldButton useCursorPointer"
onClick="quickFilter('', '<?php echo $baseurl . '/galaxies/view/' . $galaxy_id; ?>');"><?php echo __('Filter');?></span>
<input class="tabMenuFilterField" type="text" id="quickFilterField">
</span>
</div>
<table class="table table-striped table-hover table-condensed">
<tr>
<th><?php echo $this->Paginator->sort('value');?></th>
<th><?php echo $this->Paginator->sort('synonyms', __('Synonyms'));?></th>
<th><?php echo __('Activity');?></th>
<th><?php echo __('#Events');?></th>
<th><?php echo $this->Paginator->sort('description');?></th>
<th class="actions"><?php echo __('Actions');?></th>
</tr>
<?php
foreach ($list as $k => $item):
?>
<tr>
<td class="short bold"><?php echo h($item['GalaxyCluster']['value']); ?>&nbsp;</td>
<td class="short bold">
<?php
echo nl2br(h(implode("\n", $item['GalaxyCluster']['synonyms'])));
?>
&nbsp;
</td>
<td class="shortish">
<?php echo $this->element('sparkline', array('scope' => 'cluster', 'id' => $item['GalaxyCluster']['id'], 'csv' => $csv[$k])); ?>
</td>
<td class="short">
<?php
if (!empty($item['GalaxyCluster']['event_count'])):
?>
<a href="<?php echo $baseurl; ?>/events/index/searchtag:<?php echo h($item['GalaxyCluster']['tag_id']);?>" class="bold"><?php echo h($item['GalaxyCluster']['event_count']);?></a>
<?php
else:
echo '0';
endif;
?>
</td>
<td><?php echo h($item['GalaxyCluster']['description']); ?>&nbsp;</td>
<td class="short action-links">
<?php echo $this->Html->link('', array('controller' => 'galaxies', 'action' => 'viewGraph', $item['GalaxyCluster']['id']), array('class' => 'fa fa-share-alt', 'title' => __('View graph'), 'aria-label' => __('View graph')));?>
<?php echo $this->Html->link('', array('action' => 'view', $item['GalaxyCluster']['id']), array('class' => 'fa fa-eye', 'title' => __('View'), 'aria-label' => __('View')));?>
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Delete galaxy cluster');?>" role="button" tabindex="0" aria-label="<?php echo __('Delete galaxy cluster');?>" onClick="deleteObject('galaxy_clusters', 'delete', '<?php echo h($item['GalaxyCluster']['id']); ?>', '<?php echo h($item['GalaxyCluster']['id']); ?>');"></span>
</td>
</tr>
<?php
endforeach;
?>
</table>
<p>
<?php
echo $this->Paginator->counter(array('format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')));
?>
</p>
<div class="pagination">
<ul>
<?php
echo $this->Paginator->prev('&laquo; ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
echo $this->Paginator->next(__('next') . ' &raquo;', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
?>
</ul>
</div>
<script type="text/javascript">
$(document).ready(function(){