beanstalkd_view 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,30 @@
1
+ a {
2
+ color: #090;
3
+ }
4
+
5
+ .navbar-inner {
6
+ background-color: #008000;
7
+ background-image: none;
8
+ }
9
+
10
+ .navbar .brand {
11
+ color: white;
12
+ font-weight: bold;
13
+ }
14
+
15
+ .well {
16
+ background-color: #008000;
17
+ }
18
+
19
+ .modal-header {
20
+ background-color: #008000;
21
+ color: white;
22
+ }
23
+
24
+ .modal-footer {
25
+ background-color: #008000;
26
+ }
27
+
1
28
  td {
2
29
  width: 285px;
3
30
  }
@@ -0,0 +1,76 @@
1
+ <!-- Enable Peek Job Button Handlers
2
+ $(document).ready(function() {
3
+ if ($("#peek_ready_btn").length > 0) {
4
+ $("#peek_ready_btn").click(function() {
5
+ peek('ready');
6
+ });
7
+ }
8
+ if ($("#peek_delayed_btn").length > 0) {
9
+ $("#peek_delayed_btn").click(function() {
10
+ peek('delayed');
11
+ });
12
+ }
13
+ if ($("#peek_buried_btn").length > 0) {
14
+ $("#peek_buried_btn").click(function() {
15
+ peek('buried');
16
+ });
17
+ }
18
+
19
+ function peek(queue) {
20
+ var tube = document.getElementById("form_tube_name").value;
21
+ var url_base = document.getElementById("form_url_base").value;
22
+ var jqxhr = $.getJSON(url_base+"peek/"+tube+"/"+queue, function(data) {
23
+ if (data.hasOwnProperty("error")) {
24
+ alert(data["error"]);
25
+ } else {
26
+ $("#job_info_popup_title").html(create_job_info_title(data));
27
+ $("#job_info_popup_body").html(create_job_info_table(data));
28
+ $("#job_info_popup_footer").html(create_job_info_buttons(tube, data, url_base));
29
+ $("[rel=tooltip]").tooltip(); //refresh tooltips
30
+ $("#job_info_popup").modal({});
31
+ }
32
+ })
33
+ .error(function() { alert("An error occurred while trying to peek at the next job."); })
34
+ }
35
+
36
+ function create_job_info_buttons(tube, data, url_base) {
37
+ var job_id = data["id"];
38
+ var priority = data["pri"];
39
+ var job_info_buttons = "";
40
+ job_info_buttons += "<a href=\""+url_base+"delete/"+tube+"/"+job_id+"\" class=\"btn\">Delete Job</a>";
41
+ return job_info_buttons;
42
+ }
43
+
44
+ function create_job_info_title(data) {
45
+ var id = data["id"];
46
+ var state = data["state"];
47
+ return "<h3>Job id: "+id+" ("+state+")</h3>";
48
+ }
49
+
50
+ function create_job_info_table(data) {
51
+ var job_info_table = "<table class=\"table\">";
52
+ job_info_table += "<tbody>";
53
+ job_info_table += create_job_info_row("pri", data["pri"], "The priority value set by the put, release, or bury commands.");
54
+ job_info_table += create_job_info_row("age", data["age"], "The time in seconds since the put command that created this job.");
55
+ job_info_table += create_job_info_row("delay", data["delay"], "The delay value in seconds");
56
+ job_info_table += create_job_info_row("ttr", data["ttr"], "The number of seconds to allow a worker to run this job. This time is counted from the moment a worker reserves this job. If the worker does not delete, release, or bury the job within ttr seconds, the job will time out and the server will release the job.");
57
+ job_info_table += create_job_info_row("time-left", data["time-left"], "The number of seconds left until the server puts this job into the ready queue. This number is only meaningful if the job is reserved or delayed. If the job is reserved and this amount of time elapses before its state changes, it is considered to have timed out.");
58
+ job_info_table += create_job_info_row("reserves", data["reserves"], "The number of times this job has been reserved");
59
+ job_info_table += create_job_info_row("timeouts", data["timeouts"], "The number of times this job has timed out during a reservation.");
60
+ job_info_table += create_job_info_row("releases", data["releases"], "The number of times a client has released this job from a reservation.");
61
+ job_info_table += create_job_info_row("buries", data["buries"], " The number of times this job has been buried.");
62
+ job_info_table += create_job_info_row("kicks", data["kicks"], "The number of times this job has been kicked.");
63
+ job_info_table += create_job_info_row("body", data["body"], "The jobs body content.");
64
+ job_info_table += "</tbody>";
65
+ job_info_table += "</table>";
66
+ return job_info_table;
67
+ }
68
+
69
+ function create_job_info_row(key, value, title) {
70
+ var job_info_row = "<tr rel=\"tooltip\" title=\""+title+"\">";
71
+ job_info_row += "<td>"+key+"</td>";
72
+ job_info_row += "<td>"+value+"</td>";
73
+ job_info_row += "</tr>";
74
+ return job_info_row;
75
+ }
76
+ });
@@ -27,6 +27,71 @@ module BeanstalkdView
27
27
  end
