Skip to content
Open
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
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
18 changes: 15 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ AllCops:
Layout/LineLength:
Max: 150

Style/FrozenStringLiteralComment:
Style/Documentation:
Enabled: false

Style/Documentation:
Enabled: false
Metrics/BlockLength:
Exclude:
- 'test/dummy/db/seeds.rb'
- 'test/dummy/db/schema.rb'
- 'spec/requests/activejob_web/jobs_spec.rb'

Metrics/MethodLength:
Exclude:
- 'db/migrate/20231024051840_create_jobs.rb'
- 'db/migrate/20231030145254_create_active_storage_tables.active_storage.rb'

Metrics/AbcSize:
Exclude:
- 'db/migrate/20231030145254_create_active_storage_tables.active_storage.rb'
8 changes: 6 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

Expand All @@ -8,6 +10,8 @@ gem 'puma'

gem 'pg'

gem 'image_processing', '>= 1.2'

gem 'sprockets-rails'

group :development do
Expand All @@ -17,8 +21,8 @@ group :development do
end

group :development, :test do
gem 'rspec-rails'
gem 'rubocop', require: false
end

# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"
gem 'rails-controller-testing', '~> 1.0', '>= 1.0.5'
55 changes: 44 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ GEM
actionview (= 7.1.1)
activesupport (= 7.1.1)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
Expand Down Expand Up @@ -83,7 +84,8 @@ GEM
ast (2.4.2)
base64 (0.1.1)
bigdecimal (3.1.4)
brakeman (6.0.1)
brakeman (6.1.1)
racc
builder (3.2.4)
bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
Expand All @@ -93,19 +95,24 @@ GEM
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.3)
diff-lcs (1.5.0)
drb (2.1.1)
ruby2_keywords
erubi (1.12.0)
ffi (1.16.3)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
iniparse (1.5.0)
io-console (0.6.0)
irb (1.8.3)
rdoc
reline (>= 0.3.8)
json (2.6.3)
json (2.7.1)
language_server-protocol (3.17.0.3)
loofah (2.21.4)
crass (~> 1.0.2)
Expand All @@ -116,6 +123,7 @@ GEM
net-pop
net-smtp
marcel (1.0.2)
mini_magick (4.12.0)
mini_mime (1.1.5)
minitest (5.20.0)
mutex_m (0.1.2)
Expand All @@ -135,8 +143,8 @@ GEM
childprocess (>= 0.6.3, < 5)
iniparse (~> 1.4)
rexml (~> 3.2)
parallel (1.23.0)
parser (3.2.2.4)
parallel (1.24.0)
parser (3.3.0.4)
ast (~> 2.4.1)
racc
pg (1.5.4)
Expand Down Expand Up @@ -167,6 +175,10 @@ GEM
activesupport (= 7.1.1)
bundler (>= 1.15.0)
railties (= 7.1.1)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand All @@ -186,25 +198,43 @@ GEM
rake (13.0.6)
rdoc (6.5.0)
psych (>= 4.0.0)
regexp_parser (2.8.2)
regexp_parser (2.9.0)
reline (0.3.9)
io-console (~> 0.5)
rexml (3.2.6)
rubocop (1.57.1)
base64 (~> 0.1.1)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-rails (6.1.0)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.12)
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.1)
rubocop (1.60.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
ruby-vips (2.1.4)
ffi (~> 1.12)
ruby2_keywords (0.0.5)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -232,11 +262,14 @@ DEPENDENCIES
activejob-web!
brakeman
bundler-audit
image_processing (>= 1.2)
overcommit (~> 0.60.0)
pg
puma
rails-controller-testing (~> 1.0, >= 1.0.5)
rspec-rails
rubocop
sprockets-rails

BUNDLED WITH
2.4.19
2.4.21
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/setup'

APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
Expand Down
18 changes: 10 additions & 8 deletions activejob-web.gemspec
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
# frozen_string_literal: true

require_relative 'lib/activejob/web/version'

Gem::Specification.new do |spec|
spec.name = 'activejob-web'
spec.version = Activejob::Web::VERSION
spec.authors = %w[gowtham mohammednazeer]
spec.email = %w[gowtham.kuppusamy@mallow-tech.com mohammednazeer@mallow-tech.com]
spec.homepage = 'TODO'
spec.summary = 'TODO: Summary of Activejob::Web.'
spec.description = 'TODO: Description of Activejob::Web.'
spec.homepage = 'https://github.com/mallowtechdev/activejob-web'
spec.summary = 'Web-based dashboard for managing and monitoring background jobs'
spec.description = 'Activejob-web simplifies the background job management in rails'
spec.license = 'MIT'

# Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
# to allow pushing to a single host or delete this section to allow pushing to any host.
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
spec.metadata['allowed_push_host'] = 'https://github.com/mallowtechdev/activejob-web'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = "TODO: Put your gem's public repo URL here."
spec.metadata['changelog_uri'] = "TODO: Put your gem's CHANGELOG.md URL here."
spec.metadata['homepage_uri'] = 'https://github.com/mallowtechdev/activejob-web'
spec.metadata['source_code_uri'] = 'https://github.com/mallowtechdev/activejob-web'
spec.metadata['changelog_uri'] = 'https://github.com/mallowtechdev/activejob-web'
spec.metadata['rubygems_mfa_required'] = 'true'

spec.files = Dir.chdir(File.expand_path(__dir__)) do
Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']
end

spec.required_ruby_version = '>= 3.2.2'
spec.add_dependency 'rails', '>= 7.0.8'
spec.metadata['rubygems_mfa_required'] = 'true'
end
22 changes: 22 additions & 0 deletions app/controllers/activejob_web/jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module ActivejobWeb
class JobsController < ApplicationController
def index
@jobs = ActivejobWeb::Job.all
end

def show
@job = ActivejobWeb::Job.find(params[:id])
end

def download_pdf
if @job.template_file.attached?
send_file @job.template_file.download
else
flash[:error] = 'Template file not found.'
redirect_to @job
end
end
end
end
6 changes: 6 additions & 0 deletions app/helpers/activejob_web/jobs_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module ActivejobWeb
module JobsHelper
end
end
7 changes: 7 additions & 0 deletions app/models/activejob_web.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module ActivejobWeb
def self.table_name_prefix
'activejob_web_'
end
end
26 changes: 26 additions & 0 deletions app/models/activejob_web/job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module ActivejobWeb
class Job < ApplicationRecord
self.primary_key = 'id'

enum queue: {
default: 0,
long_processing: 1
}
# == Validations ===================================================================================================
validates :title, presence: true, length: { maximum: 255 }
validates :description, presence: true, length: { maximum: 1000 }

# == Callbacks =====================================================================================================
after_initialize :set_default_queue
has_one_attached :template_file

private

# Default value for queue
def set_default_queue
self.queue ||= 'default' # Set your desired default value for the queue attribute
end
end
end
22 changes: 22 additions & 0 deletions app/views/activejob_web/jobs/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<h1>Active Job Web Jobs</h1>

<table>
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>queue</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @jobs.each do |job| %>
<tr>
<td><%= job.title %></td>
<td><%= job.description %></td>
<td><%= job.queue == 'default' ? 'Default' : 'Long Processing' %></td>
<td><%= link_to 'Show', activejob_web_job_path(job) %></td>
</tr>
<% end %>
</tbody>
</table>
37 changes: 37 additions & 0 deletions app/views/activejob_web/jobs/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<h1><%= @job.title %></h1>

<p><strong>Description:</strong> <%= @job.description %></p>
<p><strong>Max Run Time:</strong> <%= @job.max_run_time %></p>
<p><strong>Minimum Approvals Required:</strong> <%= @job.minimum_approvals_required %></p>
<p><strong>Priority:</strong> <%= @job.priority %></p>
<p><strong>Queue:</strong> <%= @job.queue == 'default' ? 'Default' : 'Long Processing' %></p>
<h1>Input Arguments</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Allowed Characters</th>
<th>Max Length</th>
<th>Required</th>
</tr>
</thead>
<tbody>
<% @job.input_arguments.each do |argument| %>
<tr>
<td><%= argument["name"] %></td>
<td><%= argument["type"] %></td>
<td><%= argument["allowed_characters"] %></td>
<td><%= argument["max_length"] %></td>
<td><%= argument["required"] %></td>
</tr>
<% end %>
</tbody>
</table>

<% if @job.template_file.attached? %>
<%= link_to "Download Supporting Files", rails_blob_path(@job.template_file, disposition: "attachment"), class: "btn btn-primary" %>
<% else %>
<p>no template available</p>
<% end %>
<%= link_to 'Back', activejob_web_jobs_path %>
2 changes: 2 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

Expand Down
11 changes: 10 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# frozen_string_literal: true

Rails.application.routes.draw do
# Defines the root path route ("/")
namespace :activejob_web do
root 'jobs#index'
resources :jobs do
member do
get :download_pdf
end
end
end
end
Loading