diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..b37716faa --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +/node_modules +/yarn-error.log + +/public/assets +.byebug_history + /coverage + .DS_Store + + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 000000000..160fe391c --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.5.5 \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..ee65de097 --- /dev/null +++ b/Gemfile @@ -0,0 +1,86 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.5.5' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.2.3' +# Use postgresql as the database for Active Record +gem 'pg', '>= 0.18', '< 2.0' +# Use Puma as the app server +gem 'puma', '~> 3.11' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'mini_racer', platforms: :ruby + +# Use CoffeeScript for .coffee assets and views +# gem 'coffee-rails', '~> 4.2' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 4.0' +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use ActiveStorage variant +# gem 'mini_magick', '~> 4.8' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] + gem 'rails-controller-testing' +end + +group :development do + # Access an interactive console on exception pages or by calling 'console' anywhere in the code. + gem 'web-console', '>= 3.3.0' + gem 'listen', '>= 3.0.5', '< 3.2' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' +end + +group :test do + # Adds support for Capybara system testing and selenium driver + gem 'capybara', '>= 2.15' + gem 'selenium-webdriver' + # Easy installation and use of chromedriver to run system tests with Chrome + gem 'chromedriver-helper' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'jquery-turbolinks' +gem 'jquery-rails' +group :development, :test do + gem 'pry-rails' +end + +group :development do + gem 'better_errors' + gem 'binding_of_caller' + gem 'guard' + gem 'guard-minitest' + gem 'debase', '>= 0.2.4.1' + gem 'ruby-debug-ide', '>= 0.7.0' + gem 'rb-readline' + gem 'pry-byebug' +end + +group :test do + gem 'minitest-rails' + gem 'minitest-reporters' + gem 'minitest-skip' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..e4a82b9d6 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,288 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.3) + actionpack (= 5.2.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.3) + actionview (= 5.2.3) + activesupport (= 5.2.3) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.3) + activesupport (= 5.2.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.3) + activesupport (= 5.2.3) + globalid (>= 0.3.6) + activemodel (5.2.3) + activesupport (= 5.2.3) + activerecord (5.2.3) + activemodel (= 5.2.3) + activesupport (= 5.2.3) + arel (>= 9.0) + activestorage (5.2.3) + actionpack (= 5.2.3) + activerecord (= 5.2.3) + marcel (~> 0.3.1) + activesupport (5.2.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + ansi (1.5.0) + archive-zip (0.12.0) + io-like (~> 0.3.0) + arel (9.0.0) + better_errors (2.5.1) + coderay (>= 1.0.0) + erubi (>= 1.0.0) + rack (>= 0.9.0) + bindex (0.8.1) + binding_of_caller (0.8.0) + debug_inspector (>= 0.0.1) + bootsnap (1.4.5) + msgpack (~> 1.0) + builder (3.2.3) + byebug (11.0.1) + capybara (3.29.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + childprocess (3.0.0) + chromedriver-helper (2.1.1) + archive-zip (~> 0.10) + nokogiri (~> 1.8) + coderay (1.1.2) + concurrent-ruby (1.1.5) + crass (1.0.4) + debase (0.2.4.1) + debase-ruby_core_source (>= 0.10.2) + debase-ruby_core_source (0.10.6) + debug_inspector (0.0.3) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.11.1) + formatador (0.2.5) + globalid (0.4.2) + activesupport (>= 4.2.0) + guard (2.15.1) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-minitest (2.4.6) + guard-compat (~> 1.2) + minitest (>= 3.0) + i18n (1.7.0) + concurrent-ruby (~> 1.0) + io-like (0.3.0) + jbuilder (2.9.1) + activesupport (>= 4.2.0) + jquery-rails (4.3.5) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + jquery-turbolinks (2.1.0) + railties (>= 3.1.0) + turbolinks + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.3.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + lumberjack (1.0.13) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) + mimemagic (0.3.3) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.12.2) + minitest-rails (5.2.0) + minitest (~> 5.10) + railties (~> 5.2.0) + minitest-reporters (1.4.0) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + minitest-skip (0.0.1) + minitest (~> 5.0) + msgpack (1.3.1) + nenv (0.3.0) + nio4r (2.5.2) + nokogiri (1.10.4) + mini_portile2 (~> 2.4.0) + notiffany (0.1.3) + nenv (~> 0.1) + shellany (~> 0.0) + pg (1.1.4) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-byebug (3.7.0) + byebug (~> 11.0) + pry (~> 0.10) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (4.0.1) + puma (3.12.1) + rack (2.0.7) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.3) + actioncable (= 5.2.3) + actionmailer (= 5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) + activemodel (= 5.2.3) + activerecord (= 5.2.3) + activestorage (= 5.2.3) + activesupport (= 5.2.3) + bundler (>= 1.3.0) + railties (= 5.2.3) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.3) + actionpack (= 5.2.3) + activesupport (= 5.2.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.0) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + rb-readline (0.5.5) + regexp_parser (1.6.0) + ruby-debug-ide (0.7.0) + rake (>= 0.8.1) + ruby-progressbar (1.10.1) + ruby_dep (1.5.0) + rubyzip (2.0.0) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + selenium-webdriver (3.142.6) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) + shellany (0.0.1) + spring (2.1.0) + spring-watcher-listen (2.0.1) + listen (>= 2.7, < 4.0) + spring (>= 1.2, < 3.0) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.10) + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + better_errors + binding_of_caller + bootsnap (>= 1.1.0) + byebug + capybara (>= 2.15) + chromedriver-helper + debase (>= 0.2.4.1) + guard + guard-minitest + jbuilder (~> 2.5) + jquery-rails + jquery-turbolinks + listen (>= 3.0.5, < 3.2) + minitest-rails + minitest-reporters + minitest-skip + pg (>= 0.18, < 2.0) + pry-byebug + pry-rails + puma (~> 3.11) + rails (~> 5.2.3) + rails-controller-testing + rb-readline + ruby-debug-ide (>= 0.7.0) + sass-rails (~> 5.0) + selenium-webdriver + spring + spring-watcher-listen (~> 2.0.0) + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console (>= 3.3.0) + +RUBY VERSION + ruby 2.5.5p157 + +BUNDLED WITH + 2.0.2 diff --git a/Guardfile b/Guardfile new file mode 100644 index 000000000..e34f706f4 --- /dev/null +++ b/Guardfile @@ -0,0 +1,9 @@ +guard :minitest, autorun: false, spring: true do + watch(%r{^app/(.+).rb$}) { |m| "test/#{m[1]}_test.rb" } + watch(%r{^app/controllers/application_controller.rb$}) { 'test/controllers' } + watch(%r{^app/controllers/(.+)_controller.rb$}) { |m| "test/integration/#{m[1]}_test.rb" } + watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" } + watch(%r{^lib/(.+).rb$}) { |m| "test/lib/#{m[1]}_test.rb" } + watch(%r{^test/.+_test.rb$}) + watch(%r{^test/test_helper.rb$}) { 'test' } +end diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..e85f91391 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 000000000..b16e53d6d --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 000000000..82e6f0f6c --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's +// vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require rails-ujs +//= require activestorage +//= require turbolinks +//= require_tree . diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 000000000..739aa5f02 --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/assets/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/javascripts/drivers.js b/app/assets/javascripts/drivers.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/drivers.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/homepages.js b/app/assets/javascripts/homepages.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/homepages.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/passengers.js b/app/assets/javascripts/passengers.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/passengers.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/trips.js b/app/assets/javascripts/trips.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/trips.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 000000000..958e878e9 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,368 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's + * vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ + + +* { + font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif +} + +a { + text-decoration: none; + color: black; +} + +a:hover { + color: #A3007A; +} + +/* nav */ + +nav { + background: rgb(255,0,191); + border-radius: 15px; +} + +h1 a:visited { + color: white; +} + +nav > * { + display: inline-block; + padding: 1rem; + color: white; +} + +section h2 { + text-align: center; +} + +/* css dropdown on hover: https://www.w3schools.com/css/css_dropdowns.asp */ +.dropdown-container { + position: relative; +} + +.dropdown-content { + display: none; + position: absolute; + background: #FF5CD6; + + margin-top: 1rem; + margin-left: -1rem; +} + +.dropdown-content > div { + padding: 1rem; +} + +.dropdown-content a { + color: white; +} + +/* nav effects */ + +.dropdown-container:hover { + background-color: #CC0099; +} + +.dropdown-content div:hover { + background-color: #CC0099; +} + +.dropdown-container:hover .dropdown-content { + display: block; + width: max-content; + + /* make sure it appears on top of everything else */ + z-index: 1; +} + +/* table */ + +.table{ + margin-left:auto; + margin-right:auto; + width: auto; + table-layout: fixed; + border-collapse: collapse; + border: 1px solid black; +} + +.table tbody{ + display: block; + width: 100%; + overflow: auto; + height: auto; +} + +.table thead tr { + display: block; +} + +.table thead { + background: rgb(255,0,191); + color: white; +} + +.table th{ + height: 3em; +} + +.table th, .table td { + padding: .3em; + text-align: left; + width: 12em; + border-bottom: 1px solid #ddd; +} + +.table tr:nth-child(even) { + background-color: #f5f5f5; +} + +/* triptable */ +.triptable-container h3 { + text-align: center; +} + +.triptable-container h3 { + text-align: center; +} + +.triptable-container > div { + background-color: #FFACEA; + border-radius: 15px; + width: max-content; + padding: 1rem; + margin: auto; +} + +.trip-table{ + margin-top: 1.5rem; + margin-left:auto; + margin-right:auto; + width: auto; + table-layout: fixed; + border-collapse: collapse; + border: 1px solid black; +} + +.trip-table thead { + background: rgb(255,0,191); + color: white; +} + +.trip-table th, .trip-table td { + padding: .3em; + text-align: left; + width: 12em; + border-bottom: 1px solid #ddd; +} + +.trip-table tr:nth-child(even) { + background-color: #f5f5f5; +} + +.trip-table th{ + height: 2em; +} + +/* statuses */ +.available { + color: green; +} + +.available:before { + content: "🆗 "; +} + +.unavailable { + color: red; +} + +.unavailable:before { + content: "🚫 "; +} + +.errors { + color: #D8000C; + background-color: #FFD2D2; + display: table; + padding: 1em; + margin: 1em; +} + +.notice { + color: #D8000C; + background-color: #FFD2D2; + display: table; + padding: 1em; + margin: 1em; +} + +.driver-form label, .passenger-form label{ + display: block; + width: 100%; + padding: .2em; +} + +.driver-form input, .passenger-form input{ + display: block; + width: 15rem; + padding: .5em; +} + +.submit-button{ + background-color: rgb(255,0,191); + margin-top: .7em; + color: white; + font-size: 1.2em; + display: block; + text-align: center; + border-radius: 15px; + height: 3rem; +} + +.submit-button:hover , .trip-options div:hover{ + background-color: rgb(196, 4, 148); +} + +.submit-button:active { + background-color: rgb(196, 4, 148); + box-shadow: 0 5px rgb(102, 102, 102); + transform: translateY(4px); +} + + +/* driver and passenger view pages */ + +main section { + height: max-content; + margin-bottom: 4rem; +} + +.details-container { + margin-top: 2rem; + + display: grid; + grid-template-columns: 1fr 1fr; + align-items: center; +} + +.details-container > *:first-child { + text-align: center; + justify-self: center; +} + +.details-container > *:first-child > img { + border-radius: 2rem; +} + +.details { + width: 100%; + display: flex; + flex-direction: column; +} + +.details > * { + background-color: #FFACEA; + border-radius: 15px; + width: max-content; + padding: 1rem; + margin: 0.5rem; +} + +.modify-options, .trip-options { + width: auto; + + display: flex; + flex-flow: row wrap; + justify-content: flex-end; +} + +.modify-options > * { + margin: 0 4rem 0 1rem; +} + +.trip-options div{ + background-color: rgb(255,0,191); + color: white; + font-size: 1.2em; + display: block; + text-align: center; + border-radius: 15px; + padding:.7em; + margin: 1rem; +} + +.trip-options a { + color: white; +} + +.car-details { + display: grid; + grid-template-columns: 1fr 1fr; + row-gap: 0.5rem; +} + +.vin, .vin-label { + grid-row-start: 1; + grid-row-end: 2; +} + +.make, .make-label { + grid-row-start: 2; + grid-row-end: 3; +} + +.model, .model-label { + grid-row-start: 3; + grid-row-end: 4; +} + +/* pagination */ + +.pagination-container { + margin-top: 1.5rem; + margin-bottom: 1.5rem; + text-align: center; +} + +.pagination { + border: 1px solid pink; + background-color: #FFACEA; + padding: 0.5rem; + border-radius: .5em; +} + +.pagination a { + color: #820062 +} + +.pagination:hover { + background-color: #820062; +} + +.pagination:hover a { + color: #FFBDEE; +} + +.pagination a:active { + border-radius: 5px; +} + +.disabled_link { + background-color: #FFDDF6; + color: #FF7DDE; +} \ No newline at end of file diff --git a/app/assets/stylesheets/drivers.scss b/app/assets/stylesheets/drivers.scss new file mode 100644 index 000000000..8c1768a14 --- /dev/null +++ b/app/assets/stylesheets/drivers.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Drivers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/homepages.scss b/app/assets/stylesheets/homepages.scss new file mode 100644 index 000000000..35af21ef4 --- /dev/null +++ b/app/assets/stylesheets/homepages.scss @@ -0,0 +1,57 @@ +// Place all the styles related to the Homepages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +// BASE + +$pink: rgb(255,0,191); + +.homepage { + height: 60vh; + width: 100%; + margin: auto; + margin-top: 2rem; + + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + align-items: center; +} + +.homepage > a { + text-align: center; + font-size: 3em; + color: white; + border-radius: 15px; + + background-color: $pink; + padding: 2rem; + width: max-content; + margin: auto; + + // shades of $pink from: https://www.htmlcsscolor.com/hex/FF00BF + box-shadow: 0.05em 0.05em 0.05em #FF7DDE inset, 0.05em 0.05em 0.05em #CC0099; +} + +@media only screen and (max-width: 600px) { + .homepage > a { + font-size: 2em; + margin: 2em; + } +} + +// EFFECTS + +.homepage > *:hover { + color: $pink; + + background-color: white; + border: 0.2em solid $pink; + + box-shadow: 0 0.1em 0.3em #CC0099; +} + +.homepage > *:active { + transform: translateY(0.5rem); +} diff --git a/app/assets/stylesheets/passengers.scss b/app/assets/stylesheets/passengers.scss new file mode 100644 index 000000000..0e27942f7 --- /dev/null +++ b/app/assets/stylesheets/passengers.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Passengers controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/trips.scss b/app/assets/stylesheets/trips.scss new file mode 100644 index 000000000..f1f72ad11 --- /dev/null +++ b/app/assets/stylesheets/trips.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Trips controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 000000000..d67269728 --- /dev/null +++ b/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 000000000..0ff5442f4 --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 000000000..09705d12a --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,2 @@ +class ApplicationController < ActionController::Base +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/controllers/drivers_controller.rb b/app/controllers/drivers_controller.rb new file mode 100644 index 000000000..233cee0a7 --- /dev/null +++ b/app/controllers/drivers_controller.rb @@ -0,0 +1,103 @@ +class DriversController < ApplicationController + def index + @drivers = Driver.all + end + + def show + driver_id = params[:id].to_i + @driver = Driver.find_by(id: driver_id) + + if @driver.nil? + head :not_found + return + end + end + + def new + @driver = Driver.new + end + + def create + @driver = Driver.new(driver_params) + @driver.active = true + + if @driver.save + redirect_to driver_path(@driver.id) + return + else + render :new + return + end + end + + + def edit + driver_id = params[:id].to_i + @driver = Driver.find_by(id: driver_id) + + if @driver.nil? + redirect_to drivers_path + return + end + end + + def update + driver_id = params[:id].to_i + @driver = Driver.find_by(id: driver_id) + + if @driver.nil? + head :not_found + return + elsif @driver.update(driver_params) + redirect_to driver_path(@driver.id) + return + else + render :edit + return + end + end + + def destroy + driver_id = params[:id].to_i + @driver = Driver.find_by(id: driver_id) + + if @driver.nil? + head :not_found + return + else + @driver.destroy + redirect_to drivers_path + return + end + end + + def toggle_active + driver_id = params[:id].to_i + @driver = Driver.find_by(id: driver_id) + + if @driver.active + @driver.go_offline + else + @driver.go_online + end + + if @driver.active + redirect_back(fallback_location: driver_path(driver_id)) + return + else + redirect_back(fallback_location: driver_path(driver_id), flash: { error: "Could not save completion date" }) + return + end + end + + private + + def driver_params + if !params[:driver].nil? + return params.require(:driver).permit(:name, :vin, :active, :car_make, :car_model) + else + return nil + end + end + +end diff --git a/app/controllers/homepages_controller.rb b/app/controllers/homepages_controller.rb new file mode 100644 index 000000000..8663bd848 --- /dev/null +++ b/app/controllers/homepages_controller.rb @@ -0,0 +1,2 @@ +class HomepagesController < ApplicationController +end diff --git a/app/controllers/passengers_controller.rb b/app/controllers/passengers_controller.rb new file mode 100644 index 000000000..66f7fc3cd --- /dev/null +++ b/app/controllers/passengers_controller.rb @@ -0,0 +1,84 @@ +class PassengersController < ApplicationController + def index + @passengers = Passenger.all + end + + def show + @passenger = Passenger.find_by(id: params[:id]) + + if @passenger.nil? + head :not_found + return + end + end + + def new + @passenger = Passenger.new + end + + def create + @passenger = Passenger.new(passenger_params) + + if @passenger.save + redirect_to passenger_path(@passenger.id) + return + else + render :new + return + end + end + + + def edit + @passenger = Passenger.find_by(id: params[:id]) + + if @passenger.nil? + redirect_to passengers_path + return + end + + end + + def update + @passenger = Passenger.find_by(id: params[:id]) + + if @passenger.nil? + head :not_found + return + end + + if @passenger.update(passenger_params) + redirect_to passenger_path (@passenger.id) + return + else + render :new + return + end + end + + def destroy + passenger_id = params[:id] + @passenger = Passenger.find_by(id: passenger_id) + + if @passenger.nil? + redirect_to passengers_path + return + end + + @passenger.destroy + + redirect_to passengers_path + return + end + + private + + def passenger_params + if !params[:passenger].nil? + return params.require(:passenger).permit(:name, :phone_num) + else + return nil + end + end + +end diff --git a/app/controllers/trips_controller.rb b/app/controllers/trips_controller.rb new file mode 100644 index 000000000..dab5c8b09 --- /dev/null +++ b/app/controllers/trips_controller.rb @@ -0,0 +1,148 @@ + +class TripsController < ApplicationController + + def show + @trip = Trip.find_by(id: params[:id]) + + if @trip.nil? + head :not_found + return + end + end + + def create + passenger_trips = Trip.where(passenger_id: params[:passenger_id]) + + passenger_trips.each do |trip| + if trip.rating == nil + flash[:notice] = "You may only request a trip after your previous one has completed and you rate it." + redirect_to passenger_path(params[:passenger_id]) + return + end + end + + driver = Driver.get_driver + + if driver == nil + flash[:notice] = "There are no available drivers." + redirect_to passenger_path(params[:passenger_id]) + return + end + + date = DateTime.now + + # all costs are four digits ($10.00-$99.99) + cost = rand(1000..9999).to_i + + data_hash = { + date: date, + driver_id: driver.id, + passenger_id: params[:passenger_id], + rating: nil, + cost: cost, + } + + @trip = Trip.new(data_hash) + + if @trip.save + redirect_to passenger_path(@trip.passenger_id) + return + else + redirect_to root_path + return + end +end + +def edit + @trip = Trip.find_by(id: params[:id]) + + if @trip.nil? + redirect_to root_path + return + end +end + +def update + @trip = Trip.find_by(id: params[:id]) + + if @trip.nil? + head :not_found + return + end + + if params[:trip][:driver_name].blank? || params[:trip][:passenger_name].blank? || params[:trip][:cost].blank? + prev = Rails.application.routes.recognize_path(request.referrer) + if (prev[:action] == "rate" || prev[:action] == "show") && params[:action] != "edit" && prev[:action] != "edit" + @trip.rating = params[:trip][:rating] + if @trip.save + redirect_to trip_path(@trip.id) + return + else + flash[:notice] = "Unable to save rating." + redirect_to rate_path(params[:id]) + return + end + else + flash[:notice] = "You must enter a value for all fields." + redirect_to edit_trip_path(params[:id]) + return + end + end + + driver = Driver.find_by(name: params[:trip][:driver_name]) + passenger = Passenger.find_by(name: params[:trip][:passenger_name]) + + if driver.nil? + flash[:notice] = "This driver is not in our system." + redirect_to edit_trip_path(params[:id]) + return + end + + if passenger.nil? + flash[:notice] = "This passenger is not in our system." + redirect_to edit_trip_path(params[:id]) + return + end + + @trip.driver_id = driver.id + @trip.passenger_id = passenger.id + + if @trip.update(trip_params) + redirect_to trip_path(@trip.id) + return + else + redirect_to edit_trip_path(params[:id]) + return + end +end + +def destroy + trip_id = params[:id].to_i + @trip = Trip.find_by(id: trip_id) + + if @trip.nil? + head :not_found + return + else + @trip.destroy + redirect_to root_path + return + end +end + +def rate + @trip = Trip.find_by(id: params[:id]) + + if @trip.nil? + redirect_to root_path + return + end +end + +private + +def trip_params + return params.require(:trip).permit(:date, :rating, :cost, :driver_id, :passenger_id) +end + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/helpers/drivers_helper.rb b/app/helpers/drivers_helper.rb new file mode 100644 index 000000000..e5fc532e4 --- /dev/null +++ b/app/helpers/drivers_helper.rb @@ -0,0 +1,2 @@ +module DriversHelper +end diff --git a/app/helpers/homepages_helper.rb b/app/helpers/homepages_helper.rb new file mode 100644 index 000000000..4bd8098f3 --- /dev/null +++ b/app/helpers/homepages_helper.rb @@ -0,0 +1,2 @@ +module HomepagesHelper +end diff --git a/app/helpers/passengers_helper.rb b/app/helpers/passengers_helper.rb new file mode 100644 index 000000000..1af9e68f1 --- /dev/null +++ b/app/helpers/passengers_helper.rb @@ -0,0 +1,2 @@ +module PassengersHelper +end diff --git a/app/helpers/trips_helper.rb b/app/helpers/trips_helper.rb new file mode 100644 index 000000000..04f333d46 --- /dev/null +++ b/app/helpers/trips_helper.rb @@ -0,0 +1,2 @@ +module TripsHelper +end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 000000000..a009ace51 --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 000000000..286b2239d --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/models/driver.rb b/app/models/driver.rb new file mode 100644 index 000000000..ecbdadd98 --- /dev/null +++ b/app/models/driver.rb @@ -0,0 +1,92 @@ +class Driver < ApplicationRecord + has_many :trips, dependent: :nullify + + # validations + + validates :name, presence: true + validates :vin, presence: true + + + # methods + + def average_rating + if self.trips.empty? + average = nil + else + total_rating = 0 + counter = 0 + self.trips.each do |trip| + if !(trip.rating.nil?) + total_rating += trip.rating + counter += 1 + end + end + average = (total_rating.to_f / counter).round(2) + end + return average + end + + def total_earnings + total = 0 + self.trips.each do |trip| + total += trip.cost + end + return total + end + + # The driver gets 80% of the trip cost after a fee of $1.65 is subtracted + def driver_earnings + before_fee = self.total_earnings + + if before_fee == 0 + return 0 + end + + after_fee = (before_fee - 165) + + percentage = 0.8 + driver_earnings = after_fee * percentage + + return driver_earnings + end + + def go_online + self.active = true + + if self.save + return self + else + return false + end + end + + def go_offline + self.active = false + + if self.save + return self + else + return false + end + end + + def avatar_image + driver_id = self.id + avatar_link = "https://api.adorable.io/avatars/200/" << driver_id.to_s << ".png" + + return avatar_link + end + + # select active driver, set status to inactive + def self.get_driver + available_driver = Driver.find_by(active: true) + + if available_driver + available_driver.go_offline + return available_driver + else + return nil + end + end + +end diff --git a/app/models/passenger.rb b/app/models/passenger.rb new file mode 100644 index 000000000..b2d0cf276 --- /dev/null +++ b/app/models/passenger.rb @@ -0,0 +1,22 @@ +class Passenger < ApplicationRecord + has_many :trips, dependent: :nullify + validates :phone_num, presence: true + validates :name, presence: true + + def total_charged + total = 0 + self.trips.each do |trip| + total += trip.cost + end + return total + end + + def avatar_image + passenger_id = self.id + avatar_link = "https://api.adorable.io/avatars/200/" << passenger_id.to_s << ".png" + + return avatar_link + end + +end + diff --git a/app/models/trip.rb b/app/models/trip.rb new file mode 100644 index 000000000..c23456282 --- /dev/null +++ b/app/models/trip.rb @@ -0,0 +1,9 @@ +class Trip < ApplicationRecord + belongs_to :driver + belongs_to :passenger + + validates :driver_id, presence: true + validates :passenger_id, presence: true + validates :date, presence: true + validates :cost, presence: true +end diff --git a/app/views/drivers/_form.html.erb b/app/views/drivers/_form.html.erb new file mode 100644 index 000000000..6db2ab910 --- /dev/null +++ b/app/views/drivers/_form.html.erb @@ -0,0 +1,18 @@ +<%= form_with model: @driver, class: "driver-form" do |f| %> +
Driver Name | +VIN | +Status | +|
---|---|---|---|
<%= link_to driver.name, driver_path(driver.id) %> | +<%= driver.vin %> | + <% if driver.active %> +Available | + <% elsif !driver.active %> +Unavailable | + <% end %> +
Passenger Name | +Phone Number | +
---|---|
<%= link_to passenger.name, passenger_path(passenger.id) %> | +<%= passenger.phone_num %> | +
+ <%# Name: <%= @passenger.name %> <%#
%>
+ Phone Number: <%= @passenger.phone_num %>
+
ID | +Date | +Driver | +Passenger | +Price | +Rating | +
---|---|---|---|---|---|
+ <%= link_to trip.id, trip_path(trip.id)%> + | ++ <%= trip.date %> + | ++ <% if object == @driver %> + <%= trip.driver.name %> + <% else %> + <% if trip.driver != nil %> + <%= link_to trip.driver.name, driver_path(trip.driver.id) %> + <% else %> + deleted + <% end %> + <% end%> + | ++ <% if object == @passenger %> + <%= trip.passenger.name %> + <% else %> + <% if trip.passenger != nil %> + <%= link_to trip.passenger.name, passenger_path(trip.passenger.id) %> + <% else %> + deleted + <% end %> + <% end %> + | ++ <%= number_to_currency(trip.cost / 100.0) %> + | ++ <%= trip.rating %> + | +
Trip: <%= @trip.id %>
+ + <%= f.label :rating %> + <%= f.select :rating, [5, 4, 3, 2, 1] %> + + <%= f.submit "Save Rating", class: "submit-button" %> +<% end %> \ No newline at end of file diff --git a/app/views/trips/show.html.erb b/app/views/trips/show.html.erb new file mode 100644 index 000000000..db7157191 --- /dev/null +++ b/app/views/trips/show.html.erb @@ -0,0 +1,48 @@ +You may have mistyped the address or the page may have moved.
+If you are the application owner check the logs for more information.
+Maybe you tried to change something you didn't have access to.
+If you are the application owner check the logs for more information.
+If you are the application owner check the logs for more information.
+