28
28
  end
29
29
 
30
+ get "/peek/:tube/:type" do
31
+ content_type :json
32
+ begin
33
+ response = nil
34
+ beanstalk.on_tube(params[:tube]) do |conn|
35
+ puts "On Tube #{conn.inspect} #{params[:type]}"
36
+ if (params[:type]) == "ready"
37
+ puts "Peaking Ready"
38
+ response = conn.peek_ready()
39
+ elsif (params[:type]) == "delayed"
40
+ puts "Peaking Delayed"
41
+ response = conn.peek_delayed()
42
+ else
43
+ puts "Peeking Buried"
44
+ response = conn.peek_buried()
45
+ end
46
+ end
47
+ if response
48
+ ret_value = response.stats
49
+ ret_value["body"] = response.body
50
+ ret_value.to_json
51
+ else
52
+ { :error => "No job was found, or an error occurred while trying to peek at the next job."}.to_json
53
+ end
54
+ rescue Beanstalk::NotConnected => @error
55
+ { :error => @error.to_s }.to_json
56
+ end
57
+ end
58
+
59
+ get "/delete/:tube/:job_id" do
60
+ begin
61
+ response = nil
62
+ beanstalk.on_tube(params[:tube]) do |conn|
63
+ response = conn.delete(params[:job_id].to_i)
64
+ end
65
+ if response
66
+ session[:message] = "Deleted Job #{params[:job_id]}"
67
+ redirect url("/tube/#{params[:tube]}")
68
+ else
69
+ session[:message] = "Error deleting Job #{params[:job_id]}"
70
+ redirect url("/tube/#{params[:tube]}")
71
+ end
72
+ rescue Beanstalk::NotConnected => @error
73
+ erb :error
74
+ end
75
+ end
76
+
77
+ post "/pause" do
78
+ begin
79
+ response = beanstalk.pause_tube(params[:tube], params[:delay].to_i)
80
+ if response
81
+ session[:message] = "Paused #{params[:tube]}. No jobs will be reserved for #{params[:delay].to_i} seconds."
82
+ redirect url("/tube/#{params[:tube]}")
83
+ else
84
+ session[:message] = "Error pausing #{params[:tube]}."
85
+ redirect url("/tube/#{params[:tube]}")
86
+ end
87
+ rescue NameError => @error
88
+ session[:message] = "The pause_tube method is currently not implemented by this version of beanstalk-client."
89
+ redirect url("/tube/#{params[:tube]}")
90
+ rescue Beanstalk::NotConnected => @error
91
+ erb :error
92
+ end
93
+ end
94
+
30
95
  post "/kick" do
31
96
  begin
32
97
  response = nil
@@ -34,11 +99,11 @@ module BeanstalkdView
34
99
  response = conn.kick(params[:bound].to_i)
35
100
  end
36
101
  if response
37
- session[:message] = "Kicked #{params[:tube]} for #{response} jobs"
38
- redirect "/beanstalkd/tube/#{params[:tube]}"
102
+ session[:message] = "Kicked #{params[:tube]} for #{response} jobs."
103
+ redirect url("/tube/#{params[:tube]}")
39
104
  else
40
- session[:message] = "Error kicking #{params[:tube]}"
41
- redirect "/beanstalkd/tube/#{params[:tube]}"
105
+ session[:message] = "Error kicking #{params[:tube]}."
106
+ redirect url("/tube/#{params[:tube]}")
42
107
  end
43
108
  rescue Beanstalk::NotConnected => @error
44
109
  erb :error
@@ -1,3 +1,3 @@
1
1
  module BeanstalkdView
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -8,25 +8,33 @@
8
8
  </tr>
9
9
  </thead>
10
10
  <tbody>
