# HG changeset patch # User Nattee Niparnan # Date 2014-08-28 12:15:51 # Node ID cee35860e68948924d3bd773fc9347cd04cad872 # Parent 05396b12105882c1b0283b796f53f5692c148816 (in progress) add date range diff --git a/Gemfile b/Gemfile --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,12 @@ # To use debugger # gem 'debugger' +# + +gem 'jquery-rails' +gem 'jquery-ui-sass-rails' +gem 'jquery-timepicker-addon-rails' + gem "haml" gem "mail" diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,18 @@ i18n (0.6.11) in_place_editing (1.2.0) journey (1.0.4) + jquery-rails (3.1.1) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + jquery-timepicker-addon-rails (1.4.1) + railties (>= 3.1) + jquery-ui-rails (4.0.3) + jquery-rails + railties (>= 3.1.0) + jquery-ui-sass-rails (4.0.3.0) + jquery-rails + jquery-ui-rails (= 4.0.3) + railties (>= 3.1.0) json (1.8.1) mail (2.5.4) mime-types (~> 1.16) @@ -138,6 +150,9 @@ dynamic_form haml in_place_editing + jquery-rails + jquery-timepicker-addon-rails + jquery-ui-sass-rails mail mysql2 prototype-rails diff --git a/app/assets/javascripts/new.js b/app/assets/javascripts/new.js new file mode 100644 --- /dev/null +++ b/app/assets/javascripts/new.js @@ -0,0 +1,6 @@ +//= require jquery +//= require jquery_ujs +//= require jquery.ui.all +//= require jquery.ui.datepicker +//= require jquery.ui.slider +//= require jquery-ui-timepicker-addon diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass --- a/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -1,3 +1,11 @@ + +@import jquery.ui.core +@import jquery.ui.theme +@import jquery.ui.datepicker +@import jquery.ui.slider +@import jquery-ui-timepicker-addon + + body background: white image-url("topbg.jpg") repeat-x top center font-size: 13px @@ -290,4 +298,4 @@ h2.contest-title margin-top: 5px - margin-bottom: 5px \ No newline at end of file + margin-bottom: 5px diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -2,6 +2,11 @@ def login_stat @logins = Array.new login = Login.all + + date_and_time = '%y-%m-%d %H:%M' + since_time = strptime(params[:since_datetime],date_and_time) + until_time = strptime(params[:until_datetime],date_and_time) + User.all.each do |user| @logins << { login: user.login, full_name: user.full_name, diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,7 +5,9 @@ <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> + <%= content_for :header %> <%= yield :head %> + diff --git a/app/views/report/_date_range.html.haml b/app/views/report/_date_range.html.haml --- a/app/views/report/_date_range.html.haml +++ b/app/views/report/_date_range.html.haml @@ -1,18 +1,19 @@ -= form_tag({action: :user_stat_max }) do += form_tag({session: :url }) do .submitbox %table %tr %td{colspan: 6, style: 'font-weight: bold'} Query maximum score in submission range %tr - %td{style: 'width: 120px; font-weight: bold'} Submission ID: - %td{align: 'right'} From date: - %td= text_field_tag 'start_date', params[:start_date] - %td Time: - %td= text_field_tag 'start_time', params[:start_time], style: 'width:40px' + %td{style: 'width: 120px; font-weight: bold'}= param_text + %td{align: 'right'} since: + %td= text_field_tag 'since_datetime' + %tr + %td + %td{align: 'right'} until: + %td= text_field_tag 'until_datetime' + %tr + %td + %td %td= submit_tag 'query' - %tr - %td - %td{colspan: 5} Leave blank date and/or time for no condition - %br/ diff --git a/app/views/report/login_stat.html.haml b/app/views/report/login_stat.html.haml --- a/app/views/report/login_stat.html.haml +++ b/app/views/report/login_stat.html.haml @@ -1,13 +1,29 @@ +- content_for :header do + = javascript_include_tag 'new' + +%script{:type=>"text/javascript"} + $(function () { + $('#since_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); + $('#until_datetime').datetimepicker({ showButtonPanel: true, dateFormat: "yy-mm-dd", controlType: "slider"} ); + }); + + %h1 Login status + .task-menu Reports %br/ = link_to '[Submission]', :action => 'submit_stat' = link_to '[Login]', :action => 'login_stat' -=render partial: 'date_range' + +=render partial: 'date_range', locals: {param_text: 'Submission range:' } + +hahaha + +=params[:since_datetime] %table.info %thead