Skip to content
This repository
Browse code

filter controller or controller action via checkbox in column

  • Loading branch information...
commit f96c9fdcc542bf7e5a1281ac98572289aeb9995e 1 parent 083cd70
Andrew Brown omenking authored
18 app/assets/javascripts/rubyception/collections/entries.coffee
... ... @@ -1,3 +1,21 @@
1 1 class App.Collections.Entries extends Backbone.Collection
2 2 model: App.Models.Entry
3 3 url:-> ''
  4 + filter:(args)->
  5 + _.each @models, (model)=>
  6 + controller = model.get 'controller'
  7 + action = model.get 'action'
  8 + check_action = args.controller isnt undefined and args.action isnt undefined
  9 + check_controller = args.controller isnt undefined
  10 +
  11 + trigger = if check_action
  12 + controller is args.controller && action is args.action
  13 + else if check_controller
  14 + controller is args.controller
  15 + else
  16 + false
  17 +
  18 + if trigger && args.trigger is 'ignore'
  19 + model.trigger 'ignore'
  20 + else if trigger && args.trigger is 'notice'
  21 + model.trigger 'notice'
3  app/assets/javascripts/rubyception/collections/filter_actions.coffee
... ... @@ -0,0 +1,3 @@
  1 +class App.Collections.FilterActions extends Backbone.Collection
  2 + url: ''
  3 + model: App.Models.FilterAction
8 app/assets/javascripts/rubyception/lib/jenny.coffee
@@ -57,7 +57,7 @@ CollectionHelpers =
57 57 collect:->
58 58 e = $ @context.el
59 59 find = arguments[0]
60   - has_find = find isnt undefined
  60 + has_find = find isnt undefined && find isnt null
61 61 options = arguments[1]
62 62 options ||= {}
63 63
@@ -65,12 +65,12 @@ CollectionHelpers =
65 65 delete options.template_index
66 66 template_index = ti
67 67 template_index = "#{@name}/index" if ti is undefined
68   - e
69   - html = @context.template template_index, options.args || {}
70 68
71 69 hti = options.has_template_index
72 70 delete options.has_template_index
73   - e.html html if hti != false
  71 + if hti != false
  72 + html = @context.template template_index, options.args || {}
  73 + e.html html
74 74
75 75 t = options.template
76 76 delete options.template
2  app/assets/javascripts/rubyception/models/filter_action.coffee
... ... @@ -0,0 +1,2 @@
  1 +class App.Models.FilterAction extends Backbone.Model
  2 + url: ''
4 app/assets/javascripts/rubyception/routers/log.coffee
@@ -8,6 +8,7 @@ class App.Routers.Log extends Backbone.Router
8 8 socket.onclose = @onclose
9 9 socket.onmessage = @onmessage
10 10 @collection = new App.Collections.Entries()
  11 + App.enteries = @collection
11 12 @collection.model = App.Models.Entry
12 13 @default()
13 14 onmessage:(msg)=>
@@ -39,6 +40,7 @@ class App.Routers.Log extends Backbone.Router
39 40 m.bind 'g g' , _.bind @log.entries_index.goto_number, @, 'top'
40 41 m.bind ['o','enter'], @log.entries_index.toggle_open
41 42 index: =>
  43 + App.column = @partial '.column', 'shared/filters'
42 44 @log = @partial '.content', 'logs/show',
43   - collection: @collection
  45 + collection: @collection
