Skip to content
Permalink
Browse files

52: convert track editor to use ajax when adding new tracks (#53)

convert playlist editor to use ajax #52
  • Loading branch information...
eric-gilbertson authored and RocketMan committed Aug 14, 2019
1 parent 2a3ed75 commit b7dc87ef73dccbe7ec2f84dc0eb3869d9c488063
Showing with 409 additions and 81 deletions.
  1. +1 −0 config/ui_config.php
  2. +33 −0 css/zoostyle.css
  3. +1 −0 engine/IPlaylist.php
  4. +7 −1 engine/impl/Playlist.php
  5. +2 −0 js/jquery.min.js
  6. +1 −5 ui/AddManager.php
  7. +22 −4 ui/Main.php
  8. +342 −71 ui/Playlists.php
@@ -45,6 +45,7 @@
[ 'a', 'viewDJ%', 'DJ Zone!', ZK\UI\Playlists::class ],
[ 'a', 'viewDate', 'Playlists by Date', ZK\UI\Playlists::class ],
[ 'u', 'updateDJInfo', 'Update Profile', ZK\UI\Playlists::class ],
[ 'u', 'addTrack', '0', ZK\UI\Playlists::class ],
[ 'U', 'changePass', 'Change Password', ZK\UI\ChangePass::class ],
[ 'p', 'deepStorage', 'Deep Storage', ZK\UI\DeepStorage::class ],
[ 'x', 'adminUsers', 'Administer Users', ZK\UI\UserAdmin::class ],
@@ -409,6 +409,39 @@ TH.sec {
border: 1px solid #3b0000;
width: 120px;
}
.zk-hidden {
display: none;
}

.track-info {
color: gray;
}
.track-error {
color: red;
}

.track-editor {
padding-top: 4px;
}

.track-editor input, .track-editor select {
width: 300px;
box-sizing: border-box;
height: 24px;
margin-bottom: 4px;
}

.track-editor button {
width: 140px;
box-sizing: border-box;
}

.track-editor label {
width: 44px;
display:inline-block;
font-weight: bold;
}

INPUT[type="radio"],
INPUT[type="checkbox"] {
height: 15px;
@@ -28,6 +28,7 @@
* Playlist operations
*/
interface IPlaylist {
//NOTE: must match SPECIAL_TRACK value in javascript.
const SPECIAL_TRACK = "~~~~~~~~";
const COMMENT_FLAG = "C";
@@ -207,6 +207,8 @@ public function isWithinShow($listRow) {
return $retVal;
}
// insert playlist track. return following: 0 - fail, 1 - success no
// timestamp, 2 - sucess with timestamp.
public function insertTrack($playlistId, $tag, $artist, $track, $album, $label, $wantTimestamp) {
$row = Engine::api(IPlaylist::class)->getPlaylist($playlistId, 1);
@@ -233,7 +235,11 @@ public function insertTrack($playlistId, $tag, $artist, $track, $album, $label,
if($haveTag)
$stmt->bindValue(6, $tag);
return $stmt->execute();
$updateStatus = $stmt->execute();
if ($updateStatus == 1 && $doTimestamp)
$updateStatus = 2;
return $updateStatus;
}
// update track and set created if it is currently null, eg first edit

Large diffs are not rendered by default.

@@ -1254,7 +1254,6 @@ private function aFileActivityEmitReport(&$records, $subaction, $static=0) {
echo "<TH>DJ</TH>";
echo "<TH>Air Name</TH>";
echo "<TH>Show</TH>";
echo "<TH>D</TH>";
echo "<TH>Tracks</TH>";
echo "<TH>AFile</TH>";
echo "<TH>%</TH>";
@@ -1282,7 +1281,7 @@ private function aFileActivityEmitReport(&$records, $subaction, $static=0) {
// insert no playlist row if there is a gap in the regular
// program day, eg 6am - 11:59:59pm.
if($lastShowEnd != $showStart && $showStart != $DAY_START_TIME) {
echo "<TR CLASS='noPlaylist'><TD>" . $showDate . " <span class='sub2'>" . $lastShowEnd . "-" . $showStart . "</span></TD><TD COLSPAN=7>No playlist</TD></TR>";
echo "<TR CLASS='noPlaylist'><TD>" . $showDate . " <span class='sub2'>" . $lastShowEnd . "-" . $showStart . "</span></TD><TD COLSPAN=6>No playlist</TD></TR>";
}
$lastShowEnd = $showEnd;
@@ -1306,9 +1305,6 @@ private function aFileActivityEmitReport(&$records, $subaction, $static=0) {
"&amp;seq=selList&amp;session=".$this->session->getSessionID()."\">".
htmlentities($row["description"]) . "</A></TD>\n";
// Duration
echo "<TD align='right'>" . $row["duration"] . "</TD>\n";
// Totals
echo "<TD>" . $row["total"] . "</TD>\n";
echo "<TD>" . $row["afile"] . "</TD>\n";
@@ -37,21 +37,39 @@ class Main implements IController {
protected $dn;
protected $session;
private function getRequestHeader($headerName)
{
$headers = getallheaders();
return isset($headerName) ? $headers[$headerName] : null;
}
public function processRequest($dispatcher) {
$this->session = Engine::session();
$contentType = $_REQUEST["Content-Type"];
$action = $_REQUEST["action"];
$subAction = $_REQUEST["subaction"];
$acceptHdr = $this->getRequestHeader("Accept");
$isJson = substr($acceptHdr, 0, 16) === 'application/json';
$this->preProcessRequest($dispatcher);
$this->emitResponseHeader();
$this->emitBody($dispatcher);
if ($isJson == 1) {
//TODO: add validation
$dispatcher->dispatch($action, $subaction, $this->session);
} else {
$this->emitResponseHeader();
$this->emitBody($dispatcher);
}
}
protected function preProcessRequest($dispatcher) {
// Validate the requested action is authorized
if(!empty($_REQUEST["session"]) && !empty($_REQUEST["action"]) &&
!$dispatcher->isActionAuth($_REQUEST["action"], $this->session) &&
$_REQUEST["action"] != "loginValidate" &&
$_REQUEST["action"] != "logout")
$_REQUEST["action"] != "logout") {
$_REQUEST["action"] = "invalidSession";
}
// Setup/teardown a session
switch($_REQUEST["action"]) {
@@ -84,7 +102,7 @@ protected function emitResponseHeader() {
<?php UI::emitCSS('css/zoostyle.css'); ?>
<?php UI::emitCSS(Engine::param('stylesheet')); ?>
<?php UI::emitCSS('css/about.css'); ?>
<SCRIPT TYPE="text/javascript" SRC="<?php echo $_SERVER['REQUEST_SCHEME']; ?>://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></SCRIPT>
<?php UI::emitJS('js/jquery.min.js'); ?>
<?php UI::emitJS('js/jquery.tablesorter.min.js'); ?>
<LINK REL="alternate" TYPE="application/rss+xml" TITLE="<?php echo $station; ?> Radio Music Reviews" HREF="zkrss.php?feed=reviews">
<LINK REL="alternate" TYPE="application/rss+xml" TITLE="<?php echo $station; ?> Radio Airplay Charts" HREF="zkrss.php?feed=charts">

0 comments on commit b7dc87e

Please sign in to comment.
You can’t perform that action at this time.