From 941ed7e1940e75e9a28428f54e0603e81d785184 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 26 Jun 2013 13:45:40 -0400 Subject: [PATCH 1/7] user search in admin/users --- public/src/forum/admin/users.js | 16 ++++++---- public/templates/admin/index.tpl | 21 ++++++++++++- public/templates/admin/users.tpl | 51 +++++++++++++++++--------------- src/user.js | 27 +++++++---------- 4 files changed, 68 insertions(+), 47 deletions(-) diff --git a/public/src/forum/admin/users.js b/public/src/forum/admin/users.js index 7906579950..c589ee4b34 100644 --- a/public/src/forum/admin/users.js +++ b/public/src/forum/admin/users.js @@ -3,6 +3,7 @@ jQuery('document').ready(function() { var yourid = templates.get('yourid'); + var timeoutId = 0; var url = window.location.href, parts = url.split('/'), @@ -17,14 +18,17 @@ }); jQuery('#search-user').on('keyup', function () { - console.log('derp'); - jQuery('.icon-spinner').removeClass('none'); - console.log($('#search-user').val()); - socket.emit('api:admin.user.search', $('#search-user').val()); - }); - + if(timeoutId !== 0) { + clearTimeout(timeoutId); + timeoutId = 0; + } + timeoutId = setTimeout(function() { + jQuery('.icon-spinner').removeClass('none'); + socket.emit('api:admin.user.search', $('#search-user').val()); + }, 250); + }); function isUserAdmin(element) { diff --git a/public/templates/admin/index.tpl b/public/templates/admin/index.tpl index 7d1d74fce0..843a155ede 100644 --- a/public/templates/admin/index.tpl +++ b/public/templates/admin/index.tpl @@ -43,7 +43,26 @@ socket.emit('api:get_all_rooms'); socket.on('api:admin.user.search', function(data) { - console.log(data); + var html = templates.prepare(templates['admin/users'].blocks['users']).parse({ + users: data + }), + userListEl = document.querySelector('.users'); + + userListEl.innerHTML = html; + jQuery('.icon-spinner').addClass('none'); + + if(data && data.length === 0) { + $('#user-notfound-notify').html('User not found!') + .show() + .addClass('label-important') + .removeClass('label-success'); + } + else + $('#user-notfound-notify').html(data.length + ' user'+(data.length>1?'s':'') + ' found!') + .show() + .addClass('label-success') + .removeClass('label-important'); + }); \ No newline at end of file diff --git a/public/templates/admin/users.tpl b/public/templates/admin/users.tpl index bac6328897..1f9bc8af8a 100644 --- a/public/templates/admin/users.tpl +++ b/public/templates/admin/users.tpl @@ -11,33 +11,36 @@ - -
- - - -
- {users.username} -
-
- {users.reputation} - +
- + + diff --git a/src/user.js b/src/user.js index 2d26c535cd..9f095c6af2 100644 --- a/src/user.js +++ b/src/user.js @@ -255,22 +255,17 @@ var utils = require('./../public/src/utils.js'), User.search = function(username, callback) { console.log('searching '+username); - RDB.keys('username:'+ username + '*:uid', function(err, keys) { + RDB.keys('username:*'+ username + '*:uid', function(err, keys) { if(err === null) { - //console.log(data); - - /*var keys = []; - for(var i=0, ii=data.length; i Date: Wed, 26 Jun 2013 13:46:04 -0400 Subject: [PATCH 2/7] user search in admin/users --- src/user.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/user.js b/src/user.js index 9f095c6af2..8a89fa604f 100644 --- a/src/user.js +++ b/src/user.js @@ -254,7 +254,6 @@ var utils = require('./../public/src/utils.js'), } User.search = function(username, callback) { - console.log('searching '+username); RDB.keys('username:*'+ username + '*:uid', function(err, keys) { if(err === null) { if(keys && keys.length) { From 7a478637e3298237ba00c2756ebdfe257c601cc9 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 26 Jun 2013 13:54:04 -0400 Subject: [PATCH 3/7] added forum link to /admin header --- public/templates/admin/header.tpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl index 21ef16da22..c05d2e7ff8 100644 --- a/public/templates/admin/header.tpl +++ b/public/templates/admin/header.tpl @@ -38,6 +38,9 @@ -
+


  Forgot Password? -
+ Invalid username/password
From 07ceabd371853de79c1153bd34b8c55ceeaa5856 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 26 Jun 2013 15:55:17 -0400 Subject: [PATCH 7/7] added space after reps in topic.tpl and topic.js --- public/src/forum/topic.js | 4 ++-- public/templates/topic.tpl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 3e65275d77..5f22e626d2 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -427,8 +427,8 @@ ptotal += value; utotal += value; - post_rep.html(ptotal); - user_rep.html(utotal); + post_rep.html(ptotal+ ' '); + user_rep.html(utotal+ ' '); } diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index d8f054928b..2a9b880353 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -79,7 +79,7 @@
-
{posts.post_rep}
+
{posts.post_rep}
posted by {posts.username} {posts.relativeTime} ago