44 46 @hotkeys()
2  app/assets/javascripts/rubyception/template.js
... ... @@ -1 +1 @@
1   -Template = {"entries":{"index":"<div class='entries'></div>\n","entry":"<div class='marker'></div>\n<div class='details'>\n <div class='heading'>\n <div class='method'>{{method}}</div>\n <div class='format'>{{format}}</div>\n {{controller}}#{{action}}\n <div class='path'>{{path}}</div>\n <div class='datetime'>{{start_time}}</div>\n <div class='ms'>{{duration}}ms</div>\n </div>\n <div class='lines'></div>\n <div class='backtrace_lines'></div>\n</div>\n<div class='clear'></div>\n"},"backtrace_lines":{"index":"<table>\n <thead>\n <th class='toggle_rails'>\n <a href=\"#\" class=\"show_rails\" onclick=\"return false\">T</a>\n </th>\n <th class='exception' colspan='3'>\n {{name}}: {{message}}\n </th>\n </thead>\n <tbody></tbody>\n</table>\n","backtrace_line":"<td class='num'>{{num}}</td>\n<td class='msg'><a href=\"mvim://open?url={{url}}&amp;line={{line_num}}\">{{msg}}</a></td>\n<td class='lnum'>{{line_num}}</td>\n<td class='in'>\n <span>{{in}}</span>\n</td>\n"},"lines":{"index":"<table>\n <thead></thead>\n <tbody></tbody>\n</table>\n","action_controller":{"write_fragment":"","read_fragment":"","expire_fragment":"","exist_fragment":"","write_page":"","expire_page":"","start_processing":"","process_action":"","send_file":"","send_data":"","redirect_to":"","halted_callback":""},"action_view":{"render_template":"<td class='msg'>render template</td>\n<td class='identifier'>{{identifier}}</td>\n<td class='layout'>\n <span>layout:</span>\n {{layout}}\n</td>\n<td class='duration' colspan='10'>{{duration}}ms</td>\n","render_partial":"<td class='msg'>render partial</td>\n<td class='identifier'>{{identifier}}</td>\n<td class='duration' colspan='10'>{{duration}}ms</td>\n"},"active_record":{"sql":"<td class='name'>{{name}}</td>\n<td class='sql'>\n <pre class='brush: sql'>{{sql}}</pre>\n</td>\n<td class='duration' colspan='10'>{{duration}}ms</td>\n","identity":"<td class='name'>{{name}}</td>\n<td class='line'>{{line}}</td>\n<td class='duration' colspan='10'>{{duration}}ms</td>\n"},"action_mailer":{"receive":"","deliver":""},"active_resource":{"request":""},"active_support":{"cache_read":"","cache_generate":"","cache_fetch_hit":"","cache_write":"","cache_delete":"","cache_exist":""}}}
  1 +Template = {"entries":{"index":"<div class='entries'></div>\n","entry":"<div class='marker'></div>\n<div class='details'>\n <div class='heading'>\n <div class='method'>{{method}}</div>\n <div class='format'>{{format}}</div>\n {{controller}}#{{action}}\n <div class='path'>{{path}}</div>\n <div class='datetime'>{{start_time}}</div>\n <div class='ms'>{{duration}}ms</div>\n </div>\n <div class='lines'></div>\n <div class='backtrace_lines'></div>\n</div>\n<div class='clear'></div>\n"},"backtrace_lines":{"index":"<table>\n <thead>\n <th class='toggle_rails'>\n <a href=\"#\" class=\"show_rails\" onclick=\"return false\">T</a>\n </th>\n <th class='exception' colspan='3'>\n {{name}}: {{message}}\n </th>\n </thead>\n <tbody></tbody>\n</table>\n","backtrace_line":"<td class='num'>{{num}}</td>\n<td class='msg'><a href=\"mvim://open?url={{url}}&amp;line={{line_num}}\">{{msg}}</a></td>\n<td class='lnum'>{{line_num}}</td>\n<td class='in'>\n <span>{{in}}</span>\n</td>\n"},"shared":{"filter_controller":"<input id=\"filter\" name=\"filter\" type=\"checkbox\" value=\"1\" />\n{{controller}}\n<div class='filter_actions'></div>\n","filter_action":"<input id=\"filter\" name=\"filter\" type=\"checkbox\" value=\"1\" />\n{{action}}\n"},"lines":{"index":"<table>\n <thead></thead>\n <tbody></tbody>\n</table>\n","action_controller":{"write_fragment":"","read_fragment":"","expire_fragment":"","exist_fragment":"","write_page":"","expire_page":"","start_processing":"","process_action":"","send_file":"","send_data":"","redirect_to":"","halted_callback":""},"action_view":{"render_template":"<td class='msg'>render template</td>\n<td class='identifier'>{{identifier}}</td>\n<td class='layout'>\n <span>layout:</span>\n {{layout}}\n</td>\n<td class='duration' colspan='10'>{{duration}}ms</td>\n","render_partial":"<td class='msg'>render partial</td>\n<td class='identifier'>{{identifier}}</td>\n<td class='duration' colspan='10'>{{duration}}ms</td>\n"},"active_record":{"sql":"<td class='name'>{{name}}</td>\n<td class='sql'>\n <pre class='brush: sql'>{{sql}}</pre>\n</td>\n<td class='duration' colspan='10'>{{duration}}ms</td>\n","identity":"<td class='name'>{{name}}</td>\n<td class='line'>{{line}}</td>\n<td class='duration' colspan='10'>{{duration}}ms</td>\n"},"action_mailer":{"receive":"","deliver":""},"active_resource":{"request":""},"active_support":{"cache_read":"","cache_generate":"","cache_fetch_hit":"","cache_write":"","cache_delete":"","cache_exist":""}}}
