Skip to content

Commit

Permalink
Set correct date range and period during initial page load
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarcoux committed Dec 19, 2018
1 parent d4cc6cd commit 6a429ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/api/app/controllers/webui/projects/pulse_controller.rb
Expand Up @@ -2,6 +2,7 @@ module Webui
module Projects
class PulseController < WebuiController
before_action :set_project
before_action :set_range
before_action :set_pulse, if: -> { request.xhr? }

def show
Expand All @@ -11,8 +12,11 @@ def show

private

def set_pulse
def set_range
@range = params[:range] == 'month' ? 'month' : 'week'
end

def set_pulse
case @range
when 'month'
range = 1.month.ago..Date.tomorrow
Expand Down
8 changes: 4 additions & 4 deletions src/api/app/views/webui2/webui/projects/pulse/show.html.haml
Expand Up @@ -7,7 +7,7 @@
.row
.col-8.mb-3
%h3#range-header
= pulse_period('month')
= pulse_period(@range)
.col
.dropdown.float-right
%button.btn.btn-secondary.dropdown-toggle#period-dropdown{ 'aria-expanded': 'false',
Expand All @@ -16,7 +16,7 @@
type: 'button' }
Period: One
%span#range-text
Week
= @range.capitalize
.dropdown-menu{ 'aria-labelledby': 'dropdownMenuButton' }
%h6.dropdown-header
Period to display:
Expand All @@ -30,13 +30,13 @@
.col.text-center
%i.fas.fa-spinner.fa-spin.fa-3x


:javascript
$.ajax({
url: "#{project_pulse_path(@project)}",
url: "#{project_pulse_path(@project, range: @range)}",
type: "get",
dataType: 'script'
});

$(".dropdown-item").click(function() {
$("#pulse").html('<div class="fa-3x"><i class="fas fa-spinner fa-spin"></i></div>')
// FIXME: No idea why this is needed, maybe remote links are not covered by bootstrap?
Expand Down

0 comments on commit 6a429ea

Please sign in to comment.