Prechádzať zdrojové kódy

Added profile picture show next to name.

KrisVos130 9 rokov pred
rodič
commit
9058a10693

+ 1 - 0
app/.meteor/packages

@@ -29,3 +29,4 @@ http
 zimme:iron-router-active
 momentjs:moment
 emojione:emojione
+utilities:avatar

+ 5 - 0
app/.meteor/versions

@@ -48,6 +48,9 @@ iron:middleware-stack@1.0.11
 iron:router@1.0.12
 iron:url@1.0.11
 joncursi:socket-io-client@0.1.4
+jparker:crypto-core@0.1.0
+jparker:crypto-md5@0.1.1
+jparker:gravatar@0.3.1
 jquery@1.11.4
 launch-screen@1.0.4
 livedata@1.0.15
@@ -56,6 +59,7 @@ logging@1.0.8
 meteor@1.1.10
 meteor-base@1.0.1
 meteorhacks:async@1.0.0
+meteorhacks:inject-initial@1.0.3
 minifiers@1.1.7
 minimongo@1.0.10
 mobile-experience@1.0.1
@@ -91,6 +95,7 @@ twbs:bootstrap@3.3.5
 ui@1.0.8
 underscore@1.0.4
 url@1.0.5
+utilities:avatar@0.9.2
 webapp@1.2.3
 webapp-hashing@1.0.5
 zimme:active-route@2.3.2

+ 7 - 1
app/client/app.css

@@ -1396,4 +1396,10 @@ nav form input[type="image"]{
         margin-bottom: 0;
     }
 }
-
+.header-avatar {
+    margin-top: -9px;
+    /*width: 40px;
+    height: 40px;*/
+    margin-right: 5px;
+    float: left;
+}

+ 28 - 5
app/client/client.js

@@ -2,13 +2,25 @@ Meteor.startup(function() {
     reCAPTCHA.config({
         publickey: '6LcVxg0TAAAAAE18vBiH00UAyaJggsmLm890SjZl'
     });
+
+    Avatar.setOptions({
+        fallbackType: "initials",
+        defaultImageUrl: "http://static.boredpanda.com/blog/wp-content/uploads/2014/04/amazing-fox-photos-182.jpg",
+        generateCSS: true,
+        imageSizes: {
+            'header': 40
+        }
+    });
 });
 
-Meteor.subscribe("queues");
-Meteor.subscribe("reports");
-Meteor.subscribe("chat");
-Meteor.subscribe("playlists");
-Meteor.subscribe("alerts");
+Deps.autorun(function() {
+    Meteor.subscribe("queues");
+    Meteor.subscribe("reports");
+    Meteor.subscribe("chat");
+    Meteor.subscribe("playlists");
+    Meteor.subscribe("alerts");
+    Meteor.subscribe("userData", Meteor.userId());
+});
 
 var minterval;
 var hpSound = undefined;
@@ -165,6 +177,17 @@ Template.header.helpers({
     currentUser: function() {
         return Meteor.user();
     },
+    userId: function() {
+        return Meteor.userId();
+    },
+    initials: function() {
+        var user = Meteor.user();
+        if (user !== undefined) {
+            return user.profile.username[0].toUpperCase();
+        } else {
+            return "";
+        }
+    },
     isAdmin: function() {
         if (Meteor.user() && Meteor.user().profile) {
             return Meteor.user().profile.rank === "admin";

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

@@ -24,7 +24,7 @@
                 {{#if currentUser}}
                   <ul class="nav navbar-nav navbar-right">
                     <li class="dropdown">
-                      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{currentUser.profile.username}} <span class="caret"></span></a>
+                      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{> avatar userId=userId shape="circle" size="header" class="header-avatar" initials=initials}} {{currentUser.profile.username}} <span class="caret"></span></a>
                         <ul class="dropdown-menu" id="header-dropdown">
                             <li><a href="/u/{{currentUser.profile.username}}">Profile</a></li>
                             <li><a href="/settings">Settings</a></li>

+ 16 - 0
app/server/server.js

@@ -2,6 +2,14 @@ Meteor.startup(function() {
     reCAPTCHA.config({
         privatekey: '6LcVxg0TAAAAAI2fgIEEWHFxwNXeVIs8mzq5cfRM'
     });
+    Avatar.setOptions({
+        fallbackType: "initials",
+        defaultImageUrl: "http://static.boredpanda.com/blog/wp-content/uploads/2014/04/amazing-fox-photos-182.jpg",
+        generateCSS: true,
+        imageSizes: {
+            'header': 40
+        }
+    });
     var stations = [{tag: "edm", display: "EDM"}, {tag: "pop", display: "Pop"}]; //Rooms to be set on server startup
     for(var i in stations){
         if(Rooms.find({type: stations[i]}).count() === 0){
@@ -370,6 +378,14 @@ Meteor.publish("alerts", function() {
     return Alerts.find({active: true})
 });
 
+Meteor.publish("userData", function(userId) {
+    if (userId !== undefined) {
+        return Meteor.users.find(userId, {fields: {"services.github.username": 1}})
+    } else {
+        return undefined;
+    }
+});
+
 Meteor.publish("allAlerts", function() {
     return Alerts.find({active: false})
 });