13 app/assets/javascripts/rubyception/views/entries/entry.coffee
@@ -3,6 +3,8 @@ class App.Views.Entries.Entry extends Backbone.View
3 3 events:
4 4 'click': 'select_and_toggle'
5 5 initialize: ->
  6 + @model.bind 'notice', @notice
  7 + @model.bind 'ignore', @ignore
6 8 @render()
7 9 select_and_toggle: (event) =>
8 10 target = $ event.target
@@ -12,6 +14,7 @@ class App.Views.Entries.Entry extends Backbone.View
12 14 @index.entry $ @el
13 15 @index.toggle_open()
14 16 render: =>
  17 + @add_to_filters()
15 18 @el_template 'entries/entry'
16 19 @color_ms()
17 20 @color_marker()
@@ -19,7 +22,6 @@ class App.Views.Entries.Entry extends Backbone.View
19 22 @lines()
20 23 backtrace:->
21 24 backtrace = @model.get 'backtrace'
22   - console.log backtrace
23 25 if backtrace
24 26 el = $(@el).find '.backtrace_lines'
25 27 @collect 'backtrace_lines',
@@ -47,3 +49,12 @@ class App.Views.Entries.Entry extends Backbone.View
47 49 else 'slow'
48 50 e = $(@el).find '.ms'
49 51 e.addClass c
  52 + ignore:=> $(@el).addClass 'ignore'
  53 + notice:=> $(@el).removeClass 'ignore'
  54 + add_to_filters:->
  55 + controller = @model.get 'controller'
  56 + action = @model.get 'action'
  57 + App.filters[controller] = [] if App.filters[controller] is undefined
  58 + App.filters[controller].push action
  59 + App.filters[controller] = _.uniq App.filters[controller]
  60 + App.column.render()
20 app/assets/javascripts/rubyception/views/shared/filter_action.coffee
... ... @@ -0,0 +1,20 @@
  1 +class App.Views.Shared.FilterAction extends Backbone.View
  2 + className: 'filter_action'
  3 + events:
  4 + 'click input': 'filter'
  5 + initialize:->
  6 + @render()
  7 + render:->
  8 + @el_template 'shared/filter_action'
  9 + filter:(e)->
  10 + parent = $(e.currentTarget).parent().parent().parent()
  11 + checked = parent.find('input:first').is(':checked')
  12 + if checked is false
  13 + controller = @model.get 'controller'
  14 + action = @model.get 'action'
  15 + checked = $(e.currentTarget).is(':checked')
  16 + trigger = if checked then 'ignore' else 'notice'
  17 + App.enteries.filter
  18 + controller : controller
  19 + aciton : action
  20 + trigger : trigger