11
- <tr>
12
- <td rel="tooltip" title="The number of ready jobs with priority < 1024.">Urgent</td>
13
- <td><%= @stats["current-jobs-urgent"].inspect %></td>
14
- </tr>
15
- <tr>
16
- <td rel="tooltip" title="The number of jobs in the ready queue.">Ready</td>
17
- <td><%= @stats["current-jobs-ready"].inspect %></td>
18
- </tr>
19
- <tr>
20
- <td rel="tooltip" title="The number of jobs reserved by all clients.">Reserved</td>
21
- <td><%= @stats["current-jobs-reserved"].inspect %></td>
22
- </tr>
23
- <tr>
24
- <td rel="tooltip" title="The number of delayed jobs.">Delayed</td>
25
- <td><%= @stats["current-jobs-delayed"].inspect %></td>
26
- </tr>
27
- <tr>
28
- <td rel="tooltip" title="he number of buried jobs.">Buried</td>
29
- <td><%= @stats["current-jobs-buried"].inspect %></td>
11
+ <tr rel="tooltip" title="The number of ready jobs with priority < 1024.">
12
+ <td>Urgent</td>
13
+ <% if @stats["current-jobs-urgent"] > 0 %>
14
+ <td><span class="badge badge-warning"><%= @stats["current-jobs-urgent"] %></span></td>
15
+ <% else %>
16
+ <td><%= @stats["current-jobs-urgent"] %></td>
17
+ <% end %>
18
+ </tr>
19
+ <tr rel="tooltip" title="The number of jobs in the ready queue.">
20
+ <td>Ready</td>
21
+ <td><%= @stats["current-jobs-ready"] %></td>
22
+ </tr>
23
+ <tr rel="tooltip" title="The number of jobs reserved by all clients.">
24
+ <td>Reserved</td>
25
+ <td><%= @stats["current-jobs-reserved"] %></td>
26
+ </tr>
27
+ <tr rel="tooltip" title="The number of delayed jobs.">
28
+ <td>Delayed</td>
29
+ <td><%= @stats["current-jobs-delayed"] %></td>
30
+ </tr>
31
+ <tr rel="tooltip" title="he number of buried jobs.">
32
+ <td>Buried</td>
33
+ <% if @stats["current-jobs-buried"] > 0 %>
34
+ <td><span class="badge badge-error"><%= @stats["current-jobs-buried"] %></span></td>
35
+ <% else %>
36
+ <td><%= @stats["current-jobs-buried"] %></td>
37
+ <% end %>
30
38
  </tr>
31
39
  </tbody>
32
40
  </table>
@@ -38,57 +46,57 @@
38
46
  </tr>
39
47
  </thead>
40
48
  <tbody>
41
- <tr>
42
- <td rel="tooltip" title="The cumulative count of times a job has timed out.">Job Timeouts</td>
43
- <td><%= @stats["job-timeouts"].inspect %></td>
49
+ <tr rel="tooltip" title="The cumulative count of times a job has timed out.">
50
+ <td>Job Timeouts</td>
51
+ <td><%= @stats["job-timeouts"] %></td>
44
52
  </tr>
45
- <tr>
46
- <td rel="tooltip" title="The cumulative count of jobs created.">Total Jobs</td>
47
- <td><%= @stats["total-jobs"].inspect %></td>
53
+ <tr rel="tooltip" title="The cumulative count of jobs created.">
54
+ <td>Total Jobs</td>
55
+ <td><%= @stats["total-jobs"] %></td>
48
56
  </tr>
49
- <tr>
50
- <td rel="tooltip" title="The maximum number of bytes in a job.">Max Job Size</td>
51
- <td><%= @stats["max-job-size"].inspect %></td>
57
+ <tr rel="tooltip" title="The maximum number of bytes in a job.">
58
+ <td>Max Job Size</td>
59
+ <td><%= @stats["max-job-size"] %></td>
52
60
  </tr>
53
- <tr>
54
- <td rel="tooltip" title="The number of currently open connections.">Current Connections</td>
55
- <td><%= @stats["current-connections"].inspect %></td>
61
+ <tr rel="tooltip" title="The number of currently open connections.">
62
+ <td>Current Connections</td>
63
+ <td><%= @stats["current-connections"] %></td>
56
64
  </tr>
57
- <tr>
58
- <td rel="tooltip" title="The number of open connections that have each issued at least one put command.">Current Producers</td>
59
- <td><%= @stats["current-producers"].inspect %></td>
65
+ <tr rel="tooltip" title="The number of open connections that have each issued at least one put command.">
66
+ <td>Current Producers</td>
67
+ <td><%= @stats["current-producers"] %></td>
60
68
  </tr>
61
- <tr>
62
- <td rel="tooltip" title="The number of open connections that have each issued at least one reserve command.">Current Workers</td>
63
- <td><%= @stats["current-workers"].inspect %></td>
69
+ <tr rel="tooltip" title="The number of open connections that have each issued at least one reserve command.">
70
+ <td>Current Workers</td>
71
+ <td><%= @stats["current-workers"] %></td>
64
72
  </tr>
65
- <tr>
66
- <td rel="tooltip" title="The number of open connections that have issued a reserve command but not yet received a response.">Current Waiting</td>
67
- <td><%= @stats["current-waiting"].inspect %></td>
73
+ <tr rel="tooltip" title="The number of open connections that have issued a reserve command but not yet received a response.">
74
+ <td>Current Waiting</td>
75
+ <td><%= @stats["current-waiting"] %></td>
68
76
  </tr>
69
- <tr>
70
- <td rel="tooltip" title="The cumulative count of connections.">Total Connections</td>
71
- <td><%= @stats["total-connections"].inspect %></td>
77
+ <tr rel="tooltip" title="The cumulative count of connections.">
78
+ <td>Total Connections</td>
79
+ <td><%= @stats["total-connections"] %></td>
72
80
  </tr>
