소스 검색

re-added alert support & edited navbar & fixed addSongToQueue 'img' bug

Akira Laine 9 년 전
부모
커밋
edee63fda4

+ 9 - 13
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");
     }
 });
@@ -1475,6 +1469,7 @@ Template.room.events({
         var title = $("#title").val();
         var artist = $("#artist").val();
         var img = $("#img").val();
+        console.log(img);
         var genres = $("#genres").val() || [];
         var songData = {type: type, id: id, title: title, artist: artist, img: img, genres: genres};
         if (Songs.find({"id": songData.id}).count() > 0) {
@@ -1484,6 +1479,7 @@ Template.room.events({
             var $toastContent = $('<span><strong>Song not added.</strong> This song has already been requested.</span>');
             Materialize.toast($toastContent, 8000);
         } else {
+            console.log(songData);
             Meteor.call("addSongToQueue", songData, function (err, res) {
                 console.log(err, res);
                 if (err) {

+ 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);

+ 6 - 12
app/server/server.js

@@ -698,18 +698,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.");
         }
@@ -984,6 +977,7 @@ Meteor.methods({
     },
     addSongToQueue: function (songData) {
         if (Meteor.userId() && !isBanned()) {
+            console.log(songData);
             var userId = Meteor.userId();
             var requiredProperties = ["title", "artist", "img", "id", "genres"];
             if (songData !== undefined && Object.keys(songData).length === requiredProperties.length) {
@@ -993,7 +987,7 @@ Meteor.methods({
                     }
                 }
                 songData.duration = Number(getSongDuration(songData.title, songData.artist));
-                songData.img = getSongAlbumArt(songData.title, songData.artist) || "";
+                songData.img = songData.img || getSongAlbumArt(songData.title, songData.artist);
                 songData.skipDuration = 0;
                 songData.likes = 0;
                 songData.dislikes = 0;