Skip to content

Commit

Permalink
Schedule Preview - mark items that will be skipped in red and note pr…
Browse files Browse the repository at this point in the history
…iority reason
  • Loading branch information
dkulp committed Dec 6, 2024
1 parent 269a87c commit 3cf9359
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 44 deletions.
1 change: 1 addition & 0 deletions www/css/fpp.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ h6 {
background-color: transparent;
padding-top: 0.2em;
padding-bottom: 0.2em;
border-bottom: 0px;
}

.statusPageLoading {
Expand Down
133 changes: 89 additions & 44 deletions www/schedulePreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@
$depth = 0;

$colors = array(
array(GetSettingValue('tableColorPair1A', '00FFFF'),
GetSettingValue('tableColorPair1B', 'ADD8E6')),
array(GetSettingValue('tableColorPair2A', '008000'),
GetSettingValue('tableColorPair2B', '808000')),
array(GetSettingValue('tableColorPair3A', '808080'),
GetSettingValue('tableColorPair3B', 'C0C0C0')),
array(GetSettingValue('tableColorPair4A', 'A52A2A'),
GetSettingValue('tableColorPair4B', 'FFFF00')),
array(
GetSettingValue('tableColorPair1A', '00FFFF'),
GetSettingValue('tableColorPair1B', 'ADD8E6')
),
array(
GetSettingValue('tableColorPair2A', '008000'),
GetSettingValue('tableColorPair2B', '808000')
),
array(
GetSettingValue('tableColorPair3A', '808080'),
GetSettingValue('tableColorPair3B', 'C0C0C0')
),
array(
GetSettingValue('tableColorPair4A', 'A52A2A'),
GetSettingValue('tableColorPair4B', 'FFFF00')
),
);
$colorIndexes = array(0, 0, 0, 0);
$depthsInUse = array();
$priorities = array();
$maxDepth = 0;

$json = file_get_contents('http://localhost:32322/fppd/schedule');
Expand All @@ -27,18 +36,24 @@ function checkIfHoliday($item, $wrap = false)
global $settings;

$holiday = '';
if (($data['schedule']['entries'][$item['id']]['startDateInt'] == $item['startDateInt']) &&
(!preg_match('/^[0-9]/', $data['schedule']['entries'][$item['id']]['startDate']))) {
if (
($data['schedule']['entries'][$item['id']]['startDateInt'] == $item['startDateInt']) &&
(!preg_match('/^[0-9]/', $data['schedule']['entries'][$item['id']]['startDate']))
) {
$holiday = $data['schedule']['entries'][$item['id']]['startDate'];
}
if (($data['schedule']['entries'][$item['id']]['endDateInt'] == $item['endDateInt']) &&
(!preg_match('/^[0-9]/', $data['schedule']['entries'][$item['id']]['endDate']))) {
if (
($data['schedule']['entries'][$item['id']]['endDateInt'] == $item['endDateInt']) &&
(!preg_match('/^[0-9]/', $data['schedule']['entries'][$item['id']]['endDate']))
) {
$holiday = $data['schedule']['entries'][$item['id']]['endDate'];
}

if (($holiday != '') &&
if (
($holiday != '') &&
(isset($settings['locale'])) &&
(isset($settings['locale']['holidays']))) {
(isset($settings['locale']['holidays']))
) {
for ($h = 0; $h < count($settings['locale']['holidays']); $h++) {
if ($holiday == $settings['locale']['holidays'][$h]['shortName']) {
if ($wrap) {
Expand Down Expand Up @@ -109,7 +124,7 @@ function getItemInfo($item)
$info .= 'None';
}
$info .= '<br>';

$info .= '<b>Priority:</b> ' . $item['priority'] . '<br>';
return $info;
}

Expand All @@ -122,6 +137,7 @@ function showPlaylistEnds($currTime = 0)
global $maxDepth;
global $data;
global $depthsInUse;
global $priorities;

$deleteEnds = array();

Expand All @@ -137,26 +153,35 @@ function showPlaylistEnds($currTime = 0)
}
}

printf("<td width='20px' class='borderLeft borderBottom'>&nbsp;</td>");
printf("<td width='20px' class='borderLeft'>&nbsp;</td>");

for ($j = $endItem["previewDepth"]; $j < $maxDepth; $j++) {
if (isset($depthsInUse[$j + 1])) {
printf("<td width='20px' class='borderBottom' style='color: #%s; font-weight: bold; text-align: center;'>|</td>",
$colors[$j + 1][$colorIndexes[$j + 1]]);
printf(
"<td width='20px' style='color: #%s; font-weight: bold; text-align: center;'>|</td>",
$colors[$j + 1][$colorIndexes[$j + 1]]
);
} else {
printf("<td width='20px' class='borderBottom'>&nbsp;</td>");
printf("<td width='20px'>&nbsp;</td>");
}

}

printf("<td>%s%s</td><th>&nbsp;-&nbsp;</th><td>End Playing</td><th>&nbsp;-&nbsp;</th><td>%s (%s Stop)</td><td></td></tr>\n<tr>",
$style = "";
if ($depthsInUse[$endItem["previewDepth"]] == 2) {
$style = " style='color: red;'";
}
printf(
"<td>%s%s</td><td>&nbsp;-&nbsp;</td><td%s>End Playing</td><td>&nbsp;-&nbsp;</td><td%s>%s (%s Stop)</td><td></td></tr>\n<tr>",
$endItem["endTimeStr"],
checkIfHoliday($endItem, true),
$style,
$style,
$endItem["args"][0],
$data["schedule"]["entries"][$endItem["id"]]["stopTypeStr"]
);

unset($depthsInUse[$endItem["previewDepth"]]);
unset($priorities[$endItem["previewDepth"]]);
}

array_push($deleteEnds, $eTime);
Expand Down Expand Up @@ -231,13 +256,14 @@ function showPlaylistEnds($currTime = 0)
echo "</thead><tbody>";

foreach ($data["schedule"]["items"] as $item) {
showPlaylistEnds($item["startTime"]);

showPlaylistEnds($item["startTime"]);
$depth = 0;
while (isset($depthsInUse[$depth])) {
$depth++;
}


$colorIndex = $colorIndexes[$depth];
$colorIndex++;
if ($colorIndex > 1) {
Expand All @@ -255,7 +281,6 @@ function showPlaylistEnds($currTime = 0)
if ($item["command"] == "Start Playlist") {
$item["colorIndex"] = $colorIndex;
$item["previewDepth"] = $depth;
$depthsInUse[$depth] = 1;

if (isset($endTimes[$item["endTime"]])) {
array_unshift($endTimes[$item["endTime"]], $item);
Expand All @@ -265,38 +290,58 @@ function showPlaylistEnds($currTime = 0)
}

ksort($endTimes);
printf("<td width='20px' class='borderTop borderLeft'>&nbsp;</td>");

$priorities[$depth] = $item['priority'];
$style = "";
if ($depth == 0 || $item['priority'] < $priorities[$depth - 1]) {
$depthsInUse[$depth] = 1;
} else {
$depthsInUse[$depth] = 2;
$style = " style='color: red;'";
}
printf("<td width='20px' class='borderLeft'>&nbsp;</td>");
for ($j = $depth; $j < $maxDepth; $j++) {
printf("<td width='20px' class='borderTop'>&nbsp;</td>");
printf("<td width='20px'>&nbsp;</td>");
}
if ($depth == 0 || $item['priority'] < $priorities[$depth - 1]) {
printf(
"<td>%s%s</td><td>&nbsp;-&nbsp;</td><td>Start Playing</td><td>&nbsp;-&nbsp;</td><td>%s (%s w/ %s Stop)</td>",
$item["startTimeStr"],
checkIfHoliday($item, true),
$item["args"][0],
$data["schedule"]["entries"][$item["id"]]["repeat"] == 1 ? "Repeating" : "Non-Repeating",
$data["schedule"]["entries"][$item["id"]]["stopTypeStr"]
);
} else {
printf(
"<td>%s%s</td><td>&nbsp;-&nbsp;</td><td style='color: red;'>Skip Start Playing</td><td>&nbsp;-&nbsp;</td><td style='color: red;'>%s - Lower Priority</td>",
$item["startTimeStr"],
checkIfHoliday($item, true),
$item["args"][0]
);
}

printf("<td>%s%s</td><th>&nbsp;-&nbsp;</th><td>Start Playing</td><th>&nbsp;-&nbsp;</th><td>%s (%s w/ %s Stop)</td>",
$item["startTimeStr"],
checkIfHoliday($item, true),
$item["args"][0],
$data["schedule"]["entries"][$item["id"]]["repeat"] == 1 ? "Repeating" : "Non-Repeating",
$data["schedule"]["entries"][$item["id"]]["stopTypeStr"]
);
} else {
printf("<td width='20px' class='borderTop borderLeft borderBottom'>&nbsp;</td>");
printf("<td width='20px' class='borderLeft'>&nbsp;</td>");

for ($j = $depth; $j < $maxDepth; $j++) {
// printf("<td width='20px' class='borderTop borderBottom'>&nbsp;</td>");
// printf("<td width='20px'>&nbsp;</td>");
if (isset($depthsInUse[$j + 1])) {
printf("<td width='20px' class='borderTop borderBottom' style='color: #%s; font-weight: bold; text-align: center;'>|</td>",
$colors[$j + 1][$colorIndexes[$j + 1]]);
printf(
"<td width='20px' style='color: #%s; font-weight: bold; text-align: center;'>|</td>",
$colors[$j + 1][$colorIndexes[$j + 1]]
);
} else {
printf("<td width='20px' class='borderTop borderBottom'>&nbsp;</td>");
printf("<td width='20px'>&nbsp;</td>");
}

}

printf("<td>%s%s</td><th>&nbsp;-&nbsp;</th><td>%s</td><th>&nbsp;-&nbsp;</th><td>%s</td>",
printf(
"<td>%s%s</td><td>&nbsp;-&nbsp;</th><td>%s</td><td>&nbsp;-&nbsp;</th><td>%s</td>",
$item["startTimeStr"],
checkIfHoliday($item, true),
$item["command"],
join(' | ', $item["args"]));
join(' | ', $item["args"])
);
}

echo "<td><span data-bs-toggle='tooltip' data-bs-html='true' data-bs-placement='auto' data-bs-title=\"" . getItemInfo($item) . "\"><img src='images/redesign/help-icon.svg' class='icon-help'></span></td>";
Expand All @@ -305,9 +350,9 @@ function showPlaylistEnds($currTime = 0)
}
showPlaylistEnds();
?>
</tbody>
</tbody>
</table>
<script>
SetupToolTips();
SetupToolTips();

</script>
</script>

0 comments on commit 3cf9359

Please sign in to comment.