2
0
Эх сурвалжийг харах

Queue functionality. 50%

I have about nearly 50% of the queue functionality done here. Will have
the rest tonight. However, we can now see the amount of songs in the
queue cleanly. I will be working on adding in accepting songs.
Wesley McCann 9 жил өмнө
parent
commit
ff754ff8fe

+ 1 - 1
app/client/app.css

@@ -1317,4 +1317,4 @@ nav form input[type="image"]{
     width: 28px;
     height: 28px;
     font-size: 28px !important;
-}
+}

+ 21 - 13
app/client/client.js

@@ -315,7 +315,7 @@ Template.room.events({
             }
         }
     },
-    "click #side-panel": function(e) { 
+    "click #side-panel": function(e) {
         Meteor.setTimeout(function() {
         var elem = document.getElementById('chat');
         elem.scrollTop = elem.scrollHeight;;
@@ -813,15 +813,17 @@ Template.alertsDashboard.events({
 });
 
 Template.admin.helpers({
-  queueCount: function(i) {
-      var queues = Queues.find({}).fetch();
-      
-      if (!queues[i]) {
-        return 0;
-      }
-      else {
-        return queues[i].songs.length;
-      }
+  queueCount: function(display) {
+    display = display.toLowerCase();
+    var queues = Queues.findOne({type:display});
+    return queues && "songs" in queues ? queues.songs.length : 0;
+  },
+  queues: function() {
+    var queues = Queues.find({}).fetch();
+    queues.map(function(queue) {
+      return queue;
+    });
+    return queues;
   },
   users: function(){
       Meteor.call("getUserNum", function(err, num){
@@ -843,11 +845,17 @@ Template.admin.helpers({
           }
       });
       return playlists;
-  },
+  }/*,
   reports: function() {
       var reports = Reports.find({}).fetch();
-      console.log(reports);
-  }
+      reports.findOne(
+        {
+          $eq: [
+
+          ]
+        }
+      )
+  }*/
 });
 
 Template.stations.helpers({

+ 29 - 4
app/client/templates/admin.html

@@ -5,6 +5,7 @@
           <div class="row" style="margin-top: 20px; height: 100%;">
             <div class="col-md-5 col-md-offset-1 admin-container" style="height: 50%;">
               <h1>Playlists</h1>
+              <div>
               {{#each playlists}}
                 <p>{{display}} playlist</p>
                 <table class="table" style="border-bottom: 1px solid white;">
@@ -19,23 +20,47 @@
                     <td>{{songs.length}}</td>
                     <td></td>
                     <td></td>
-                    <td>{{reports}}</td>
-                    <td>{{queueCount @index}}</td>
+                    <td></td>
+                    <td>{{queueCount display}}</td>
                     <td><a href="/stations">Edit</a></td>
                   </tr>
                 </table>
               {{/each}}
+              </div>
             </div>
             <div class="col-md-4 col-md-offset-1 admin-container" style="height: 30%;">
               <h1>Site statistics</h1>
-              <p>Total Users: {{{users}}}</p>
+              <p>Total Users Online: {{users}}</p>
             </div>
             <div style="clear: both;"></div>
                 <div class="col-md-5 col-md-offset-1 admin-container" style="height: 50%;">
-                    <h1>Reports</h1>
+                    <h1>Queue</h1>
+                    {{#each queues}}
+                    <p>{{type}} playlist</p>
+                    <table class="table" style="border-bottom: 1px solid white;">
+                      <tr>
+                        <th>Title</th>
+                        <th>Artist</th>
+                        <th>Duration</th>
+                        <th>Type</th>
+                      </tr>
+                      {{#each songs}}
+                      <tr>
+                        <td>{{this.title}}</td>
+                        <td>{{this.artist}}</td>
+                        <td>{{this.duration}}</td>
+                        <td>{{this.type}}</td>
+                        <!--<td><a href="/stations">Edit</a></td>-->
+                      </tr>
+                      {{/each}}
+                    </table>
+                    {{/each}}
                 </div>
                 <div class="col-md-4 col-md-offset-1 admin-container" style="height: 50%">
                     <h1>Reports</h1>
+                    {{#each reports}}
+                      <p>{{reports}}</p>
+                    {{/each}}
                 </div>
           </div>