Skip to content
Draft
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
4 changes: 4 additions & 0 deletions backend-rails/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.rbc
*.swp
capybara-*.html
/public
/log
/tmp
/db/*.sqlite3
Expand Down Expand Up @@ -35,3 +36,6 @@ config/master.key
/yarn-error.log
yarn-debug.log*
.yarn-integrity

/app/assets/builds/*
!/app/assets/builds/.keep
6 changes: 6 additions & 0 deletions backend-rails/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ gem 'sass-rails', '~> 6.0.0'
gem 'sendgrid', '~> 1.2.4'
gem 'sprockets', '~> 3.7.2'
gem 'yaaf', '~> 2.2'
gem 'wicked_pdf'
# gem 'wkhtmltopdf-binary'
gem 'wkhtmltopdf-binary-edge'

# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
Expand Down Expand Up @@ -73,3 +77,5 @@ end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

gem "cssbundling-rails", "~> 1.1"
8 changes: 8 additions & 0 deletions backend-rails/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ GEM
crack (0.4.5)
rexml
crass (1.0.6)
cssbundling-rails (1.1.2)
railties (>= 6.0.0)
date (3.3.3)
debug_inspector (1.1.0)
delayed_job (4.1.11)
Expand Down Expand Up @@ -434,6 +436,9 @@ GEM
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
wicked_pdf (2.6.3)
activesupport
wkhtmltopdf-binary-edge (0.12.6.0)
yaaf (2.2.0)
activemodel (>= 5.2)
activerecord (>= 5.2)
Expand All @@ -452,6 +457,7 @@ DEPENDENCIES
bootsnap (~> 1.4, >= 1.4.5)
brakeman (~> 5.1)
bullet (~> 7.0.3)
cssbundling-rails (~> 1.1)
delayed_job_active_record (~> 4.1, >= 4.1.5)
devise (~> 4.7, >= 4.7.2)
devise_token_auth (~> 1.2)!
Expand Down Expand Up @@ -489,6 +495,8 @@ DEPENDENCIES
tzinfo-data
uglifier (~> 4.2)
webmock (~> 3.7, >= 3.7.6)
wicked_pdf
wkhtmltopdf-binary-edge
yaaf (~> 2.2)

RUBY VERSION
Expand Down
2 changes: 2 additions & 0 deletions backend-rails/Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: unset PORT && bin/rails server
css: yarn build:css --watch
Empty file.
2 changes: 1 addition & 1 deletion backend-rails/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../builds
15 changes: 15 additions & 0 deletions backend-rails/app/assets/stylesheets/application.bootstrap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@import 'bootstrap/scss/bootstrap';
@import 'bootstrap-icons/font/bootstrap-icons';

.text_center {
text-align: center;
align-items: center;
display: flex;

}
.flex-container {
justify-content: center;
}
.flex {
display: flex;
}
13 changes: 0 additions & 13 deletions backend-rails/app/assets/stylesheets/application.css

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Api
module V1
class ServiceOrderReportsController < ApplicationController
def show
respond_to do |format|
format.html
format.pdf do
render pdf: "file_name",
page_size: 'A4'
end
end
end
end
end
end
10 changes: 10 additions & 0 deletions backend-rails/app/views/api/v1/service_order_reports/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%= stylesheet_link_tag :application %>
<html>
<div class="header_center">
Ordem de Sevico
</div>
<div class="flex flex-container">1</div>
<div>2</div>
<div>3</div>
</div>
</html>
13 changes: 13 additions & 0 deletions backend-rails/app/views/api/v1/service_order_reports/show.pdf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
<title>PDF</title>
<%= wicked_pdf_stylesheet_link_tag "application" -%>
</head>
<div class="header_center">
Ordem de Sevico
</div>
<div class="flex flex-container">1</div>
<div>2</div>
<div>3</div>
</div>
</html>
14 changes: 14 additions & 0 deletions backend-rails/app/views/layouts/pdf.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Page title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track':
'reload' %>
<%= wicked_pdf_stylesheet_link_tag "styles" %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'%>
</head>
<body>
<%= yield %>
</body>
</html>
8 changes: 8 additions & 0 deletions backend-rails/bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh

if ! gem list foreman -i --silent; then
echo "Installing foreman..."
gem install foreman
fi

exec foreman start -f Procfile.dev "$@"
5 changes: 3 additions & 2 deletions backend-rails/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: postgres
password: postgres
username: edimo
# password: postgres
password:
host: <%= ENV['DEV_DATABASE_HOST'] || 'db' %>
port: 5432

Expand Down
2 changes: 2 additions & 0 deletions backend-rails/config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap-icons/font")
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.application.config.assets.paths << Rails.root.join("node_modules/bootstrap-icons/font")

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
Expand Down
30 changes: 30 additions & 0 deletions backend-rails/config/initializers/wicked_pdf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# WickedPDF Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `render :pdf` call.
#
# To learn more, check out the README:
#
# https://github.com/mileszs/wicked_pdf/blob/master/README.md

WickedPdf.config = {
# Path to the wkhtmltopdf executable: This usually isn't needed if using
# one of the wkhtmltopdf-binary family of gems.
# exe_path: '/usr/local/bin/wkhtmltopdf',
# or
# exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')

# Needed for wkhtmltopdf 0.12.6+ to use many wicked_pdf asset helpers
# enable_local_file_access: true,

# Layout file to be used for all PDFs
# (but can be overridden in `render :pdf` calls)
# layout: 'pdf.html',

# Using wkhtmltopdf without an X server can be achieved by enabling the
# 'use_xvfb' flag. This will wrap all wkhtmltopdf commands around the
# 'xvfb-run' command, in order to simulate an X server.
#
# use_xvfb: true,
}
1 change: 1 addition & 0 deletions backend-rails/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
resources :customers, only: %i[index create destroy update]
resources :sales_units, only: %i[index]
resources :service_orders, only: %i[index create destroy update]
resources :service_order_reports, only: %i[show]

get :status, to: 'api#status'

Expand Down
13 changes: 13 additions & 0 deletions backend-rails/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "app",
"private": "true",
"dependencies": {
"@popperjs/core": "^2.11.6",
"bootstrap": "^5.2.3",
"bootstrap-icons": "^1.10.3",
"sass": "^1.59.2"
},
"scripts": {
"build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules"
}
}
Loading