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

Commit

Permalink
Enables administrators to dismiss missing manifest warnings in Dashbo…
Browse files Browse the repository at this point in the history
…ard.
  • Loading branch information
nzmacgeek committed Apr 18, 2013
1 parent d25c1a9 commit 88e4d95
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 108 deletions.
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>

This comment has been minimized.

Copy link
@jnraine

jnraine Apr 18, 2013

Owner

I almost forgot to mention, can you switch out double hyphen for a larger dash (e.g, — or –)?

</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

0 comments on commit 88e4d95

Please sign in to comment.