diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 0d2b687..4cbf858 100755 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -25,10 +25,7 @@ class MapsController < ApplicationController before_filter :require_user def index - if session[:uploadSuccess] - flash.now[:notice] = "File has been uploaded successfully" - session[:uploadSuccess] = false - end + end def uploadFile @@ -36,5 +33,24 @@ class MapsController < ApplicationController session[:uploadSuccess] = post redirect_to(:back) end + + def deleteMap + map = Map.find_by_map(params[:map]) + if map != nil + map.destroy + directory = "public/maps" + File.delete("#{RAILS_ROOT}/public/maps/#{params[:map]}") + flash.now[:notice] = "Map deleted successfully" + else + flash.now[:error] = "No Map Found" + end + end + + def new + if session[:uploadSuccess] + flash.now[:notice] = "File has been uploaded successfully" + session[:uploadSuccess] = false + end + end end #EOF diff --git a/app/models/map.rb b/app/models/map.rb index 88fc2f8..3504088 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -62,8 +62,4 @@ class Map < ActiveRecord::Base map.map = sha1.hexdigest map.save end - - def getMap() - - end end diff --git a/app/views/maps/deleteMap.html.erb b/app/views/maps/deleteMap.html.erb new file mode 100644 index 0000000..5b8340f --- /dev/null +++ b/app/views/maps/deleteMap.html.erb @@ -0,0 +1,2 @@ +exterminate! +<%= params[:map] %> diff --git a/app/views/maps/index.html.erb b/app/views/maps/index.html.erb index db58d59..86f0e32 100755 --- a/app/views/maps/index.html.erb +++ b/app/views/maps/index.html.erb @@ -1,29 +1,9 @@

Exception Handler Maps


- -<%= form_tag ({:action => 'uploadFile'}, :multipart => true) %> - -
- -
- -
- -
- <%= form_tag ({:action => 'uploadFile'}, :multipart => true) %> -

: -
- <%= file_field 'upload', 'datafile' %>

- <%= submit_tag "Upload" %> +
+Current Maps: +<% Map.all.each do |map| %>
-
- Current Maps: - - <% Map.all.each do |map| %> - -
- <%= map[:package] %> <%= map[:build] %> - - <% end %> -<%= form_tag %> + <%= map[:package] %> <%= map[:build] %> <%= link_to "Delete", "maps/delete/#{map[:map]}" %> +<% end %> diff --git a/app/views/maps/new.html.erb b/app/views/maps/new.html.erb new file mode 100644 index 0000000..3b94fd7 --- /dev/null +++ b/app/views/maps/new.html.erb @@ -0,0 +1,16 @@ +

Exception Handler Map Uploader

+<%= form_tag ({:action => 'uploadFile'}, :multipart => true) %> + +
+ +
+ +
+ +
+ <%= form_tag ({:action => 'uploadFile'}, :multipart => true) %> +

: +
+ <%= file_field 'upload', 'datafile' %>

+ <%= submit_tag "Upload" %> +<%= form_tag %> diff --git a/config/routes.rb b/config/routes.rb index 4a6fe68..c1d1209 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,8 +20,10 @@ # When a new exception report is recieved, it will be compared to existing bug issues. # If there is a match, the existing issue will be updated # if not a new bug issue will be generated. -ActionController::Routing::Routes.draw do |map| +ActionController::Routing::Routes.draw do |map| map.connect '/exceptionhandler', :controller => 'exceptionhandler', :action => 'index' - map.connect '/maps', :controller => 'maps', :action => 'index' + map.connect '/exceptionhandler/maps', :controller => 'maps', :action => 'index' map.connect '/uploadFile', :controller => 'maps', :action => 'uploadFile' + map.connect '/exceptionhandler/maps/delete/:map', :controller => 'maps', :action => 'deleteMap' + map.connect '/exceptionhandler/maps/new', :controller => 'maps', :action => 'new' end