73
- <tr>
74
- <td rel="tooltip" title="The process id of the server.">pid</td>
75
- <td><%= @stats["pid"].inspect %></td>
81
+ <tr rel="tooltip" title="The process id of the server.">
82
+ <td>pid</td>
83
+ <td><%= @stats["pid"] %></td>
76
84
  </tr>
77
- <tr>
78
- <td rel="tooltip" title="The version string of the server.">Version</td>
79
- <td><%= @stats["version"].inspect %></td>
85
+ <tr rel="tooltip" title="The version string of the server.">
86
+ <td>Version</td>
87
+ <td><%= @stats["version"] %></td>
80
88
  </tr>
81
- <tr>
82
- <td rel="tooltip" title="The accumulated user CPU time of this process in seconds and microseconds.">rusage-utime</td>
83
- <td><%= @stats["rusage-utime"].inspect %></td>
89
+ <tr rel="tooltip" title="The accumulated user CPU time of this process in seconds and microseconds.">
90
+ <td>rusage-utime</td>
91
+ <td><%= @stats["rusage-utime"] %></td>
84
92
  </tr>
85
- <tr>
86
- <td rel="tooltip" title="The accumulated system CPU time of this process in seconds and microseconds.">rusage-stime</td>
87
- <td><%= @stats["rusage-stime"].inspect %></td>
93
+ <tr rel="tooltip" title="The accumulated system CPU time of this process in seconds and microseconds.">
94
+ <td>rusage-stime</td>
95
+ <td><%= @stats["rusage-stime"] %></td>
88
96
  </tr>
89
- <tr>
90
- <td rel="tooltip" title="The number of seconds since this server started running.">Uptime</td>
91
- <td><%= @stats["uptime"].inspect %></td>
97
+ <tr rel="tooltip" title="The number of seconds since this server started running.">
98
+ <td>Uptime</td>
99
+ <td><%= @stats["uptime"] %></td>
92
100
  </tr>
93
101
  </tbody>
94
102
  </table>
@@ -100,17 +108,17 @@
100
108
  </tr>
101
109
  </thead>
102
110
  <tbody>
103
- <tr>
104
- <td rel="tooltip" title="The index of the oldest binlog file needed to store the current jobs.">Oldest Index</td>
105
- <td><%= @stats["binlog-oldest-index"].inspect %></td>
111
+ <tr rel="tooltip" title="The index of the oldest binlog file needed to store the current jobs.">
112
+ <td>Oldest Index</td>
113
+ <td><%= @stats["binlog-oldest-index"] %></td>
106
114
  </tr>
107
- <tr>
108
- <td rel="tooltip" title="The index of the current binlog file being written to. If binlog is not active this value will be 0.">Current Index</td>
109
- <td><%= @stats["binlog-current-index"].inspect %></td>
115
+ <tr rel="tooltip" title="The index of the current binlog file being written to. If binlog is not active this value will be 0.">
116
+ <td>Current Index</td>
117
+ <td><%= @stats["binlog-current-index"] %></td>
110
118
  </tr>
111
- <tr>
112
- <td rel="tooltip" title="The maximum size in bytes a binlog file is allowed to get before a new binlog file is opened.">Max Size</td>
113
- <td><%= @stats["binlog-max-size"].inspect %></td>
119
+ <tr rel="tooltip" title="The maximum size in bytes a binlog file is allowed to get before a new binlog file is opened.">
120
+ <td>Max Size</td>
121
+ <td><%= @stats["binlog-max-size"] %></td>
114
122
  </tr>
115
123
  </tbody>
116
124
  </table>
@@ -122,85 +130,85 @@
122
130
  </tr>
123
131
  </thead>
124
132
  <tbody>
125
- <tr>
126
- <td rel="tooltip" title="The cumulative number of put commands.">put</td>
127
- <td><%= @stats["cmd-put"].inspect %></td>
133
+ <tr rel="tooltip" title="The cumulative number of put commands.">
134
+ <td>put</td>
135
+ <td><%= @stats["cmd-put"] %></td>
128
136
  </tr>
129
- <tr>
130
- <td rel="tooltip" title="The cumulative number of peek commands.">peek</td>
131
- <td><%= @stats["cmd-peek"].inspect %></td>
137
+ <tr rel="tooltip" title="The cumulative number of peek commands.">
138
+ <td>peek</td>
139
+ <td><%= @stats["cmd-peek"] %></td>
132
140
  </tr>
133
- <tr>
134
- <td rel="tooltip" title="The cumulative number of peek-ready commands.">peek-ready</td>
135
- <td><%= @stats["cmd-peek-ready"].inspect %></td>
141
+ <tr rel="tooltip" title="The cumulative number of peek-ready commands.">
142
+ <td>peek-ready</td>
143
+ <td><%= @stats["cmd-peek-ready"] %></td>
136
144
  </tr>
