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

Made current song title display for each room on dashboard.

KrisVos130 9 жил өмнө
parent
commit
8710811e0c

+ 17 - 4
app/app.js

@@ -174,10 +174,23 @@ if (Meteor.isClient) {
     });
 
     Template.dashboard.helpers({
-      rooms: function() {
-        return Rooms.find({});
-      }
-    })
+        rooms: function() {
+          return Rooms.find({});
+        },
+        currentSong: function() {
+            var history = History.find({type: this.type}).fetch();
+            if (history.length < 1) {
+                return {};
+            } else {
+                history = history[0];
+                return history.history[history.history.length - 1];
+            }
+        }
+    });
+
+    Template.dashboard.onCreated(function() {
+        Meteor.subscribe("history");
+    });
 
     Template.room.events({
         "click #add-song-button": function(e){

+ 3 - 1
app/templates/dashboard.html

@@ -5,7 +5,9 @@
               <div class="col-md-4 col-sm-6 col-xs-12">
                   <div class="station">
                       <h3>{{type}}</h3>
-                      <h5>Song</h5>
+                      {{#with type=type}}
+                        <h5>{{currentSong.song.title}}</h5>
+                      {{/with}}
                       <a href="/{{type}}" class="station_link"></a>
                   </div>
               </div>