Skip to content

Commit

Permalink
Merge pull request #262 from jeanbez/view-submission
Browse files Browse the repository at this point in the history
view all details of submissions
  • Loading branch information
gflofst authored Oct 30, 2023
2 parents bda86c8 + b27efe4 commit 647af0c
Show file tree
Hide file tree
Showing 5 changed files with 302 additions and 139 deletions.
75 changes: 24 additions & 51 deletions src/Controller/SubmissionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class SubmissionsController extends AppController
*/
public function view($id = null)
{
$prefix = Configure::read('IO500.storage');

$submission = $this->Submissions->get($id);

// We need to fetch the scores
Expand All @@ -65,60 +63,35 @@ public function view($id = null)

$submission->io500_score = $score->score;

$target_files = [
'ior_easy_read',
'ior_easy_write',
'ior_hard_read',
'ior_hard_write',
'mdtest_easy_delete',
'mdtest_easy_stat',
'mdtest_easy_write',
'mdtest_hard_delete',
'mdtest_hard_stat',
'mdtest_hard_write',
'mdtest_hard_read',
'result_summary',
'result.txt',
'result-summary.txt',
'io500.sh',
];
$questionnaire = $this->Submissions->Questionnaires->find('all')
->where([
'Questionnaires.submission_id' => $submission->id
])
->first();

$selected_files = [];
$submitted_files = [];

$path = $prefix . $submission->information_list_name . '/' . str_replace('.zip', '', $submission->storage_data);

if ($submission->storage_data && is_dir($path)) {
$dir_iterator = new \RecursiveDirectoryIterator($path);
$iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST);

foreach ($iterator as $file) {
if ($file->isFile()) {
foreach ($target_files as $target) {
if (
(
strpos($file->getPathname(), $target) !== false ||
strpos(str_replace('_', '-', $file->getPathname()), str_replace('_', '-', $target)) !== false
) &&
strpos($file->getPathname(), '._') === false
) {
$selected_files[] = $file->getPathname();
}
}
}
}
$this->set('submission', $submission);
$this->set('questionnaire', $questionnaire);
}

foreach ($selected_files as $file) {
$file = new File($file);
$submitted_files[$file->name()] = $file->read();
$file->close();
}
/**
* Configuration method
*
* @param string|null $id Submission id.
* @return \Cake\Http\Response|null|void Renders view
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function configuration($id = null)
{
$submission = $this->Submissions->get($id);

ksort($submitted_files);
}
$questionnaire = $this->Submissions->Questionnaires->find('all')
->where([
'Questionnaires.submission_id' => $submission->id
])
->first();

$this->set('submission', $submission);
$this->set('submitted_files', $submitted_files);
$this->set('questionnaire', $questionnaire);
}

/**
Expand Down
64 changes: 64 additions & 0 deletions templates/Questionnaires/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,70 @@

<?php echo h($submission->information_system) ?>
</h2>

<div class="submissions-action">
<?php
echo $this->Html->link(
_('Summary'),
[
'controller' => 'submissions',
'action' => 'view',
$submission->id
],
[
'class' => 'button-navigation'
]
);

echo $this->Html->link(
_('Configuration'),
[
'controller' => 'submissions',
'action' => 'configuration',
$submission->id
],
[
'class' => 'button-navigation'
]
);

if ($questionnaire) {
echo $this->Html->link(
_('Reproducibility'),
[
'controller' => 'questionnaires',
'action' => 'view',
$submission->id
],
[
'class' => 'button'
]
);
}

if ($submission->repository_url) {
echo $this->Html->link(
_('Files'),
$submission->repository_url,
[
'target' => '_blank',
'class' => 'button-navigation'
]
);
}

if ($submission->cdcl_url) {
echo $this->Html->link(
_('Data Center'),
$submission->cdcl_url,
[
'class' => 'button-navigation',
'target' => '_blank'
]
);
}
?>
</div>
</div>
</div>
</div>
Expand Down
143 changes: 143 additions & 0 deletions templates/Submissions/configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<nav id="breadcrumb">
<p>YOU ARE HERE</p>

<?php
$this->Breadcrumbs->add(_('LISTS'), ['controller' => 'releases', 'action' => 'index']);
$this->Breadcrumbs->add(strtoupper($submission->information_list_name), ['controller' => 'listings', 'action' => 'list', strtolower($submission->information_list_name), 'io500']);
$this->Breadcrumbs->add(strtoupper($submission->information_system), ['controller' => 'submissions', 'action' => 'view', $submission->id]);
$this->Breadcrumbs->add(_('CONFIGURATION'), ['controller' => 'submissions', 'action' => 'configuration', $submission->id]);

echo $this->Breadcrumbs->render([], ['separator' => ' / ']);
?>
</nav>

<div class="row">
<div class="column-responsive column-80">
<div class="submissions view content">
<h2 class="submissions-name">
<?php if ($questionnaire) { ?>
<div class="badge badge-<?php echo $questionnaire->reproducibility_score_id; ?>"></div>
<?php } ?>

<?php echo h($submission->information_system); ?>
</h2>

<div class="submissions-action">
<?php
echo $this->Html->link(
_('Summary'),
[
'controller' => 'submissions',
'action' => 'view',
$submission->id
],
[
'class' => 'button-navigation'
]
);

echo $this->Html->link(
_('Configuration'),
[
'controller' => 'submissions',
'action' => 'configuration',
$submission->id
],
[
'class' => 'button'
]
);

if ($questionnaire) {
echo $this->Html->link(
_('Reproducibility'),
[
'controller' => 'questionnaires',
'action' => 'view',
$submission->id
],
[
'class' => 'button-navigation'
]
);
}

if ($submission->repository_url) {
echo $this->Html->link(
_('Files'),
$submission->repository_url,
[
'target' => '_blank',
'class' => 'button-navigation'
]
);
}

if ($submission->cdcl_url) {
echo $this->Html->link(
_('Data Center'),
$submission->cdcl_url,
[
'class' => 'button-navigation',
'target' => '_blank'
]
);
}
?>
</div>

<div class="information">
<div id="dcl_wrap"></div>
</div>
</div>
</div>
</div>


<?php
echo $this->Html->css([
'https://submission.io500.org/css/dcl.min.css'
]);

echo $this->Html->script(
[
'https://submission.io500.org/js/js-yaml.min.js',
'https://submission.io500.org/js/c3.min.js',
'https://submission.io500.org/js/d3.min.js',
'https://submission.io500.org/js/jquery.min.js',
'https://submission.io500.org/js/math.min.js',
'https://unpkg.com/@popperjs/core@2',
'https://unpkg.com/tippy.js@6',
'https://submission.io500.org/js/dcl.js',
'https://submission.io500.org/js/dcl-load.js',
'https://submission.io500.org/js/dcl-move.js',
'https://submission.io500.org/js/dcl-vis.js'
],
[
'block' => 'script'
]
);

$url_site = 'https://submission.io500.org/files/submissions/' . $submission->id . '.json?timestamp=' . time();
$url_schema = 'https://submission.io500.org/model/schema-io500.json?timestamp=' . time();

$this->Html->scriptBlock(
"
$(document).ready(function() {
dcl_draw_graph = false;
dcl_draw_table = false;
dcl_draw_toolbar = false;
dcl_draw_aggregation = false;
dcl_global_readonly = true;
dcl_schema = '" . $url_schema . "';
dcl_site = '" . $url_site . "';
dcl_startup();
});
",
[
'block' => 'script'
]
);
?>
Loading

0 comments on commit 647af0c

Please sign in to comment.