Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Decommissioned as a status. #371

Merged
merged 8 commits into from
Jul 9, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,10 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.24.0)
minitest (5.24.1)
msgpack (1.7.2)
mutex_m (0.2.0)
mysql2 (0.5.6)
net-imap (0.4.13)
net-imap (0.4.14)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -265,7 +264,7 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.0)
rexml (3.3.1)
strscan
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
Expand Down Expand Up @@ -299,12 +298,12 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-rails (2.25.0)
rubocop-rails (2.25.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.0.1)
rubocop-rspec (3.0.2)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
rubyzip (2.3.2)
Expand Down Expand Up @@ -359,15 +358,14 @@ GEM
sqlite3 (1.7.3-x86-linux)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
sshkit (1.22.2)
sshkit (1.23.0)
base64
mutex_m
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
strscan (3.1.0)
thor (1.3.1)
tilt (2.3.0)
tilt (2.4.0)
timeout (0.4.1)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
Expand All @@ -384,7 +382,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
websocket (1.2.10)
websocket (1.2.11)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/front_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ def search
@parameter = params[:search].downcase
search_term = "%#{@parameter}%"

software_records_columns = SoftwareRecord.columns.map { |column| "lower(#{column.name}) LIKE :search" }
@softwarerecords_results = SoftwareRecord.where(software_records_columns.join(' OR '), search: search_term)
software_records_columns = SoftwareRecord.columns.map { |column| "lower(software_records.#{column.name}) LIKE :search" }
@softwarerecords_results = SoftwareRecord.joins(:status)
.where.not(statuses: { status_type: 'Decommissioned' })
.where(software_records_columns.join(' OR '), search: search_term)

vendor_records_columns = VendorRecord.columns.map { |column| "lower(#{column.name}) LIKE :search" }
@vendorrecords_results = VendorRecord.where(vendor_records_columns.join(' OR '), search: search_term)
Expand Down
48 changes: 39 additions & 9 deletions app/controllers/software_records_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ def index
@params = request.query_parameters

@software_records = if @params['filter_by'].to_s == 'software_types' && !@params['software_type_filter'].nil? && !@params['software_type_filter'].empty?
SoftwareRecord.where(software_type_id: @params['software_type_filter']).order("#{sort_column} #{sort_direction}")
SoftwareRecord.joins(:status).where(software_type_id:
@params['software_type_filter']).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_column} #{sort_direction}")
elsif @params['filter_by'].to_s == 'vendor_records' && !@params['vendor_record_filter'].nil? && !@params['vendor_record_filter'].empty?
SoftwareRecord.where(vendor_record_id: @params['vendor_record_filter']).order("#{sort_column} #{sort_direction}")
SoftwareRecord.joins(:status).where(vendor_record_id:
@params['vendor_record_filter']).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_column} #{sort_direction}")
else
SoftwareRecord.order("#{sort_column} #{sort_direction}")
SoftwareRecord.joins(:status).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_column}
#{sort_direction}")
end
@vendor_records = VendorRecord.all
@software_types = SoftwareType.all
Expand Down Expand Up @@ -158,16 +161,40 @@ def check_and_decrypt(sensitive_data)
decrypt sensitive_data if sensitive_data.to_s.present?
end

def list_decommissioned
$page_title = 'Decommissioned Software | UCL Application Portfolio'
@params = request.query_parameters

@software_records = if @params['filter_by'].to_s == 'software_types' && !@params['software_type_filter'].nil? &&
!@params['software_type_filter'].empty?
SoftwareRecord.joins(:status).where(software_type_id: @params['software_type_filter']).where(status:
'Decommissioned').order("#{sort_priority} #{sort_direction_priority}")
elsif @params['filter_by'].to_s == 'vendor_records' && !@params['vendor_record_filter'].nil? &&
!@params['vendor_record_filter'].empty?
SoftwareRecord.joins(:status).where(vendor_record_id: @params['vendor_record_filter']).where(status:
'Decommissioned').order("#{sort_priority} #{sort_direction_priority}")
else
SoftwareRecord.joins(:status).where(statuses: { status_type: 'Decommissioned' }).order("#{sort_column}
#{sort_direction}")
end
@vendor_records = VendorRecord.all
@software_types = SoftwareType.all
@softwarerecords_count = SoftwareRecord.count
end

def list_upgrades
$page_title = 'Maintenance Priority| UCL Application Portfolio'
@params = request.query_parameters

@software_records = if @params['filter_by'].to_s == 'software_types' && !@params['software_type_filter'].nil? && !@params['software_type_filter'].empty?
SoftwareRecord.where(software_type_id: @params['software_type_filter']).order("#{sort_priority} #{sort_direction_priority}")
SoftwareRecord.joins(:status).where(software_type_id:
@params['software_type_filter']).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_priority} #{sort_direction_priority}")
elsif @params['filter_by'].to_s == 'vendor_records' && !@params['vendor_record_filter'].nil? && !@params['vendor_record_filter'].empty?
SoftwareRecord.where(vendor_record_id: @params['vendor_record_filter']).order("#{sort_priority} #{sort_direction_priority}")
SoftwareRecord.joins(:status).where(vendor_record_id:
@params['vendor_record_filter']).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_priority} #{sort_direction_priority}")
else
SoftwareRecord.order("#{sort_priority} #{sort_direction_priority}")
SoftwareRecord.joins(:status).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_priority}
#{sort_direction_priority}")
end
@vendor_records = VendorRecord.all
@software_types = SoftwareType.all
Expand All @@ -179,12 +206,15 @@ def list_road_map
@params = request.query_parameters