137
- <tr>
138
- <td rel="tooltip" title="The cumulative number of peek-delayed commands.">peek-delayed</td>
139
- <td><%= @stats["cmd-peek-delayed"].inspect %></td>
145
+ <tr rel="tooltip" title="The cumulative number of peek-delayed commands.">
146
+ <td>peek-delayed</td>
147
+ <td><%= @stats["cmd-peek-delayed"] %></td>
140
148
  </tr>
141
- <tr>
142
- <td rel="tooltip" title="The cumulative number of peek-buried commands.">peek-buried</td>
143
- <td><%= @stats["cmd-peek-buried"].inspect %></td>
149
+ <tr rel="tooltip" title="The cumulative number of peek-buried commands.">
150
+ <td>peek-buried</td>
151
+ <td><%= @stats["cmd-peek-buried"] %></td>
144
152
  </tr>
145
- <tr>
146
- <td rel="tooltip" title="The cumulative number of reserve commands.">reserve</td>
147
- <td><%= @stats["cmd-reserve"].inspect %></td>
153
+ <tr rel="tooltip" title="The cumulative number of reserve commands.">
154
+ <td>reserve</td>
155
+ <td><%= @stats["cmd-reserve"] %></td>
148
156
  </tr>
149
- <tr>
150
- <td rel="tooltip" title="The cumulative number of use commands.">use</td>
151
- <td><%= @stats["cmd-use"].inspect %></td>
157
+ <tr rel="tooltip" title="The cumulative number of use commands.">
158
+ <td>use</td>
159
+ <td><%= @stats["cmd-use"] %></td>
152
160
  </tr>
153
- <tr>
154
- <td rel="tooltip" title="The cumulative number of watch commands.">watch</td>
155
- <td><%= @stats["cmd-watch"].inspect %></td>
161
+ <tr rel="tooltip" title="The cumulative number of watch commands.">
162
+ <td>watch</td>
163
+ <td><%= @stats["cmd-watch"] %></td>
156
164
  </tr>
157
- <tr>
158
- <td rel="tooltip" title="The cumulative number of ignore commands.">ignore</td>
159
- <td><%= @stats["cmd-ignore"].inspect %></td>
165
+ <tr rel="tooltip" title="The cumulative number of ignore commands.">
166
+ <td>ignore</td>
167
+ <td><%= @stats["cmd-ignore"] %></td>
160
168
  </tr>
161
- <tr>
162
- <td rel="tooltip" title="The cumulative number of delete commands.">delete</td>
163
- <td><%= @stats["cmd-delete"].inspect %></td>
169
+ <tr rel="tooltip" title="The cumulative number of delete commands.">
170
+ <td>delete</td>
171
+ <td><%= @stats["cmd-delete"] %></td>
164
172
  </tr>
165
- <tr>
166
- <td rel="tooltip" title="The cumulative number of release commands.">release</td>
167
- <td><%= @stats["cmd-release"].inspect %></td>
173
+ <tr rel="tooltip" title="The cumulative number of release commands.">
174
+ <td>release</td>
175
+ <td><%= @stats["cmd-release"] %></td>
168
176
  </tr>
169
- <tr>
170
- <td rel="tooltip" title="The cumulative number of bury commands.">bury</td>
171
- <td><%= @stats["cmd-bury"].inspect %></td>
177
+ <tr rel="tooltip" title="The cumulative number of bury commands.">
178
+ <td>bury</td>
179
+ <td><%= @stats["cmd-bury"] %></td>
172
180
  </tr>
173
- <tr>
174
- <td rel="tooltip" title="The cumulative number of kick commands.">kick</td>
175
- <td><%= @stats["cmd-kick"].inspect %></td>
181
+ <tr rel="tooltip" title="The cumulative number of kick commands.">
182
+ <td>kick</td>
183
+ <td><%= @stats["cmd-kick"] %></td>
176
184
  </tr>
177
- <tr>
178
- <td rel="tooltip" title="The cumulative number of stats commands.">stats</td>
179
- <td><%= @stats["cmd-stats"].inspect %></td>
185
+ <tr rel="tooltip" title="The cumulative number of stats commands.">
186
+ <td>stats</td>
187
+ <td><%= @stats["cmd-stats"] %></td>
180
188
  </tr>
181
- <tr>
182
- <td rel="tooltip" title="The cumulative number of stats-job commands.">stats-job</td>
183
- <td><%= @stats["cmd-stats-job"].inspect %></td>
189
+ <tr rel="tooltip" title="The cumulative number of stats-job commands.">
190
+ <td>stats-job</td>
191
+ <td><%= @stats["cmd-stats-job"] %></td>
184
192
  </tr>
185
- <tr>
186
- <td rel="tooltip" title="The cumulative number of stats-tube commands.">stats-tube</td>
187
- <td><%= @stats["cmd-stats-tube"].inspect %></td>
193
+ <tr rel="tooltip" title="The cumulative number of stats-tube commands.">
194
+ <td>stats-tube</td>
195
+ <td><%= @stats["cmd-stats-tube"] %></td>
188
196
  </tr>
