delayed_job_ui 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d5748551e76adba7e11cb2fd9193f22a9fd1e44e
4
+ data.tar.gz: adb43b66e8d8d1ce4f9ff129646ded83dfffdac3
5
+ SHA512:
6
+ metadata.gz: 36dadf322d87b7c7a207071891dcdc0f507eb8f01217244ffc37ac637fcebd4b16bad2aac9b722ccd5d64ab2a7df074e166f7d388208d7d026e155e518f41d41
7
+ data.tar.gz: b23ef4af1416fb35675e4556e4c983149c0e7a665d2079c60b2084e780af65cdad816d6af82c8e506cfdda6b19e105a1408593259e24dce4a0c70c6d8e4eea09
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'byebug'
5
+ end
6
+
7
+ gemspec
8
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Sean Woojin Kim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ Delayed Job UI
2
+ ==============
3
+ My first attempt at a gem. A small and simple (and hopefully unintrusive) UI wrapper for delayed_job in Rails
4
+
5
+ To get the routes properly set up, insert this into your routes.rb file.
6
+ ```ruby
7
+ unless Rails.env.production?
8
+ mount DelayedJobUi::Engine => '/delayed_job_ui'
9
+ end
10
+ ```
11
+
12
+ To drop in the UI element, insert the following at the bottom of your application's layout file.
13
+ ```erb
14
+ <% unless Rails.env.production? #prevent this view in production %>
15
+ <%= delayed_job_ui_layout %>
16
+ <% end %>
17
+ ```
@@ -0,0 +1,52 @@
1
+ //= require jquery
2
+ //= require jquery.dataTables
3
+
4
+ window.delayed_job_ui = (function($){
5
+ var dj_obj = {};
6
+ var namespace = ("#delayed-job-ui");
7
+
8
+
9
+ dj_obj.initialize = function(){
10
+ dj_obj.$parent = $(namespace);
11
+ instantiate_datatable();
12
+ tab_handlers();
13
+ hide_tab_content();
14
+ show_active_tab();
15
+ }
16
+
17
+ var instantiate_datatable = function(){
18
+ dj_obj.$parent.find('.job_table').DataTable();
19
+ }
20
+
21
+ var tab_handlers = function() {
22
+ dj_obj.$parent.on('click', '.link_to_tab', function(e){
23
+ e.preventDefault();
24
+ $tab_link = $(e.target);
25
+ set_active_tab($tab_link)
26
+ })
27
+ }
28
+
29
+ var set_active_tab = function($tab_link) {
30
+ var content_id = $tab_link.attr('href');
31
+ var tab_selector = ".tab-title[href='" + content_id + "']";
32
+ var old_content_id = dj_obj.$parent.find(".tab-title.active").attr('href');
33
+ var $old_active = dj_obj.$parent.find(".tab-title.active").removeClass('active');
34
+ var $new_active = dj_obj.$parent.find(tab_selector);
35
+ $new_active.addClass('active');
36
+ dj_obj.$parent.find(content_id).show();
37
+ dj_obj.$parent.find(old_content_id).hide();
38
+ }
39
+
40
+ var hide_tab_content = function(){
41
+ dj_obj.$parent.find(".tab-content").hide();
42
+ }
43
+
44
+ var show_active_tab = function(){
45
+ var content_id = dj_obj.$parent.find(".tab-title.active").attr('href');
46
+ dj_obj.$parent.find(content_id).show();
47
+ }
48
+
49
+ return dj_obj
50
+ })(jQuery);
51
+
52
+ $(window.delayed_job_ui.initialize);