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

Feature/devise with tem UI #124

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cf6c9f7
added tailwindcss in the app
Dec 4, 2021
421bf6a
Merge pull request #1 from rns-jey/feature/tailwindcss
rns-jey Dec 4, 2021
fb81657
added migrations for users table
Dec 7, 2021
0b39171
Merge pull request #3 from rns-jey/feature/user-migration
preeets Dec 7, 2021
fde0ff6
created migration for creating roles table
Dec 7, 2021
87e2ba9
Merge pull request #4 from rns-jey/feature/role-migration
preeets Dec 7, 2021
fae80aa
create migration for cryptocurrency table
Dec 7, 2021
7da79fa
Merge pull request #5 from rns-jey/feature/cryptos-migration
preeets Dec 7, 2021
d11794f
Align ruby tool version to latest
rns-jey Dec 14, 2021
1c304ce
created user registration form
Dec 14, 2021
fd60fa2
Merge pull request #6 from rns-jey/feature/registration
rns-jey Dec 14, 2021
6a2c3a0
Destroyed CryptoCurrency model for redefinition
rns-jey Dec 14, 2021
3a0bc0d
Generate model Cryptocurrency
rns-jey Dec 14, 2021
a6040b0
Populate cryptocurrency table columns
rns-jey Dec 14, 2021
cda36d7
Rails DB Migration
rns-jey Dec 14, 2021
aad33a0
Redefine cryptocurrency table
rns-jey Dec 14, 2021
fd2cc75
DB migrate cryptocurrency table
rns-jey Dec 14, 2021
06bae0e
Created db seed for sample cryptocurrencies
rns-jey Dec 14, 2021
57602cc
Put comma at the end of every lines
rns-jey Dec 14, 2021
9750eac
Added httparty ruby gem
rns-jey Dec 14, 2021
1ff15ba
Installed httparty ruby gem
rns-jey Dec 14, 2021
e2f019c
Defined current_price method
rns-jey Dec 14, 2021
3a89e22
Merge pull request #7 from rns-jey/features/crypto
preeets Dec 14, 2021
47d4475
created users index page with table component
Dec 14, 2021
eaf3e02
Merge pull request #8 from rns-jey/feature/user-index
rns-jey Dec 14, 2021
78234b5
Generate model Wallet
rns-jey Dec 15, 2021
99590ab
Populate wallets table columns
rns-jey Dec 15, 2021
2f77087
Rails dg migrate wallets table
rns-jey Dec 15, 2021
b17351c
Created wallets routes
rns-jey Dec 15, 2021
09092fb
Moved users view index page to wallets view folder as its page
rns-jey Dec 15, 2021
45db682
Define a variable that will hold all cryptocurrency data
rns-jey Dec 15, 2021
c801ea6
Display cryptocurrencies in a table
rns-jey Dec 16, 2021
2c253a0
Hide API key
iam-ajm Jan 4, 2022
b846442
Added crypto name/symbol in wallets table to identify what crypto owned
iam-ajm Jan 4, 2022
9de9299
Hide API key
iam-ajm Jan 4, 2022
fd842a6
Display all cryptocoins from API
iam-ajm Jan 4, 2022
b9c597a
Changed max supply column into currency kind(type)
iam-ajm Jan 5, 2022
9b7d04e
Db migrate cryptocurrency migration changes
iam-ajm Jan 5, 2022
0e57e9f
Created db seed to populate cryptocurrency table
iam-ajm Jan 5, 2022
305ea45
Created cryptocurrency routes
iam-ajm Jan 5, 2022
4d6522d
Removed crypto API request and changed to just a simple wallets contr…
iam-ajm Jan 5, 2022
eea1664
Created cryptocurrency controller
iam-ajm Jan 5, 2022
da01271
Changed crypto displays from api response to crypto table
iam-ajm Jan 5, 2022
ceffd54
Display selected crypto
iam-ajm Jan 6, 2022
6844198
Display total balance per crypto owned
iam-ajm Jan 6, 2022
dfb9411
Merge pull request #9 from rns-jey/features/wallet
rns-jey Jan 6, 2022
8595136
devise gem: ui not finalized and sign-in is working
Jan 10, 2022
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ yarn-debug.log*
.yarn-integrity

