"Now Playing" Admin page -> Only valid Shows in "Filter by show" dropdown menu and jquery tweaks
  • Hi all.
    Fist of all excuse my English (i am from Greece). Also excuse me if someone has already given a solution to this that i am unaware of.

    I am using the "Now Playing" tab to Schedule my shows once a week because i find it the fastest way possible.
    With selecting a whole week from the Start-End calendar (starting 00:00 ending 23:55) i can quickly add a specific block (lets say "Classic Rock") to every suitable show (for example a show also named Classic Rock) by selecting it from the "Filter by show" dropdown menu.
    So for a whole week if i select the show i will see 7 entries and by holding control key and marking each cursor underneath the show i can then press "Add to selected show" and voila all 7 days are ready for this show.

    The problem here was that this dropdown list is showing all the shows you ever created even if they are inactive and by inactive i mean they are not scheduled in any future date so as you imagine in a period of 1,5 year experimenting i had a list with many many records with the same name most of them useless and i had to check each item in the list one by one to find out if there is something scheduled or not.

    For anyone using the same page, my solution was this (have in mind that i have version 2.5.1 so every "hack" applies to that version)
    I went to the file ShowBuilder.php (/usr/share/airtime/application/forms/ShowBuilder.php) and modified the getShowNames() function.
    After many experiments (i tried at first to modify the CcShowQuery) i concluded to this:

    private function getShowNames()
        {
            $showNames = array("0" => "-------------------------");

            $shows = CcShowQuery::create()
                ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
                ->orderByDbName()
                ->find();

            $utcTimezone = new DateTimeZone("UTC");
            $nowDateTime = new DateTime("now", $utcTimezone);

            foreach ($shows as $show) {

                $showInstances = CcShowInstancesQuery::create()
                ->filterByDbShowId($show->getDbId())
                ->filterByDbStarts($nowDateTime->format("Y-m-d H:i:s"), Criteria::GREATER_EQUAL)
                ->find();

                 if (array_key_exists("0",$showInstances)){
                    $showNames[$show->getDbId()] = $show->getDbName();
                 }
            }
            return $showNames;
        }

    so what i am doing is for every show i check if there is an instance for this show with a future date (greater or equal than now). 
    If there is (the object will be an array) then i add it to the array that will fill the dropdown list.
    Maybe there is a better way but this works for me.


    I will post some jquery changes for cursors on that page.

    Hope this comes handy to some people :)
    Post edited by Stathis Simos at 2015-11-19 11:57:13
  • 2 Comments sorted by
  • CURSORS

    Now for the cursors, i did some jquery tweaks in order to make my life easier.

    Every time i do the week scheduling as i described above, i user the cursors. 
    The first thing i want to do is to add some jingles at the beggining of each show, so for a whole week i need to hold the control key and click EVERY cursor on the empty shows in order to add a playlist (with the jingles) there.
    This is very time consuming.

    Also after i add the jingles i select each show from the dropdownlist and on the 7 records i get (for the week) i need to add specific blocks under the jingles i just added. To do this i also need to select every last cursor on every show.

    So what i did is that i added a dropdown menu like the "Select" on that page, that is called "Select Cursors"
    There i have 2 options
    1) Select last -> selects every last cursor on every show (and finally the very last cursor on the list)
    2) Select none -> that disselects the selected cursors

    We could use a "Select all" but personally i dont find it needed as selecting every last cursor in a show is sufficient enough (when shows are empty is like selecting all cursors).

    The above changes are done to the builder.js file (/usr/share/airtime/public/js/airtime/showbuilder/builder.js)

    I dont have the line numbers since i didnt keep them before the changes but here it is...

    first we add this line:
    headers = [],

    we add this under the "cursors = []," (about line 13)

    Then we add 2 new functions. I added them after the function mod.removeCursor
    Here is the code i created (i am not that good at jquery so you may have a much better way for this)

    1)

        mod.selectLastCursors = function($el) {
            mod.selectCursor($(".sb-future:last"));
            mod.selectCursor($(".ui-state-error:last"));

            headers = $(".sb-header");

            for (i = 0; i < headers.length; i++) {
              mod.selectCursor($(headers.get(i)).prev(".ui-state-error"));
              mod.selectCursor($(headers.get(i)).prev(".sb-future"));
            }

            mod.checkToolBarIcons();
        };


    2)

        mod.selectNoCursors = function () {
            cursors = $(".cursor-selected-row");

            for (i = 0; i < cursors.length; i++) {
                mod.removeCursor($(cursors.get(i)));
            }

            mod.checkToolBarIcons();
        };


    Then on the menu creation (search for $menu) i have changed it to (with bold the additions):

            $menu = $("<div class='btn-toolbar'/>");
            $menu.append("<div class='btn-group'>" +
                         "<button class='btn btn-small dropdown-toggle'  id='timeline-select' data-toggle='dropdown'>" +
                             $.i18n._("Select")+" <span class='caret'></span>" +
                         "</button>" +
                         "<ul class='dropdown-menu'>" +
                             "<li id='timeline-sa'><a href='#'>"+$.i18n._("Select all")+"</a></li>" +
                             "<li id='timeline-sn'><a href='#'>"+$.i18n._("Select none")+"</a></li>" +
                         "</ul>" +
                         "</div>")
                .append("<div class='btn-group'>" +
                         "<button class='btn btn-small dropdown-toggle'  id='cursor-select' data-toggle='dropdown'>" +
                             $.i18n._("Select Cursors")+" <span class='caret'></span>" +
                         "</button>" +
                         "<ul class='dropdown-menu'>" +
                             "<li id='cursor-sl'><a href='#'>"+$.i18n._("Select last")+"</a></li>" +
                             "<li id='cursor-sn'><a href='#'>"+$.i18n._("Select none")+"</a></li>" +
                         "</ul>" +
                         "</div>")
                .append("<div class='btn-group'>" +
                        "<button title='"+$.i18n._("Remove overbooked tracks")+"' class='ui-state-disabled btn btn-small' disabled='disabled'>" +
                        "<i class='icon-white icon-cut'></i></button></div>")
                .append("<div class='btn-group'>" +
                        "<button title='"+$.i18n._("Remove selected scheduled items")+"' class='ui-state-disabled btn btn-small' disabled='disabled'>" +
                        "<i class='icon-white icon-trash'></i></button></div>");


    Finally under the line "$('#timeline-sn').click(function(){mod.selectNone();});" i added the following 3 lines:
            $('#cursor-sl').click(function(){mod.selectLastCursors();});
            $('#cursor-sn').click(function(){mod.selectNoCursors();});

    That's it. You now have a new dropdown menu that you can select all every last cursor in a show or disselect them.
    Post edited by Stathis Simos at 2015-11-19 11:35:30
  • A new "hack" to have a genre column in the schedule list and be able to select rows by filtering with genre

    I dont know if this is needed by anybody. Created it for another reason but i think the best place for this is here.

    Here is what i have done in the "now playing" tab (that is also used in the calendar in most cases).. 

    First of all i dont care to see the column "album" in the schedule list so i changed it to "genre" like that:
    In the file application/models/Schedule.php
    i changed the line ft.file_album_title AS file_album_title, to ft.genre AS file_album_title, (used an existing column to avoid any other changes)

    In the public/js/airtime/showbuilder/builder.js file
    Just under the $menu.append("<div class='btn-group'>" + Added the two rows below:
    "<label style='vertical-align: middle;'>Genre contains:</label>" +
    "<input type='text' id='txtGenre' style='width:70px; margin-right: 5px; background-color: #dddddd; vertical-align: middle;'></input>" +

    and changed the mod.selectAll function like that:

    mod.selectAll = function () {

            if ($("#txtGenre").val() != ""){
                    $genre = $('#txtGenre').val();
                    $row = $(".sb-album:contains('" + $genre + "')").parent()
                    $row.find("input:checkbox").attr("checked", true);
                    $row.find("input:checkbox").parents("tr").addClass(SB_SELECTED_CLASS);
            }
            else
            {
                    $inputs = $sbTable.find("input:checkbox");
                    $inputs.attr("checked", true);
                    $trs = $inputs.parents("tr");
                    $trs.addClass(SB_SELECTED_CLASS);
            }

            mod.checkToolBarIcons();
        };

    Also i changed the line
    /* album */ {"mDataProp": "album", "sTitle": $.i18n._("Album"), "sClass": "sb-album"},
    to
    /* album */ {"mDataProp": "album", "sTitle": $.i18n._("Genre"), "sClass": "sb-album"},

    Just to show the correct label...

    So now you have a genre column in the schedule (right) list and also a textbox before the "Select" dropdown that if it has text then the "select all" only selects rows that "genre" column contains that text.
    Post edited by Stathis Simos at 2015-12-22 18:23:11