Browse Source

Merge remote-tracking branch 'origin/master'

KrisVos130 9 years ago
parent
commit
4c8ad979c0

+ 12 - 1
app/client/app.css

@@ -267,6 +267,17 @@ ul {
   padding-bottom: 10px;
   text-align: center;
 }
+
+.admin-container div a {
+  text-decoration: none;
+  font-size: 22px;
+  padding-left: 5px;
+  vertical-align: top;
+}
+
+.admin-container div a:hover {
+  text-decoration: none;
+}
 .admin-container h1 {
   margin: 0;
   display: inline-block;
@@ -1474,4 +1485,4 @@ input[type="checkbox"]:checked + #two-label:after {
 
 .unread-messages {
     background-color: orange;
-}
+}

+ 52 - 90
app/client/client.js

@@ -724,74 +724,25 @@ Template.room.events({
         }
     },
     "click #report-song-button": function() {
-        var report = {};
-        report.reportSongB = $("#report-song").is(":checked");
-        report.reportTitleB = $("#report-title").is(":checked");
-        report.reportAuthorB = $("#report-author").is(":checked");
-        report.reportDurationB = $("#report-duration").is(":checked");
-        report.reportAudioB = $("#report-audio").is(":checked");
-        report.reportAlbumartB = $("#report-albumart").is(":checked");
-        report.reportOtherB = $("#report-other").is(":checked");
-
-        if (report.reportSongB) {
-            report.reportSong = {};
-            report.reportSong.notPlayingB = $("#report-song-not-playing").is(":checked");
-            report.reportSong.doesNotExistB = $("#report-song-does-not-exist").is(":checked");
-            report.reportSong.otherB = $("#report-song-other").is(":checked");
-            if (report.reportSong.otherB) {
-                report.reportSong.other = $("#report-song-other-ta").val();
-            }
-        }
-        if (report.reportTitleB) {
-            report.reportTitle = {};
-            report.reportTitle.incorrectB = $("#report-title-incorrect").is(":checked");
-            report.reportTitle.inappropriateB = $("#report-title-inappropriate").is(":checked");
-            report.reportTitle.otherB = $("#report-title-other").is(":checked");
-            if (report.reportTitle.otherB) {
-                report.reportTitle.other = $("#report-title-other-ta").val();
-            }
-        }
-        if (report.reportAuthorB) {
-            report.reportAuthor = {};
-            report.reportAuthor.incorrectB = $("#report-author-incorrect").is(":checked");
-            report.reportAuthor.inappropriateB = $("#report-author-inappropriate").is(":checked");
-            report.reportAuthor.otherB = $("#report-author-other").is(":checked");
-            if (report.reportAuthor.otherB) {
-                report.reportAuthor.other = $("#report-author-other-ta").val();
-            }
-        }
-        if (report.reportDurationB) {
-            report.reportDuration = {};
-            report.reportDuration.longB = $("#report-duration-incorrect").is(":checked");
-            report.reportDuration.shortB = $("#report-duration-inappropriate").is(":checked");
-            report.reportDuration.otherB = $("#report-duration-other").is(":checked");
-            if (report.reportDuration.otherB) {
-                report.reportDuration.other = $("#report-duration-other-ta").val();
-            }
-        }
-        if (report.reportAudioB) {
-            report.reportAudio = {};
-            report.reportAudio.inappropriate = $("#report-audio-inappropriate").is(":checked");
-            report.reportAudio.notPlayingB = $("#report-audio-incorrect").is(":checked");
-            report.reportAudio.otherB = $("#report-audio-other").is(":checked");
-            if (report.reportAudio.otherB) {
-                report.reportAudio.other = $("#report-audio-other-ta").val();
-            }
-        }
-        if (report.reportAlbumartB) {
-            report.reportAlbumart = {};
-            report.reportAlbumart.incorrectB = $("#report-albumart-incorrect").is(":checked");
-            report.reportAlbumart.inappropriateB = $("#report-albumart-inappropriate").is(":checked");
-            report.reportAlbumart.notShowingB = $("#report-albumart-inappropriate").is(":checked");
-            report.reportAlbumart.otherB = $("#report-albumart-other").is(":checked");
-            if (report.reportAlbumart.otherB) {
-                report.reportAlbumart.other = $("#report-albumart-other-ta").val();
-            }
-        }
-        if (report.reportOtherB) {
-            report.other = $("#report-other-ta").val();
-        }
-        Meteor.call("submitReport", report, Session.get("id"), function() {
+        var room = Session.get("type");
+        var reportData = {};
+        reportData.song = Session.get("currentSong").mid;
+        reportData.type = [];
+        reportData.reason = [];
+
+        $(".report-layer-1 > .checkbox input:checked").each(function(){
+          reportData.type.push(this.id);
+          if (this.id == "report-other") {
+            var otherText = $(".other-textarea").val();
+          }
+        });
+
+        $(".report-layer-2 input:checked").each(function(){
+          reportData.reason.push(this.id);
+        });
+
+        console.log(reportData);
+        Meteor.call("submitReport", room, reportData, Session.get("id"), function() {
             $("#close-modal-r").click();
         });
     }
@@ -1075,7 +1026,7 @@ Template.admin.helpers({
     var queues = Queues.find({}).fetch();
     return queues;
   },
-  users: function(){
+  usersOnline: function(){
       Meteor.call("getUserNum", function(err, num){
           if(err){
               console.log(err);
@@ -1084,6 +1035,8 @@ Template.admin.helpers({
       });
       return Session.get("userNum");
   },
+  allUsers: function(){
+  },
   playlists: function() {
       var playlists = Playlists.find({}).fetch();
       playlists.map(function(playlist) {
@@ -1095,31 +1048,40 @@ Template.admin.helpers({
           }
       });
       return playlists;
-  }/*,
-  reports: function() {
-      var reports = Reports.find({}).fetch();
-      reports.findOne(
-        {
-          $eq: [
+  },
+  reportsCount: function(room) {
+    room = room.toLowerCase();
+    var reports = Reports.findOne({room:room});
+    return reports && "report" in reports ? reports.report.length : 0;
+  }
+});
 
-          ]
-        }
-      )
-  }*/
+Template.admin.events({
+  "click #croom_create": function() {
+      Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), function (err, res) {
+          if (err) {
+              alert("Error " + err.error + ": " + err.reason);
+          } else {
+              window.location = "/" + $("#croom_tag").val();
+          }
+      });
+  },
+  "click a": function(e){
+    var id = e.currentTarget.id;
+    console.log(id.toLowerCase());
+    Session.set("playlistToEdit", id);
+  }
 });
 
 Template.stations.helpers({
-    playlists: function() {
-        var playlists = Playlists.find({}).fetch();
-        playlists.map(function(playlist) {
-            if (Rooms.find({type: playlist.type}).count() !== 1) {
-                return;
-            } else {
-                playlist.display = Rooms.findOne({type: playlist.type}).display;
-                return playlist;
-            }
-        });
-        return playlists;
+    playlist: function() {
+      var query = {type: Session.get("playlistToEdit").toLowerCase()};
+      var playlists = Playlists.find(query).fetch();
+      console.log(Session.get("playlistToEdit"), query, playlists);
+      return playlists;
+    },
+    whichStation: function(){
+      return Session.get("playlistToEdit");
     }
 });
 

+ 37 - 43
app/client/templates/admin.html

@@ -3,12 +3,12 @@
     <div class="landing">
         {{> header}}
           <div class="row" style="margin-top: 20px; height: 100%;">
-            <div class="col-md-5 col-md-offset-1 admin-container" style="height: 50%;">
+            <div class="col-md-6 col-md-offset-1 admin-container" style="height: 80%;">
               <div>
-                <h1>Playlists</h1>
+                <h1>Stations</h1><a href="#" data-toggle="modal" data-target="#addStation">(+)</a>
               </div>
               {{#each playlists}}
-                <p>{{display}} playlist</p>
+                <p>{{display}}</p>
                 <table class="table" style="border-bottom: 1px solid white;">
                   <tr>
                     <th>Songs</th>
@@ -21,56 +21,50 @@
                     <td>{{songs.length}}</td>
                     <td></td>
                     <td></td>
-                    <td></td>
+                    <td>{{reportsCount display}}</td>
                     <td>{{queueCount display}}</td>
-                    <td><a href="/admin/stations">Edit</a></td>
+                    <td><a href="/admin/stations" id={{display}}>Edit</a></td>
                   </tr>
                 </table>
               {{/each}}
             </div>
-            <div class="col-md-4 col-md-offset-1 admin-container" style="height: 30%;">
+            <div class="col-md-3 col-md-offset-1 admin-container" style="height: 80%;">
               <div>
                 <h1>Site statistics</h1>
               </div>
-              <p>Total Users Online: {{users}}</p>
+              <p>Total Users Online: {{usersOnline}}</p>
+              <p>Total Registered Users: </p>
+              <a href="/admin/queues">Edit the queues</a>
             </div>
-            <div style="clear: both;"></div>
-                <div class="col-md-5 col-md-offset-1 admin-container" style="height: 50%;">
-                  <div>
-                    <h1>Song Requests</h1><a href="/admin/queues" style="margin-left:10px;">(review)</a>
-                  </div>
-                    <table class="table queueTable">
-                      <tr>
-                        <th>Playlist</th>
-                        <th>Title</th>
-                        <th>Artist</th>
-                        <th>Duration</th>
-                        <th>Type</th>
-                      </tr>
-                      {{#each queues}}
-                        {{#each songs}}
-                          <tr>
-                            <td>{{../type}}</td>
-                            <td>{{title}}</td>
-                            <td>{{artist}}</td>
-                            <td>{{duration}}</td>
-                            <td>{{type}}</td>
-                            <!--<td><a href="/stations">Edit</a></td>-->
-                          </tr>
-                          {{/each}}
-                      {{/each}}
-                      </table>
-                </div>
-                <div class="col-md-4 col-md-offset-1 admin-container" style="height: 50%">
-                  <div>
-                    <h1>Reports</h1>
-                  </div>
-                    {{#each reports}}
-                      <p>{{reports}}</p>
-                    {{/each}}
-                </div>
           </div>
+          <div id="addStation" class="modal fade" role="dialog">
+              <div class="modal-dialog">
 
-        {{> bubbles}}
+                  <!-- Modal content-->
+                  <div class="modal-content">
+                      <div class="modal-header">
+                          <button type="button" class="close" data-dismiss="modal">&times;</button>
+                          <h4 class="modal-title">Create new station</h4>
+                      </div>
+                      <div class="modal-body">
+                        <div id="croom_container">
+                          <label for="croom_display" class="croom_label">Room Display Name (eg 'Edm'):</label>
+                          <div class="input-group">
+                            <input type="text" class="croom" id="croom_display" name="croom" required />
+                          </div>
+                          <label for="croom_tag" class="croom_label">Room Tag Name (eg 'edm'):</label>
+                          <div class="input-group">
+                            <input type="text" class="croom" id="croom_tag" name="croom" required />
+                          </div>
+                          <button class="btn btn-warning btn-block" id="croom_create">Create</button>
+                        </div>
+                      </div>
+                      <div class="modal-footer">
+                          <button id="close-modal-a" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                      </div>
+                  </div>
+
+              </div>
+          </div>
     </div>
 </template>

+ 0 - 1
app/client/templates/room.html

@@ -184,7 +184,6 @@
             <!-- Report Modal -->
             <div id="reportModal" class="modal fade" role="dialog">
                 <div class="modal-dialog">
-
                     <!-- Modal content-->
                     <div class="modal-content">
                         <div class="modal-body">

+ 8 - 51
app/client/templates/stations.html

@@ -2,12 +2,12 @@
     {{> alerts}}
   <div class="landing">
     {{> header}}
-      <h1 class="col-md-8 col-md-offset-2 admin-header">Playlists:</h1>
-      {{#each playlists}}
+      <h1 class="col-md-8 col-md-offset-2 admin-header">Playlist for {{whichStation}}</h1>
+      {{#each playlist}}
           <div class="col-md-8 col-md-offset-2 admin-playlist-panel">
               <div class="panel panel-primary">
                   <div class="panel-heading">
-                      <h3 class="panel-title"><span>{{display}}</span> playlist</h3> <i class="fa fa-times delete-room" name="Delete room"></i>
+                      <h3 class="panel-title">Delete</h3> <i class="fa fa-times delete-room" name="Delete room"></i>
                   </div>
                   <div class="panel-body admin-panel-body">
                       <table class="table table-striped">
@@ -20,7 +20,6 @@
                               <th>Id</th>
                               <th>Likes</th>
                               <th>Dislikes</th>
-                              <th>Copy/Move</th>
                               <th>Img</th>
                               <th>Preview</th>
                               <th>Edit</th>
@@ -37,7 +36,6 @@
                               <td>{{id}}</td>
                               <td>{{likes}}</td>
                               <td>{{dislikes}}</td>
-                              <td class="column-small"><button class="btn btn-primary copyMove-button" data-genre="{{../type}}" id="copyMoveButton" data-toggle="modal" data-target="#copyMoveModal">Copy/Move</button></td>
                               <td class="column-small"><button class="btn btn-primary preview-button" id="previewImageButton" data-toggle="modal" data-target="#previewImageModal">Preview Image</button></td>
                               <td class="column-small"><button class="btn btn-primary preview-button" data-toggle="modal" data-target="#previewModal">Preview</button></td>
                               <td class="column-small"><button class="btn btn-primary edit-playlist-button" data-genre="{{../type}}" data-toggle="modal" data-target="#editModal">Edit</button></td>
@@ -51,23 +49,7 @@
           </div>
       {{/each}}
 
-      <button class="btn btn-danger col-md-6 col-md-offset-3" id="rrating" data-toggle="modal" data-target="#confirmModal" style="margin-bottom: 10px">Reset Rating</button>
-
-      <div class="col-md-4 col-md-offset-4">
-          <div id="croom_container">
-              <label for="croom_display" class="croom_label">Room Display Name (eg 'Edm'):</label>
-              <div class="input-group">
-                  <input type="text" class="croom" id="croom_display" name="croom" required />
-              </div>
-              <label for="croom_tag" class="croom_label">Room Tag Name (eg 'edm'):</label>
-              <div class="input-group">
-                  <input type="text" class="croom" id="croom_tag" name="croom" required />
-              </div>
-              <input type="checkbox" name="two" id="two"/>
-              <label id="two-label" for="two">Make Room Private?</label>
-              <button class="btn btn-warning btn-block" id="croom_create">Create</button>
-          </div>
-      </div>
+      <!--<button class="btn btn-danger col-md-6 col-md-offset-3" id="rrating" data-toggle="modal" data-target="#confirmModal">Reset Rating</button>-->
 
         <div id="confirmModal" class="modal fade" role="dialog">
             <div class="modal-dialog">
@@ -81,37 +63,12 @@
                         <button id="rreset_confirm" class="btn btn-danger">Reset All Ratings</button>
                     </div>
                     <div class="modal-footer">
-                        <button id="close-modal" type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
+                        <button id="close-modal" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                     </div>
                 </div>
             </div>
         </div>
 
-        <div id="copyMoveModal" class="modal fade" role="dialog">
-            <div class="modal-dialog">
-                <!-- Modal content-->
-                <div class="modal-content">
-                    <div class="modal-header">
-                        <button type="button" class="close" data-dismiss="modal">&times;</button>
-                        <h4 class="modal-title">Move & Copy</h4>
-                    </div>
-                    <div class="modal-body">
-                        <h4><i class="fa fa-arrows"></i> Move This Song To:</h4>
-                        {{#each playlists}}
-                        <button id="moveSong" data-genre="{{type}}" type="button" class="btn btn-warning"> <span>{{display}}</span> playlist</button>
-                        {{/each}}
-                      <hr />
-                        <h4><i class="fa fa-files-o"></i> Copy This Song To:</h4>
-                        {{#each playlists}}
-                        <button id="copySong" data-genre="{{type}}" type="button" class="btn btn-warning"> <span>{{display}}</span> playlist</button>
-                        {{/each}}
-                    </div>
-                    <div class="modal-footer">
-                        <button id="close-modal" type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
-                    </div>
-                </div>
-            </div>
-        </div>
 
       <div id="previewModal" class="modal fade" role="dialog">
           <div class="modal-dialog">
@@ -131,7 +88,7 @@
                       </div>
                   </div>
                   <div class="modal-footer">
-                      <button id="close-modal" type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
+                      <button id="close-modal" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                   </div>
               </div>
           </div>
@@ -149,7 +106,7 @@
                         <img alt="Not loading" id="preview-image" height="210px" width="210px" src=""/>
                     </div>
                     <div class="modal-footer">
-                        <button id="close-modal" type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
+                        <button id="close-modal" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                     </div>
                 </div>
             </div>
@@ -191,7 +148,7 @@
                       <button type="button" id="save-song-button" class="button">Save Changes</button>
                   </div>
                   <div class="modal-footer">
-                      <button id="close-modal" type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
+                      <button id="close-modal" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                   </div>
               </div>
           </div>

+ 28 - 6
app/server/server.js

@@ -700,12 +700,34 @@ Meteor.methods({
             })
         }
     },
-    submitReport: function(report, id) {
-        if (!isBanned()) {
-            var obj = report;
-            obj.id = id;
-            Reports.insert(obj);
-        }
+    submitReport: function(room, reportData) {
+      if (Meteor.userId() && !isBanned()) {
+          room = room.toLowerCase();
+          if (Rooms.find({type: room}).count() === 1) {
+              if (Reports.find({room: room}).count() === 0) {
+                  Reports.insert({room: room, report: []});
+              }
+              if (reportData !== undefined) {
+                      Reports.update({room: room}, {
+                          $push: {
+                              report: {
+                                  song: reportData.song,
+                                  type: reportData.type,
+                                  reason: reportData.reason,
+                                  other: reportData.other
+                              }
+                          }
+                      });
+                      return true;
+              } else {
+                  throw new Meteor.Error(403, "Invalid data.");
+              }
+          } else {
+              throw new Meteor.Error(403, "Invalid genre.");
+          }
+      } else {
+          throw new Meteor.Error(403, "Invalid permissions.");
+      }
     },
     shufflePlaylist: function(type) {
         if (isAdmin() && !isBanned()) {