Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F1090641
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Oct 15, 9:53 AM
Size
7 KB
Mime Type
text/x-diff
Expires
Fri, Oct 17, 9:53 AM (5 h, 46 m)
Engine
blob
Format
Raw Data
Handle
280078
Attached To
rARCHIVING archiving
View Options
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 0b63664..c265ed8 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,105 +1,110 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :current_user, :warden
# GET /
def index
redirect_to clients_path if current_user
end
+ # GET /faq
+ def faq
+ @faqs = Faq.order(priority: :desc).all
+ end
+
# Warden handler for authentication failure
def unauthenticated
flash[:error] = warden.message || 'There was an error with your login'
if attempted_path == '/grnet'
redirect_to admin_login_path
else
redirect_to root_path
end
end
# POST /grnet
def grnet
if current_user
warden.logout
reset_current_user
end
begin
warden.authenticate!(:admin)
rescue
return unauthenticated
end
current_user
redirect_to admin_path
end
# GET /institutional
def institutional
begin
warden.authenticate!(:institutional)
rescue
return unauthenticated
end
current_user
redirect_to clients_path
end
# POST /vima
def vima
begin
warden.authenticate!(:vima)
rescue
return unauthenticated
end
current_user
redirect_to clients_path
end
def logout
warden.logout
reset_current_user
redirect_to root_path
end
protected
def warden
request.env['warden']
end
def current_user
@current_user ||= warden.user
end
def reset_current_user
@current_user = nil
end
def fetch_logs
days_ago = params.fetch(:days_back, 7).to_i rescue 7
if @client
@logs = Log.includes(:job).joins(job: :client).where(Client: { ClientId: @client.id })
else
@logs = Log.includes(:job).joins(job: { client: { host: :users } }).
where(users: { id: current_user.id })
end
@logs = @logs.where('Time > ?', days_ago.days.ago).
order(Time: :desc, LogId: :desc).page(params[:page])
end
private
def require_logged_in
return if current_user
flash[:alert] = 'You need to log in first'
redirect_to root_path
end
def attempted_path
(request.env['warden.options'] || {})[:attempted_path]
end
end
diff --git a/app/views/application/_faq.html.erb b/app/views/application/_faq.html.erb
new file mode 100644
index 0000000..9b0d470
--- /dev/null
+++ b/app/views/application/_faq.html.erb
@@ -0,0 +1,6 @@
+<%= cache(['faq', 'v1', faq], expires_in: 1.day) do %>
+ <tr>
+ <td><%= faq.title %></td>
+ <td><%= faq.body %></td>
+ </tr>
+<% end %>
diff --git a/app/views/application/faq.html.erb b/app/views/application/faq.html.erb
new file mode 100644
index 0000000..401010b
--- /dev/null
+++ b/app/views/application/faq.html.erb
@@ -0,0 +1,17 @@
+<h3>Frequently Asked Questions</h3>
+<h4>...and some useful tips</h4>
+
+<div class="table-responsive">
+ <table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <th class="col-xs-3">Title</th>
+ <th class="col-xs-8">Body</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <%= render partial: 'faq', collection: @faqs %>
+ </tbody>
+ </table>
+</div>
diff --git a/app/views/shared/_nav.html.erb b/app/views/shared/_nav.html.erb
index 1e24683..c71a7d3 100644
--- a/app/views/shared/_nav.html.erb
+++ b/app/views/shared/_nav.html.erb
@@ -1,40 +1,43 @@
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="logo">
<%= link_to root_path do %>
<p><b>GRNET NOC</b></p>
<p>Archiving</p>
<% end %>
</li>
<% if current_user %>
<%= content_tag(:li, active_class(clients_path, true)) do %>
<%= link_to 'Clients', clients_path %>
<% end %>
<li><%= link_to current_user.username, '#' %></li>
<% end %>
+ <%= content_tag(:li, active_class(faq_path)) do %>
+ <%= link_to 'FAQ', faq_path %>
+ <% end %>
</ul>
<% if current_user %>
<ul class="nav navbar-nav navbar-right">
<li>
<%= link_to logout_path do %>
<label class="glyphicon glyphicon-log-out"></label>
Logout
<% end %>
</li>
</ul>
<% end %>
<%= render partial: 'shared/admin' if current_user.try(:admin?) %>
</div><!--/.nav-collapse -->
</div>
</nav>
diff --git a/config/routes.rb b/config/routes.rb
index 6c4f625..41a7982 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,105 +1,106 @@
Rails.application.routes.draw do
root 'application#index'
+ get 'faq' => 'application#faq'
post 'grnet' => 'application#grnet'
get 'institutional' => 'application#institutional'
match 'vima', to: 'application#vima', :via => [:get, :post]
get 'logout' => 'application#logout'
resources :clients, only: [:index, :show] do
member do
get :jobs
get :logs
get :stats
post :stats
get :users
get :restore
post :run_restore
post :restore_selected
delete :remove_user
end
collection do
post :index
end
end
resources :clients, only: [], param: :client_id do
member do
get :tree
end
end
resources :invitations, only: [:create]
get '/invitations/:host_id/:verification_code/accept' => 'invitations#accept',
as: :accept_invitation
resources :hosts, only: [:new, :create, :show, :edit, :update, :destroy] do
member do
post :submit_config
post :disable
delete :revoke
end
collection do
get :fetch_vima_hosts, to: 'hosts#fetch_vima_hosts', as: :fetch_vima
end
resources :jobs, only: [:new, :create, :show, :edit, :update, :destroy] do
member do
patch :toggle_enable
post :backup_now
end
end
resources :filesets, only: [:show, :new, :create, :edit, :update, :destroy]
resources :schedules, only: [:show, :new, :edit, :create, :update, :destroy]
end
namespace :admin do
match '/', to: 'base#index', via: [:get, :post]
get '/login' => 'base#login', as: :login
resources :settings, only: [:index, :new, :create, :edit, :update] do
member do
delete :reset
end
end
resources :clients, only: [:index, :show] do
member do
get :jobs
get :logs
get :stats
post :stats
get :configuration
post :disable
post :block
post :unblock
delete :revoke
end
end
resources :hosts, only: [] do
collection do
get :unverified
end
member do
post :verify
end
end
resources :users, only: [:index, :new, :create, :show, :edit, :update] do
member do
patch :ban
patch :unban
end
end
resources :pools, only: [:index, :new, :create]
resources :faqs
end
end
Event Timeline
Log In to Comment