Skip to content

Commit

Permalink
Finished downloads + workflows page
Browse files Browse the repository at this point in the history
  • Loading branch information
joshhazlewood committed Aug 8, 2018
1 parent 7d57965 commit 690c18e
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 13 deletions.
43 changes: 43 additions & 0 deletions Downloads.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
require 'header.php';
require 'navbar.php';
session_start();
if(empty($_SESSION['moduleFileCreated'])) {
$_SESSION['moduleFileCreated'] = false;
}
if(empty($_SESSION['inputFileCreated'])) {
$_SESSION['inputFileCreated'] = false;
}
?>
<br>
<div class="container">
<div class="card">
<div class="card-body">
<div>
<h5>Default Build</h5>
<form method="get" action="scripts/defaultBuild.php">
<button class="btn btn-secondary" type="submit">Download</button>
</form>
</div>
<?php if ($_SESSION['inputFileCreated']): ?>
<hr>
<div>
<h5>Input File</h5>
<form method="get" action="scripts/userInputFile.php">
<button class="btn btn-secondary" type="submit">Download</button>
</form>
</div>
<?php endif; ?>
<?php if ($_SESSION['moduleFileCreated']): ?>
<hr>
<div>
<h5>Module File With User-Added Modules</h5>
<form method="get" action="scripts/userModuleFile.php">
<button class="btn btn-secondary" type="submit">Download</button>
</form>
</div>
<?php endif; ?>
</div>
</div>

</div>
4 changes: 2 additions & 2 deletions Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
require 'header.php';
require 'navbar.php';
require 'Module.php';
require './models/Module.php';
session_start();
$userModule = null;
require 'addModule.php';
require './scripts/addModule.php';

$xml = simplexml_load_file("module.xml") or die("Error: Cannot create xml object.");
$modules = array();
Expand Down
8 changes: 4 additions & 4 deletions Workflows.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
require 'header.php';
require 'navbar.php';
require 'Module.php';
require './models/Module.php';
session_start();
require 'createInputFile.php';
require './scripts/createInputFile.php';

$xml = simplexml_load_file("module.xml") or die("Error: Cannot create xml object.");
$modules = array();
Expand Down Expand Up @@ -50,7 +50,7 @@
</div>
<div class="form-group">
<label for="outputFolder">Output Folder</label>
<input type="text" class="form-control" name="outputFolder" id="outputFolder">
<input type="text" class="form-control" name="outputFolder" placeholder="Output Folder" id="outputFolder">
</div>
<div class="input-group mb-3">
<select class="form-control" id="moduleSelect">
Expand Down Expand Up @@ -132,7 +132,7 @@ function setButtonDisabledIfInvalid() {
const uniqueID = $("#uniqueId").val();
const outputFolder = $("#outputFolder").val();
const workflowStr = createWorkflowString();
$.get("./moduleList.php", function (data) {
$.get("./scripts/moduleList.php", function (data) {
const parsedData = JSON.parse(data);
workflow.map( module => {
for (let i = 0; i < parsedData.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bioliner</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="./styles.css">
<link rel="stylesheet" href="../styles.css">
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
require 'header.php';
require 'navbar.php';
require './header.php';
require './navbar.php';
?>
<div class="container">
<h4>Welcome to Bioliner.</h4>
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions navbar.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="./index.php">Bioliner</a>
<a class="navbar-brand" href="/index.php">Bioliner</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link" href="./Modules.php">Modules</a>
<a class="nav-item nav-link" href="./Workflows.php">Workflows</a>
<a class="nav-item nav-link" href="/views/Modules.php">Modules</a>
<a class="nav-item nav-link" href="/views/Workflows.php">Workflows</a>
<a class="nav-item nav-link" href="/views/Downloads.php">Downloads</a>
</div>
</div>
</nav>
2 changes: 1 addition & 1 deletion addModule.php → scripts/addModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if(!file_exists($target_dir)) {
mkdir($target_dir);
}

$userModuleFile = $target_dir . "module.xml";
$_SESSION["userModules"][] = $userModule;
// If they have already added a module, append to that file.
Expand Down
File renamed without changes.
22 changes: 22 additions & 0 deletions scripts/defaultBuild.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
session_start();
$file = "../zip-files/bioliner.zip";
$rootPath = realpath("../zip-files/bioliner.zip");

if (file_exists($rootPath) && is_file($rootPath)) {

header('Content-Description: File Transfer');
header("Content-Type: application/zip");
header('Content-Disposition: attachment; filename="'.basename($rootPath).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($rootPath));
if (ob_get_level()) {
ob_end_clean();
}
readfile($file);
exit;
} else {
echo "Invalid file";
}
File renamed without changes.
20 changes: 20 additions & 0 deletions scripts/userInputFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
session_start();
$inputFile = "../uploads" . DIRECTORY_SEPARATOR . session_id() . DIRECTORY_SEPARATOR . "input.xml";
if (file_exists($inputFile) && is_file($inputFile)) {

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($inputFile).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($inputFile));
if (ob_get_level()) {
ob_end_clean();
}
readfile($inputFile);
exit;
} else {
echo "Error downloading file";
}
20 changes: 20 additions & 0 deletions scripts/userModuleFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
session_start();
$inputFile = "../uploads" . DIRECTORY_SEPARATOR . session_id() . DIRECTORY_SEPARATOR . "module.xml";
if (file_exists($inputFile) && is_file($inputFile)) {

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($inputFile).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($inputFile));
if (ob_get_level()) {
ob_end_clean();
}
readfile($inputFile);
exit;
} else {
echo "Error downloading file";
}

0 comments on commit 690c18e

Please sign in to comment.