This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from aaronlippold/control_filter
Added filtering capability, forms, and tests
- Loading branch information
Showing
59 changed files
with
2,157 additions
and
425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class DashboardController < ApplicationController | ||
def index | ||
# nop | ||
session[:filter] = nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
class FilterGroupsController < ApplicationController | ||
load_and_authorize_resource | ||
protect_from_forgery | ||
# authorize_resource only: [:show, :destroy, :filter, :clear_filter] | ||
# before_action :set_filter_group, only: [:show, :edit, :update, :destroy, :remove_filter] | ||
|
||
# GET /filter_groups | ||
# GET /filter_groups.json | ||
def index | ||
@filter_groups = FilterGroup.all | ||
end | ||
|
||
# GET /filter_groups/1 | ||
# GET /filter_groups/1.json | ||
def show | ||
end | ||
|
||
# GET /filter_groups/new | ||
def new | ||
@filter_group = FilterGroup.new | ||
end | ||
|
||
# GET /filter_groups/1/edit | ||
def edit | ||
end | ||
|
||
# POST /filter_groups | ||
# POST /filter_groups.json | ||
def create | ||
@filter_group = FilterGroup.new(filter_group_params) | ||
|
||
respond_to do |format| | ||
if @filter_group.save | ||
format.html { redirect_to @filter_group, notice: 'Filter group was successfully created.' } | ||
format.json { render :show, status: :created, location: @filter_group } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @filter_group.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /filter_groups/1 | ||
# PATCH/PUT /filter_groups/1.json | ||
def update | ||
logger.debug "filter_group_params: #{filter_group_params.inspect}" | ||
if (filter_ids = filter_group_params[:filter_ids]) | ||
if (filter = Filter.find(filter_ids[:id])) | ||
@filter_group.filters << filter | ||
redirect_to @filter_group, notice: 'Filter was added.' | ||
end | ||
else | ||
respond_to do |format| | ||
if @filter_group.update(filter_group_params) | ||
format.html { redirect_to @filter_group, notice: 'Filter group was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @filter_group } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @filter_group.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
end | ||
|
||
# DELETE /filter_groups/1 | ||
# DELETE /filter_groups/1.json | ||
def destroy | ||
@filter_group.destroy | ||
respond_to do |format| | ||
format.html { redirect_to filter_groups_url, notice: 'Filter group was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def filter_group_params | ||
params.require(:filter_group).permit(:name, { filter_ids: [:id] }) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
class FiltersController < ApplicationController | ||
load_and_authorize_resource | ||
protect_from_forgery | ||
|
||
# GET /filters | ||
# GET /filters.json | ||
def index | ||
@filters = Filter.all | ||
end | ||
|
||
# GET /filters/1 | ||
# GET /filters/1.json | ||
def show | ||
end | ||
|
||
# GET /filters/new | ||
def new | ||
@filter = Filter.new | ||
@nist_hash = Constants::NIST_800_53 | ||
end | ||
|
||
# GET /filters/1/edit | ||
def edit | ||
@nist_hash = Constants::NIST_800_53 | ||
end | ||
|
||
# POST /filters | ||
# POST /filters.json | ||
def create | ||
@filter = Filter.valid_filter filter_params | ||
@filter.save | ||
respond_to do |format| | ||
format.html { redirect_to Filter.find(@filter.id), notice: 'Filter was successfully created.' } | ||
format.json { render :show, status: :created, location: @filter } | ||
end | ||
end | ||
|
||
# PATCH/PUT /filters/1 | ||
# PATCH/PUT /filters/1.json | ||
def update | ||
respond_to do |format| | ||
@filter.update(filter_params) | ||
format.html { redirect_to @filter, notice: 'Filter was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @filter } | ||
end | ||
end | ||
|
||
# DELETE /filters/1 | ||
# DELETE /filters/1.json | ||
def destroy | ||
if params.key?(:filter_group_id) | ||
@filter_group = FilterGroup.find(params[:filter_group_id]) | ||
@filter_group.filters.delete(Filter.find(params[:id])) | ||
respond_to do |format| | ||
format.html { redirect_to @filter_group, notice: 'Filter was successfully removed.' } | ||
format.json { head :no_content } | ||
end | ||
else | ||
@filter.destroy | ||
respond_to do |format| | ||
format.html { redirect_to filters_url, notice: 'Filter was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def filter_params | ||
params.require(:filter).permit(family: [], number: [], sub_fam: [], sub_num: [], enhancement: [], enh_sub_fam: [], enh_sub_num: []) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.