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 Road Map Feature #368

Merged
merged 9 commits into from
Jun 6, 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
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ gem 'jbuilder', '~> 2.5'
gem 'rails-controller-testing'
# Use rubocop for static code analysis
gem 'rubocop'

# bundler audit
gem 'rexml', '>= 3.2.7'
gem 'rubocop-rails', require: false

gem 'rubocop-rspec', require: false
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.6)
rexml (3.2.8)
strscan (>= 3.0.9)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
Expand Down Expand Up @@ -364,6 +365,7 @@ GEM
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)
timeout (0.4.1)
Expand Down Expand Up @@ -430,6 +432,7 @@ DEPENDENCIES
rails-controller-testing
rb-readline
recaptcha
rexml (>= 3.2.7)
rspec-rails (~> 4.1.0)
rspec_junit_formatter
rubocop
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/software_records.scss
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ option {
}

.table td, .table th {
vertical-align: middle !important;
vertical-align: top !important;
border-top: none;
}

Expand Down
42 changes: 40 additions & 2 deletions app/controllers/software_records_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ class SoftwareRecordsController < ApplicationController
before_action :authenticate_user!, except: %i[new create show]
before_action :set_software_record, only: %i[show edit update destroy]
before_action :navigation, except: %i[edit update]
access all: %i[create show], viewer: %i[index show], owner: %i[index show edit update list_upgrades],
manager: %i[index show edit update new create destroy list_upgrades], root_admin: :all, message: 'Permission Denied ! <br/> Please contact the administrator for more info.'
access all: %i[create show], viewer: %i[index show], owner: %i[index show edit update list_upgrades list_road_map edit_road_map update_road_map],
manager: %i[index show edit update new create destroy list_upgrades list_road_map edit_road_map update_road_map], root_admin: :all, message: 'Permission Denied ! <br/> Please
contact the administrator for more
info.'

# GET /software_records

def index
Expand Down Expand Up @@ -171,8 +174,42 @@ def list_upgrades
@softwarerecords_count = SoftwareRecord.count
end

def list_road_map
$page_title = 'Road Map | 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}")
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}")
else
SoftwareRecord.order("#{sort_column} #{sort_direction}")
end
@vendor_records = VendorRecord.all
@software_types = SoftwareType.all
@softwarerecords_count = SoftwareRecord.count
end

def edit_road_map
@software_record = SoftwareRecord.find(params[:id])
end

def update_road_map
@software_record = SoftwareRecord.find(params[:id])
if @software_record.update(road_map_params)
redirect_to list_road_map_path, notice: 'Road map was successfully updated.'
else
render :edit_road_map
end
end

private

def road_map_params
params.require(:software_record).permit(:road_map)
end

# Use callbacks to share common setup or constraints between actions.
def set_software_record
@software_record = SoftwareRecord.find(params[:id])
Expand Down Expand Up @@ -239,6 +276,7 @@ def software_record_params
:installed_version,
:latest_version,
:proposed_version,
:road_map,
:last_upgrade_date,
:upgrade_available,
:vulnerabilities_reported,
Expand Down
3 changes: 3 additions & 0 deletions app/views/shared/_dashboard_menu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<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_road_map_path %>"><i class="fas fa-users float-right"></i> Road Map 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 Down Expand Up @@ -47,6 +48,7 @@
<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_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>
</div>
<br/>
Expand All @@ -64,6 +66,7 @@
<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_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>
<a href="<%= export_software_types_path %>"><i class="fas fa-file-export float-right"></i> Export Software Types</a>
Expand Down
7 changes: 7 additions & 0 deletions app/views/software_records/_form_general.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@
</div>
<% end %>

<% if current_user.role.to_s == "root_admin" or current_user.role.to_s == "manager" or current_user.role.to_s == "technician"%>
<div class="form-group">
<%= form.label :road_map, 'Road Map' %>
<%= form.text_area :road_map, :cols => 30, :rows => 7, :class => "form-control" %>
</div>
<% end %>