189
- <tr>
190
- <td rel="tooltip" title="The cumulative number of list-tubes commands.">list-tubes</td>
191
- <td><%= @stats["cmd-list-tubes"].inspect %></td>
197
+ <tr rel="tooltip" title="The cumulative number of list-tubes commands.">
198
+ <td>list-tubes</td>
199
+ <td><%= @stats["cmd-list-tubes"] %></td>
192
200
  </tr>
193
- <tr>
194
- <td rel="tooltip" title="The cumulative number of list-tube-used commands.">list-tube-used</td>
195
- <td><%= @stats["cmd-list-tube-used"].inspect %></td>
201
+ <tr rel="tooltip" title="The cumulative number of list-tube-used commands.">
202
+ <td>list-tube-used</td>
203
+ <td><%= @stats["cmd-list-tube-used"] %></td>
196
204
  </tr>
197
- <tr>
198
- <td rel="tooltip" title="The cumulative number of list-tubes-watched commands.">list-tubes-watched</td>
199
- <td><%= @stats["cmd-list-tubes-watched"].inspect %></td>
205
+ <tr rel="tooltip" title="The cumulative number of list-tubes-watched commands.">
206
+ <td>list-tubes-watched</td>
207
+ <td><%= @stats["cmd-list-tubes-watched"] %></td>
200
208
  </tr>
201
- <tr>
202
- <td rel="tooltip" title="The cumulative number of pause-tube commands.">pause-tube</td>
203
- <td><%= @stats["cmd-pause-tube"].inspect %></td>
209
+ <tr rel="tooltip" title="The cumulative number of pause-tube commands.">
210
+ <td>pause-tube</td>
211
+ <td><%= @stats["cmd-pause-tube"] %></td>
204
212
  </tr>
205
213
  </tbody>
206
214
  </table>
@@ -0,0 +1,10 @@
1
+ <div class="modal" id="job_info_popup" style="display:none;">
2
+ <div class="modal-header">
3
+ <a class="close" data-dismiss="modal">×</a>
4
+ <h3 id="job_info_popup_title"></h3>
5
+ </div>
6
+ <div class="modal-body" id="job_info_popup_body">
7
+ </div>
8
+ <div class="modal-footer" id="job_info_popup_footer">
9
+ </div>
10
+ </div>
@@ -8,6 +8,7 @@
8
8
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
9
9
  <script type="text/javascript" src="<%= url('/resources/js/jquery-1.7.1.min.js') %>"></script>
10
10
  <script type="text/javascript" src="<%= url('/resources/bootstrap/js/bootstrap.min.js') %>"></script>
11
+ <script type="text/javascript" src="<%= url('/resources/js/peek_jobs.js') %>"></script>
11
12
  <script type="text/javascript">
12
13
  <!-- Enable Tooltips -->
