ソースを参照

Fixed rank permissions, added queues and queue review tables on admin page.

KrisVos130 9 年 前
コミット
2f17f762ea
4 ファイル変更96 行追加45 行削除
  1. 8 8
      app/.meteor/versions
  2. 3 0
      app/app.css
  3. 47 14
      app/app.js
  4. 38 23
      app/templates/admin.html

+ 8 - 8
app/.meteor/versions

@@ -39,14 +39,14 @@ html-tools@1.0.5
 htmljs@1.0.5
 http@1.1.1
 id-map@1.0.4
-iron:controller@1.0.8
-iron:core@1.0.8
-iron:dynamic-template@1.0.8
-iron:layout@1.0.8
-iron:location@1.0.9
-iron:middleware-stack@1.0.9
-iron:router@1.0.9
-iron:url@1.0.9
+iron:controller@1.0.12
+iron:core@1.0.11
+iron:dynamic-template@1.0.12
+iron:layout@1.0.12
+iron:location@1.0.11
+iron:middleware-stack@1.0.11
+iron:router@1.0.12
+iron:url@1.0.11
 joncursi:socket-io-client@0.1.4
 jquery@1.11.4
 launch-screen@1.0.4

+ 3 - 0
app/app.css

@@ -625,3 +625,6 @@ footer a:hover{
     height: 0;
   }
 }
+.column-small {
+  width: 1px;
+}

+ 47 - 14
app/app.js

@@ -1,6 +1,7 @@
 History = new Mongo.Collection("history");
 Playlists = new Mongo.Collection("playlists");
 Rooms = new Mongo.Collection("rooms");
+Queues = new Mongo.Collection("queues");
 
 if (Meteor.isClient) {
     Meteor.startup(function() {
@@ -9,6 +10,8 @@ if (Meteor.isClient) {
         });
     });
 
+    Meteor.subscribe("queues");
+
     var hpSound = undefined;
     var songsArr = [];
     var ytArr = [];
