Permalink
Browse files

Add ability to delete notes

  • Loading branch information...
1 parent ab9caef commit b31b8873df83ee5502d48055f08d3f3860f6f6ab @gip committed Apr 13, 2012
Showing with 17 additions and 3 deletions.
  1. +1 −1 README.md
  2. +5 −0 lib/resque-telework/redis.rb
  3. +6 −1 lib/resque-telework/server.rb
  4. +5 −1 lib/resque-telework/server/views/telework.erb
View
@@ -151,4 +151,4 @@ The following features are planned for future releases:
Thanks
------
-I would like to thank [RG Labs](http://www.rglabsinc.com/) for the awesome environment and support to open-source development
+I would like to thank [Entelo](http://www.entelo.com/) for the awesome environment and support to open-source development
@@ -200,6 +200,11 @@ def notes_push( info )
def notes_pop ( lim= 100 )
Resque.redis.lrange(notes_key, 0, lim-1).collect { |s| ActiveSupport::JSON.decode(s) }
end
+
+ def notes_del( id )
+ info= Resque.redis.lindex(notes_key, id)
+ Resque.redis.lrem(notes_key, 0, info)
+ end
def acks_pop( h )
Resque.redis.rpop(acks_key(h))
@@ -117,14 +117,19 @@ def generic_filter(id, name, list, more= "")
end
app.post "/#{appn.downcase}_add_note" do
- puts "note"
@user= params[:user]
@date= Time.now
@note= params[:note]
redis.notes_push({ 'user'=> @user, 'date'=> @date, 'note' => @note })
redirect "/resque/#{appn.downcase}"
end
+ app.post "/#{appn.downcase}_del_note/:note" do
+ @note_id= params[:note]
+ redis.notes_del(@note_id)
+ redirect "/resque/#{appn.downcase}"
+ end
+
app.post "/#{appn.downcase}_do_start" do
@host= params[:h]
@queue= params[:q]
@@ -47,12 +47,16 @@ $(document).ready(function() {
<th>User</th>
<th>Date</th>
<th>Note</th>
+ <th>Action</th>
</tr>
- <% for note in notes %>
+ <% for note,id in notes.each_with_index %>
<tr>
<td><%= note['user'] %></td>
<td><%= "#{redis.fmt_date(note['date'], true)}" %></td>
<td><%= note['note'] %></td>
+ <td>
+ <form id="deln" name="deln" method="post" action="/resque/telework_del_note/<%= id %>" ><input type="submit" value= "Delete" /></form>
+ </td>
</tr>
<% end %>
</table>

0 comments on commit b31b887

Please sign in to comment.