Skip to content

Commit

Permalink
Starting Admin Panel to add applications
Browse files Browse the repository at this point in the history
  • Loading branch information
starstryder committed Jul 18, 2024
1 parent 0ba95c8 commit 30ef55c
Show file tree
Hide file tree
Showing 184 changed files with 120 additions and 16 deletions.
10 changes: 5 additions & 5 deletions csb/apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@
<script src="/csb/csb-content/js/CsbApp.js"></script>

<!-- Application definitions -->
<script src="/csb/csb-apps/bennu_mappers/js/bennu_mappers.js"></script>
<script src="/csb/csb-apps/moon_mappers/js/moon_mappers.js"></script>
<script src="/csb/csb-apps/mars_mappers/js/mars_mappers.js"></script>
<script src="/csb/csb-apps/mercury_mappers/js/mercury_mappers.js"></script>
<script src="/csb/csb-apps/deprecated/bennu_mappers/js/bennu_mappers.js"></script>
<script src="/csb/csb-apps/deprecated/moon_mappers/js/moon_mappers.js"></script>
<script src="/csb/csb-apps/deprecated/mars_mappers/js/mars_mappers.js"></script>
<script src="/csb/csb-apps/deprecated/mercury_mappers/js/mercury_mappers.js"></script>

<!-- Following is the code to launch -->
<script type="text/javascript">
Expand All @@ -121,4 +121,4 @@
</script>

<?php
loadFooter();
loadFooter();
104 changes: 104 additions & 0 deletions csb/csb-admin/dashboards/admin-apps/admin-apps.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

function doSwitch($db, $option) {
switch ($option) {
case "create":
$text = create($db);
break;
default:
$text['main'] = "<p>ERROR: No Option Selected. Did you try URL hacking?</p>";
$text['notes'] = "";
}
return array("main" => $text['main'], "notes" => $text['notes']);
}

function landing()
{
global $db_servername, $db_username, $db_password, $db_name, $db_port, $BASE_URL;
$main = "Turn apps on and off";
$notes = "Instructions will go here";

// Connect to Databass
$db = new DB($db_servername, $db_username, $db_password, $db_name, $db_port);

// Get names of all applications in the database
$query = "SELECT name FROM applications";
$result = $db->runQuery($query);

// if there are no results, add the phrase "none" to $main
if (!$result) {
$main .= "No Apps are available<br>";
}
else
{
// list the names in the result
foreach ($result as $row) {
$main .= $row['name'] . " - ";
}
}

// add form to create new application with all data in the database
$main .= "
<form id='profile-form' action='$BASE_URL/csb-admin/index.php?option=admin-apps' method='POST'>
<input type='hidden' name='action' value='create'>
<label for='name'>Name:</label>
<input type='text' name='name' id='name' class='mt-4'>
<label for='description'>Description:</label>
<input type='text' name='description' id='description' class='mt-4'>
<label for='url'>URL:</label>
<input type='text' name='url' id='url' class='mt-4'>
<label for='status'>Status:</label>
<input type='text' name='status' id='status' class='mt-4'>
<input type='submit' value='Create Application' class='btn btn-cq mt-4 right'>
</form>
";
return array("main" => $main, "notes" => $notes);

}

