浏览代码

added disliked songs on profile page

Akira Laine 9 年之前
父节点
当前提交
98093da7cb
共有 2 个文件被更改,包括 29 次插入1 次删除
  1. 16 0
      app/client/client.js
  2. 13 1
      app/client/templates/profile.html

+ 16 - 0
app/client/client.js

@@ -82,6 +82,21 @@ Template.profile.helpers({
             })
             })
         });
         });
         return likedArr;
         return likedArr;
+    },
+    dislikedSongs: function(){
+        var dislikedArr = [];
+        Session.get("disliked").forEach(function(mid){
+            Rooms.find().forEach(function(room){
+                Playlists.find({type: room.type}).forEach(function(pl){
+                    for(var i in pl.songs){
+                        if(pl.songs[i].mid === mid){
+                            dislikedArr.push({title: pl.songs[i].title, artist: pl.songs[i].artist, room: room.display});
+                        }
+                    }
+                });
+            })
+        });
+        return dislikedArr;
     }
     }
 });
 });
 
 
@@ -98,6 +113,7 @@ Template.profile.onCreated(function() {
             Session.set("first_joined", data.createdAt);
             Session.set("first_joined", data.createdAt);
             Session.set("rank", data.profile.rank);
             Session.set("rank", data.profile.rank);
             Session.set("liked", data.profile.liked);
             Session.set("liked", data.profile.liked);
+            Session.set("disliked", data.profile.disliked);
             Session.set("loaded", true);
             Session.set("loaded", true);
         }
         }
     });
     });

+ 13 - 1
app/client/templates/profile.html

@@ -6,7 +6,7 @@
         {{#if loaded}}
         {{#if loaded}}
             <h1 id="profile-name">{{username}}</h1>
             <h1 id="profile-name">{{username}}</h1>
 
 
-            <div class="col-md-4 col-md-offset-2">
+            <div class="col-md-4">
                 <div class="panel panel-primary">
                 <div class="panel panel-primary">
                     <div class="panel-heading">Basic Info</div>
                     <div class="panel-heading">Basic Info</div>
                     <div class="panel-body">
                     <div class="panel-body">
@@ -29,6 +29,18 @@
                     </div>
                     </div>
                 </div>
                 </div>
             </div>
             </div>
+            <div class="col-md-4">
+                <div class="panel panel-danger">
+                    <div class="panel-heading">Disliked Songs</div>
+                    <div class="panel-body">
+                        <ul>
+                            {{#each dislikedSongs}}
+                                <li>{{title}} - {{artist}} - {{room}}</li>
+                            {{/each}}
+                        </ul>
+                    </div>
+                </div>
+            </div>
         {{else}}
         {{else}}
             {{> loading}}
             {{> loading}}
         {{/if}}
         {{/if}}