Skip to content

Commit

Permalink
Merge pull request #249 from CLOSER-Cohorts/removing_home_graphics
Browse files Browse the repository at this point in the history
Turning off code that generates Archivist's graphics. Rearranging Arc…
  • Loading branch information
charlesdebarros authored Aug 20, 2018
2 parents 531b7c0 + 661471c commit 814476f
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 95 deletions.
179 changes: 90 additions & 89 deletions app/assets/javascripts/application.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ archivist.config([ '$routeProvider', '$locationProvider', '$rootScopeProvider',
controller: 'HomeController'
)
$locationProvider.html5Mode true
$rootScopeProvider.digestTtl(14);
$rootScopeProvider.digestTtl(14)
])

archivist.controller('RootController',
Expand Down Expand Up @@ -104,94 +104,95 @@ archivist.controller('HomeController',
'$scope',
'DataManager'
($scope, DataManager)->
$scope.chart_one = {}
$scope.chart_two = {}
$scope.chart_three = {}
$scope.chart_four = {}
$scope.chart_one.type = $scope.chart_three.type = $scope.chart_four.type = "ColumnChart"
$scope.chart_two.type = "Histogram"
$scope.instruments = DataManager.getInstruments {}, (res)->
$scope.chart_one.data = {
cols: [
{
id: "s",
label: "Study",
type: "string"
},
{
id: "i",
label: "Instruments",
type: "number"
}
]
}
$scope.chart_two.data = [
[
'Instrument',
'Control Constructs'
]
]
$scope.chart_three.data = {
cols: [
{
id: "s",
label: "Study",
type: "string"
},
{
id: "s",
label: "Avg. Constructs Per Instrument",
type: "number"
}
]
}
$scope.chart_one.data['rows'] = []
$scope.chart_three.data['rows'] = []
data = {}
for i in res
if i.study of data
data[i.study]['instruments'] += 1
data[i.study]['ccs'] += i.ccs
else
data[i.study] =
'instruments' : 1
'ccs' : i.ccs

$scope.chart_two.data.push [
i.title,
i.ccs
]
Object.sort(data)
for s of data
$scope.chart_one.data['rows'].push {
c: [
{v: s}, {v: data[s]['instruments']}
]
}
$scope.chart_three.data['rows'].push {
c: [
{v: s}, {v: data[s]['ccs'] / data[s]['instruments']}
]
}
$scope.studies = Object.keys data
$scope.datasets = DataManager.getDatasets()
console.log $scope

$scope.chart_one.options =
'title': 'Instruments'
'legend':
'position': 'none'
'colors': ['#652C90']
$scope.chart_two.options =
'title': 'Control Construct Distribution'
'legend':
'position': 'none'
'colors': ['#FBAF3F']
$scope.chart_three.options =
'title': 'Avg. Constructs per Instrument'
'legend':
'position': 'none'
'colors': ['#00ADEF']
console.log 'HomeController loading...'
# $scope.chart_one = {}
# $scope.chart_two = {}
# $scope.chart_three = {}
# $scope.chart_four = {}
# $scope.chart_one.type = $scope.chart_three.type = $scope.chart_four.type = "ColumnChart"
# $scope.chart_two.type = "Histogram"
# $scope.instruments = DataManager.getInstruments {}, (res)->
# $scope.chart_one.data = {
# cols: [
# {
# id: "s",
# label: "Study",
# type: "string"
# },
# {
# id: "i",
# label: "Instruments",
# type: "number"
# }
# ]
# }
# $scope.chart_two.data = [
# [
# 'Instrument',
# 'Control Constructs'
# ]
# ]
# $scope.chart_three.data = {
# cols: [
# {
# id: "s",
# label: "Study",
# type: "string"
# },
# {
# id: "s",
# label: "Avg. Constructs Per Instrument",
# type: "number"
# }
# ]
# }
# $scope.chart_one.data['rows'] = []
# $scope.chart_three.data['rows'] = []
# data = {}
# for i in res
# if i.study of data
# data[i.study]['instruments'] += 1
# data[i.study]['ccs'] += i.ccs
# else
# data[i.study] =
# 'instruments' : 1
# 'ccs' : i.ccs
#
# $scope.chart_two.data.push [
# i.title,
# i.ccs
# ]
# Object.sort(data)
# for s of data
# $scope.chart_one.data['rows'].push {
# c: [
# {v: s}, {v: data[s]['instruments']}
# ]
# }
# $scope.chart_three.data['rows'].push {
# c: [
# {v: s}, {v: data[s]['ccs'] / data[s]['instruments']}
# ]
# }
# $scope.studies = Object.keys data
# $scope.datasets = DataManager.getDatasets()
# console.log $scope
#
# $scope.chart_one.options =
# 'title': 'Instruments'
# 'legend':
# 'position': 'none'
# 'colors': ['#652C90']
# $scope.chart_two.options =
# 'title': 'Control Construct Distribution'
# 'legend':
# 'position': 'none'
# 'colors': ['#FBAF3F']
# $scope.chart_three.options =
# 'title': 'Avg. Constructs per Instrument'
# 'legend':
# 'position': 'none'
# 'colors': ['#00ADEF']
]
)

Expand Down
11 changes: 10 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Application Controller
class ApplicationController < ActionController::Base
include Pundit
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
include Pundit
Expand All @@ -8,6 +8,15 @@ class ApplicationController < ActionController::Base

after_action :set_csrf_cookie_for_ng

# around_action :collect_metrics

# def collect_metrics
# start = Time.now
# yield
# duration = Time.now - start
# Rails.logger.info "#{controller_name}##{action_name}: #{duration}s"
# end

def current_user
super || User.where(api_key: params['api_key']).where('api_key IS NOT NULL').first
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<title data-ng-bind-template="{{page.title}} | Archivist">Archivist</title>
<%= stylesheet_link_tag 'application', media: 'all'%>
<%= javascript_include_tag 'application'%>
Expand Down
3 changes: 0 additions & 3 deletions app/views/main/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
</div>
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav" data-ng-show="user.logged_in">
<li data-ng-class="{active: isActive('/')}">
<a href="/">Home</a>
</li>
<li data-ng-class="{active: isActive('/instruments')}">
<a href="/instruments">Instruments</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( *.png *.gif *.jpg *.jpeg *.eot *.woff *.ttf worker.js basic.js basic.css )
Rails.application.config.assets.precompile += %w( *.png *.gif *.jpg *.jpeg *.eot *.woff *.ttf worker.js basic.js *.js *.coffee basic.css )
6 changes: 6 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
as :user do
patch '/users/confirmation' => 'users/confirmations#update', :via => :patch, :as => :update_user_confirmation
end

devise_for :users, controllers: {
sessions: 'users/sessions',
confirmations: 'users/confirmations',
Expand All @@ -20,6 +21,11 @@
end
end
end

authenticated :user do
root 'main#index', to: 'instruments#index', as: :authenticated_root
end

root 'main#index'

match 'admin/import/instruments', to: 'instruments#import', via: [:post, :put], constraints: {format: ''}
Expand Down

0 comments on commit 814476f

Please sign in to comment.