function create($db)
{
global $db_servername, $db_username, $db_password, $db_name, $db_port, $BASE_URL;

// Connect to Databass
$db = new DB($db_servername, $db_username, $db_password, $db_name, $db_port);

// Fetch old data to compare.
$query = "SELECT * FROM applications";
$result = $db->runQuery($query);

$changed = FALSE;

// Get the data from the form
$name = $_POST['name'];
$description = $_POST['description'];
$url = $_POST['url'];
$status = $_POST['status'];

// Check if the name is already in the database
foreach ($result as $row) {
if ($row['name'] == $name) {
$changed = TRUE;
}
}

// If the name is not in the database, add it
if (!$changed) {
$query = "INSERT INTO applications (name, description, url, status) VALUES (?, ?, ?, ?)";
$params = array($name, $description, $url, $status);
//$result = $db->runQueryWhere($query, "ssss", $params);
$status = "created";
}

// If the name is in the database, update it
else {
$query = "UPDATE applications SET description = ?, url = ?, status = ? WHERE name = ?";
$params = array($description, $url, $status, $name);
//$result = $db->runQueryWhere($query, "ssss", $params);
$status = "updated";
}

// Return the main text
$main = "Application " . $_POST['name'] . " $status";
return array("main" => $main, "notes" => "");
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function mars_mappers(csbApp) {
{
"type": "dropdown",
"title": "Tutorial",
"text": "Welcome to Mars Mappers! To start,<br /> we'll quickly explain how to do the following: <ol><li><img src='/csb/csb-apps/mars_mappers/images/tutorial/eraser.png' /> Erase a mistake</li><li><img src='/csb/csb-apps/mars_mappers/images/tutorial/crater.png' /> Find a crater</li><li><img src='/csb/csb-apps/mars_mappers/images/tutorial/light-image.png' /> Complete an image</li><li><img src='/csb/csb-apps/mars_mappers/images/tutorial/ejecta.png' /> Find crater ejecta</li>",
"text": "Welcome to Mars Mappers! To start,<br /> we'll quickly explain how to do the following: <ol><li><img src='/csb/csb-apps/deprecated/mars_mappers/images/tutorial/eraser.png' /> Erase a mistake</li><li><img src='/csb/csb-apps/deprecated/mars_mappers/images/tutorial/crater.png' /> Find a crater</li><li><img src='/csb/csb-apps/deprecated/mars_mappers/images/tutorial/light-image.png' /> Complete an image</li><li><img src='/csb/csb-apps/deprecated/mars_mappers/images/tutorial/ejecta.png' /> Find crater ejecta</li>",
"ok-button": {}, // Should have text like "Okay, let's start!",
"goal": "GOAL: Learn About Craters"
},
Expand Down Expand Up @@ -202,4 +202,4 @@ function mars_mappers(csbApp) {
}
]
)
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function mercury_mappers(csbApp) {
{
"type": "dropdown",
"title": "Tutorial",
"text": "Welcome to Mercury Mappers! To start,<br /> we'll quickly explain how to do the following: <ol><li><img src='/csb/csb-apps/mercury_mappers/images/tutorial/eraser.png' /> Erase a mistake</li><li><img src='/csb/csb-apps/mercury_mappers/images/tutorial/crater.png' /> Find a crater</li><li><img src='/csb/csb-apps/mercury_mappers/images/tutorial/easy.png' /> Complete an easy image</li><li><img src='/csb/csb-apps/mercury_mappers/images/tutorial/hard.png' /> Complete a hard image</li>",
"text": "Welcome to Mercury Mappers! To start,<br /> we'll quickly explain how to do the following: <ol><li><img src='/csb/csb-apps/deprecated/mercury_mappers/images/tutorial/eraser.png' /> Erase a mistake</li><li><img src='/csb/csb-apps/deprecated/mercury_mappers/images/tutorial/crater.png' /> Find a crater</li><li><img src='/csb/csb-apps/deprecated/mercury_mappers/images/tutorial/easy.png' /> Complete an easy image</li><li><img src='/csb/csb-apps/deprecated/mercury_mappers/images/tutorial/hard.png' /> Complete a hard image</li>",
"ok-button": {}, // Should have text like "Okay, let's start!",
"goal": "GOAL: Learn About Craters"
},
Expand Down Expand Up @@ -241,4 +241,4 @@ function mercury_mappers(csbApp) {
}
]
)
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function moon_mappers(csbApp) {
{
"type": "dropdown",
"title": "Tutorial",
"text": "Welcome to Moon Mappers! To start,<br /> we'll quickly explain how to do the following: <ol><li><img src='/csb/csb-apps/moon_mappers/images/tutorial/eraser.png' /> Erase a mistake</li><li><img src='/csb/csb-apps/moon_mappers/images/tutorial/crater.png' /> Find a crater</li><li><img src='/csb/csb-apps/moon_mappers/images/tutorial/light-image.png' /> Complete a light image</li><li><img src='/csb/csb-apps/moon_mappers/images/tutorial/dark-image.png' /> Complete a dark image</li>",
"text": "Welcome to Moon Mappers! To start,<br /> we'll quickly explain how to do the following: <ol><li><img src='/csb/csb-apps/deprecated/moon_mappers/images/tutorial/eraser.png' /> Erase a mistake</li><li><img src='/csb/csb-apps/deprecated/moon_mappers/images/tutorial/crater.png' /> Find a crater</li><li><img src='/csb/csb-apps/deprecated/moon_mappers/images/tutorial/light-image.png' /> Complete a light image</li><li><img src='/csb/csb-apps/deprecated/moon_mappers/images/tutorial/dark-image.png' /> Complete a dark image</li>",
"ok-button": {}, // Should have text like "Okay, let's start!",
"goal": "GOAL: Learn About Craters"
},
Expand Down Expand Up @@ -214,4 +214,4 @@ function moon_mappers(csbApp) {
}
]
)
}
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion csb/csb-apps/moon_mosaic/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
---------------------------------------------------------------------- */
global $page_title, $header_title, $SITE_TITLE;

$page_title = "Moon Mosaic1";
$page_title = "Moon Mosaic";

// Make sure the page title is set
if (!isset($page_title)) { $page_title = $SITE_TITLE; };
Expand Down
8 changes: 4 additions & 4 deletions csb/csb-themes/default/app-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<div class="app-sidebar-title">Examples</div>
<img id="app-example-up-arrow" src="/csb/csb-content/images/applications/buttons/up-arrow.png" />
<div id="example-images">

<img class="example-image" src="/csb/csb-apps/<?php echo $app; ?>/images/examples/crater/crater1.png" />
<img class="example-image" src="/csb/csb-apps/<?php echo $app; ?>/images/examples/crater/crater2.png" />
<img class="example-image" src="/csb/csb-apps/<?php echo $app; ?>/images/examples/crater/crater3.png" />
Expand Down Expand Up @@ -204,9 +204,9 @@
</ul>
</li>
</ul>
<?php if ($app == "mercury_mappers") {
<?php if ($app == "mercury_mappers") {

echo "<video controls preload='metadata' id='mercury-crater-video' class='example-video'><source src='/csb/csb-apps/mercury_mappers/images/tutorial/crater-video.mp4' type='video/mp4'>You need to update your browser to view animations. </video>";
echo "<video controls preload='metadata' id='mercury-crater-video' class='example-video'><source src='/csb/csb-apps/deprecated/mercury_mappers/images/tutorial/crater-video.mp4' type='video/mp4'>You need to update your browser to view animations. </video>";
}
?>
<div class="app-button okay-button">Got it</div>
Expand Down Expand Up @@ -239,4 +239,4 @@
<div id="text-bubble-okay-button" style="display: none">Okay</div>
</div>
<canvas id='zoom-canvas' width='100' height='100'></canvas>
</div>
</div>

0 comments on commit 30ef55c

Please sign in to comment.