Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
show single snapshot in aggregation at once
Browse files Browse the repository at this point in the history
  • Loading branch information
vvval committed Feb 23, 2016
1 parent db7a54f commit b5fc8a0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 36 deletions.
15 changes: 11 additions & 4 deletions source/Snapshotter/Controllers/SnapshotsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@ public function editAction(

$this->authorize('view', compact('aggregation'));

return $this->views->render('snapshotter:aggregation', [
'source' => $snapshotSource->findStored($aggregation)->orderBy('id', 'DESC'),
'aggregation' => $aggregation
]);
$snapshot = null;
$source = $snapshotSource->findStored($aggregation)->orderBy('id', 'DESC');

if ($source->count() === 1) {
$snapshot = $source->findOne();
}

return $this->views->render(
'snapshotter:aggregation',
compact('source', 'snapshot', 'aggregation')
);
}

/**
Expand Down
86 changes: 54 additions & 32 deletions source/views/aggregation.dark.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@
/**
* @var \Spiral\Snapshotter\Database\Aggregation $aggregation
* @var \Spiral\Snapshotter\Database\Snapshot $entity
* @var \Spiral\Snapshotter\Database\Snapshot $snapshot
*/
?>
<define:resources>
<block:resources/>
<script language="javascript" type="text/javascript">
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
</define:resources>

<define:actions>
<?php
Expand Down Expand Up @@ -98,42 +107,55 @@ class="btn red waves-effect waves-light"
</div>
<?php
//todo graph
?>
<vault:grid source="<?= $source ?>" as="entity" color="teal">
<grid:cell label="[[ID:]]" value="<?= $entity->id ?>"/>
if (!empty($snapshot)) {
?>
<p class="card-panel-title">
[[You have only one snapshot occurred, so it is shown instead of aggregation:]]
</p>
<iframe src="<?= vault()->uri('snapshots:iframe', ['id' => $snapshot->id]) ?>" width="100%"
height="100%" frameborder="0" scrolling="no"
onload="javascript:resizeIframe(this);"></iframe>
<?php
} else {
?>
<vault:grid source="<?= $source ?>" as="entity" color="teal">
<grid:cell label="[[ID:]]" value="<?= $entity->id ?>"/>

<grid:cell label="[[Occurred:]]">
<?= $entity->when() ?>
<span class="grey-text">(<?= $entity->when(true) ?>)</span>
</grid:cell>
<grid:cell label="[[Occurred:]]">
<?= $entity->when() ?>
<span class="grey-text">(<?= $entity->when(true) ?>)</span>
</grid:cell>

<grid:cell label="[[Status:]]" value="<?= e($entity->status) ?>"/>
<grid:cell label="[[Class:]]" value="<?= e($entity->exception_classname) ?>"/>
<grid:cell label="[[Filename:]]" value="<?= e(basename($entity->filename)) ?>"/>
<grid:cell label="[[Status:]]" value="<?= e($entity->status) ?>"/>
<grid:cell label="[[Class:]]" value="<?= e($entity->exception_classname) ?>"/>
<grid:cell label="[[Filename:]]" value="<?= e(basename($entity->filename)) ?>"/>

<grid:cell style="text-align:right">
<?php
if ($entity->stored()) {
?>
<vault:uri target="snapshots:snapshot" icon="edit" class="btn-flat waves-effect"
options="<?= ['id' => $entity->id] ?>"/>
<grid:cell style="text-align:right">
<?php
}
?>
</grid:cell>

<grid:cell style="text-align:right">
<?php
if ($entity->stored()) {
if ($entity->stored()) {
?>
<vault:uri target="snapshots:snapshot" icon="edit" class="btn-flat waves-effect"
options="<?= ['id' => $entity->id] ?>"/>
<?php
}
?>
<vault:uri target="snapshots:removeSnapshot" icon="delete"
class="btn red waves-effect waves-light"
options="<?= ['id' => $entity->id] ?>">
[[Remove]]
</vault:uri>
</grid:cell>

<grid:cell style="text-align:right">
<?php
}
?>
</grid:cell>
</vault:grid>
if ($entity->stored()) {
?>
<vault:uri target="snapshots:removeSnapshot" icon="delete"
class="btn red waves-effect waves-light"
options="<?= ['id' => $entity->id] ?>">
[[Remove]]
</vault:uri>
<?php
}
?>
</grid:cell>
</vault:grid>
<?php
}
?>
</define:content>

0 comments on commit b5fc8a0

Please sign in to comment.