فهرست منبع

Made private rooms display gray and only display for moderators and admins.

KrisVos130 9 سال پیش
والد
کامیت
da39ee34ac
2فایلهای تغییر یافته به همراه42 افزوده شده و 25 حذف شده
  1. 15 13
      app/client/client.js
  2. 27 12
      app/client/templates/dashboard.html

+ 15 - 13
app/client/client.js

@@ -229,7 +229,7 @@ Template.header.helpers({
         } else {
             return false;
         }
-    },
+    }
 });
 
 Template.header.events({
@@ -343,6 +343,20 @@ Template.dashboard.helpers({
         } else {
             return {};
         }
+    },
+    isAdmin: function() {
+        if (Meteor.user() && Meteor.user().profile) {
+            return Meteor.user().profile.rank === "admin";
+        } else {
+            return false;
+        }
+    },
+    isModerator: function() {
+        if (Meteor.user() && Meteor.user().profile && (Meteor.user().profile.rank === "admin" || Meteor.user().profile.rank === "moderator")) {
+            return true;
+        } else {
+            return false;
+        }
     }
 });
 
@@ -361,18 +375,6 @@ Template.dashboard.onCreated(function() {
     Session.set("type", undefined);
 });
 
-Template.dashboard.onRendered(function(){
-    Rooms.find().fetch().forEach(function(room){
-        if(room.private === true){
-            $(".station h3").each(function(i, el){
-                if($(el).text() === room.display && Meteor.user().profile.rank !== "admin"){
-                    $(el).parent().css("display", "none");
-                }
-            })
-        }
-    })
-})
-
 function executeCommand(command, params){
     if (command === "help" || command === "commands") {
         $('#helpModal').modal('show');

+ 27 - 12
app/client/templates/dashboard.html

@@ -1,16 +1,31 @@
 <template name="dashboard">
     <div class="row">
-       {{#each rooms}}
-          <div class="col-md-4 col-sm-6 col-xs-12">
-              <div class="station">
-                  <h3>{{display}}</h3>
-                  {{#with type=type}}
-                      <h5>{{currentSong.song.title}}</h5>
-                      <h6>{{currentSong.song.artist}}</h6>
-                  {{/with}}
-                  <a href="/{{type}}" class="station_link"></a>
-              </div>
-          </div>
-       {{/each}}
+        {{#each rooms}}
+            {{#if private}}
+                {{#if isModerator}}
+                    <div class="col-md-4 col-sm-6 col-xs-12">
+                        <div class="station" style="background-color: gray">
+                            <h3>{{display}}</h3>
+                            {{#with type=type}}
+                                <h5>{{currentSong.song.title}}</h5>
+                                <h6>{{currentSong.song.artist}}</h6>
+                            {{/with}}
+                            <a href="/{{type}}" class="station_link"></a>
+                        </div>
+                    </div>
+                {{else}}
+                    <div class="col-md-4 col-sm-6 col-xs-12">
+                        <div class="station">
+                            <h3>{{display}}</h3>
+                            {{#with type=type}}
+                                <h5>{{currentSong.song.title}}</h5>
+                                <h6>{{currentSong.song.artist}}</h6>
+                            {{/with}}
+                            <a href="/{{type}}" class="station_link"></a>
+                        </div>
+                    </div>
+                {{/if}}
+            {{/if}}
+        {{/each}}
     </div>
 </template>