exception_notification_server 0.0.1 → 0.0.2
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 +4 -4
- data/VERSION +1 -1
- data/app/assets/javascripts/exception_notification_server/pages/notifications.js.coffee +19 -1
- data/app/controllers/exception_notification_server/notifications_controller.rb +22 -16
- data/app/helpers/exception_notification_server/application_helper.rb +1 -1
- data/app/models/exception_notification_server/notification.rb +25 -2
- data/app/views/exception_notification_server/notifications/_notifications.html.haml +5 -0
- data/app/views/exception_notification_server/notifications/index.html.haml +6 -1
- data/app/views/exception_notification_server/notifications/index.js.haml +2 -1
- data/app/views/exception_notification_server/notifications/show.html.haml +1 -0
- data/config/routes.rb +7 -1
- data/exception_notification_server.gemspec +1 -1
- data/lib/exception_notification_server/version.rb +1 -1
- data/readme.md +56 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff6c4b7d7d6d97d6904d24ee91605c7e5c14b2b6
|
4
|
+
data.tar.gz: db3b49e19a0f56b3c96ad6a6360bf7e73c87600a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49d28e04e01f321f6d40c0325bd4f9846b965f58a1264e484cdd4438544692e64b11e9990c4eb563cb21bd2c48dbc19374c3f268a78bc5bbbddda1163cfd8857
|
7
|
+
data.tar.gz: 933ace4582c0c80ddbd9597728c92c9248542b21200d12e0e5f859339800fa6d29ffbf7663914e72d113a4e76dbef4383ac7e107c1a5bbb80765b2a99ba4203a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -1,3 +1,17 @@
|
|
1
|
+
@initialize_links = ->
|
2
|
+
$('.actions a').on 'click', (e)->
|
3
|
+
e.preventDefault()
|
4
|
+
e.stopPropagation()
|
5
|
+
ids = $("input[type='checkbox'][name='ids[]']").serializeArray().map((item)-> item.value)
|
6
|
+
return if ids.length == 0
|
7
|
+
$.ajax
|
8
|
+
url: $(this).attr('href')
|
9
|
+
type: $(this).data('ajax-method') || 'put'
|
10
|
+
dataType: 'json'
|
11
|
+
data:
|
12
|
+
ids: ids
|
13
|
+
success: ->
|
14
|
+
$('.filter form').trigger('submit.rails')
|
1
15
|
$ ->
|
2
16
|
$('body.notifications_show').each ->
|
3
17
|
options =
|
@@ -11,5 +25,9 @@ $ ->
|
|
11
25
|
xaxis:
|
12
26
|
mode: 'time',
|
13
27
|
timeformat: "%m/%d/%y",
|
14
|
-
tickSize: [7,
|
28
|
+
tickSize: [7, 'day'],
|
15
29
|
$('.graph').plot([$('.graph').data('values')], options)
|
30
|
+
$('body.notifications_index').each ->
|
31
|
+
initialize_links()
|
32
|
+
$(document).on 'change', "input[type='checkbox'][name='ids-select-all']", ->
|
33
|
+
$("input[type='checkbox'][name='ids[]']").prop('checked', $(this).prop('checked'))
|
@@ -4,11 +4,11 @@ module ExceptionNotificationServer
|
|
4
4
|
password: ExceptionNotificationServer.configuration.password, only: :create
|
5
5
|
respond_to :html, :json, :js
|
6
6
|
|
7
|
-
before_filter :load_notification, only: [:show, :update
|
7
|
+
before_filter :load_notification, only: [:show, :update]
|
8
8
|
skip_before_filter :redirect_to_root, only: [:create]
|
9
9
|
|
10
10
|
def index
|
11
|
-
params[:env] ||=
|
11
|
+
params[:env] ||= 'all'
|
12
12
|
params[:status] ||= :new
|
13
13
|
@notifications = Notification.base_notifications(params[:status])
|
14
14
|
.application(params[:application])
|
@@ -18,7 +18,6 @@ module ExceptionNotificationServer
|
|
18
18
|
.group('"exception_notification_server_notifications"."id"')
|
19
19
|
.order('count(ensn.id) DESC')
|
20
20
|
.paginate(page: params[:page], per_page: 10)
|
21
|
-
# .where('last month')
|
22
21
|
respond_with @notifications
|
23
22
|
end
|
24
23
|
|
@@ -35,29 +34,24 @@ module ExceptionNotificationServer
|
|
35
34
|
end
|
36
35
|
|
37
36
|
def update
|
38
|
-
@notification
|
37
|
+
update_notification(@notification, notification_params_update, params[:recursive])
|
39
38
|
respond_with @notification
|
40
39
|
end
|
41
40
|
|
42
41
|
def investigate
|
43
|
-
|
44
|
-
params[:notification] ||= {}
|
45
|
-
params[:notification][:status] = :investigating
|
46
|
-
update
|
42
|
+
notifications_actions { |notification| update_notification(notification, { status: :investigating }, true) }
|
47
43
|
end
|
48
44
|
|
49
45
|
def fix
|
50
|
-
|
51
|
-
params[:notification] ||= {}
|
52
|
-
params[:notification][:status] = :fixed
|
53
|
-
update
|
46
|
+
notifications_actions { |notification| update_notification(notification, { status: :fixed }, true) }
|
54
47
|
end
|
55
48
|
|
56
49
|
def renew
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
50
|
+
notifications_actions { |notification| update_notification(notification, { status: :new }, true) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def destroy
|
54
|
+
notifications_actions(&:destroy_recursive)
|
61
55
|
end
|
62
56
|
|
63
57
|
protected
|
@@ -93,5 +87,17 @@ module ExceptionNotificationServer
|
|
93
87
|
def notification_params_update
|
94
88
|
params.require(:notification).permit!
|
95
89
|
end
|
90
|
+
|
91
|
+
def update_notification(notification, notification_params = notification_params_update, recursive = true)
|
92
|
+
notification.send("update#{'_recursive_all' if recursive}", notification_params)
|
93
|
+
notification.remove_data if recursive && notification_params[:status] == :fixed
|
94
|
+
notification.recover_data if recursive && notification_params[:status] == :new && notification.status == 'fixed'
|
95
|
+
end
|
96
|
+
|
97
|
+
def notifications_actions(&block)
|
98
|
+
notications = Notification.where(id: params[:ids] || params[:id])
|
99
|
+
notications.each(&block)
|
100
|
+
params[:id] && notications.first ? respond_with(notications.first) : respond_with({}, location: root_path)
|
101
|
+
end
|
96
102
|
end
|
97
103
|
end
|
@@ -18,7 +18,7 @@ module ExceptionNotificationServer
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def environment_options(options)
|
21
|
-
default_environment = %w(production staging development test)
|
21
|
+
default_environment = %w(all production staging development test)
|
22
22
|
options_for_select((default_environment + Notification.group(:env).pluck(:env)).uniq.map { |env| [env.humanize, env] }, options[:selected])
|
23
23
|
end
|
24
24
|
|
@@ -15,7 +15,7 @@ module ExceptionNotificationServer
|
|
15
15
|
scope "#{status}_notifications", -> { where(status: status) }
|
16
16
|
end
|
17
17
|
scope :application, ->(application = nil) { application.present? ? where(application: application) : all }
|
18
|
-
scope :env, ->(env = nil) { where(env: env || Rails.env) }
|
18
|
+
scope :env, ->(env = nil) { env == 'all' ? all : where(env: env || Rails.env) }
|
19
19
|
|
20
20
|
before_create do
|
21
21
|
self.status = :new
|
@@ -45,10 +45,29 @@ module ExceptionNotificationServer
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def update_recursive(updates)
|
48
|
-
base_id
|
48
|
+
Notification.where(parent_id: base_id).update_all(updates) if base_id.present?
|
49
|
+
end
|
50
|
+
|
51
|
+
def update_recursive_all(updates)
|
49
52
|
Notification.where(arel_table[:id].eq(base_id).or(arel_table[:parent_id].eq(base_id))).update_all(updates) if base_id.present?
|
50
53
|
end
|
51
54
|
|
55
|
+
# Those 4 fields can contain a lot of information (like 0.22mb), so we wanna decrease it by removing this info from children notification.
|
56
|
+
# I think it is enough to have this info in base notification.
|
57
|
+
def remove_data
|
58
|
+
update_recursive(data: nil, request: nil, session: nil, environment: nil)
|
59
|
+
end
|
60
|
+
|
61
|
+
# We recover information from base notification. Better solution is just use base info but i wanna divide notifications.
|
62
|
+
def recover_data
|
63
|
+
base_notification = Notification.find(base_id)
|
64
|
+
update_recursive(data: base_notification.data, request: base_notification.request, session: base_notification.session, environment: base_notification.environment)
|
65
|
+
end
|
66
|
+
|
67
|
+
def destroy_recursive
|
68
|
+
Notification.where(arel_table[:id].eq(base_id).or(arel_table[:parent_id].eq(base_id))).delete_all if base_id.present?
|
69
|
+
end
|
70
|
+
|
52
71
|
protected
|
53
72
|
|
54
73
|
def graph_data(from)
|
@@ -65,5 +84,9 @@ module ExceptionNotificationServer
|
|
65
84
|
def gen_exception_hash
|
66
85
|
Digest::SHA1.hexdigest("#{application}#{exception_class}#{exception_message}#{backtrace.to_s.gsub(rails_root, '')}")
|
67
86
|
end
|
87
|
+
|
88
|
+
def base_id
|
89
|
+
parent_id || id
|
90
|
+
end
|
68
91
|
end
|
69
92
|
end
|
@@ -2,10 +2,13 @@
|
|
2
2
|
count = local_assigns.fetch :count, true
|
3
3
|
last_time = local_assigns.fetch :last_time, true
|
4
4
|
env = local_assigns.fetch :env, false
|
5
|
+
checkbox = local_assigns.fetch :checkbox, false
|
5
6
|
%table
|
6
7
|
%thead
|
7
8
|
%tr
|
8
9
|
%th
|
10
|
+
- if checkbox
|
11
|
+
%th= check_box_tag 'ids-select-all', 'select-all'
|
9
12
|
%th.hide-md Class
|
10
13
|
%th Message
|
11
14
|
%th.hide-md.hide-lg{style: 'width: 100px'} Server
|
@@ -22,6 +25,8 @@
|
|
22
25
|
- notifications.each do |notification|
|
23
26
|
%tr
|
24
27
|
%td= link_to notification.id, notification_path(notification)
|
28
|
+
- if checkbox
|
29
|
+
%td= check_box_tag 'ids[]', notification.id
|
25
30
|
%td.hide-md= link_to notification.exception_class, notification_path(notification)
|
26
31
|
%td= link_to notification.exception_message, notification_path(notification)
|
27
32
|
%td.hide-md.hide-lg= link_to notification.server, notification_path(notification)
|
@@ -3,5 +3,10 @@
|
|
3
3
|
= select_tag :status, status_options(selected: params[:status]), onchange: '$(this.form).trigger(\'submit.rails\')'
|
4
4
|
= select_tag :application, application_options(selected: params[:application]), prompt: 'All', onchange: '$(this.form).trigger(\'submit.rails\')'
|
5
5
|
= select_tag :env, environment_options(selected: params[:env]), onchange: '$(this.form).trigger(\'submit.rails\')'
|
6
|
-
|
6
|
+
.actions
|
7
|
+
= link_to 'Investigate', investigate_notifications_path, data: {ajax_method: :put}
|
8
|
+
= link_to 'Fix', fix_notifications_path, data: {ajax_method: :put}
|
9
|
+
= link_to 'Renew', renew_notifications_path, data: {ajax_method: :put}
|
10
|
+
= link_to 'Destroy', notifications_path, data: {ajax_method: :delete}
|
11
|
+
= render partial: 'exception_notification_server/notifications/notifications', object: @notifications, as: :notifications, locals: {env: true, checkbox: true}
|
7
12
|
= will_paginate @notifications, remote: true
|
@@ -1,2 +1,3 @@
|
|
1
|
-
$('body > .content').html("#{escape_javascript( render file: 'exception_notification_server/notifications/index', layout: false, formats: [:html] )}");
|
1
|
+
$('body > .content').html("#{escape_javascript( render file: 'exception_notification_server/notifications/index', layout: false, formats: [:html], locals: {env: true, checkbox: true} )}");
|
2
2
|
initialize_sparkline();
|
3
|
+
initialize_links();
|
@@ -2,6 +2,7 @@
|
|
2
2
|
= link_to 'Investigate', investigate_notification_path, data: {method: :put} if @notification.status.to_sym == :new
|
3
3
|
= link_to 'Fix', fix_notification_path, data: {method: :put} if @notification.status.to_sym == :investigating
|
4
4
|
= link_to 'Renew', renew_notification_path, data: {method: :put} if @notification.status.to_sym == :fixed
|
5
|
+
= link_to 'Destroy', notification_path, data: {method: :delete}
|
5
6
|
.graphic
|
6
7
|
%h3 Last 3 month count:
|
7
8
|
.graph{data: {values: @notification.similar_count_flot.to_json}}
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
ExceptionNotificationServer::Engine.routes.draw do
|
2
|
-
resources :notifications, only: [:index, :create, :show, :update] do
|
2
|
+
resources :notifications, only: [:index, :create, :show, :update, :destroy] do
|
3
3
|
member do
|
4
4
|
put :investigate
|
5
5
|
put :fix
|
6
6
|
put :renew
|
7
7
|
end
|
8
|
+
collection do
|
9
|
+
put :investigate
|
10
|
+
put :fix
|
11
|
+
put :renew
|
12
|
+
delete :destroy
|
13
|
+
end
|
8
14
|
end
|
9
15
|
root to: 'notifications#index'
|
10
16
|
end
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ['lib']
|
13
13
|
s.authors = ['Anatoliy Varanitsa']
|
14
|
-
s.date = '2015-10-
|
14
|
+
s.date = '2015-10-19'
|
15
15
|
s.description = 'Gem that receive errors from exception_notification gem and show it grouped on pages'
|
16
16
|
s.email = 'Prizrack13@mail.ru'
|
17
17
|
s.extra_rdoc_files = [
|
data/readme.md
CHANGED
@@ -1,5 +1,60 @@
|
|
1
|
-
|
1
|
+
# Exception Notification Server
|
2
2
|
|
3
|
+
**THIS README IS FOR THE MASTER BRANCH AND REFLECTS THE WORK CURRENTLY EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF EXCEPTION NOTIFICATION, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.**
|
4
|
+
|
5
|
+
-
|
6
|
+
|
7
|
+
The Exception Notification Server gem provides a engine for receiving notifications from Exception Notification gem (webhook-notifier).
|
8
|
+
|
9
|
+
|
10
|
+
## Requirements
|
11
|
+
|
12
|
+
* Ruby 1.9.2 or greater
|
13
|
+
* Rails 4.1 or greater.
|
14
|
+
|
15
|
+
For previous releases, please checkout [this](#versions).
|
16
|
+
|
17
|
+
|
18
|
+
## Getting Started
|
19
|
+
|
20
|
+
Add the following line to your application's Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
3
23
|
gem 'exception_notification_server'
|
24
|
+
```
|
4
25
|
|
26
|
+
Run
|
5
27
|
rails g exception_notification_server:install
|
28
|
+
|
29
|
+
This command generates an initialize file (`config/initializers/exception_notification_server.rb`) where you can customize your configurations, migration and add routes.
|
30
|
+
|
31
|
+
### Webhook notifier
|
32
|
+
|
33
|
+
This notifier ships notifications over the HTTP protocol.
|
34
|
+
|
35
|
+
#### Usage
|
36
|
+
|
37
|
+
Just add the [HTTParty](https://github.com/jnunemaker/httparty) gem to your `Gemfile`:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
gem 'httparty'
|
41
|
+
```
|
42
|
+
|
43
|
+
To configure it, you need to set the `url` option, like this:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
ExceptionNotification.configure do |config|
|
47
|
+
config.add_notifier :webhook, {
|
48
|
+
url: 'http://domain.com:5555/notifier/notifications.json',
|
49
|
+
verify: false,
|
50
|
+
basic_auth: {
|
51
|
+
username: 'username',
|
52
|
+
password: 'password'
|
53
|
+
},
|
54
|
+
body: {
|
55
|
+
application: 'application_name',
|
56
|
+
env: Rails.env
|
57
|
+
}
|
58
|
+
}
|
59
|
+
end
|
60
|
+
```
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_notification_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoliy Varanitsa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|