@@ -151,7 +154,7 @@ if (Meteor.isClient) {
             var artist = $("#artist").val();
             var songData = {type: type, id: id, title: title, artist: artist};
             console.log(songData);
-            Meteor.call("addPlaylistSong", genre, songData, function(err, res) {
+            Meteor.call("addSongToQueue", genre, songData, function(err, res) {
                 console.log(err, res);
             });
         },
@@ -270,8 +273,8 @@ if (Meteor.isClient) {
     });
 
     Template.admin.helpers({
-        rooms: function() {
-            return Rooms.find({});
+        queues: function() {
+            return Queues.find({});
         }
     });
 
@@ -562,13 +565,13 @@ if (Meteor.isServer) {
     function getSongsByType(type) {
         if (type === "edm") {
             return [
-                {id: "aE2GCa-_nyU", title: "Radioactive - Lindsey Stirling and Pentatonix", duration: getSongDuration("Radioactive - Lindsey Stirling and Pentatonix"), albumart: getSongAlbumArt("Radioactive - Lindsey Stirling and Pentatonix"), type: "youtube"},
+                {id: "aE2GCa-_nyU", title: "Radioactive - Lindsey Stirling and Pentatonix", duration: getSongDuration("Radioactive - Lindsey Stirling and Pentatonix"), albumart: getSongAlbumArt("Radioactive - Lindsey Stirling and Pentatonix"), artist: "Lindsey Stirling, Pentatonix", type: "youtube"},
                 {id: "aHjpOzsQ9YI", title: "Crystallize", artist: "Linsdey Stirling", duration: getSongDuration("Crystallize"), albumart: getSongAlbumArt("Crystallize"), type: "youtube"}
             ];
         } else if (type === "nightcore") {
-            return [{id: "f7RKOP87tt4", title: "Monster (DotEXE Remix)", duration: getSongDuration("Monster (DotEXE Remix)"), albumart: getSongAlbumArt("Monster (DotEXE Remix)"), type: "youtube"}];
+            return [{id: "f7RKOP87tt4", title: "Monster (DotEXE Remix)", duration: getSongDuration("Monster (DotEXE Remix)"), albumart: getSongAlbumArt("Monster (DotEXE Remix)"), artist: "Meg & Dia", type: "youtube"}];
         } else {
-            return [{id: "dQw4w9WgXcQ", title: "Never Gonna Give You Up", duration: getSongDuration("Never Gonna Give You Up"), albumart: getSongAlbumArt("Never Gonna Give You Up"), type: "youtube"}];
+            return [{id: "dQw4w9WgXcQ", title: "Never Gonna Give You Up", duration: getSongDuration("Never Gonna Give You Up"), albumart: getSongAlbumArt("Never Gonna Give You Up"), artist: "Rick Astley", type: "youtube"}];
         }
     }
 
@@ -656,7 +659,15 @@ if (Meteor.isServer) {
     });
 
     Meteor.publish("rooms", function() {
-        return Rooms.find()
+        return Rooms.find({});
+    });
+
+    Meteor.publish("queues", function() {
+        return Queues.find({});
+    });
+
+    Meteor.publish("isAdmin", function() {
+        return Meteor.users.find({_id: this.userId, "profile.rank": "admin"});
     });
 
     Meteor.methods({
@@ -675,13 +686,16 @@ if (Meteor.isServer) {
             }
             return true;
         },
-        addPlaylistSong: function(type, songData) {
+        addSongToQueue: function(type, songData) {
             type = type.toLowerCase();
             if (Rooms.find({type: type}).count() === 1) {
                 console.log(songData);
+                if (Queues.find({type: type}).count() === 0) {
+                    Queues.insert({type: type, songs: []});
+                }
                 if (songData !== undefined && Object.keys(songData).length === 4 && songData.type !== undefined && songData.title !== undefined && songData.title !== undefined && songData.artist !== undefined) {
                     songData.duration = getSongDuration(songData.title);
-                    Playlists.update({type: type}, {$push: {songs: {id: songData.id, title: songData.title, artist: songData.artist, duration: songData.duration, type: songData.type}}});
+                    Queues.update({type: type}, {$push: {songs: {id: songData.id, title: songData.title, artist: songData.artist, duration: songData.duration, type: songData.type}}});
                     return true;
                 } else {
                     throw new Meteor.error(403, "Invalid data.");
@@ -768,6 +782,19 @@ if (Meteor.isServer) {
     });
 }
 
+/*Router.waitOn(function() {
+    Meteor.subscribe("isAdmin", Meteor.userId());
+});*/
+
+/*Router.onBeforeAction(function() {
+    /*Meteor.autorun(function () {
+        if (admin.ready()) {
+            this.next();
+        }
+    });*/
+    /*this.next();
+});*/
+
 Router.route("/", {
     template: "home"
 });
@@ -780,11 +807,17 @@ Router.route("/privacy", {
     template: "privacy"
 });
 
-Router.route("/admin", function() {
-    if (Meteor.user() !== undefined && Meteor.user().profile !== undefined && Meteor.user().profile.rank === "admin") {
-        this.render("admin");
-    } else {
-        this.redirect("/");
+Router.route("/admin", {
+    waitOn: function() {
+        return Meteor.subscribe("isAdmin", Meteor.userId());
+    },
+    action: function() {
+        var user = Meteor.users.find({}).fetch();
+        if (user[0] !== undefined && user[0].profile !== undefined && user[0].profile.rank === "admin") {
+            this.render("admin");
+        } else {
+            this.redirect("/");
+        }
     }
 });
 

+ 38 - 23
app/templates/admin.html

@@ -1,27 +1,42 @@
 <template name="admin">
-    <div class="landing">
-
-        <form>
-            <label for="genre">Song Genre</label>
-            <select name="genre" id="genre">
-                {{#each rooms}}
-                    <option name="{{type}}" id="{{type}}">{{type}}</option>
-                {{/each}}
-                <!--option name="nightcore" id="nightcore">Nightcore</option-->
-            </select>
-            <label for="type">Song Type</label>
-            <select name="type" id="type">
-                <option name="youtube" id="youtube">YouTube</option>
-                <option name="soundcloud" id="soundcloud">SoundCloud</option>
-            </select>
-            <label for="id">Song ID</label>
-            <input name="id" id="id" type="text" />
-            <label for="id">Song Artist</label>
-            <input name="artist" id="artist" type="text" />
-            <label for="title">Song Title</label>
-            <input name="title" id="title" type="text" />
-            <button type="submit">Submit</button>
-        </form>
+    <div class="landing row">
+        {{#each queues}}
+            <div class="col-md-8 col-md-offset-2 ">
+                <div class="panel panel-primary">
+                    <div class="panel-heading">
+                        <h3 class="panel-title">{{type}} review queue</h3>
+                    </div>
+                    <div class="panel-body">
+                        <table class="table table-striped">
+                            <thead>
+                                <tr>
+                                    <th>Title</th>
+                                    <th>Artist(s)</th>
+                                    <th>Type</th>
+                                    <th>Id</th>
+                                    <th>Preview</th>
+                                    <th>Add</th>
+                                    <th colspan="10">Remove</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                                {{#each songs}}
+                                    <tr>
+                                        <th scope="row">{{title}}</th>
+                                        <td>{{artist}}</td>
+                                        <td>{{type}}</td>
+                                        <td>{{id}}</td>
+                                        <td class="column-small"><button class="btn btn-primary">Preview</button></td>
+                                        <td class="column-small"><button class="btn btn-success"><i class="fa fa-check-circle"></i></button></td>
+                                        <td class="column-small"><button class="btn btn-danger"><i class="fa fa-ban"></i></button></td>
+                                    </tr>
+                                {{/each}}
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        {{/each}}
 
         <ul class="bg-bubbles">
             <li></li>