Skip to content

Commit

Permalink
Add ability to delete notes
Browse files Browse the repository at this point in the history
  • Loading branch information
gip committed Apr 13, 2012
1 parent ab9caef commit b31b887
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions lib/resque-telework/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 6 additions & 1 deletion lib/resque-telework/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 5 additions & 1 deletion lib/resque-telework/server/views/telework.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit b31b887

Please sign in to comment.