Skip to content

Commit 27f0128

Browse files
committed
new navbar + notifications
1 parent a80d769 commit 27f0128

File tree

14 files changed

+97
-36
lines changed

14 files changed

+97
-36
lines changed

client/components/announcer/announcer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function getAnnouncement(){
4444
}
4545

4646
function clearFields(){
47-
$('.ui.form input, .ui.form textarea').val("");
47+
$(".ui.form input[type='text'], .ui.form textarea").val("");
4848
}
4949

5050
function isValid(){

client/components/nav/nav.html

+34-16
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,46 @@
22
{{#if currentUser }}
33
<div id="nav">
44
<div class="ui secondary inverted menu">
5+
<a class="icon item" href="/">
6+
<i class="ui home icon"></i>
7+
</a>
8+
59
{{#if userIs 'admin'}}
6-
<a class="item" href="/admin">
7-
Admin
8-
</a>
9-
{{/if}}
10-
{{#if userIs 'mentor'}}
11-
<a class="item" href="/mentor">
12-
Mentor
10+
<a class="icon item" href="/admin">
11+
<i class="ui settings icon"></i>
1312
</a>
1413
{{/if}}
15-
<a class="item" href="/">
16-
Queue
17-
</a>
14+
1815
<div class="right menu">
19-
<a class="item" href="/profile">
20-
{{profile}}
21-
</a>
22-
<a class="ui item" id="logout">
23-
Logout
24-
</a>
16+
{{> navMentor }}
17+
{{> navAccount }}
2518
</div>
2619
</div>
2720
</div>
2821
{{/if}}
22+
</template>
23+
24+
<template name="navMentor">
25+
{{#if userIs 'mentor'}}
26+
<a class="icon item" href="/mentor">
27+
<i class="ui world icon"></i>
28+
{{#if openTickets}}
29+
<div class="ui tiny floating notification red label">
30+
{{ openTickets }}
31+
</div>
32+
{{/if}}
33+
</a>
34+
{{/if}}
35+
</template>
36+
37+
<template name="navAccount">
38+
39+
<div class="ui dropdown item">
40+
{{profile}}<i class="dropdown icon"></i>
41+
<div class="menu">
42+
<a class="item" href="/profile">Your Profile</a>
43+
<a class="item" id="logout">Logout</a>
44+
</div>
45+
</div>
46+
2947
</template>

client/components/nav/nav.js

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
1-
Template.nav.events({
1+
// -----------------------------
2+
// Mentor section of Nav
3+
// -----------------------------
4+
Template.navMentor.helpers({
5+
openTickets: function(){
6+
return Tickets.find({
7+
status: {
8+
$in: ["OPEN", "CLAIMED"]
9+
}
10+
}).fetch().length;
11+
}
12+
});
13+
14+
// -----------------------------
15+
// Account section of Nav
16+
// -----------------------------
17+
Template.navAccount.rendered = function(){
18+
$(this.findAll('.ui.dropdown')).dropdown();
19+
};
20+
21+
Template.navAccount.events({
222
'click #logout': function(){
323
Meteor.logout();
424
}
525
});
626

7-
Template.nav.helpers({
27+
Template.navAccount.helpers({
828
profile: function(){
929
if (Meteor.user().profile.name){
10-
return Meteor.user().profile.name;
30+
return Meteor.user().profile.name.split(" ")[0];
1131
}
1232
return "Profile";
1333
}

client/components/ticketPanel/ticketPanel.html

+3-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@
3333
{{else}}
3434

3535
<div class="title">
36-
Hey, I'm
37-
{{#if currentUser.profile.name}}
38-
{{currentUser.profile.name}}!
39-
{{else}}
40-
{{currentUser.services.github.username}}!
41-
{{/if}}
36+
{{greeting}}
37+
<br>
38+
{{constant 'TICKET_PANEL_GREETING'}}
4239
</div>
4340
<div class="content">
4441
{{constant 'TICKET_PANEL_TOPIC'}}

client/components/ticketPanel/ticketPanel.js

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ Template.ticketPanel.helpers({
1111
statusIs: function(status){
1212
return this.status === status;
1313
},
14+
greeting: function(){
15+
// Return the first name
16+
if (Meteor.user().profile.name){
17+
return "Hey, " + Meteor.user().profile.name.split(" ")[0] + "!";
18+
}
19+
20+
if (Meteor.user().services.github){
21+
return "Hey, " + Meteor.user().services.github.username + "!";
22+
}
23+
24+
return "Hey there!";
25+
26+
},
1427
queueEnabled: function(){
1528
var settings = Settings.findOne({});
1629
if (settings){

client/components/tickets/tickets.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
{{> ticket }}
66
{{/each}}
77
{{else}}
8-
<i class="ui huge smile icon"></i>
9-
<br>
8+
<div style="font-size: 4em">
9+
🙌
10+
</div>
1011
<br>
1112
Looks like it's all clear!
1213
{{/if}}

client/helpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ UI.registerHelper('constant', function(variable){
1414
// Check if a user is a certain role
1515
UI.registerHelper('userIs', function(role){
1616
return authorized[role]();
17-
});
17+
});

client/stylesheets/css/site.css

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/stylesheets/scss/components/_nav.scss

+6
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
position: absolute;
33
padding: 12px;
44
width: 100%;
5+
6+
.floating.notification.label {
7+
top: -0.5em;
8+
left: 90%;
9+
padding: 0.4em;
10+
}
511
}

client/views/admin/admin.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Session.set('admin', 'settings');
2-
31
Template.admin.helpers({
42
pageIs: function(page){
53
return Session.equals("admin", page);

client/views/settings/settings.js

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Template.settings.helpers({
1111

1212
Template.settings.events({
1313
"click #queueEnabled.ui.checkbox": function(e, t){
14-
debugger
1514
Meteor.call("toggleSetting",
1615
'queueEnabled',
1716
$('#queueEnabled input').prop('checked'));

lib/constants.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CONSTANTS = {
77
* This is most the branding, such as your queue's name.
88
*
99
*/
10-
Q_NAME: "HACKq",
10+
Q_NAME: "HELPq",
1111
SPLASH_MESSAGE: "Have a question? Get matched with a mentor for help.",
1212

1313
// Path to image asset for desktop notifications
@@ -32,7 +32,8 @@ CONSTANTS = {
3232
* " " PLACEHOLDER: "my red shirt, blue hat, etc"
3333
*
3434
*/
35-
35+
36+
TICKET_PANEL_GREETING: "How can we help you?",
3637
TICKET_PANEL_TOPIC: "I need help with",
3738
TICKET_PANEL_TOPIC_PLACEHOLDER: "describe your problem",
3839

server/lib/helpers.js

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ _getUserName = function(user){
1717
return "Anonymous";
1818
};
1919

20+
_settings = function(){
21+
return Settings.findOne({});
22+
};
23+
2024
_log = function(message){
2125
console.log("[", new Date().toLocaleString(), "]", message);
2226
};

server/methods.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Meteor.methods({
2121
});
2222

2323
function createTicket(topic, location, contact) {
24-
// Must be logged in
25-
if (authorized.user(this.userId)) {
24+
// Must be logged in and queue must be open
25+
if (authorized.user(this.userId) && _settings().queueEnabled) {
2626
// User can't have more than one
2727
var userActiveTickets = Tickets.find(
2828
{

0 commit comments

Comments
 (0)