@software_records = if @params['filter_by'].to_s == 'software_types' && !@params['software_type_filter'].nil? && !@params['software_type_filter'].empty?
SoftwareRecord.where(software_type_id: @params['software_type_filter']).order("#{sort_priority} #{sort_direction_priority}")
SoftwareRecord.joins(:status).where(software_type_id: @params['software_type_filter']).where.not(status:
'Decommissioned').order("#{sort_priority} #{sort_direction_priority}")
elsif @params['filter_by'].to_s == 'vendor_records' && !@params['vendor_record_filter'].nil? &&
!@params['vendor_record_filter'].empty?
SoftwareRecord.where(vendor_record_id: @params['vendor_record_filter']).order("#{sort_priority} #{sort_direction_priority}")
SoftwareRecord.joins(:status).where(vendor_record_id: @params['vendor_record_filter']).where.not(status:
'Decommissioned').order("#{sort_priority} #{sort_direction_priority}")
else
SoftwareRecord.order("#{sort_column} #{sort_direction}")
SoftwareRecord.joins(:status).where.not(statuses: { status_type: 'Decommissioned' }).order("#{sort_column}
#{sort_direction}")
end
@vendor_records = VendorRecord.all
@software_types = SoftwareType.all
Expand Down
9 changes: 5 additions & 4 deletions app/views/shared/_dashboard_menu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
<a href="<%= hosting_environments_path %>"><i class="fab fa-envira float-right"></i> View all Hosting Environments</a>
<a href="<%= change_requests_path %>"><i class="fab fa-envira float-right"></i> View all Change Requests</a>
<hr style="background-color: white">
<a href="<%= list_upgrades_path %>"><i class="fas fa-users float-right"></i> Next Software Upgrades</a>
<a href="<%= list_upgrades_path %>"><i class="fas fa-users float-right"></i> Maintenance List</a>
<a href="<%= list_road_map_path %>"><i class="fas fa-users float-right"></i> Road Map List</a>
<a href="<%= list_decommissioned_path %>"><i class="fas fa-users float-right"></i> Decommissioned List</a>
<a href="<%= users_path %>"><i class="fas fa-users float-right"></i> Manage all Users</a>
<a href="<%= file_uploads_new_path %>"><i class="fas fa-file-import float-right"></i> Import Data</a>
<hr style="background-color: white">
Expand All @@ -47,9 +48,9 @@
<a href="<%= statuses_path %>"><i class="far fa-file-alt float-right"></i> View all Status</a>
<a href="<%= hosting_environments_path %>"><i class="fab fa-envira float-right"></i> View all Hosting Environments</a>
<hr style="background-color: white">
<a href="<%= list_upgrades_path %>"><i class="fas fa-users float-right"></i> Next Software Upgrades</a>
<a href="<%= list_upgrades_path %>"><i class="fas fa-users float-right"></i> Maintenance List</a>
<a href="<%= list_road_map_path %>"><i class="fas fa-users float-right"></i> Road Map List</a>
<a href="<%= change_requests_path %>"><i class="fab fa-envira float-right"></i> View all Change Requests</a>
<a href="<%= change_requests_path %>"><i class="fab fa-envira float-right"></i> Change Request List</a>
</div>
<br/>
<% end %>
Expand All @@ -65,7 +66,7 @@
<a href="<%= hosting_environments_path %>"><i class="fab fa-envira float-right"></i> View all Hosting Environments</a>
<a href="<%= change_requests_path %>"><i class="fab fa-envira float-right"></i> View all Change Request</a>
<hr style="background-color: white">
<a href="<%= list_upgrades_path %>"><i class="fas fa-users float-right"></i> Next Software Upgrades</a>
<a href="<%= list_upgrades_path %>"><i class="fas fa-users float-right"></i> Maintenance List</a>
<a href="<%= list_road_map_path %>"><i class="fas fa-users float-right"></i> Road Map List</a>
<hr style="background-color: white">
<a href="<%= export_software_records_path %>"><i class="fas fa-file-export float-right"></i> Export Software Records</a>
Expand Down
60 changes: 60 additions & 0 deletions app/views/software_records/list_decommissioned.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<section class="jumbotron text-center">
<br/>
<hr style = "background-color: black; width: 54%;">
<div class="container-fluid">
<h1 class="jumbotron-heading display-4" style="text-align: center; color: black; font-family: Courier New, Lucida, Console">Decommissioned
List</h1>
<em style="font-size: 14px; color: black">Collection of all the software application that have been decommissioned.</em><br/><br/>
</div>
<br/>
<hr style = "background-color: black; width: 54%;">
</section>

<% if @softwarerecords_count != 0 %>
<div class="container animated fadeInLeft" style="margin-bottom: 10rem">
<div class="row">
<table class="table software-records-table" style="word-break: initial;">
<thead>
<tr>
<th class="text-left" style="padding-left: 20px"><%= sortable "title", "Title" %>
<% if params[:direction] == "asc" || params[:direction] == nil %>
<i class="fa fa-caret-up"></i>
<% else %>
<i class="fa fa-caret-down"></i>
<% end %></th>

<% if current_user.role.to_s == "viewer" %>
<th class="text-left" style="padding-left: 20px">Actions</th>
<% elsif current_user.role.to_s == "owner" %>
<th colspan="2" class="text-left" style="padding-left: 20px">Actions</th>
<% else %>
<th colspan="3" class="text-left" style="padding-left: 20px">Actions</th>
<% end %>
</tr>
</thead>

<tbody>
<% @software_records.each do |software_record| %>
<tr>
<td style="padding-left: 40px; white-space: nowrap;"><%= software_record.title %></td>
<% if current_user.role.to_s == "viewer" %>
<td><%= link_to 'View', software_record , { :class => "btn btn-success action-btn" }%></td>
<% elsif current_user.role.to_s == "owner" %>
<td><%= link_to 'View', software_record , { :class => "btn btn-success action-btn" }%></td>
<td><%= link_to 'Edit', edit_software_record_path(software_record), class: "btn btn-primary action-btn", style:
"white-space: nowrap;" %></td>
<% else %>
<td><%= link_to 'View', software_record , { :class => "btn btn-success action-btn" }%></td>
<td><%= link_to 'Edit', edit_software_record_path(software_record), class: "btn btn-primary action-btn", style:
"white-space: nowrap;" %></td>

<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<% else %>
<h3 class="text-center">No records found</h3>
<% end %>
6 changes: 4 additions & 2 deletions app/views/statuses/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
<div class="field">
<%= form.label :status_type %>
<% if component.eql?("new") %>
<%= form.select :status_type, options_for_select(['Design', 'Production', 'Other'], :selected=>"Design"), {}, {:class => "form-control"} %>
<%= form.select :status_type, options_for_select(['Design', 'Production', 'Decommissioned', 'Development', 'Other'], :selected=>"Design"),
{}, {:class => "form-control"} %>
<% else %>
<%= form.select :status_type, options_for_select(['Design', 'Production', 'Other'], :selected=>Status.find_by_id(params[:id]).status_type.to_s), {}, {:class => "form-control"} %>
<%= form.select :status_type, options_for_select(['Design', 'Production', 'Decommissioned', 'Development', 'Other'],
:selected=>Status.find_by_id(params[:id]).status_type.to_s), {}, {:class => "form-control"} %>
<% end %>
</div>
<br/><br/>
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
root 'front#index'
get 'list_upgrades' => 'software_records#list_upgrades'
get 'list_road_map' => 'software_records#list_road_map'
get 'list_decommissioned' => 'software_records#list_decommissioned'

resources :software_records do
member do
get 'edit_road_map'
Expand All @@ -25,6 +27,7 @@

# get 'software_records/:id/edit_roadmap', to: 'software_records#edit_road_map', as: 'edit_road_map_software_record'
get 'edit_road_map_software_records' => 'software_records#list_road_map'
get 'edit_decommissioned_software_records' => 'software_records#list_decommissioned'
get 'about', to: 'front#about'
get 'contact', to: 'front#contact'
get 'request/new', to: 'front#new'
Expand Down
3 changes: 2 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
# Create default status types
status = { 'Available': 'Production',
'Development': 'Design',
'Production': 'Production' }
'Production': 'Production',
'Decommissioned': 'Decommissioned' }

status.each do |name, desc|
Status.create(title: name, status_type: desc)
Expand Down
3 changes: 2 additions & 1 deletion exports/software_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
class SoftwareRecords < ApplicationRecord
def software_records
file = "#{Dir.pwd}/public/software_records.csv"
software_records = SoftwareRecords.all
# software_records = SoftwareRecords.all
software_records = SoftwareRecord.joins(:status).where.not(statuses: { status_type: 'Decommissioned' })

headers = [
'Software Record', 'Description', 'Status', 'Created on', 'Software Type',
Expand Down
10 changes: 10 additions & 0 deletions lib/tasks/create_decommissioned.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

namespace 'app_port' do
desc 'Creates Decommissioned Status'
task create_decom: :environment do
# NOTE: In order to see progress in the logs, you must have logging at :info or above
WorksResave.work_resave
Status.new(title: 'Decommissioned', status_type: 'Decommissioned')
end
end
Loading
Loading