chg: [galaxyCluster:views] Added `extended_by` and `extended_from`

information
pull/6120/head
mokaddem 2020-04-15 15:35:52 +02:00
parent ce65189fea
commit e3fe66807b
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
5 changed files with 109 additions and 2 deletions

View File

@ -102,8 +102,8 @@ class GalaxyClustersController extends AppController
$this->paginate['contain'] = array_merge($this->paginate['contain'], array('Org', 'Orgc'));
$clusters = $this->paginate();
foreach ($clusters as $k => $cluster) {
// $clusters[$k] = $this->GalaxyCluster->attachExtendByInfo($this->Auth->user(), $clusters[$k]);
// $clusters[$k] = $this->GalaxyCluster->attachExtendFromInfo($this->Auth->user(), $clusters[$k]);
$clusters[$k] = $this->GalaxyCluster->attachExtendByInfo($this->Auth->user(), $clusters[$k]);
$clusters[$k] = $this->GalaxyCluster->attachExtendFromInfo($this->Auth->user(), $clusters[$k]);
}
$sgs = $this->GalaxyCluster->Tag->EventTag->Event->SharingGroup->fetchAllAuthorised($this->Auth->user());
foreach ($clusters as $k => $cluster) {
@ -208,6 +208,8 @@ class GalaxyClustersController extends AppController
$cluster['GalaxyCluster']['GalaxyElement'] = $cluster['GalaxyElement'];
return $this->RestResponse->viewData(array('GalaxyCluster' => $cluster['GalaxyCluster']), $this->response->type());
} else {
$cluster = $this->GalaxyCluster->attachExtendByInfo($this->Auth->user(), $cluster);
$cluster = $this->GalaxyCluster->attachExtendFromInfo($this->Auth->user(), $cluster);
$this->set('id', $id);
$this->set('galaxy_id', $cluster['GalaxyCluster']['galaxy_id']);
$this->set('cluster', $cluster);

View File

@ -194,6 +194,26 @@ class GalaxyCluster extends AppModel
return $errors;
}
public function attachExtendByInfo($user, $cluster)
{
$extensions = $this->fetchGalaxyClusters($user, array('conditions' => array('extends_uuid' => $cluster['GalaxyCluster']['uuid'])));
$cluster['GalaxyCluster']['extended_by'] = $extensions;
return $cluster;
}
public function attachExtendFromInfo($user, $cluster)
{
if (!empty($cluster['GalaxyCluster']['extends_uuid'])) {
$extensions = $this->fetchGalaxyClusters($user, array('conditions' => array('uuid' => $cluster['GalaxyCluster']['extends_uuid'])));
if (!empty($extensions)) {
$cluster['GalaxyCluster']['extended_from'] = $extensions[0];
} else {
$cluster['GalaxyCluster']['extended_from'] = array();
}
}
return $cluster;
}
// receive a full galaxy and add all new clusters, update existing ones contained in the new galaxy, cull old clusters that are removed from the galaxy
public function update($id, $galaxy)
{

View File

@ -0,0 +1,47 @@
<?php
$data = Hash::extract($row, $field['data_path']);
if (isset($field['parent'])) {
echo h($field['parent']);
} else {
echo $this->element('/genericElements/IndexTable/Fields/generic_field', array(
'row' => $row,
'field' => $field
));
}
$extendsData = Hash::extract($row, $field['fields']['extend_data_path']);
?>
<?php if (!empty($extendsData)): ?>
<?php
if (!isset($extendsData[0])) {
$extendsData = array($extendsData);
}
?>
<?php foreach ($extendsData as $extendData): ?>
<?php
if (isset($field['title'])) {
$linkTitle = $field['title'];
} else {
$linkTitle = Hash::extract($extendData, $field['fields']['extend_link_title']);
if (!empty($linkTitle)) {
$linkTitle = $linkTitle[0];
}
}
?>
<div>
<span class="apply_css_arrow">
<i class="<?php echo $this->FontAwesome->findNamespace('code-branch'); ?> fa-code-branch"></i>
<?php
echo $this->element('genericElements/IndexTable/Fields/links', array(
'row' => $extendData,
'field' => array(
'url' => $baseurl . '/galaxies/view/%s',
'data_path' => $field['fields']['extend_link_path'],
'title' => $linkTitle
),
));
?>
</span>
</div>
<?php endforeach; ?>
<?php endif; ?>

View File

@ -100,6 +100,12 @@
'name' => __('Description'),
'sort' => 'description',
'data_path' => 'GalaxyCluster.description',
'element' => 'extended_by',
'fields' => array(
'extend_data_path' => 'GalaxyCluster.extended_by',
'extend_link_path' => 'GalaxyCluster.uuid',
'extend_link_title' => 'GalaxyCluster.value'
)
),
array(
'name' => __('Distribution'),

View File

@ -1,6 +1,36 @@
<?php
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'galaxies', 'menuItem' => 'view_cluster'));
$extendedFromHtml = '';
$extendFromLinks = array();
if (!empty($cluster['GalaxyCluster']['extended_from'])) {
$element = $this->element('genericElements/IndexTable/Fields/links', array(
'url' => $baseurl . '/galaxy_clusters/view/',
'row' => $cluster,
'field' => array(
'data_path' => 'GalaxyCluster.extended_from.GalaxyCluster.id',
'title' => $cluster['GalaxyCluster']['extended_from']['GalaxyCluster']['value']
),
));
$extendFromLinks[] = sprintf('<li>%s</li>', $element);
}
$extendedFromHtml = sprintf('<ul>%s</ul>', implode('', $extendFromLinks));
$extendedByHtml = '';
$extendByLinks = array();
foreach($cluster['GalaxyCluster']['extended_by'] as $extendCluster) {
$element = $this->element('genericElements/IndexTable/Fields/links', array(
'url' => '/galaxy_clusters/view/',
'row' => $extendCluster,
'field' => array(
'data_path' => 'GalaxyCluster.id',
'title' => $extendCluster['GalaxyCluster']['value']
),
));
$extendByLinks[] = sprintf('<li>%s</li>', $element);
}
$extendedByHtml = sprintf('<ul>%s</ul>', implode('', $extendByLinks));
$table_data = array();
$table_data[] = array('key' => __('Cluster ID'), 'value' => $cluster['GalaxyCluster']['id']);
$table_data[] = array('key' => __('Name'), 'value' => $cluster['GalaxyCluster']['value']);
@ -19,6 +49,8 @@
):
'<span>0</span>'
);
$table_data[] = array('key' => __('Extended From'), 'html' => $extendedFromHtml);
$table_data[] = array('key' => __('Extended By'), 'html' => $extendedByHtml);
?>
<div class='view'>