diff --git a/backend/app/controllers/documentos_controller.rb b/backend/app/controllers/documentos_controller.rb
index 48ad648..b0ea64f 100644
--- a/backend/app/controllers/documentos_controller.rb
+++ b/backend/app/controllers/documentos_controller.rb
@@ -1,14 +1,14 @@
class DocumentosController < ApplicationController
- before_action :set_documento, only: %i[ show edit update destroy ]
+ before_action :set_documento, only: %i[show edit update destroy]
# GET /documentos or /documentos.json
def index
@documentos = Documento.all
+ render json: @documentos
end
# GET /documentos/1 or /documentos/1.json
- def show
- end
+ def show; end
# GET /documentos/new
def new
@@ -16,8 +16,7 @@ def new
end
# GET /documentos/1/edit
- def edit
- end
+ def edit; end
# POST /documentos or /documentos.json
def create
@@ -25,7 +24,7 @@ def create
respond_to do |format|
if @documento.save
- format.html { redirect_to documento_url(@documento), notice: "Documento was successfully created." }
+ format.html { redirect_to documento_url(@documento), notice: 'Documento was successfully created.' }
format.json { render :show, status: :created, location: @documento }
else
format.html { render :new, status: :unprocessable_entity }
@@ -38,7 +37,7 @@ def create
def update
respond_to do |format|
if @documento.update(documento_params)
- format.html { redirect_to documento_url(@documento), notice: "Documento was successfully updated." }
+ format.html { redirect_to documento_url(@documento), notice: 'Documento was successfully updated.' }
format.json { render :show, status: :ok, location: @documento }
else
format.html { render :edit, status: :unprocessable_entity }
@@ -52,19 +51,20 @@ def destroy
@documento.destroy!
respond_to do |format|
- format.html { redirect_to documentos_url, notice: "Documento was successfully destroyed." }
+ format.html { redirect_to documentos_url, notice: 'Documento was successfully destroyed.' }
format.json { head :no_content }
end
end
private
- # Use callbacks to share common setup or constraints between actions.
- def set_documento
- @documento = Documento.find(params[:id])
- end
- # Only allow a list of trusted parameters through.
- def documento_params
- params.fetch(:documento, {})
- end
+ # Use callbacks to share common setup or constraints between actions.
+ def set_documento
+ @documento = Documento.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def documento_params
+ params.require(:documento).permit(:nome, :link, :user_id)
+ end
end
diff --git a/backend/app/controllers/reuniaos_controller.rb b/backend/app/controllers/reuniaos_controller.rb
index 32c5ba1..720ffc8 100644
--- a/backend/app/controllers/reuniaos_controller.rb
+++ b/backend/app/controllers/reuniaos_controller.rb
@@ -1,14 +1,14 @@
class ReuniaosController < ApplicationController
- before_action :set_reuniao, only: %i[ show edit update destroy ]
+ before_action :set_reuniao, only: %i[show edit update destroy]
# GET /reuniaos or /reuniaos.json
def index
@reuniaos = Reuniao.all
+ render json: @reuniaos
end
# GET /reuniaos/1 or /reuniaos/1.json
- def show
- end
+ def show; end
# GET /reuniaos/new
def new
@@ -16,19 +16,16 @@ def new
end
# GET /reuniaos/1/edit
- def edit
- end
+ def edit; end
# POST /reuniaos or /reuniaos.json
def create
- @reuniao = Reuniao.new(reuniao_params)
-
+ nome = reuniao_params[:nome]
+ @reuniao = Reuniao.new(nome: nome, link: 'NULL', user_id: 1)
respond_to do |format|
if @reuniao.save
- format.html { redirect_to reuniao_url(@reuniao), notice: "Reuniao was successfully created." }
format.json { render :show, status: :created, location: @reuniao }
else
- format.html { render :new, status: :unprocessable_entity }
format.json { render json: @reuniao.errors, status: :unprocessable_entity }
end
end
@@ -38,7 +35,7 @@ def create
def update
respond_to do |format|
if @reuniao.update(reuniao_params)
- format.html { redirect_to reuniao_url(@reuniao), notice: "Reuniao was successfully updated." }
+ format.html { redirect_to reuniao_url(@reuniao), notice: 'Reuniao was successfully updated.' }
format.json { render :show, status: :ok, location: @reuniao }
else
format.html { render :edit, status: :unprocessable_entity }
@@ -52,19 +49,20 @@ def destroy
@reuniao.destroy!
respond_to do |format|
- format.html { redirect_to reuniaos_url, notice: "Reuniao was successfully destroyed." }
+ format.html { redirect_to reuniaos_url, notice: 'Reuniao was successfully destroyed.' }
format.json { head :no_content }
end
end
private
- # Use callbacks to share common setup or constraints between actions.
- def set_reuniao
- @reuniao = Reuniao.find(params[:id])
- end
- # Only allow a list of trusted parameters through.
- def reuniao_params
- params.fetch(:reuniao, {})
- end
+ # Use callbacks to share common setup or constraints between actions.
+ def set_reuniao
+ @reuniao = Reuniao.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def reuniao_params
+ params.require(:reuniao).permit(:nome, :link, :user_id)
+ end
end
diff --git a/backend/app/controllers/users_controller.rb b/backend/app/controllers/users_controller.rb
index 78aab39..574a98a 100644
--- a/backend/app/controllers/users_controller.rb
+++ b/backend/app/controllers/users_controller.rb
@@ -1,46 +1,43 @@
-require "bcrypt"
-require 'jwt'
+require 'bcrypt'
+# require 'jwt'
class UsersController < ApplicationController
protect_from_forgery with: :null_session
- before_action :set_user, only: %i[ show edit update destroy ]
+ before_action :set_user, only: %i[show edit update destroy]
# GET /users or /users.json
def index
@users = User.all
- render json: @users
+ render json: @users
end
# GET /users/1 or /users/1.json
- def show
- end
+ def show; end
def login
- if User.find_by(matricula: user_params[:matricula])
+ if User.find_by(matricula: user_params[:matricula])
user = User.find_by(matricula: user_params[:matricula])
- pass = BCrypt::Password.new(user.senha)
- else
- render json: "MATRICULA INEXISTENTE"
- return
- end
- if pass == user_params[:senha]
- hmac_secret = 'Secreto'
- payload = user_params[:matricula]
- token = JWT.encode payload, hmac_secret, 'HS256'
+ pass = BCrypt::Password.new(user.senha)
+ else
+ render json: 'MATRICULA INEXISTENTE'
+ return
+ end
+ if pass == user_params[:senha]
+ hmac_secret = 'Secreto'
+ payload = user_params[:matricula]
+ token = JWT.encode payload, hmac_secret, 'HS256'
render json: token
- else
- render json: "SENHA INCORRETA"
- end
+ else
+ render json: 'SENHA INCORRETA'
+ end
end
-
# GET /users/new
def new
- #@user = User.new
+ # @user = User.new
end
# GET /users/1/edit
- def edit
- end
+ def edit; end
# POST /users or /users.json
def create
@@ -50,15 +47,15 @@ def create
matricula = user_params[:matricula]
email = user_params[:email]
cargoID = user_params[:cargo_id]
- @user = User.new(nome: nome,matricula: matricula,email: email,senha: hash,cargo_id: cargoID)
+ @user = User.new(nome:, matricula:, email:, senha: hash, cargo_id: cargoID)
if @user.save
render json: @user
else
render json: @user.errors
end
-
- #respond_to do |format|
+
+ # respond_to do |format|
# if @user.save
# format.html { redirect_to user_url(@user), notice: "User was successfully created." }
# format.json { render :show, status: :created, location: @user }
@@ -66,7 +63,7 @@ def create
# format.html { render :new, status: :unprocessable_entity }
# format.json { render json: @user.errors, status: :unprocessable_entity }
# end
- #end
+ # end
end
# PATCH/PUT /users/1 or /users/1.json
@@ -79,34 +76,35 @@ def update
end
end
- #PATCH /users/password/:id
+ # PATCH /users/password/:id
def update_password
set_user
senha = password_params[:senha]
pp senha
hash = BCrypt::Password.create(senha)
@user.senha = hash
-
+
if @user.save
render json: @user
else
render json: @user.errors
end
end
+
# DELETE /users/1 or /users/1.json
def destroy
@user.destroy!
end
private
- # Use callbacks to share common setup or constraints between actions.
- def set_user
- @user = User.find(params[:id])
- end
- # Only allow a list of trusted parameters through.
- def user_params
- params.require(:user).permit(:nome, :matricula, :email, :senha, :cargo_id, :token)
- end
+ # Use callbacks to share common setup or constraints between actions.
+ def set_user
+ @user = User.find(params[:id])
+ end
+ # Only allow a list of trusted parameters through.
+ def user_params
+ params.require(:user).permit(:nome, :matricula, :email, :senha, :cargo_id, :token)
+ end
end
diff --git a/backend/app/models/reuniao.rb b/backend/app/models/reuniao.rb
index 452ba31..c23fa75 100644
--- a/backend/app/models/reuniao.rb
+++ b/backend/app/models/reuniao.rb
@@ -1,3 +1,4 @@
class Reuniao < ApplicationRecord
- belongs_to :user
+ has_many :reunioes_usuarios
+ has_many :user, through: :reunioes_usuarios
end
diff --git a/backend/app/models/user.rb b/backend/app/models/user.rb
index e1408f7..760be2b 100644
--- a/backend/app/models/user.rb
+++ b/backend/app/models/user.rb
@@ -3,5 +3,6 @@ class User < ApplicationRecord
has_many :estoques
has_many :tarefas
has_many :documentos
- has_many :reuniaos
+ has_many :reunioes_usuarios
+ has_many :reuniaos, through: :reunioes_usuarios
end
diff --git a/backend/app/views/documentos/_documento.html.erb b/backend/app/views/documentos/_documento.html.erb
new file mode 100644
index 0000000..cc33eac
--- /dev/null
+++ b/backend/app/views/documentos/_documento.html.erb
@@ -0,0 +1,17 @@
+
+
+ Nome:
+ <%= documento.nome %>
+
+
+
+ Link:
+ <%= documento.link %>
+
+
+
+ User:
+ <%= documento.user_id %>
+
+
+
diff --git a/backend/app/views/documentos/_documento.json.jbuilder b/backend/app/views/documentos/_documento.json.jbuilder
new file mode 100644
index 0000000..8950be5
--- /dev/null
+++ b/backend/app/views/documentos/_documento.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! documento, :id, :nome, :link, :user_id, :created_at, :updated_at
+json.url documento_url(documento, format: :json)
diff --git a/backend/app/views/documentos/_form.html.erb b/backend/app/views/documentos/_form.html.erb
new file mode 100644
index 0000000..229a55f
--- /dev/null
+++ b/backend/app/views/documentos/_form.html.erb
@@ -0,0 +1,32 @@
+<%= form_with(model: documento) do |form| %>
+ <% if documento.errors.any? %>
+
+
<%= pluralize(documento.errors.count, "error") %> prohibited this documento from being saved:
+
+
+ <% documento.errors.each do |error| %>
+ - <%= error.full_message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :nome, style: "display: block" %>
+ <%= form.text_field :nome %>
+
+
+
+ <%= form.label :link, style: "display: block" %>
+ <%= form.text_field :link %>
+
+
+
+ <%= form.label :user_id, style: "display: block" %>
+ <%= form.text_field :user_id %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/backend/app/views/documentos/edit.html.erb b/backend/app/views/documentos/edit.html.erb
new file mode 100644
index 0000000..3369330
--- /dev/null
+++ b/backend/app/views/documentos/edit.html.erb
@@ -0,0 +1,10 @@
+Editing documento
+
+<%= render "form", documento: @documento %>
+
+
+
+
+ <%= link_to "Show this documento", @documento %> |
+ <%= link_to "Back to documentos", documentos_path %>
+
diff --git a/backend/app/views/documentos/index.html.erb b/backend/app/views/documentos/index.html.erb
new file mode 100644
index 0000000..9676801
--- /dev/null
+++ b/backend/app/views/documentos/index.html.erb
@@ -0,0 +1,14 @@
+<%= notice %>
+
+Documentos
+
+
+ <% @documentos.each do |documento| %>
+ <%= render documento %>
+
+ <%= link_to "Show this documento", documento %>
+
+ <% end %>
+
+
+<%= link_to "New documento", new_documento_path %>
diff --git a/backend/app/views/documentos/index.json.jbuilder b/backend/app/views/documentos/index.json.jbuilder
new file mode 100644
index 0000000..d4cdd72
--- /dev/null
+++ b/backend/app/views/documentos/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @documentos, partial: "documentos/documento", as: :documento
diff --git a/backend/app/views/documentos/new.html.erb b/backend/app/views/documentos/new.html.erb
new file mode 100644
index 0000000..818d357
--- /dev/null
+++ b/backend/app/views/documentos/new.html.erb
@@ -0,0 +1,9 @@
+New documento
+
+<%= render "form", documento: @documento %>
+
+
+
+
+ <%= link_to "Back to documentos", documentos_path %>
+
diff --git a/backend/app/views/documentos/show.html.erb b/backend/app/views/documentos/show.html.erb
new file mode 100644
index 0000000..8d8f775
--- /dev/null
+++ b/backend/app/views/documentos/show.html.erb
@@ -0,0 +1,10 @@
+<%= notice %>
+
+<%= render @documento %>
+
+
+ <%= link_to "Edit this documento", edit_documento_path(@documento) %> |
+ <%= link_to "Back to documentos", documentos_path %>
+
+ <%= button_to "Destroy this documento", @documento, method: :delete %>
+
diff --git a/backend/app/views/documentos/show.json.jbuilder b/backend/app/views/documentos/show.json.jbuilder
new file mode 100644
index 0000000..2c1e7a9
--- /dev/null
+++ b/backend/app/views/documentos/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "documentos/documento", documento: @documento
diff --git a/backend/app/views/reuniaos/_form.html.erb b/backend/app/views/reuniaos/_form.html.erb
new file mode 100644
index 0000000..fffebc3
--- /dev/null
+++ b/backend/app/views/reuniaos/_form.html.erb
@@ -0,0 +1,32 @@
+<%= form_with(model: reuniao) do |form| %>
+ <% if reuniao.errors.any? %>
+
+
<%= pluralize(reuniao.errors.count, "error") %> prohibited this reuniao from being saved:
+
+
+ <% reuniao.errors.each do |error| %>
+ - <%= error.full_message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= form.label :nome, style: "display: block" %>
+ <%= form.text_field :nome %>
+
+
+
+ <%= form.label :link, style: "display: block" %>
+ <%= form.text_field :link %>
+
+
+
+ <%= form.label :user_id, style: "display: block" %>
+ <%= form.text_field :user_id %>
+
+
+
+ <%= form.submit %>
+
+<% end %>
diff --git a/backend/app/views/reuniaos/_reuniao.html.erb b/backend/app/views/reuniaos/_reuniao.html.erb
new file mode 100644
index 0000000..6fc7a9e
--- /dev/null
+++ b/backend/app/views/reuniaos/_reuniao.html.erb
@@ -0,0 +1,17 @@
+
+
+ Nome:
+ <%= reuniao.nome %>
+
+
+
+ Link:
+ <%= reuniao.link %>
+
+
+
+ User:
+ <%= reuniao.user_id %>
+
+
+
diff --git a/backend/app/views/reuniaos/_reuniao.json.jbuilder b/backend/app/views/reuniaos/_reuniao.json.jbuilder
new file mode 100644
index 0000000..021fc05
--- /dev/null
+++ b/backend/app/views/reuniaos/_reuniao.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! reuniao, :id, :nome, :link, :user_id, :created_at, :updated_at
+json.url reuniao_url(reuniao, format: :json)
diff --git a/backend/app/views/reuniaos/edit.html.erb b/backend/app/views/reuniaos/edit.html.erb
new file mode 100644
index 0000000..a273b2b
--- /dev/null
+++ b/backend/app/views/reuniaos/edit.html.erb
@@ -0,0 +1,10 @@
+Editing reuniao
+
+<%= render "form", reuniao: @reuniao %>
+
+
+
+
+ <%= link_to "Show this reuniao", @reuniao %> |
+ <%= link_to "Back to reuniaos", reuniaos_path %>
+
diff --git a/backend/app/views/reuniaos/index.html.erb b/backend/app/views/reuniaos/index.html.erb
new file mode 100644
index 0000000..9d661b6
--- /dev/null
+++ b/backend/app/views/reuniaos/index.html.erb
@@ -0,0 +1,14 @@
+<%= notice %>
+
+Reuniaos
+
+
+ <% @reuniaos.each do |reuniao| %>
+ <%= render reuniao %>
+
+ <%= link_to "Show this reuniao", reuniao %>
+
+ <% end %>
+
+
+<%= link_to "New reuniao", new_reuniao_path %>
diff --git a/backend/app/views/reuniaos/index.json.jbuilder b/backend/app/views/reuniaos/index.json.jbuilder
new file mode 100644
index 0000000..2214399
--- /dev/null
+++ b/backend/app/views/reuniaos/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @reuniaos, partial: "reuniaos/reuniao", as: :reuniao
diff --git a/backend/app/views/reuniaos/new.html.erb b/backend/app/views/reuniaos/new.html.erb
new file mode 100644
index 0000000..d61c0ba
--- /dev/null
+++ b/backend/app/views/reuniaos/new.html.erb
@@ -0,0 +1,9 @@
+New reuniao
+
+<%= render "form", reuniao: @reuniao %>
+
+
+
+
+ <%= link_to "Back to reuniaos", reuniaos_path %>
+
diff --git a/backend/app/views/reuniaos/show.html.erb b/backend/app/views/reuniaos/show.html.erb
new file mode 100644
index 0000000..2916365
--- /dev/null
+++ b/backend/app/views/reuniaos/show.html.erb
@@ -0,0 +1,10 @@
+<%= notice %>
+
+<%= render @reuniao %>
+
+
+ <%= link_to "Edit this reuniao", edit_reuniao_path(@reuniao) %> |
+ <%= link_to "Back to reuniaos", reuniaos_path %>
+
+ <%= button_to "Destroy this reuniao", @reuniao, method: :delete %>
+
diff --git a/backend/app/views/reuniaos/show.json.jbuilder b/backend/app/views/reuniaos/show.json.jbuilder
new file mode 100644
index 0000000..a287548
--- /dev/null
+++ b/backend/app/views/reuniaos/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "reuniaos/reuniao", reuniao: @reuniao
diff --git a/backend/config/application.rb b/backend/config/application.rb
index 59ec585..685bbc5 100644
--- a/backend/config/application.rb
+++ b/backend/config/application.rb
@@ -1,8 +1,8 @@
-require_relative "boot"
+require_relative 'boot'
require 'rack'
require 'rack/cors'
-require "rails/all"
-require "dotenv"
+require 'rails/all'
+require 'dotenv'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
@@ -16,29 +16,30 @@ class Application < Rails::Application
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
- config.autoload_lib(ignore: %w(assets tasks))
+ config.autoload_lib(ignore: %w[assets tasks])
+ config.action_controller.allow_forgery_protection = false
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
-
+
# config/initializers/cors.rb
- # config.middleware.insert_before 0, Rack::Cors do
- # allow do
- # origins '*'
- # resource(
- # '*',
- # headers: :any,
- # methods: [:get, :post, :patch, :put]
- # )
- # end
- # end
+ config.middleware.insert_before 0, Rack::Cors do
+ allow do
+ origins '*'
+ resource(
+ '*',
+ headers: :any,
+ methods: %i[get post patch put]
+ )
+ end
+ end
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
- #dotenv config
+ # dotenv config
Dotenv.load
end
end
diff --git a/backend/config/routes.rb b/backend/config/routes.rb
index bf91cc0..b158121 100644
--- a/backend/config/routes.rb
+++ b/backend/config/routes.rb
@@ -1,11 +1,11 @@
Rails.application.routes.draw do
+ resources :reuniaos
resources :storages
- post "/users/new", to: 'users#create'
- post '/users/login', to: 'users#login'
+ post '/users/new', to: 'users#create'
+ post '/users/login', to: 'users#login'
post '/users/token', to: 'users#validaToken'
-
- resources :reuniaos
- resources :documentos
+ post '/reuniaos', to: 'reuniaos#create'
+ post '/documentos', to: 'documentos#create'
resources :tarefas
resources :acaos
resources :cargos
@@ -14,9 +14,9 @@
# 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
+ get 'up' => 'rails/health#show', as: :rails_health_check
- patch "users/password/:id", to: "users#update_password"
+ patch 'users/password/:id', to: 'users#update_password'
# Defines the root path route ("/")
# root "posts#index"
diff --git a/backend/db/migrate/20240524214222_create_reuniaos.rb b/backend/db/migrate/20240613161521_create_reuniaos.rb
similarity index 81%
rename from backend/db/migrate/20240524214222_create_reuniaos.rb
rename to backend/db/migrate/20240613161521_create_reuniaos.rb
index b5a7d1c..8ee6e23 100644
--- a/backend/db/migrate/20240524214222_create_reuniaos.rb
+++ b/backend/db/migrate/20240613161521_create_reuniaos.rb
@@ -1,8 +1,8 @@
class CreateReuniaos < ActiveRecord::Migration[7.1]
def change
create_table :reuniaos do |t|
- t.string :titulo
- t.string :ata
+ t.string :nome
+ t.string :link
t.references :user, null: false, foreign_key: true
t.timestamps
diff --git a/backend/db/migrate/20240613163007_create_reunioes_usuarios.rb b/backend/db/migrate/20240613163007_create_reunioes_usuarios.rb
new file mode 100644
index 0000000..7cf4488
--- /dev/null
+++ b/backend/db/migrate/20240613163007_create_reunioes_usuarios.rb
@@ -0,0 +1,10 @@
+class CreateReunioesUsuarios < ActiveRecord::Migration[7.1]
+ def change
+ create_table :reunioes_usuarios do |t|
+ t.references :reuniao, null: false, foreign_key: true
+ t.references :user, null: false, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/backend/db/migrate/20240524214047_create_documentos.rb b/backend/db/migrate/20240613170605_create_documentos.rb
similarity index 65%
rename from backend/db/migrate/20240524214047_create_documentos.rb
rename to backend/db/migrate/20240613170605_create_documentos.rb
index b8bc084..ddae804 100644
--- a/backend/db/migrate/20240524214047_create_documentos.rb
+++ b/backend/db/migrate/20240613170605_create_documentos.rb
@@ -1,10 +1,8 @@
class CreateDocumentos < ActiveRecord::Migration[7.1]
def change
create_table :documentos do |t|
- t.string :titulo
- t.integer :nivelAcesso
- t.string :data
- t.string :tipoDocumento
+ t.string :nome
+ t.string :link
t.references :user, null: false, foreign_key: true
t.timestamps
diff --git a/backend/db/schema.rb b/backend/db/schema.rb
index 4213b88..fe996e4 100644
--- a/backend/db/schema.rb
+++ b/backend/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_06_11_054248) do
+ActiveRecord::Schema[7.1].define(version: 2024_06_13_170605) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -32,28 +32,30 @@
end
create_table "documentos", force: :cascade do |t|
- t.string "titulo"
- t.integer "nivelAcesso"
- t.string "data"
- t.string "tipoDocumento"
+ t.string "nome"
+ t.string "link"
t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_documentos_on_user_id"
end
- create_table "estoques", force: :cascade do |t|
+ create_table "reuniaos", force: :cascade do |t|
+ t.string "nome"
+ t.string "link"
+ t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.index ["user_id"], name: "index_reuniaos_on_user_id"
end
- create_table "reuniaos", force: :cascade do |t|
- t.string "titulo"
- t.string "ata"
+ create_table "reunioes_usuarios", force: :cascade do |t|
+ t.bigint "reuniao_id", null: false
t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.index ["user_id"], name: "index_reuniaos_on_user_id"
+ t.index ["reuniao_id"], name: "index_reunioes_usuarios_on_reuniao_id"
+ t.index ["user_id"], name: "index_reunioes_usuarios_on_user_id"
end
create_table "storages", force: :cascade do |t|
@@ -91,6 +93,8 @@
add_foreign_key "acaos", "users"
add_foreign_key "documentos", "users"
add_foreign_key "reuniaos", "users"
+ add_foreign_key "reunioes_usuarios", "reuniaos"
+ add_foreign_key "reunioes_usuarios", "users"
add_foreign_key "storages", "users"
add_foreign_key "tarefas", "users"
add_foreign_key "users", "cargos"
diff --git a/backend/test/controllers/documentos_controller_test.rb b/backend/test/controllers/documentos_controller_test.rb
index 3fe16c5..cc7516d 100644
--- a/backend/test/controllers/documentos_controller_test.rb
+++ b/backend/test/controllers/documentos_controller_test.rb
@@ -17,7 +17,7 @@ class DocumentosControllerTest < ActionDispatch::IntegrationTest
test "should create documento" do
assert_difference("Documento.count") do
- post documentos_url, params: { documento: { } }
+ post documentos_url, params: { documento: { link: @documento.link, nome: @documento.nome, user_id: @documento.user_id } }
end
assert_redirected_to documento_url(Documento.last)
@@ -34,7 +34,7 @@ class DocumentosControllerTest < ActionDispatch::IntegrationTest
end
test "should update documento" do
- patch documento_url(@documento), params: { documento: { } }
+ patch documento_url(@documento), params: { documento: { link: @documento.link, nome: @documento.nome, user_id: @documento.user_id } }
assert_redirected_to documento_url(@documento)
end
diff --git a/backend/test/controllers/reuniaos_controller_test.rb b/backend/test/controllers/reuniaos_controller_test.rb
index 6253b5c..05832e1 100644
--- a/backend/test/controllers/reuniaos_controller_test.rb
+++ b/backend/test/controllers/reuniaos_controller_test.rb
@@ -17,7 +17,7 @@ class ReuniaosControllerTest < ActionDispatch::IntegrationTest
test "should create reuniao" do
assert_difference("Reuniao.count") do
- post reuniaos_url, params: { reuniao: { } }
+ post reuniaos_url, params: { reuniao: { link: @reuniao.link, nome: @reuniao.nome, user_id: @reuniao.user_id } }
end
assert_redirected_to reuniao_url(Reuniao.last)
@@ -34,7 +34,7 @@ class ReuniaosControllerTest < ActionDispatch::IntegrationTest
end
test "should update reuniao" do
- patch reuniao_url(@reuniao), params: { reuniao: { } }
+ patch reuniao_url(@reuniao), params: { reuniao: { link: @reuniao.link, nome: @reuniao.nome, user_id: @reuniao.user_id } }
assert_redirected_to reuniao_url(@reuniao)
end
diff --git a/backend/test/fixtures/documentos.yml b/backend/test/fixtures/documentos.yml
index 7cf3c67..aa15649 100644
--- a/backend/test/fixtures/documentos.yml
+++ b/backend/test/fixtures/documentos.yml
@@ -1,15 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
- titulo: MyString
- nivelAcesso: 1
- data: MyString
- tipoDocumento: MyString
+ nome: MyString
+ link: MyString
user: one
two:
- titulo: MyString
- nivelAcesso: 1
- data: MyString
- tipoDocumento: MyString
+ nome: MyString
+ link: MyString
user: two
diff --git a/backend/test/fixtures/reuniaos.yml b/backend/test/fixtures/reuniaos.yml
index 7753c46..aa15649 100644
--- a/backend/test/fixtures/reuniaos.yml
+++ b/backend/test/fixtures/reuniaos.yml
@@ -1,11 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
- titulo: MyString
- ata: MyString
+ nome: MyString
+ link: MyString
user: one
two:
- titulo: MyString
- ata: MyString
+ nome: MyString
+ link: MyString
user: two
diff --git a/backend/test/system/documentos_test.rb b/backend/test/system/documentos_test.rb
index 61f35d8..ad81f60 100644
--- a/backend/test/system/documentos_test.rb
+++ b/backend/test/system/documentos_test.rb
@@ -14,6 +14,9 @@ class DocumentosTest < ApplicationSystemTestCase
visit documentos_url
click_on "New documento"
+ fill_in "Link", with: @documento.link
+ fill_in "Nome", with: @documento.nome
+ fill_in "User", with: @documento.user_id
click_on "Create Documento"
assert_text "Documento was successfully created"
@@ -24,6 +27,9 @@ class DocumentosTest < ApplicationSystemTestCase
visit documento_url(@documento)
click_on "Edit this documento", match: :first
+ fill_in "Link", with: @documento.link
+ fill_in "Nome", with: @documento.nome
+ fill_in "User", with: @documento.user_id
click_on "Update Documento"
assert_text "Documento was successfully updated"
diff --git a/backend/test/system/reuniaos_test.rb b/backend/test/system/reuniaos_test.rb
index 6431107..993f36f 100644
--- a/backend/test/system/reuniaos_test.rb
+++ b/backend/test/system/reuniaos_test.rb
@@ -14,6 +14,9 @@ class ReuniaosTest < ApplicationSystemTestCase
visit reuniaos_url
click_on "New reuniao"
+ fill_in "Link", with: @reuniao.link
+ fill_in "Nome", with: @reuniao.nome
+ fill_in "User", with: @reuniao.user_id
click_on "Create Reuniao"
assert_text "Reuniao was successfully created"
@@ -24,6 +27,9 @@ class ReuniaosTest < ApplicationSystemTestCase
visit reuniao_url(@reuniao)
click_on "Edit this reuniao", match: :first
+ fill_in "Link", with: @reuniao.link
+ fill_in "Nome", with: @reuniao.nome
+ fill_in "User", with: @reuniao.user_id
click_on "Update Reuniao"
assert_text "Reuniao was successfully updated"
diff --git a/view/src/pages/Documents/index.jsx b/view/src/pages/Documents/index.jsx
index d50d3a7..8669f08 100644
--- a/view/src/pages/Documents/index.jsx
+++ b/view/src/pages/Documents/index.jsx
@@ -1,6 +1,31 @@
import React, { useState } from 'react';
import SideBar from "../../components/SideBar"
import './Documents.css';
+import axios from 'axios';
+
+function criarDocumento(descricao, link) {
+ // Variável para armazenar o ID do usuário
+ const userId = 12; // Altere conforme necessário
+
+ // Dados a serem enviados no corpo da solicitação POST
+ const data = {
+ nome: descricao,
+ link: link,
+ user_id: userId
+ };
+
+ // Fazendo a solicitação POST usando Axios
+ axios.post("http://localhost:3000/documentos", data)
+ .then(function (response) {
+ // Resposta recebida com sucesso
+ console.log("Documento criado com sucesso:", response.data);
+ })
+ .catch(function (error) {
+ // Ocorreu um erro ao fazer a solicitação
+ console.error("Erro ao criar documento:", error);
+ });
+}
+
function Documents() {
const [showPopup, setShowPopup] = useState(false);
@@ -33,6 +58,7 @@ function Documents() {
setLink('');
setDescricao('');
};
+
const handleRemoveLink = (index) => {
const updatedLinks = [...links];
@@ -78,7 +104,7 @@ function Documents() {
required
/>
-
+
@@ -104,4 +130,4 @@ function Documents() {
}
-export default Documents;
\ No newline at end of file
+export default Documents;
diff --git a/view/src/pages/Meeting/index.jsx b/view/src/pages/Meeting/index.jsx
index e7e875c..04e2ccf 100644
--- a/view/src/pages/Meeting/index.jsx
+++ b/view/src/pages/Meeting/index.jsx
@@ -1,6 +1,7 @@
import React, { useState } from "react";
import './Meeting.css';
import SideBar from "../../components/SideBar";
+import axios from 'axios';
function Meeting() {
const [meetings, setMeetings] = useState([]);
@@ -9,6 +10,13 @@ function Meeting() {
const [link, setLink] = useState('');
const [descricao, setDescricao] = useState('');
const [links, setLinks] = useState([]);
+ let reunioes_existentes;
+axios.get("http://127.0.0.1:3000/reuniaos").then(function (response) {
+ reunioes_existentes = response.data;
+ console.log(reunioes_existentes);
+}).catch(function (error) {
+ console.error('Erro ao buscar reuniões:', error);
+});
const handleAddMeeting = () => {
const newMeeting = {
@@ -22,7 +30,8 @@ function Meeting() {
};
setMeetings([...meetings, newMeeting]);
setLinks([...links, []]); // Adiciona uma nova lista vazia de links para a nova reunião
- };
+
+ };
const handleImageClick = (index) => {
setCurrentMeetingIndex(index);
@@ -86,7 +95,7 @@ function Meeting() {
{meeting.nome}
handleImageClick(meetingIndex)} />
-
Adicionar Arquivo
+
Adicionar link do Arquivo
{meeting.files.map((item, fileIndex) => (