Răsfoiți Sursa

Merge remote-tracking branch 'origin/february_release' into february_release

Conflicts:
	app/client/scripts/events.js
	app/server/server.js
KrisVos130 9 ani în urmă
părinte
comite
d29c90a461

+ 43 - 41
app/client/scripts/events.js

@@ -212,20 +212,14 @@ Template.admin.events({
         var description = $("#desc_text").val();
         Meteor.call("editRoomDesc", Session.get("roomDesc"), description);
         $("#desc-modal").closeModal();
-    }
-});
-
-Template.alertsDashboard.events({
-    "click #calart-create": function() {
-        Meteor.call("addAlert", $("#calert-description").val(), $("#calert-priority").val().toLowerCase(), function (err, res) {
-            if (err) {
-                alert("Error " + err.error + ": " + err.reason);
-            } else {
-                $("#calert-description").val("");
-            }
-        });
     },
-    "click #ralert-button": function() {
+    "click #submit-alert": function(){
+        var alertDesc = $("#alert-desc").val()
+        if(alertDesc !== ""){
+            Meteor.call("addAlert", alertDesc);
+        }
+    },
+    "click #remove-alerts": function(){
         Meteor.call("removeAlerts");
     }
 });
@@ -501,15 +495,16 @@ Template.queues.events({
                                     seekerBarInterval = undefined;
                                 }
                             }
-                            if (event.data == YT.PlayerState.UNSTARTED) {
-                                if (seekerBarInterval !== undefined) {
-                                    Meteor.clearInterval(seekerBarInterval);
-                                    seekerBarInterval = undefined;
-                                }
-                                $(".seeker-bar").css({width: "0"});
-                                $("#time-elapsed").text("0:00");
-                                $("#previewPlayerContainer").addClass("hide-preview");
-                            }
+                            // if (event.data == YT.PlayerState.UNSTARTED) {
+                            //     if (seekerBarInterval !== undefined) {
+                            //         Meteor.clearInterval(seekerBarInterval);
+                            //         seekerBarInterval = undefined;
+                            //     }
+                            //     $(".seeker-bar").css({width: "0"});
+                            //     $("#time-elapsed").text("0:00");
+                            //     $("#previewPlayerContainer").addClass("hide-preview");
+                            //     console.log("HIDE MEY STACY!!!!")
+                            // }
                             if (event.data == YT.PlayerState.PLAYING) {
                                 seekerBarInterval = Meteor.setInterval(function() {
                                     var duration = Session.get("song").duration;
@@ -731,15 +726,15 @@ Template.manageStation.events({
                                     seekerBarInterval = undefined;
                                 }
                             }
-                            if (event.data == YT.PlayerState.UNSTARTED) {
-                                if (seekerBarInterval !== undefined) {
-                                    Meteor.clearInterval(seekerBarInterval);
-                                    seekerBarInterval = undefined;
-                                }
-                                $(".seeker-bar").css({width: "0"});
-                                $("#time-elapsed").text("0:00");
-                                $("#previewPlayerContainer").addClass("hide-preview");
-                            }
+                            // if (event.data == YT.PlayerState.UNSTARTED) {
+                            //     if (seekerBarInterval !== undefined) {
+                            //         Meteor.clearInterval(seekerBarInterval);
+                            //         seekerBarInterval = undefined;
+                            //     }
+                            //     $(".seeker-bar").css({width: "0"});
+                            //     $("#time-elapsed").text("0:00");
+                            //     $("#previewPlayerContainer").addClass("hide-preview");
+                            // }
                             if (event.data == YT.PlayerState.PLAYING) {
                                 seekerBarInterval = Meteor.setInterval(function() {
                                     var duration = Session.get("song").duration;
@@ -970,15 +965,15 @@ Template.manageSongs.events({
                                     seekerBarInterval = undefined;
                                 }
                             }
-                            if (event.data == YT.PlayerState.UNSTARTED) {
-                                if (seekerBarInterval !== undefined) {
-                                    Meteor.clearInterval(seekerBarInterval);
-                                    seekerBarInterval = undefined;
-                                }
-                                $(".seeker-bar").css({width: "0"});
-                                $("#time-elapsed").text("0:00");
-                                $("#previewPlayerContainer").addClass("hide-preview");
-                            }
+                            // if (event.data == YT.PlayerState.UNSTARTED) {
+                            //     if (seekerBarInterval !== undefined) {
+                            //         Meteor.clearInterval(seekerBarInterval);
+                            //         seekerBarInterval = undefined;
+                            //     }
+                            //     $(".seeker-bar").css({width: "0"});
+                            //     $("#time-elapsed").text("0:00");
+                            //     $("#previewPlayerContainer").addClass("hide-preview");
+                            // }
                             if (event.data == YT.PlayerState.PLAYING) {
                                 seekerBarInterval = Meteor.setInterval(function() {
                                     var duration = Session.get("song").duration;
@@ -1214,18 +1209,25 @@ Template.room.events({
         Session.set("editingSong", true);
         var title = currentSong.title;
         var artist = currentSong.artist;
+        var img = currentSong.img;
         getSpotifyInfo(title.replace(/\[.*\]/g, ""), function (data) {
             if (data.tracks.items.length > 0) {
                 title = data.tracks.items[0].name;
                 var artists = [];
+                img = data.tracks.items[0].album.images[2].url;
+                data.tracks.items[0].artists.forEach(function (artist) {
+                    artists.push(artist.name);
+                });
                 artist = artists.join(", ");
                 $("#title").val(title).change();
                 $("#artist").val(artist).change();
+                $("#img").val(img).change();
                 $("#id").val(id).change();
                 $("#genres").val(null).change();
             } else {
                 $("#title").val(title).change();
                 $("#artist").val(artist).change();
+                $("#img").val(img).change();
                 $("#id").val(id).change();
                 $("#genres").val(null).change();
                 // I give up for now... Will fix this later. -Kris
@@ -1438,7 +1440,7 @@ Template.room.events({
         Meteor.call("dislikeSong", Session.get("currentSong").mid);
     },
     "click #vote-skip": function () {
-        Meteor.call("voteSkip", Session.get("type"), function (err, res) {
+        Meteor.call("voteSkip", type, function (err, res) {
             $("#vote-skip").attr("disabled", true);
         });
     },

+ 1 - 10
app/client/scripts/helpers.js

@@ -53,15 +53,6 @@ Template.alerts.helpers({
     }
 });
 
-Template.alertsDashboard.helpers({
-    "activeAlerts": function () {
-        return Alerts.find({active: true});
-    },
-    "inactiveAlerts": function () {
-        return Alerts.find({active: false});
-    }
-});
-
 Template.banned.helpers({
     bannedAt: function () {
         if (Session.get("ban") !== undefined) {
@@ -429,4 +420,4 @@ Template.settings.helpers({
             return "";
         }
     }
-});
+});

+ 0 - 6
app/client/scripts/onCreated.js

@@ -1,12 +1,6 @@
 var StationSubscription = undefined;
 var resizeSeekerbarInterval;
 
-Template.alertsDashboard.onCreated(function() {
-    if (allAlertSub === undefined) {
-        allAlertSub = Meteor.subscribe("allAlerts");
-    }
-});
-
 Template.landing.onCreated(function(){
     $("body").css("overflow", "hidden");
     function pageScroll() {

+ 15 - 6
app/client/stylesheets/app.css

@@ -36,6 +36,7 @@ textarea{
 
 .brand-logo {
     margin-left: 10px;
+    font-weight: 300 !important;
 }
 
 .feedback-btn{
@@ -256,12 +257,20 @@ textarea{
     float: left;
     height: 10%;
 }
-body {
-    display: flex;
-    min-height: 100vh;
-    flex-direction: column;
-}
 
 .container {
     flex: 1 0 auto;
-}
+}
+
+.alert{
+    font-size: 1.3em;
+    text-align: center;
+    padding: 5px;
+    margin: 0;
+    background-color: #009C87 !important;
+    color: white;
+}
+
+.alert i{
+    vertical-align: middle;
+}

+ 33 - 12
app/client/templates/admin.html

@@ -35,9 +35,7 @@
                         </tbody>
                     </table>
                 <div class="row">
-                    <button class="btn col m6 s6 l6 waves-effect waves-light" id="rrating" data-toggle="modal"
-                            data-target="#confirmModal">Reset All Ratings
-                    </button>
+                    <a class="btn col m6 s6 l6 waves-effect waves-light" href="/admin/queues">Manage Queues</a> <!-- TODO Make this redirect to the queues -->
                     <a class="waves-effect waves-light btn col m6 s6 l6 modal-trigger" id="new_room" href="#addStation"> <!-- TODO Make this actually open the new room modal  -->
                         Add Room
                     </a>
@@ -45,14 +43,18 @@
             </div>
             <div class="col s12 m8 l3 offset-l1 offset-m2 card-panel teal accent-3 white-text" style="height: 80%;">
                 <div>
-                    <h2 class="center-align">Site statistics</h2>
+                    <h2 class="center-align">Other</h2>
                 </div>
                 <div class="section">
                     <p class="flow-text">Total Users Online: {{usersOnline}}</p>
                     <p class="flow-text">Total Registered Users: {{allUsers}}</p>
                 </div>
                 <div class="row">
-                    <a class="btn col l12 s12 m12 waves-effect waves-light" href="/admin/queues">Manage Queues</a> <!-- TODO Make this redirect to the queues -->
+                    <a class="btn col m12 s12 l12 waves-effect waves-light" id="rrating" data-toggle="modal" data-target="#confirmModal">Reset All Ratings</a>
+                </div>
+                <div class="row">
+                    <a class="btn col l6 m6 s12 waves-effect waves-light modal-trigger" href="#alerts-modal">Create New Alert</a>
+                    <a id="remove-alerts" class="btn col l6 m6 s12 waves-effect waves-light red darken-3">Remove Alerts</a>
                 </div>
             </div>
         </div>
@@ -86,13 +88,6 @@
             </div>
         </div>
     </div>
-    <script>
-        $(document).ready(function(){
-            // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
-            $('.modal-trigger').leanModal();
-        });
-    </script>
-
     <div id="confirmModal" class="modal fade" role="dialog">
         <div class="modal-dialog">
             <!-- Modal content-->
@@ -130,4 +125,30 @@
             </div>
         </div>
     </div>
+    <div id="alerts-modal" class="modal fade" role="dialog">
+        <div class="modal-dialog">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h4 class="modal-title">Add New Alert</h4>
+                </div>
+                <div class="modal-body">
+                    <div class="input-field">
+                        <input type="text" class="croom" id="alert-desc" required/>
+                        <label for="alert-desc" class="black-text">Alert Text</label>
+                        <a id="submit-alert" class="waves-effect waves-light btn">Submit</a>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <a href="#!" class=" modal-action modal-close waves-effect waves-light btn-flat">Close</a>
+                </div>
+            </div>
+        </div>
+    </div>
+    <script>
+        $(document).ready(function(){
+            // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
+            $('.modal-trigger').leanModal();
+            $("select").material_select();
+        });
+    </script>
 </template>

+ 2 - 4
app/client/templates/alerts.html

@@ -1,7 +1,5 @@
 <template name="alerts">
     {{#each alerts}}
-        <div class="alert alert-{{priority}}" style="margin: 0" role="alert">
-            <a href="#" class="alert-link">{{description}}</a>
-        </div>
+        <p class="alert"><i class="material-icons">announcement</i> {{description}}</p>
     {{/each}}
-</template>
+</template>

+ 0 - 27
app/client/templates/alertsDashboard.html

@@ -1,27 +0,0 @@
-<template name="alertsDashboard">
-    {{> alerts}}
-    <div class="landing">
-        {{> header}}
-        <div class="row">
-            <div class="col-md-4 col-md-offset-4">
-                <button class="btn btn-block btn-danger" id="ralert-button">Remove all alerts.</button>
-                <div id="calert_container">
-                    <label for="calert-description" class="calert_label">Alert Description:</label>
-                    <div class="input-group">
-                        <input type="text" class="calert" id="calert-description" name="calert" required />
-                    </div>
-                    <label for="calert-priority" class="croom_label">Alert Priority:</label>
-                    <div class="input-group">
-                        <select class="calert" id="calert-priority" name="calert" required>
-                            <option selected>Danger</option>
-                            <option>Warning</option>
-                            <option>Primary</option>
-                            <option>Success</option>
-                        </select>
-                    </div>
-                    <button class="btn btn-warning btn-block" id="calart-create">Create</button>
-                </div>
-            </div>
-        </div>
-    </div>
-</template>

+ 2 - 2
app/client/templates/header.html

@@ -22,8 +22,8 @@
             {{/if}}
         </ul>
         <nav>
-            <div class="nav-wrapper grey darken-4">
-                <a href="/" class="brand-logo light white-text">Musare</a>
+            <div class="nav-wrapper grey darken-3">
+                <a href="/" class="brand-logo white-text">Musare</a>
                 <a href="#" data-activates="mobile-navi" class="button-collapse white-text"><i class="material-icons">menu</i></a>
                 <ul class="right hide-on-med-and-down scroll-fix">
                   {{#if isModerator}}

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

@@ -1,6 +1,7 @@
 <template name="home">
     {{> header}}
     <main>
+        {{> alerts}}
         <div class="col s12 m10 l8">
             <div class="row">
                 {{#each rooms}}

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

@@ -1,5 +1,4 @@
 <template name="room">
-    {{> alerts}}
     {{#if loaded}}
         <header>
             <nav>
@@ -57,7 +56,7 @@
                 </div>
             </nav>
         </header>
-
+        {{> alerts}}
         <main id="room-content">
             <div class="container">
                 <div class="row">

+ 1 - 6
app/database/schemas.js

@@ -153,11 +153,6 @@ Schemas.Alert = new SimpleSchema({
         type: String,
         label: "The Alert's Description"
     },
-    priority: {
-        type: String,
-        allowedValues: ["danger", "warning", "success", "primary"],
-        label: "The Alert's Priority"
-    },
     active: {
         type: Boolean,
         label: "Whether or not the alert is active or not"
@@ -539,4 +534,4 @@ Meteor.users.attachSchema(Schemas.User);
 Reports.attachSchema(Schemas.Report);
 Feedback.attachSchema(Schemas.Feedback);
 Songs.attachSchema(Schemas.FullSong);
-News.attachSchema(Schemas.Article);
+News.attachSchema(Schemas.Article);

+ 4 - 11
app/server/server.js

@@ -738,18 +738,11 @@ Meteor.methods({
             throw Meteor.Error(403, "Invalid permissions.");
         }
     },
-    addAlert: function (description, priority) {
+    addAlert: function (description) {
         if (isAdmin()) {
-            if (description.length > 0 && description.length < 400) {
-                var username = Meteor.user().profile.username;
-                if (["danger", "warning", "success", "primary"].indexOf(priority) === -1) {
-                    priority = "warning";
-                }
-                Alerts.insert({description: description, priority: priority, active: true, createdBy: username});
-                return true;
-            } else {
-                throw Meteor.Error(403, "Invalid description length.");
-            }
+            var username = Meteor.user().profile.username;
+            Alerts.insert({description: description, active: true, createdBy: username});
+            return true;
         } else {
             throw Meteor.Error(403, "Invalid permissions.");
         }