<div class="form-group">
<%= form.label :notes %>
<%= form.text_area :notes, :cols => 30, :rows => 3, :class => "form-control" %>
Expand Down
7 changes: 7 additions & 0 deletions app/views/software_records/_general.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@
<% end %>
<% end %>

<% if !@software_record.road_map.nil? && !@software_record.road_map.to_s.empty? %>
<dt>Road Map</dt>
<dd>
<ul><%= simple_format(@software_record.road_map) %></ul>
</dd>
<% end %>

<% if !@software_record.notes.nil? && !@software_record.notes.to_s.empty? %>
<dt>Notes</dt>
<dd>
Expand Down
38 changes: 38 additions & 0 deletions app/views/software_records/edit_road_map.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<div class="container animated fadeIn" style="opacity: 0.8;">
<div class="card-detail bg-dark text-white p-4">
<hr class="bg-white">

<h1 class="text-center" style="color: white;">Edit Road Map</h1>

<%= form_with(model: @software_record, url: update_road_map_software_record_path(@software_record), local: true, class: 'mt-4') do |form| %>
<% if @software_record.errors.any? %>
<div id="error_explanation" class="alert alert-danger">
<h2><%= pluralize(@software_record.errors.count, "error") %> prohibited this road map from being saved:</h2>
<ul>
<% @software_record.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<% if !@software_record.title.nil? && !@software_record.title.to_s.empty? %>
<div class="form-group">
<%= form.label :title, class: 'form-label' %>
<p class="form-control-plaintext text-white"><%= @software_record.title %></p> <!-- Display the title but don't allow editing -->
</div>
<% end %>

<div class="form-group">
<%= form.label :road_map, class: 'form-label' %>
<%= form.text_area :road_map, class: 'form-control', rows: 10 %>
</div>

<div class="actions mt-3">
<%= form.submit 'Update', class: 'btn btn-primary' %>
<%= link_to 'Back', software_records_path, class: 'btn btn-secondary ml-2' %>
</div>
<% end %>
</div>
</div>

65 changes: 65 additions & 0 deletions app/views/software_records/list_road_map.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<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">Road Map List</h1>
<em style="font-size: 14px; color: black">Collection of all the software application and their road maps.</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>

<th class="text-left" style="padding-left: 20px"><%= sortable "road_map", "Road Map" %>
<% 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>
<td><%= simple_format(software_record.road_map) %></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 'Edit Road Map', edit_road_map_software_record_path(software_record), class: "btn btn-primary action-btn", style:
"white-space: nowrap;" %></td>
<% else %>
<td><%= link_to 'Edit Road Map', edit_road_map_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 %>
10 changes: 10 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'front#index'
get 'list_upgrades' => 'software_records#list_upgrades'
get 'list_road_map' => 'software_records#list_road_map'
resources :software_records do
member do
get 'edit_road_map'
patch 'update_road_map'
end
end

# 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 'about', to: 'front#about'
get 'contact', to: 'front#contact'
get 'request/new', to: 'front#new'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddRoadmapReferenceToSoftwareRecords < ActiveRecord::Migration[6.1]
def change
add_column :software_records, :road_map, :text
end
end
7 changes: 4 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20_240_307_190_949) do
ActiveRecord::Schema.define(version: 20_240_521_135_737) do
create_table "change_requests", force: :cascade do |t|
t.integer "software_record_id", null: false
t.string "change_title"
Expand Down Expand Up @@ -99,6 +99,8 @@
t.string "monitor_errors"
t.string "authentication_type"
t.text "admin_users"
t.boolean "themes"
t.boolean "modules"
t.string "service"
t.string "installed_version"
t.string "latest_version"
Expand All @@ -120,8 +122,7 @@
t.text "dev_support_servers"
t.date "date_cert_expires"
t.string "monitor_certificates"
t.boolean "themes"
t.boolean "modules"
t.text "road_map"
t.index ["hosting_environment_id"], name: "index_software_records_on_hosting_environment_id"
t.index ["software_type_id"], name: "index_software_records_on_software_type_id"
t.index ["status_id"], name: "index_software_records_on_status_id"
Expand Down
Loading
Loading