22 app/assets/javascripts/rubyception/views/shared/filter_controller.coffee
... ... @@ -0,0 +1,22 @@
  1 +class App.Views.Shared.FilterController extends Backbone.View
  2 + className: 'filter_controller'
  3 + events:
  4 + 'click input:first': 'filter'
  5 + initialize:->
  6 + @render()
  7 + render:->
  8 + @el_template 'shared/filter_controller'
  9 + @collect 'filter_actions',
  10 + el : @$ '.filter_actions'
  11 + template: 'shared/filter_actions'
  12 + filters = @model.get 'filters'
  13 + @collection.reset filters
  14 + filter:(e)->
  15 + e = $(e.currentTarget)
  16 + controller = @model.get 'controller'
  17 + checked = e.is(':checked')
  18 + trigger = if checked then 'ignore' else 'notice'
  19 + $(@el).find('input').attr 'checked', checked
  20 + App.enteries.filter
  21 + controller : controller
  22 + trigger : trigger
15 app/assets/javascripts/rubyception/views/shared/filters.coffee
... ... @@ -0,0 +1,15 @@
  1 +class App.Views.Shared.Filters extends Backbone.View
  2 + initialize:->
  3 + App.filters = {}
  4 + @render()
  5 + render:->
  6 + $(@el).empty()
  7 + _.each App.filters, (v,k)=>
  8 + v = _.map v, (action)=>
  9 + {controller: k, action: v}
  10 + attrs =
  11 + controller : k
  12 + filters : v
  13 + model = new Backbone.Model attrs
  14 + e = @partial null, 'shared/filter_controller', model: model
  15 + $(@el).append e.el
7 app/assets/javascripts/rubyception/views/shared/filters_actions.coffee
... ... @@ -0,0 +1,7 @@
  1 +class App.Views.Shared.FilterActions extends Backbone.View
  2 + initialize:->
  3 + @bind_render()
  4 + render:->
  5 + @collection.collect null,
  6 + template : 'shared/filter_action'
  7 + has_template_index : false
7 app/assets/stylesheets/rubyception/default.sass
@@ -24,12 +24,19 @@ html,body
24 24
25 25 .wrapper.filter
26 26 .column
  27 + :display block
27 28 :float left
28 29 :width 260px
29 30 :margin-left -100%
  31 + :color rgb(195,195,195)
  32 + :font-size 14px
30 33 .content_wrap
31 34 :float left
32 35 :width 100%
33 36 .content
34 37 :margin
35 38 :left 260px
  39 +
  40 +.filter_action
  41 + :padding
  42 + :left 15px
2  app/assets/stylesheets/rubyception/entries.sass
@@ -47,6 +47,8 @@
47 47 :color rgb(120,120,120)
48 48 .lines, .backtrace_lines
49 49 :display none
  50 + &.ignore
  51 + :display none
50 52 &.selected
51 53 :background rgb(55,55,55)
52 54 &.open
2  app/views/rubyception/shared/_filter_action.haml
... ... @@ -0,0 +1,2 @@
  1 += check_box_tag :filter
  2 +{{action}}
3  app/views/rubyception/shared/_filter_controller.haml
... ... @@ -0,0 +1,3 @@
  1 += check_box_tag :filter
  2 +{{controller}}
  3 +.filter_actions
3  config/templating.yml
@@ -4,6 +4,9 @@ entries:
4 4 backtrace_lines:
5 5 - index
6 6 - backtrace_line
  7 +shared:
  8 + - filter_controller
  9 + - filter_action
7 10 lines:
8 11 index:
9 12 action_controller:

0 comments on commit f96c9fd

Please sign in to comment.
Something went wrong with that request. Please try again.