Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Moved pages around, created new page to restart javo/marceline, added…
Browse files Browse the repository at this point in the history
… warning to short playlists
  • Loading branch information
connor642 committed Apr 14, 2018
1 parent 6ed5f67 commit f5135f2
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 44 deletions.
68 changes: 25 additions & 43 deletions sustainer/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@

MainTemplate::set_subtitle("Perform common sustainer tasks");

if (isset($_POST["restart-marceline"])) {
system("sudo /etc/init.d/marceline restart");
}

if (isset($_POST["restart-javo"])) {
system("sudo /etc/init.d/javo restart");
}

if (isset($_POST['trackid']) || isset($_GET['trackid'])) {
if ((isset($_POST['trackid']) || isset($_GET['trackid'])) && Session::is_group_user("Administrators")) {
$query = "SELECT * FROM audio WHERE id=:trackid";
$parameters = array(':trackid' => $_REQUEST['trackid']);
$result = DigiplayDB::query($query, $parameters);
Expand Down Expand Up @@ -44,34 +36,7 @@
$currentQueue = Sustainer::get_queue();
$i = 0;
?>
<div class="row">
<table class="table table-striped table-hover">
<thead>
<tr>
<th class="title">Service</th>
<th class="title">Status</th>
<th class="icon">Restart</th>
</tr>
</thead>
<tbody>
<tr>
<td>Marceline</td>
<td>
<?echo preg_replace('/\(pid\s\d+\)/', '', substr(exec("sudo /etc/init.d/marceline status"), 8));?>
</td>
<td><form method="POST"><input name="restart-marceline" type="submit" class="btn btn-danger" value="Restart" /></form></td>
</tr>
<tr>
<td>JAVO</td>
<td>
<?echo preg_replace('/\(pid\s\d+\)/', '', substr(exec("sudo /etc/init.d/javo status"), 8));?>
</td>
<td><form method="POST"><input name="restart-javo" type="submit" class="btn btn-danger" value="Restart" /></form></td>
</tr>
</tbody>
</table>
</div>
<h3>Current queue:</h3>
<h3>Current Queue</h3>
<?
if (!is_null($currentQueue)) {

Expand Down Expand Up @@ -102,19 +67,32 @@
<?}?>
</tbody>
</table>
<?} else {

<?
}
else {
Bootstrap::alert("warning","<b>Warning: </b>The current queue is empty","",false);
}?>
<h3>Schedule audio:</h3>
<p>You can use this tool to schedule the next audio track to be played on Sue by using its audio id.</p>
}

if(Session::is_group_user("Administrators")) {
?>

<h3>Schedule Audio</h3>
<p>You can use this tool to schedule the next audio track to be played on Sue by using its Audio ID.</p>
<form method="post">
Track ID: <input type="text" name="trackid" /><input type="submit" name="submit" value="Schedule" />
<div class="form-group">
<label for="trackid">Track ID</label>
<input type="text" class="form-control" name="trackid" id="trackid">
</div>
<button class="btn btn-primary" type="submit" name="submit">Schedule</button>
</form>

<?
$currentLog = Sustainer::get_log();
$i = 0;
?>
<h3>Scheduler log:</h3>

<h3>Scheduler Log</h3>
<table class="table table-striped table-bordered">
<thead>
<tr>
Expand All @@ -136,3 +114,7 @@
<?}?>
</tbody>
</table>

<?php
}
?>
43 changes: 43 additions & 0 deletions sustainer/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

Output::require_group("Administrators");

Output::set_title("Sustainer Services");
MainTemplate::set_subtitle("Manage the sustainer services");

if(isset($_POST["restart-marceline"])) {
system("sudo /etc/init.d/marceline restart");
}

if(isset($_POST["restart-javo"])) {
system("sudo /etc/init.d/javo restart");
}
?>

<div class="row">
<table class="table table-striped table-hover">
<thead>
<tr>
<th class="title">Service</th>
<th class="title">Status</th>
<th class="icon">Restart</th>
</tr>
</thead>
<tbody>
<tr>
<td>Marceline</td>
<td>
<?echo preg_replace('/\(pid\s\d+\)/', '', substr(exec("sudo /etc/init.d/marceline status"), 8));?>
</td>
<td><form method="POST"><input name="restart-marceline" type="submit" class="btn btn-danger" value="Restart" /></form></td>
</tr>
<tr>
<td>JAVO</td>
<td>
<?echo preg_replace('/\(pid\s\d+\)/', '', substr(exec("sudo /etc/init.d/javo status"), 8));?>
</td>
<td><form method="POST"><input name="restart-javo" type="submit" class="btn btn-danger" value="Restart" /></form></td>
</tr>
</tbody>
</table>
</div>
26 changes: 25 additions & 1 deletion sustainer/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ function menu() {
array("url" => LINK_ABS.$site_path_array[0]."/adverts.php", "text" => "Advert Manager", "icon" => "gbp")
);

if(Session::is_group_user("Administrators"))
$menu[] = array("url" => LINK_ABS.$site_path_array[0]."/services.php", "text" => "Service Manager", "icon" => "cog");

foreach($menu as &$item) if($site_path_array[1] == array_pop(explode("/",$item["url"]))) $item["active"] = true;
return Bootstrap::list_group($menu);
}

function sidebar() {
$return .= "
<h4>Sustainer Service</h4>
Expand Down Expand Up @@ -42,7 +46,27 @@ function sidebar() {
$color = "#" . $color;
}

$return .= "<a href=\"../playlists/detail/".$playlist->get_id()."\" class=\"list-group-item\" style=\"background-color:".$color.";color:".$text."\">".$playlist->get_name()."</a>";
if($playlist->count_tracks() < 40) {
$error = "Less than 40 tracks on playlist";
}
else {
$length = 0;
foreach($playlist->get_tracks() as $track) {
$length += $track->get_length();
}

if($length < (2 * 60 * 60))
$error = "Length of playlist less than 2 hours";
}

$icon = "";
$hoverInformation = "";
if(isset($error)) {
$hoverInformation = " title=\"".$error."\" rel=\"twipsy\"";
$icon = Bootstrap::fontawesome("exclamation-triangle", "fa-lg fa-fw fa-pull-left");
}

$return .= "<a href=\"../playlists/detail/".$playlist->get_id()."\" class=\"list-group-item\" style=\"background-color:".$color.";color:".$text."\"".$hoverInformation.">".$icon.$playlist->get_name()."</a>";
}

$return .= "</div>";
Expand Down

0 comments on commit f5135f2

Please sign in to comment.