Skip to content
This repository has been archived by the owner on Mar 1, 2018. It is now read-only.

New feature: allow administrators to dismiss missing manifest warnings #175

Merged
merged 2 commits into from Apr 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/controllers/dashboard_controller.rb
Expand Up @@ -12,6 +12,14 @@ def widget
end
end

def dismiss_manifest
respond_to do |format|
@missing_manifest = MissingManifest.find(params[:id])
@missing_manifest.update_attributes :dismissed => true
format.js
end
end

private
def authorize_resource
authorize! params[:action], :dashboard
Expand Down
2 changes: 2 additions & 0 deletions app/models/missing_manifest.rb
Expand Up @@ -9,9 +9,11 @@ class MissingManifest < ActiveRecord::Base
else
MissingManifest.where("created_at > ?", 7.days.ago)
end
scope = scope.merge(not_dismissed)
scope = scope.limit(options[:limit]) if options[:limit].present?
scope.order("created_at DESC")
}
scope :not_dismissed, where(:dismissed => false)

def request_ip=(value)
self.hostname = get_hostname(value)
Expand Down
1 change: 1 addition & 0 deletions app/views/dashboard/dismiss_manifest.js.erb
@@ -0,0 +1 @@
$("#missing_manifest_<%= @missing_manifest.id %>").fadeOut();
4 changes: 2 additions & 2 deletions app/views/widgets/_missing_manifests.html.erb
@@ -1,9 +1,9 @@
<% if @widget.missing_manifests.present? %>
<% @widget.missing_manifests.each do |missing_manifest|%>
<div class="alert-message">
<div class="alert-message" id="missing_manifest_<%= missing_manifest.id %>">
<p>
<strong><%= missing_manifest %></strong> request manifest for "<strong><%= missing_manifest.identifier %></strong>"
<small><%= missing_manifest.request_time %></small>
<small><%= missing_manifest.request_time %> — <%= link_to "dismiss", dismiss_manifest_path(missing_manifest), :remote => true %></small>
</p>
</div>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -87,6 +87,7 @@

match 'dashboard' => "dashboard#index", :as => "dashboard"
match 'dashboard/widget/:name' => 'dashboard#widget', :as => "widget"
match 'dashboard/dismiss_manifest/:id' => 'dashboard#dismiss_manifest', :as => "dismiss_manifest"

match "permissions" => "permissions#index", :as => "permissions", :via => "GET"
match "permissions/edit/:principal_pointer(/:unit_id)" => "permissions#edit", :as => "edit_permissions", :via => "GET"
Expand Down
@@ -0,0 +1,5 @@
class AddDismissedToMissingManifests < ActiveRecord::Migration
def change
add_column :missing_manifests, :dismissed, :boolean, :default => false
end
end