config/database.yml
.env
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ruby 2.7.2
ruby 3.0.2
yarn 1.22.4
nodejs 12.18.3
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.2'
ruby '3.0.2'

gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
gem 'sqlite3', '~> 1.4'
gem 'pg'
gem 'puma', '~> 4.1'
gem 'sass-rails', '>= 6'
Expand All @@ -15,6 +16,9 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'devise'
gem 'hamlit-rails'
gem 'httparty'
gem 'dotenv-rails'
gem 'rest-client'

group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
Expand Down
36 changes: 32 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ GEM
responders
warden (~> 1.2.3)
diff-lcs (1.4.4)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
erubi (1.10.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
Expand All @@ -96,6 +102,12 @@ GEM
hamlit (>= 1.2.0)
railties (>= 4.0.1)
hashdiff (1.0.1)
http-accept (1.7.0)
http-cookie (1.0.4)
domain_name (~> 0.5)
httparty (0.20.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
jbuilder (2.11.2)
Expand All @@ -110,12 +122,15 @@ GEM
mini_mime (>= 0.1.1)
marcel (1.0.1)
method_source (1.0.0)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.1115)
mini_mime (1.1.0)
minitest (5.14.4)
msgpack (1.4.2)
multi_xml (0.6.0)
netrc (0.11.0)
nio4r (2.5.7)
nokogiri (1.11.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.11.3-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
Expand Down Expand Up @@ -167,6 +182,11 @@ GEM
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.5)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
Expand Down Expand Up @@ -227,6 +247,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
temple (0.8.2)
thor (1.1.0)
thread_safe (0.3.6)
Expand All @@ -236,6 +257,9 @@ GEM
turbolinks-source (5.2.0)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.8)
unicode-display_width (2.0.0)
vcr (6.0.0)
warden (1.2.9)
Expand Down Expand Up @@ -266,20 +290,24 @@ DEPENDENCIES
byebug
database_rewinder
devise
dotenv-rails
factory_bot_rails
hamlit-rails
httparty
jbuilder (~> 2.7)
listen (~> 3.2)
pg
puma (~> 4.1)
rails (~> 6.0.3, >= 6.0.3.4)
rest-client
rspec-rails
rubocop-rails
rubocop-rspec
sass-rails (>= 6)
shoulda-matchers
spring
spring-watcher-listen (~> 2.0.0)
sqlite3 (~> 1.4)
turbolinks (~> 5)
tzinfo-data
vcr
Expand All @@ -288,7 +316,7 @@ DEPENDENCIES
webpacker (~> 4.0)

RUBY VERSION
ruby 2.7.2p137
ruby 3.0.2p107

BUNDLED WITH
2.2.7
2.2.22
11 changes: 11 additions & 0 deletions app/api/QuoteRandomizer/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module QuoteRandomizer
class Client
def self.today
response = Request.call(http_method: 'get', endpoint:'/today.json')
end

def self.random(lang="en")
response = Request.call(http_method: 'get', endpoint:'/random.json')
end
end
end
19 changes: 19 additions & 0 deletions app/api/QuoteRandomizer/request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'rest-client'

module QuoteRandomizer
class Request
BASE_URL = 'https://uselessfacts.jsph.pl/'
TOKEN = 'token'

def self.call(http_method:, endpoint:)
result = RestClient::Request.execute(
method: http_method,
url: "#{BASE_URL}#{endpoint}",
# url: "#{BASE_URL}#{endpoint}?apikey=#{TOKEN}"
headers: {'Content-Type'=> 'application/json'}
)
JSON.parse(result)
end
end