13
14
  $(document).ready(function() {
@@ -20,7 +21,7 @@
20
21
  <div class="navbar">
21
22
  <div class="navbar-inner">
22
23
  <div class="container">
23
- <a class="brand" href="/beanstalkd">Beanstalkd View - <%= BeanstalkdView::VERSION %></a>
24
+ <a class="brand" href="<%= url('/') %>">Beanstalkd View - <%= BeanstalkdView::VERSION %></a>
24
25
  </div>
25
26
  </div>
26
27
  </div>
@@ -31,7 +32,7 @@
31
32
  <div id='flash' class='notice'>
32
33
  <div class="row">
33
34
  <div class="span12">
34
- <div class="alert alert-notice">
35
+ <div class="alert alert-success">
35
36
  <h4 class="alert-heading">Notice:</h4>
36
37
  <%= @message %>
37
38
  </div>
@@ -1,6 +1,6 @@
1
1
  <div class="row">
2
2
  <div class="span6">
3
- <h1>Tube: <%= @stats["name"] %></h1>
3
+ <h1><%= @stats["name"] %></h1>
4
4
 
5
5
  <table class="table">
6
6
  <thead>
@@ -9,25 +9,33 @@
9
9
  </tr>
10
10
  </thead>
11
11
  <tbody>
12
- <tr>
13
- <td rel="tooltip" title="The number of ready jobs with priority < 1024 in this tube.">Urgent</td>
14
- <td><%= @stats["current-jobs-urgent"].inspect %></td>
12
+ <tr rel="tooltip" title="The number of ready jobs with priority < 1024 in this tube.">
13
+ <td>Urgent</td>
14
+ <% if @stats["current-jobs-urgent"] > 0 %>
15
+ <td><span class="badge badge-warning"><%= @stats["current-jobs-urgent"] %></span></td>
16
+ <% else %>
17
+ <td><%= @stats["current-jobs-urgent"] %></td>
18
+ <% end %>
15
19
  </tr>
16
- <tr>
17
- <td rel="tooltip" title="The number of jobs in the ready queue in this tube.">Ready</td>
18
- <td><%= @stats["current-jobs-ready"].inspect %></td>
20
+ <tr rel="tooltip" title="The number of jobs in the ready queue in this tube.">
21
+ <td>Ready</td>
22
+ <td><%= @stats["current-jobs-ready"] %></td>
19
23
  </tr>
20
- <tr>
21
- <td rel="tooltip" title="The number of jobs reserved by all clients in this tube.">Reserved</td>
22
- <td><%= @stats["current-jobs-reserved"].inspect %></td>
24
+ <tr rel="tooltip" title="The number of jobs reserved by all clients in this tube.">
25
+ <td>Reserved</td>
26
+ <td><%= @stats["current-jobs-reserved"] %></td>
23
27
  </tr>
24
- <tr>
25
- <td rel="tooltip" title="The number of delayed jobs in this tube.">Delayed</td>
26
- <td><%= @stats["current-jobs-delayed"].inspect %></td>
28
+ <tr rel="tooltip" title="The number of delayed jobs in this tube.">
29
+ <td>Delayed</td>
30
+ <td><%= @stats["current-jobs-delayed"] %></td>
27
31
  </tr>
28
- <tr>
29
- <td rel="tooltip" title="The number of buried jobs in this tube.">Buried</td>
30
- <td><%= @stats["current-jobs-buried"].inspect %></td>
32
+ <tr rel="tooltip" title="The number of buried jobs in this tube.">
33
+ <td>Buried</td>
34
+ <% if @stats["current-jobs-buried"] > 0 %>
35
+ <td><span class="badge badge-error"><%= @stats["current-jobs-buried"] %></span></td>
36
+ <% else %>
37
+ <td><%= @stats["current-jobs-buried"] %></td>
38
+ <% end %>
31
39
  </tr>
32
40
  </tbody>
33
41
  </table>
@@ -39,21 +47,25 @@
39
47
  </tr>
40
48
  </thead>
41
49
  <tbody>
42
- <tr>
43
- <td rel="tooltip" title="The cumulative count of jobs created in this tube.">Total Jobs</td>
44
- <td><%= @stats["total-jobs"].inspect %></td>
50
+ <tr rel="tooltip" title="The cumulative count of jobs created in this tube.">
51
+ <td>Total Jobs</td>
52
+ <td><%= @stats["total-jobs"] %></td>
45
53
  </tr>
46
- <tr>
47
- <td rel="tooltip" title="The number of open connections that have issued a reserve command while watching this tube but not yet received a response.">Current Waiting</td>
48
- <td><%= @stats["current-waiting"].inspect %></td>
54
+ <tr rel="tooltip" title="The number of open connections that have issued a reserve command while watching this tube but not yet received a response.">
55
+ <td>Current Waiting</td>
56
+ <td><%= @stats["current-waiting"] %></td>
49
57
  </tr>
50
- <tr>
51
- <td rel="tooltip" title="The number of seconds the tube has been paused for.">Time Paused</td>
52
- <td><%= @stats["pause"].inspect %></td>
58
+ <tr rel="tooltip" title="The number of seconds the tube has been paused for.">
59
+ <td>Time Paused</td>
60
+ <td><%= @stats["pause"] %></td>
53
61
  </tr>
54
- <tr>
55
- <td rel="tooltip" title="The number of seconds until the tube is un-paused.">Pause Time Left</td>
56
- <td><%= @stats["pause-time-left"].inspect %></td>
62
+ <tr rel="tooltip" title="The number of seconds until the tube is un-paused.">
63
+ <td>Pause Time Left</td>
64
+ <% if @stats["pause-time-left"] > 0 %>
65
+ <td><span class="badge badge-warning"><%= @stats["pause-time-left"] %></span></td>
66
+ <% else %>
67
+ <td><%= @stats["pause-time-left"] %></td>
68
+ <% end %>
57
69
  </tr>
58
70
  </tbody>
59
71
  </table>
@@ -65,23 +77,39 @@
65
77
  </tr>
66
78
  </thead>
67
79
  <tbody>
68
- <tr>
69
- <td rel="tooltip" title="The cumulative number of pause-tube commands for this tube.">pause-tube</td>
70
- <td><%= @stats["cmd-pause-tube"].inspect %></td>
80
+ <tr rel="tooltip" title="The cumulative number of pause-tube commands for this tube.">
81
+ <td>pause-tube</td>
82
+ <td><%= @stats["cmd-pause-tube"] %></td>
71
83
  </tr>
72
84
  </tbody>
73
85
  </table>
74
86
  </div>
75
87
 
76
88
  <div class="span6">
77
- <h2>Actions</h2>
89
+ <h3>Pause Tube</h3>
90
+ <form class="well form-inline" name="pause_form" action="<%= url('/pause') %>" method="POST">
91
+ <input id="form_tube_name" type="hidden" name="tube" value="<%= @stats["name"] %>">
92
+ <input id="form_url_base" type="hidden" name="url_base" value="<%= url('/') %>">
93
+ <input type="text" class="span3" placeholder="Number of seconds to wait" name="delay">
94
+ <button type="submit" class="btn">Pause</button>
95
+ </form>
78
96
 
79
97
  <h3>Kick Tube</h3>
80
- <form class="well form-inline" name="pause_form" action="/beanstalkd/kick" method="POST">
98
+ <form class="well form-inline" name="kick_form" action="<%= url('/kick') %>" method="POST">
81
99
  <input type="hidden" name="tube" value="<%= @stats["name"] %>">
82
- <input type="text" class="input-medium" placeholder="Number of Jobs" name="bound">
100
+ <input type="text" class="span3" placeholder="Number of jobs" name="bound">
83
101
  <button type="submit" class="btn">Kick</button>
84
102
  </form>
85
-
103
+
104
+ <h3>Peek Jobs</h3>
105
+ <form class="well" name="peek_jobs">
106
+ <a id="peek_ready_btn" href="javascript:false" class="btn">Peek Ready</a>
107
+ <a id="peek_delayed_btn" href="javascript:false" class="btn">Peek Delayed</a>
108
+ <a id="peek_buried_btn" href="javascript:false" class="btn">Peek Buried</a>
109
+ </form>
110
+
86
111
  </div>
112
+
113
+ <%= erb :job_info_popup %>
114
+
87
115
  </div>
@@ -12,7 +12,7 @@
12
12
  <% @tubes[key].each do |tube| %>
13
13
  <tr>
14
14
  <td><%= key %></td>
15
- <td><a href="/beanstalkd/tube/<%= tube %>"><%= tube %></a></td>
15
+ <td><a href="<%= url("/tube/#{tube}") %>"><%= tube %></a></td>
16
16
  </tr>
17
17
  <% end %>
18
18
  <% end %>
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'sinatra/base'
3
3
  require 'erb'
4
4
  require "beanstalk-client"
5
+ require "json"
5
6
  require "beanstalkd_view/version"
6
7
  require "beanstalkd_view/beanstalkd_utils"
7
8
  require 'beanstalkd_view/server'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beanstalkd_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-22 00:00:00.000000000 Z
12
+ date: 2012-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &2152269980 !ruby/object:Gem::Requirement
16
+ requirement: &2160590880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152269980
24
+ version_requirements: *2160590880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: beanstalk-client
27
- requirement: &2152268620 !ruby/object:Gem::Requirement
27
+ requirement: &2160706180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,21 @@ dependencies:
32
32
  version: 1.1.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152268620
35
+ version_requirements: *2160706180
36
+ - !ruby/object:Gem::Dependency
37
+ name: json
38
+ requirement: &2160705540 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2160705540
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rake
38
- requirement: &2152267240 !ruby/object:Gem::Requirement
49
+ requirement: &2160704600 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *2152267240
57
+ version_requirements: *2160704600
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: rack-test
49
- requirement: &2152265980 !ruby/object:Gem::Requirement
60
+ requirement: &2160703660 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '0'
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *2152265980
68
+ version_requirements: *2160703660
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rspec
60
- requirement: &2152263720 !ruby/object:Gem::Requirement
71
+ requirement: &2160702140 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ! '>='
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: '0'
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *2152263720
79
+ version_requirements: *2160702140
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: capybara
71
- requirement: &2152278100 !ruby/object:Gem::Requirement
82
+ requirement: &2160700900 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,7 +87,7 @@ dependencies:
76
87
  version: '0'
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *2152278100
90
+ version_requirements: *2160700900
80
91
  description: A Sinatra app to view/manage beanstalkd queues that can be embedded in
81
92
  a Rails app similar to what's available in Resque
82
93
  email: dennis.kuczynski@gmail.com
@@ -96,11 +107,13 @@ files:
96
107
  - lib/beanstalkd_view/resources/bootstrap/img/glyphicons-halflings.png
97
108
  - lib/beanstalkd_view/resources/bootstrap/js/bootstrap.min.js
98
109
  - lib/beanstalkd_view/resources/js/jquery-1.7.1.min.js
110
+ - lib/beanstalkd_view/resources/js/peek_jobs.js
99
111
  - lib/beanstalkd_view/server.rb
100
112
  - lib/beanstalkd_view/version.rb
101
113
  - lib/beanstalkd_view/views/error.erb
102
114
  - lib/beanstalkd_view/views/general_stats.erb
103
115
  - lib/beanstalkd_view/views/index.erb
116
+ - lib/beanstalkd_view/views/job_info_popup.erb
104
117
  - lib/beanstalkd_view/views/layout.erb
105
118
  - lib/beanstalkd_view/views/tube_stats.erb
106
119
  - lib/beanstalkd_view/views/tubes.erb