Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# Ignore all environment files.
/.env*

db/structure.sql

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ group :development, :test do
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
gem "brakeman", require: false
gem "factory_bot_rails"
gem "faker"

# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false
Expand All @@ -65,6 +66,7 @@ end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "rails-controller-testing"
gem "selenium-webdriver"
gem "shoulda-matchers"
end
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ GEM
factory_bot_rails (6.4.4)
factory_bot (~> 6.5)
railties (>= 5.0.0)
faker (3.5.1)
i18n (>= 1.8.11, < 2)
ffi (1.17.1-aarch64-linux-gnu)
ffi (1.17.1-aarch64-linux-musl)
ffi (1.17.1-arm-linux-gnu)
Expand Down Expand Up @@ -262,6 +264,10 @@ GEM
activesupport (= 8.0.1)
bundler (>= 1.15.0)
railties (= 8.0.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 Down Expand Up @@ -422,6 +428,7 @@ DEPENDENCIES
capybara
debug
factory_bot_rails
faker
hotwire-spark
importmap-rails
jbuilder
Expand All @@ -431,6 +438,7 @@ DEPENDENCIES
propshaft
puma (>= 5.0)
rails (~> 8.0.1)
rails-controller-testing
rspec-rails
rubocop-rails-omakase
selenium-webdriver
Expand Down
39 changes: 39 additions & 0 deletions app/controllers/languages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class LanguagesController < ApplicationController
before_action :set_language, only: [ :edit, :update ]

def index
@languages = Language.all
end

def new
@language = Language.new
end

def create
@language = Language.new(language_params)

if @language.save
redirect_to languages_path
else
render :new
end
end

def edit
end

def update
@language.update(language_params)
redirect_to languages_path
end

private

def language_params
params.require(:language).permit(:name, :file_share_folder)
end

def set_language
@language = Language.find(params[:id])
end
end
3 changes: 3 additions & 0 deletions app/models/language.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Language < ApplicationRecord
validates :name, :file_share_folder, presence: true, uniqueness: true
end
22 changes: 22 additions & 0 deletions app/views/languages/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

<%= form_for language do |f| %>
<div class="form-body">
<div class="row">
<%= render "shared/errors", resource: language %>
<div class="col-12">
<div class="form-group">
<%= f.label :name %>
<%= f.text_field :name, class: "form-control", placeholder: "Name" %>
</div>
<div class="form-group">
<%= f.label :file_share_folder %>
<%= f.text_field :file_share_folder, class: "form-control", placeholder: "Folder" %>
</div>
<div class="col-12 d-flex justify-content-end">
<%= f.submit "Save", class: "btn btn-primary me-1 mb-1" %>
<%= link_to "Cancel", languages_path, class: "btn btn-light-secondary me-1 mb-1" %>
</div>
</div>
</div>
</div>
<% end %>
19 changes: 19 additions & 0 deletions app/views/languages/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<% content_for :title, "Editing language" %>

<section id="basic-vertical-layouts">
<div class="row match-height">
<div class="col-md-6 col-12">
<div class="card">
<div class="card-header">
<h2 class="card-title">Edit language</h2>
</div>
<div class="card-content">
<div class="card-body">
<%= render "form", language: @language %>
</div>
</div>
</div>
</div>
</div>
</section>

45 changes: 45 additions & 0 deletions app/views/languages/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<% content_for :title, "Languages" %>

<section class="section">
<div class="row" id="table-striped">
<div class="col-12 cold-md-12">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h2 class="card-title">Languages</h2>
<%= link_to new_language_path, class: "btn btn-primary" do %>
<i class="bi bi-plus"></i> Add New Language
<% end %>
</div>
<div class="card-content">
<div class="card-body">
<p class="card-text"> Some important information or instruction can be placed here.</p>
<div class="table-responsive">
<table class="table table-lg table-striped mb-0">
<thead>
<tr>
<th>Name</th>
<th>File share folder</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
<% @languages.each do |language| %>
<tr>
<td class="text-bold-500"><%= language.name %></td>
<td class="text-bold-500"><%= language.file_share_folder %></td>
<td class="text-end">
<%= link_to edit_language_path(language), class: "btn btn-secondary btn-sm" do %>
<i class="bi bi-pencil"></i> Edit
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
18 changes: 18 additions & 0 deletions app/views/languages/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<% content_for :title, "New language" %>

<section id="basic-vertical-layouts">
<div class="row match-height">
<div class="col-md-6 col-12">
<div class="card">
<div class="card-header">
<h2 class="card-title">New language</h2>
</div>
<div class="card-content">
<div class="card-body">
<%= render "form", language: @language %>
</div>
</div>
</div>
</div>
</div>
</section>
32 changes: 11 additions & 21 deletions app/views/layouts/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,48 +42,38 @@

<div class="sidebar-menu">
<ul class="menu">
<li class="sidebar-title">Menu</li>

<li class="sidebar-item ">
<a href="index.html" class='sidebar-link'>
<i class="bi bi-grid-fill"></i>
<span>Dashboard</span>
</a>

</li>

<li class="sidebar-title">Administration</li>

<li class="sidebar-item ">
<%= link_to regions_path, class: 'sidebar-link' do %>
<li class="sidebar-item">
<%= link_to regions_path, class: "sidebar-link" do %>
<i class="bi bi-hospital-fill"></i>
<span>Regions</span>
<% end %>
</li>

<li class="sidebar-item ">
<%= link_to providers_path, class: 'sidebar-link' do %>
<li class="sidebar-item">
<%= link_to providers_path, class: "sidebar-link" do %>
<i class="bi bi-hospital-fill"></i>
<span>Providers</span>
<% end %>
</li>

<li class="sidebar-item ">
<a href="ui-file-uploader.html" class='sidebar-link'>
<li class="sidebar-item">
<a href="ui-file-uploader.html" class="sidebar-link">
<i class="bi bi-tags-fill"></i>
<span>Topics</span>
</a>
</li>

<li class="sidebar-item ">
<a href="application-email.html" class='sidebar-link'>
<li class="sidebar-item">
<%= link_to languages_path, class: "sidebar-link" do %>
<i class="bi bi-translate"></i>
<span>Languages</span>
</a>
<% end %>
</li>

<li class="sidebar-item ">
<a href="application-chat.html" class='sidebar-link'>
<li class="sidebar-item">
<a href="application-chat.html" class="sidebar-link">
<i class="bi bi-people"></i>
<span>Users</span>
</a>
Expand Down
47 changes: 0 additions & 47 deletions app/views/layouts/mazer.html.erb

This file was deleted.

10 changes: 10 additions & 0 deletions app/views/shared/_errors.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% if resource.errors.any? %>
<div style="color: red">
<h4><%= "#{pluralize(resource.errors.count, "error")} prohibited this #{resource.class_name} from being saved:" %>></h4>
<ul>
<% resource.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
3 changes: 3 additions & 0 deletions bin/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

overmind start -r all
4 changes: 0 additions & 4 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
default: &default
adapter: postgresql
encoding: unicode
username: postgres
password: postgres
host: localhost
port: 5432
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
Expand Down
19 changes: 9 additions & 10 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
Rails.application.routes.draw do
resources :providers
resources :regions
root "home#index"
get "home/index", as: :home
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
resource :session
resources :passwords, param: :token
resources :users, only: :create
resource :registration, only: %i[new create]
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
get "up" => "rails/health#show", as: :rails_health_check
resources :regions
resources :providers
resources :languages, only: %i[index show new create edit update]

# Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb)
# get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
# get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
get "home/index", as: :home

resources :users
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
get "up" => "rails/health#show", as: :rails_health_check

# Defines the root path route ("/")
root "home#index"
end
10 changes: 10 additions & 0 deletions db/migrate/20250203130619_create_languages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateLanguages < ActiveRecord::Migration[8.0]
def change
create_table :languages do |t|
t.string :name
t.string :file_share_folder

t.timestamps
end
end
end
Loading