From 10218aeeb5c2ad71e3bd489e91e5b75e946e0e00 Mon Sep 17 00:00:00 2001 From: mkonecny Date: Tue, 21 Dec 2010 18:28:17 -0500 Subject: [PATCH 1/2] Commit so that I may access project from a different computer. Many things do not work/ are incomplete!!! -Added unfinalized API for getting schedule and currently playing item. --- application/configs/navigation.php | 6 ++ .../controllers/ScheduleController.php | 12 ++- application/models/Schedule.php | 91 +++++++++++++++++-- .../schedule/get-current-playlist.phtml | 3 + .../scripts/schedule/get-scheduler-time.phtml | 86 ++++++++++++++++++ pypo/pypo-cli.py | 2 +- 6 files changed, 190 insertions(+), 10 deletions(-) create mode 100644 application/views/scripts/schedule/get-current-playlist.phtml create mode 100644 application/views/scripts/schedule/get-scheduler-time.phtml diff --git a/application/configs/navigation.php b/application/configs/navigation.php index c2990f357..0d95dcda6 100644 --- a/application/configs/navigation.php +++ b/application/configs/navigation.php @@ -58,6 +58,12 @@ $pages = array( ) ) ), + array( + 'label' => 'Test', + 'module' => 'default', + 'controller' => 'Schedule', + 'action' => 'get-scheduler-time' + ), array( 'label' => 'Schedule', 'module' => 'default', diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 97b4fd727..d3ffae065 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -18,7 +18,8 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('resize-show', 'json') ->addActionContext('delete-show', 'json') ->addActionContext('schedule-show', 'json') - ->addActionContext('clear-show', 'json') + ->addActionContext('clear-show', 'json') + ->addActionContext('get-current-playlist', 'json') ->initContext(); } @@ -173,6 +174,15 @@ class ScheduleController extends Zend_Controller_Action } } + public function getSchedulerTimeAction() + { + $this->view->headScript()->appendFile('/js/progressbar/jquery.progressbar.min.js','text/javascript'); + } + + public function getCurrentPlaylistAction() + { + $this->view->entries = Schedule::GetPlayOrderRange(); + } } diff --git a/application/models/Schedule.php b/application/models/Schedule.php index b5398809b..f54844024 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -351,7 +351,7 @@ class Schedule { /** - * Returns array indexed numberically of: + * Returns array indexed by: * "playlistId"/"playlist_id" (aliases to the same thing) * "start"/"starts" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn * "end"/"ends" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn @@ -369,7 +369,7 @@ class Schedule { * @param string $p_toDateTime * In the format YYYY-MM-DD HH:MM:SS.nnnnnn * @param boolean $p_playlistsOnly - * Retreive playlists as a single item. + * Retrieve playlists as a single item. * @return array * Returns empty array if nothing found */ @@ -412,19 +412,94 @@ class Schedule { return $rows; } - public function getSchedulerTime() { - + + /** + * Returns the date of the server in the format + * "YYYY-MM-DD HH:mm:SS". + * + * Note: currently assuming that Web Server and Scheduler are on the + * same host. + * + * @return date Current server time. + */ + public static function GetSchedulerTime() { + return date("Y-m-d H:i:s"); } - public function getCurrentlyPlaying() { + /** + * Returns current playlist. + * + * Note: Total playlist length is prev + next + 1 + * + * @param int $prev + * @param int $next + * @return date + */ + public static function GetPlayOrderRange($prev = 1, $next = 1) { + if (!is_int($prev) || !is_int($next)){ + //must enter integers to specify ranges + return "{}"; + } + $timeNow = Schedule::GetSchedulerTime(); + $currentSong = Schedule::getCurrentlyPlaying(); + return array("schedulerTime"=>$timeNow,"previous"=>Schedule::getPreviousItems($timeNow), + "current"=>Schedule::getCurrentlyPlaying($timeNow), + "next"=>Schedule::getNextItems($timeNow)); } - public function getNextItem($nextCount = 1) { - + private static function GetPreviousItems($timeNow, $prevCount = 1){ + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE (starts < TIMESTAMP '$timeNow')" + ." ORDER BY id" + ." LIMIT $prevCount"; + $rows = $CC_DBC->GetAll($sql); + foreach ($rows as &$row) { + $row["count"] = "1"; + $row["playlistId"] = $row["playlist_id"]; + $row["start"] = $row["starts"]; + $row["end"] = $row["ends"]; + $row["id"] = $row["group_id"]; + } + return $rows; } - public function getStatus() { + private static function GetCurrentlyPlaying($timeNow){ + global $CC_CONFIG, $CC_DBC; + + $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE (starts < TIMESTAMP '$timeNow') " + ." AND (ends > TIMESTAMP '$timeNow')"; + $rows = $CC_DBC->GetAll($sql); + foreach ($rows as &$row) { + $row["count"] = "1"; + $row["playlistId"] = $row["playlist_id"]; + $row["start"] = $row["starts"]; + $row["end"] = $row["ends"]; + $row["id"] = $row["group_id"]; + } + return $rows; + } + + private static function GetNextItems($timeNow, $nextCount = 1) { + global $CC_CONFIG, $CC_DBC; + $sql = "SELECT * FROM ".$CC_CONFIG["scheduleTable"] + ." WHERE (starts > TIMESTAMP '$timeNow')" + ." ORDER BY id" + ." LIMIT $nextCount"; + $rows = $CC_DBC->GetAll($sql); + foreach ($rows as &$row) { + $row["count"] = "1"; + $row["playlistId"] = $row["playlist_id"]; + $row["start"] = $row["starts"]; + $row["end"] = $row["ends"]; + $row["id"] = $row["group_id"]; + } + return $rows; + } + + public static function GetStatus() { } diff --git a/application/views/scripts/schedule/get-current-playlist.phtml b/application/views/scripts/schedule/get-current-playlist.phtml new file mode 100644 index 000000000..789c0e6d5 --- /dev/null +++ b/application/views/scripts/schedule/get-current-playlist.phtml @@ -0,0 +1,3 @@ +entries; +?> diff --git a/application/views/scripts/schedule/get-scheduler-time.phtml b/application/views/scripts/schedule/get-scheduler-time.phtml new file mode 100644 index 000000000..8cff686e4 --- /dev/null +++ b/application/views/scripts/schedule/get-scheduler-time.phtml @@ -0,0 +1,86 @@ +
+ +0% +
diff --git a/pypo/pypo-cli.py b/pypo/pypo-cli.py index 3ef5fd095..f57a35a42 100755 --- a/pypo/pypo-cli.py +++ b/pypo/pypo-cli.py @@ -106,7 +106,7 @@ class Global: def selfcheck(self): self.api_client = api_client.api_client_factory(config) if (not self.api_client.is_server_compatible()): - sys.exit() + sys.exit() """ From c437d2f6715bd521d9b7f5c7a7e72e4004c8abf2 Mon Sep 17 00:00:00 2001 From: mkonecny Date: Tue, 21 Dec 2010 18:30:30 -0500 Subject: [PATCH 2/2] -added some required files. --- public/js/progressbar/images/progressbar.gif | Bin 0 -> 120 bytes .../js/progressbar/images/progressbg_black.gif | Bin 0 -> 1626 bytes .../js/progressbar/images/progressbg_green.gif | Bin 0 -> 1308 bytes .../js/progressbar/images/progressbg_orange.gif | Bin 0 -> 1308 bytes public/js/progressbar/images/progressbg_red.gif | Bin 0 -> 1308 bytes .../js/progressbar/images/progressbg_yellow.gif | Bin 0 -> 1308 bytes public/js/progressbar/jquery.progressbar.min.js | 9 +++++++++ 7 files changed, 9 insertions(+) create mode 100644 public/js/progressbar/images/progressbar.gif create mode 100644 public/js/progressbar/images/progressbg_black.gif create mode 100644 public/js/progressbar/images/progressbg_green.gif create mode 100644 public/js/progressbar/images/progressbg_orange.gif create mode 100644 public/js/progressbar/images/progressbg_red.gif create mode 100644 public/js/progressbar/images/progressbg_yellow.gif create mode 100644 public/js/progressbar/jquery.progressbar.min.js diff --git a/public/js/progressbar/images/progressbar.gif b/public/js/progressbar/images/progressbar.gif new file mode 100644 index 0000000000000000000000000000000000000000..abe588c15c4eda53bcecc0ab00434c925cb1b45f GIT binary patch literal 120 zcmV-;0EhoaNk%w1VS4}!0FeLyVr61;d3%F}ga7~kA^8LW2LJ;AEC2ui0DAxo0006> zT!5*|?GK}zlnMie-n{z{hT=$;rU?ky$+qqbpGZvC_U+C1&iA733kq?-q4CHnBA3kE astJWEqtqebP|XTcn2Prc4vQz30suSWax&ro literal 0 HcmV?d00001 diff --git a/public/js/progressbar/images/progressbg_black.gif b/public/js/progressbar/images/progressbg_black.gif new file mode 100644 index 0000000000000000000000000000000000000000..74fd1f9b3e052e2ca18058526c39f6eaef580cba GIT binary patch literal 1626 zcmZ?wbhEHb{J_A&(9XcX%*^cP=jZS5KWEOIsZ*!+_xJbq_I7u7Po6xvt*x!5rlz8z zqNJpxtgNh|p`od%simc*s;a84uI|&PPaPc{A3uIfN=iydNQjM%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w0etE23elO60 G!5RRh`|ElD literal 0 HcmV?d00001 diff --git a/public/js/progressbar/images/progressbg_green.gif b/public/js/progressbar/images/progressbg_green.gif new file mode 100644 index 0000000000000000000000000000000000000000..f3f3bf681141982dc72429b21b4c8af7dbfd2b70 GIT binary patch literal 1308 zcmZ?wbhEHb{J_A&(9Xb+l$vz#b;JHwRXbng?Rb&B?RnasS0x*s#jbelz3h?O(udAV z9y+ak61L%K)Yq?HH$P8Y{Uo6GmT=cio{6`mr`}bWa!0ZCI#bJahEJb9wclWS_Uzf+ zyLWHhy2UUGMnhmIgn$mnk)XW5&hd|dkweB~!-9j&9Ku>LCpIiR+%BN(HOFIP(jf*W zwhS4E28YIeHYceEFFrCfv2cm4h}qfT*gV}pdWOr%qNS&2=%+7Rb5kh&++^$Qdq+5@ zr2Ege3b%?lwPoeyib#-+FZ^@S*8xJ(IGrLXtbE9F|#f27UKe5 ze|J*~xABYU9Yq^o-95d1ef*l(y>+$)4F@6)^1Qisbmol}Ub}dutlM;c>fAZiotzZ* zYy0Ns=NHVbt9AIH+I(O!zd^woA*M@L*Tg;!Ia}5EX2zD}{nu=zw_Ut&pqYDq)d3S` zHUT*fwcK6ba%Y~ceBSf!N9D&8=L&-4Me zP3E%uP5-?5zPkJV`T6-R96~G>jI5#}84p;*Vir7T;&w}T(9B_^v9Ot6Ok!aRZ&*fR zlZ2K>Vyk%455*RlvKI<$8p~EZ>eAWv;!(H3F^$JPCf76^*(4(j9yO{aX*9Npw!BcD z;NcrZz&%;MSPv^WQ~ z{>*hd6K7|Xy-1r7pts`*Tg9`L&*#;Ad-;5R1Dn>11ubG#YLk*?Sw3g!Jms0P*jb5d y`I5e%sLV#0lvOX6%_)2Ja`}Qbtye3SOv_s3x?NSD+|H4{TcmQQK=FDE)AcBZPoF;Bh+}*9?AhJB zcW>Rg#V`s+LtrR`fDXu!puE7&@sEL#L&jsnf`iQ*!dfvWHY_~cE}-l+$75sCAqFP4 z3>k+8hsJ(3C#eT7J~A}1aEYym+1cROJl#NghReyKrKe};r!QM`Qz-r1Wb5pEM>waX z`_H!uw~9EmW##4N0gJundTm{Gb#(-9$(J7+4>YqgyG{CYqhZ;_g%)Q&xkv}E4VbTg zcT){F>Okb+!c!2O@x`_~7tAX8S&wrq>5&iEggpEB^fJ^sDeq z=Cb=u|GfIXy8Hh5`S~pzLM#@HtfC?r4_L%v7CdO;c1w8B%weRlu$f;>Vqpt!SVm%# zgqBBQt9a56#TJ>e7Yb||%T_$<(%JUnQMbV{jmJGE*EAg2BqIzSHL50QG`5MhyilIt zcNYT3{5OtVk=^HHaIplm6UjSaxxt#o13T(!py3=Ih_x zl)`QNB6>&B##eVwZ(kq3CU$R~Z9&6j7-=kQ<`8D%fhCIsm1c*0ikY~}NLHQ!!7pWncy^ wFDNRrQ6^>8%Vl%QUcFqtpiS%5iY3#sR=KWNw(8ZYHQQdjTFuPH%EDj`0N~Rv?EnA( literal 0 HcmV?d00001 diff --git a/public/js/progressbar/images/progressbg_yellow.gif b/public/js/progressbar/images/progressbg_yellow.gif new file mode 100644 index 0000000000000000000000000000000000000000..fdb0dfc981cbbfbca4e80f4ff5ccfac247b3be91 GIT binary patch literal 1308 zcmZ?wbhEHb{J_A&(9Xb+nws?bX~U~0RWBaqy?B`Y{6X5Q$0g71#Xi36{phCK!yC>I zZ#X@<6ZZ6O)Yq?HpFc=^awp){dEuMqcy3>izI$2a&Lzd`r?arL;I#qs z_3v&<;WmB|y`yO3tGlPSua937ySL7^py5EoL7q4Fj?TQX!fO|=ly#fVPn|obx|5T_ zer@0U{QQF1b+ryZRGSYh<~JxYCWcA!n-^-^|#Oy#Jc5^tOu^4m5MmuR37D z%qAemp_aSrTkg!WmCt+L{iytS;#^_y^UPZ7^A8^!{>N-&c3vKR-Xeg+qwNf{|5JB;x^#Sj>V4P26q?51KiQG!{1Vi%BeO;SI}3 zY?9FONNg2P`k~k&Q}#lEO=H=LM_oGGUOehHIHvKq$K;xZBb#J|!J|giB#p*4(Uup= z6P&z$EN*i(s!-{$)$&Z4>=(A+;FOTC%%@W$(pEm57E|`}>GXuO1rH{vlvzBRoEGPx z)}Ogh1UM^qIruAyYl4)71Tvsex^=j3cZLeOfW@ck$VXy`OH^w~^ literal 0 HcmV?d00001 diff --git a/public/js/progressbar/jquery.progressbar.min.js b/public/js/progressbar/jquery.progressbar.min.js new file mode 100644 index 000000000..4689bc4d2 --- /dev/null +++ b/public/js/progressbar/jquery.progressbar.min.js @@ -0,0 +1,9 @@ + +(function($){$.extend({progressBar:new function(){this.defaults={increment:2,speed:15,showText:true,width:120,boxImage:'/js/progressbar/images/progressbar.gif',barImage:'/js/progressbar/images/progressbg_green.gif',height:12};this.construct=function(arg1,arg2){var argpercentage=null;var argconfig=null;if(arg1!=null){if(!isNaN(arg1)){argpercentage=arg1;if(arg2!=null){argconfig=arg2;}}else{argconfig=arg1;}} +return this.each(function(child){var pb=this;if(argpercentage!=null&&this.bar!=null&&this.config!=null){this.config.tpercentage=argpercentage;if(argconfig!=null) +pb.config=$.extend(this.config,argconfig);}else{var $this=$(this);var config=$.extend({},$.progressBar.defaults,argconfig);var percentage=argpercentage;if(argpercentage==null) +var percentage=$this.html().replace("%","");$this.html("");var bar=document.createElement('img');var text=document.createElement('span');bar.id=this.id+"_percentImage";text.id=this.id+"_percentText";bar.src=config.boxImage;bar.width=config.width;var $bar=$(bar);var $text=$(text);this.bar=$bar;this.ntext=$text;this.config=config;this.config.cpercentage=0;this.config.tpercentage=percentage;$bar.css("width",config.width+"px");$bar.css("height",config.height+"px");$bar.css("background-image","url("+config.barImage+")");$bar.css("padding","0");$bar.css("margin","0");$this.append($bar);$this.append($text);bar.alt=this.tpercentage;bar.title=this.tpercentage;} +var t=setInterval(function(){var config=pb.config;var cpercentage=parseInt(config.cpercentage);var tpercentage=parseInt(config.tpercentage);var increment=parseInt(config.increment);var bar=pb.bar;var text=pb.ntext;var pixels=config.width/100;bar.css("background-position",(((config.width*-1))+(cpercentage*pixels))+'px 50%');if(config.showText) +text.html(" "+Math.round(cpercentage)+"%");if(cpercentage>tpercentage){if(cpercentage-incrementtpercentage){pb.config.cpercentage=tpercentage}else{pb.config.cpercentage+=increment;}} +else{clearInterval(t);}},pb.config.speed);});};}});$.fn.extend({progressBar:$.progressBar.construct});})(jQuery);