diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index b90401f..acf9b6e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,62 +1,82 @@ // 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, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, 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. // // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details // about supported directives. // //= require jquery.min //= require jquery_ujs //= require jquery.timepicker.min //= require jquery-ui.min //= require bootstrap.min //= require jstree //= require chosen.jquery.min //= require jquery.dataTables.min //= require dataTables.bootstrap.min //= require_tree . //= require highcharts //= require jobs //= require filesets //= require clients $(document).ready(function() { if ($('table#admin_clients').size() > 0) { $('table#admin_clients').DataTable({ paging: false, columnDefs: [ { targets: 'neither-search-nor-order', orderable: false, searchable: false }, { targets: 'no-search', orderable: true, searchable: false }], }); }; if ($('table#admin_jobs').size() > 0) { $('table#admin_jobs').DataTable({ paging: false, columnDefs: [ { targets: 'neither-search-nor-order', orderable: false, searchable: false }, { targets: 'no-search', orderable: true, searchable: false }], }); }; - + if ($('table#logs').size() > 0) { + $('table#logs').DataTable({ + paging: false, + columnDefs: [ + { + targets: 'neither-search-nor-order', + orderable: false, + searchable: false + }, + { + targets: 'no-order', + orderable: false, + searchable: true + }, + { + targets: 'no-search', + orderable: true, + searchable: false + }], + }); + }; }); diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ecf3f2b..fbfb632 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,112 +1,111 @@ 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, :days_ago # 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 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]) + @logs = @logs.order(Time: :desc, LogId: :desc) end def days_ago params.fetch(:days_back, 7).to_i rescue 7 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/admin/clients/logs.html.erb b/app/views/admin/clients/logs.html.erb index aff1bb2..77554eb 100644 --- a/app/views/admin/clients/logs.html.erb +++ b/app/views/admin/clients/logs.html.erb @@ -1,37 +1,30 @@ <%= render partial: 'header' %>
-

Logs (<%= @logs.total_count %>)

-
-
- -
-
- <%= page_entries_info @logs, entry_name: 'log' %> -
-
- <%= paginate @logs %> +

Logs (<%= @logs.count %>)

-
- - - - - - - - - - - <%= render partial: 'log', collection: @logs %> - -
LogIdJobId - JobTimeText
+
+
+ + + + + + + + + + + <%= render partial: 'log', collection: @logs %> + +
LogIdJobId + JobTimeText
+
diff --git a/app/views/clients/logs.html.erb b/app/views/clients/logs.html.erb index 7fe8304..d144f20 100644 --- a/app/views/clients/logs.html.erb +++ b/app/views/clients/logs.html.erb @@ -1,37 +1,30 @@ <%= render partial: 'header' %>
-

Logs (<%= @logs.total_count %>)

-
-
- -
-
- <%= page_entries_info @logs, entry_name: 'log' %> -
-
- <%= paginate @logs %> +

Logs (<%= @logs.count %>)

-
- - - - - - - - - - - - <%= render partial: 'log', collection: @logs %> - -
LogIdJobIdJobTimeText
+
+
+ + + + + + + + + + + + <%= render partial: 'log', collection: @logs %> + +
LogIdJobIdJobTimeText
+