end
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class ApplicationController < ActionController::Base
before_action :authenticate_user!
end
10 changes: 10 additions & 0 deletions app/controllers/cryptocurrencies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CryptocurrenciesController < ApplicationController
def index
@cryptos = Cryptocurrency.all
end

def show
@crypto = Cryptocurrency.find(params[:id])
@crypto_owned = Wallet.where(user_id: 3, cryptocurrency: @crypto.symbol).sum(:balance)
end
end
9 changes: 9 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class UsersController < ApplicationController
def index
@roles = Role.all
end

def new
@user = User.new
end
end
15 changes: 15 additions & 0 deletions app/controllers/wallets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class WalletsController < ApplicationController
def index
@cryptos = Cryptocurrency.all
@owned = Wallet.where(user_id: 3).distinct.pluck(:cryptocurrency)
end

def show
@crypto = Cryptocurrency.find(params[:id])
end

def new
@crypto = Cryptocurrency.find(params[:id])
@crypto_owned = Wallet.where(user_id: 3, cryptocurrency: @crypto.symbol).sum(:balance)
end
end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module UsersHelper
end
1 change: 1 addition & 0 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")

import 'stylesheets/application'

// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
Expand Down
8 changes: 8 additions & 0 deletions app/javascript/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@import "tailwindcss/base";
@import "tailwindcss/components";
select {
padding: 14px;
background-color: transparent;
width: 100%;
}
@import "tailwindcss/utilities";
11 changes: 11 additions & 0 deletions app/javascript/stylesheets/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
purge: [],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
18 changes: 18 additions & 0 deletions app/models/cryptocurrency.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Cryptocurrency < ApplicationRecord
def current_price
api_key = ENV["COINMARKET_API_KEY"]
url = "https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest"
symbol = self.symbol
query = {
"symbol" => symbol
}
headers = {
"X-CMC_PRO_API_KEY" => api_key,
"Accepts" => "application/json"
}
request = HTTParty.get(url, :headers => headers, :query => query)
puts request

response = JSON.parse(request.body)["data"][symbol]["quote"]["USD"]["price"]
end
end
2 changes: 2 additions & 0 deletions app/models/role.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Role < ApplicationRecord
end
6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
end
2 changes: 2 additions & 0 deletions app/models/wallet.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Wallet < ApplicationRecord
end
6 changes: 6 additions & 0 deletions app/views/cryptocurrencies/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%h1
= @crypto.name

%p
1 #{@crypto.symbol} = #{number_to_currency(@crypto.current_price, unit: "USD", format: "%n %u")}
= @crypto_owned
16 changes: 16 additions & 0 deletions app/views/devise/confirmations/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h2>Resend confirmation instructions</h2>

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>

<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>

<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>

<%= render "devise/shared/links" %>
5 changes: 5 additions & 0 deletions app/views/devise/mailer/confirmation_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p>Welcome <%= @email %>!</p>

<p>You can confirm your account email through the link below:</p>

<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
7 changes: 7 additions & 0 deletions app/views/devise/mailer/email_changed.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>Hello <%= @email %>!</p>

<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<% end %>
3 changes: 3 additions & 0 deletions app/views/devise/mailer/password_change.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>Hello <%= @resource.email %>!</p>

<p>We're contacting you to notify you that your password has been changed.</p>
8 changes: 8 additions & 0 deletions app/views/devise/mailer/reset_password_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>

<p>Someone has requested a link to change your password. You can do this through the link below.</p>

<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>

<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
7 changes: 7 additions & 0 deletions app/views/devise/mailer/unlock_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>Hello <%= @resource.email %>!</p>

<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>

<p>Click the link below to unlock your account:</p>

<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
25 changes: 25 additions & 0 deletions app/views/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<h2>Change your password</h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>

<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
</div>

<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>

<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>

<%= render "devise/shared/links" %>
16 changes: 16 additions & 0 deletions app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h2>Forgot your password?</h2>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>

<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>

<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>

<%= render "devise/shared/links" %>
Loading