metric_admin 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8fd7589666c761b69d4e7ee4ecd14d9199de3bba
4
+ data.tar.gz: 7ad211780457ec217fdc5b231cc616a38c3f0d65
5
+ SHA512:
6
+ metadata.gz: d72ffa6ec7ff1bbad23428339bc813de6c3b961cb01096fae0a82eb4cf6516a2f405dabde92216a20a29eed98906d6ff9e8617f07c5531cb00de9804fcd683aa
7
+ data.tar.gz: 09d3b8e32fef84b0b58d96626eb2356924ca2139ce9e41c7649226ea8d4442360e3da1e05141ef6ab0f8b0f2f1dc27a7d52151eaa544e8c52f67189df085aec0
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in metric_admin.gemspec
4
+ gemspec
data/HEAD ADDED
@@ -0,0 +1 @@
1
+ ref: refs/heads/master
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Matt McFarling
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Metric Admin
2
+
3
+ This gem builds and edits metrics.
4
+
5
+ ## Updating
6
+
7
+ Bump version in version.rb
8
+ Commit
9
+ rake build
10
+ rake release
11
+
12
+ ## Installation
13
+
14
+ Clone this repo to your local computer.
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'metric_admin'
19
+
20
+ And then execute:
21
+
22
+ $ bundle install
23
+
24
+ ## Usage
25
+
26
+ In your application.js file add the following snippet:
27
+
28
+ $(function(){
29
+ $('a[rel="popover"]').popover();
30
+ $(".list-group").sortable({
31
+ update: function(event, ui) {
32
+ var data = $(this).sortable('serialize');
33
+ //alert(data);
34
+ $.ajax({
35
+ data: data,
36
+ type: 'POST',
37
+ url: '/metrics/sort'
38
+ });
39
+ }
40
+ });
41
+ // this excludes the div with class header from being sorted.
42
+ $(".list-group").sortable({ cancel: '.header' });
43
+ });
44
+
45
+ Also ensure that you are allowing for the CSRF Meta tags:
46
+
47
+ $(function(){
48
+ $.ajaxSetup({
49
+ beforeSend: function( xhr ) {
50
+ var token = $('meta[name="csrf-token"]').attr('content');
51
+ if (token) xhr.setRequestHeader('X-CSRF-Token', token);
52
+ }
53
+ });
54
+ });
55
+
56
+ In your config/routes.rb add the following:
57
+
58
+ map.connect "/metrics/sort", :controller => "admin/admin", :action => "sort"
59
+
60
+ Make a new css file in public/css for the gem:
61
+
62
+ h2.page-subtitle.pull-left {
63
+ margin-left: 1.1em;
64
+ }
65
+
66
+ .list-group {
67
+ margin-bottom: 15px;
68
+ border: 1px solid #ccc;
69
+ border-radius: 3px;
70
+ }
71
+
72
+ .list-group-item,
73
+ .header {
74
+ background-color: #f4f4f4;
75
+ border-bottom: 1px solid #ccc;
76
+ padding: 8px 15px;
77
+ vertical-align: middle;
78
+ }
79
+
80
+ .list-group-item:last-child {
81
+ border-bottom: none;
82
+ }
83
+
84
+ .list-group-item.odd {
85
+ background-color: #f4f4f4;
86
+ }
87
+ .list-group-item.even {
88
+ background-color: #fff;
89
+ }
90
+
91
+ In the AdminController add the following:
92
+
93
+ def sort
94
+ params[:metric].each_with_index do |metric_id, i|
95
+ metric = Metric.find(metric_id)
96
+ metric.update_attribute(:public_sort, i)
97
+ end
98
+ render :json => "sorted"
99
+ end
100
+
101
+
102
+ ## Contributing
103
+
104
+ 1. Fork it ( https://github.com/analyticsforlawyers/afl_teamwork/fork )
105
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
106
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
107
+ 4. Push to the branch (`git push origin my-new-feature`)
108
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,115 @@
1
+ module MetricAdmin
2
+ class Admin::MetricsController < ApplicationController
3
+
4
+ layout "admin"
5
+
6
+ def index
7
+ @metric_categories = ResourceType.all
8
+ end
9
+
10
+ def show
11
+ @metric = Metric.find(params[:id])
12
+ @metricnote = MetricNote.new
13
+ end
14
+
15
+ def edit
16
+ @metric_categories = ResourceType.all
17
+ @metric = Metric.find(params[:id])
18
+ @resource_type = ResourceType.find_by_id(@metric.resource_type_id)
19
+ end
20
+
21
+ def new
22
+ @metric = Metric.new
23
+ @metric.resource_type_id = params[:resource_type_id]
24
+ @metric.resource_type = params[:resource_type]
25
+ end
26
+
27
+ def destroy
28
+
29
+ if @metric = Metric.find(params[:id])
30
+ @metric.destroy
31
+ flash[:success] = "Metric has been removed."
32
+ redirect_to admin_metrics_url
33
+ else
34
+ flash[:alert] = "Metric has not been removed."
35
+ redirect_to admin_metrics_url
36
+ end
37
+ end
38
+
39
+ def create
40
+ @metric = Metric.new(params[:metric])
41
+ if @metric.save
42
+ flash[:success] = "#{@metric.title} has been created"
43
+ redirect_to admin_metrics_url
44
+ else
45
+ flash[:notice] = "There was an error"
46
+ render :action => :new, :status => :unprocessable_entity
47
+ end
48
+ end
49
+
50
+ def clone
51
+ @metric_to_clone = Metric.find(params[:id])
52
+ @metric = @metric_to_clone.clone
53
+ @metric.title = "Copy of #{@metric.title}"
54
+ @metric.sort = Metric.maximum(:sort, :conditions=>["resource_type_id = ?", @metric_to_clone.resource_type_id ]).to_i + 1
55
+ if @metric.save
56
+ flash[:notice] = "#{@metric.title} has been cloned"
57
+ redirect_to edit_admin_metric_url(@metric)
58
+ else
59
+ flash[:notice] = "There was an error"
60
+ render :action => :new, :status => :unprocessable_entity
61
+ end
62
+ end
63
+
64
+ def calculate
65
+ CalculateMetrics.calculate_metrics_for_id(params[:id])
66
+ flash[:notice] = "Completed calculating"
67
+ redirect_to admin_metrics_url
68
+ end
69
+
70
+ def evaluate
71
+ metric_logic = params["logic"].gsub(":staff", params[:logic_staff])
72
+ error = {}
73
+
74
+ res = Thread.new{
75
+ require 'rubygems'
76
+ require 'active_support'
77
+
78
+ begin
79
+ @has_error = false
80
+ ActiveRecord::Base.establish_connection "needles_#{RAILS_ENV}"
81
+ @result, @results = eval(metric_logic)
82
+ ActiveRecord::Base.verify_active_connections!
83
+ [@result,@results]
84
+ rescue Exception => e
85
+ logger.info "Error Message: #{e.message}"
86
+ @has_error = true
87
+ @errors = [e.message, e.backtrace.join("\r\n")].join("\r\n")
88
+ end
89
+ }
90
+
91
+ @result, @results = res.value
92
+ @results = @results.to_json
93
+
94
+ respond_to do |format|
95
+ format.js
96
+ end
97
+
98
+ end
99
+
100
+ # PUT /admin/metrics/id
101
+ #----------------------------------------------------------------------------
102
+ def update
103
+ @metric = Metric.find_by_id(params[:metric][:id])
104
+
105
+ if @metric.update_attributes(params[:metric])
106
+ flash[:notice] = "#{@metric.title} has been updated"
107
+ # CalculateMetrics.calculate_metrics_for_id(@metric.id)
108
+ redirect_to :action => :edit
109
+ else
110
+ render :action => :index, :status => :unprocessable_entity
111
+ end
112
+ end
113
+
114
+ end
115
+ end
@@ -0,0 +1,155 @@
1
+ .row-fluid
2
+ .span3
3
+ .well.sidebar-nav
4
+ = link_to "<i class='icon-arrow-left'></i> Back to metrics", admin_metrics_url, :class=>"btn"
5
+ %hr
6
+ %p
7
+ %strong Actions:
8
+ %ul
9
+ %li= link_to "Calculate", "/admin/metrics/#{@metric.id}/calculate"
10
+ %li= link_to "Clone", "/admin/metrics/#{@metric.id}/clone"
11
+ %li= link_to "Delete", admin_metric_path(@metric.id), :confirm => "Are you sure?", :method => :delete
12
+ / %p
13
+ / %strong Previous versions:
14
+ / %ul
15
+ / - @metric.versions.each do |version|
16
+ / %li= "#{time_ago_in_words(version.created_at)} ago"
17
+ .span9.well
18
+ .metric-content
19
+ .row-fluid
20
+ .span12
21
+ %h3{:style=>"margin:0;"}= "Editing: #{@metric.title}"
22
+ %hr
23
+ - form_for :metric, @metric, :url => admin_metric_path(@metric.id), :html => { :method => :put } do |f|
24
+ = f.error_messages
25
+ = f.hidden_field :id, :value => @metric.id
26
+ .row-fluid
27
+ .span4
28
+ .control-group
29
+ %label.control-label{:for => "title"} Title
30
+ .controls
31
+ = f.text_field :title, :placeholder => "title", :value => @metric.title
32
+
33
+
34
+ .control-group
35
+ %label.control-label{:for => "title"} Status
36
+ .controls
37
+ = f.select(:status, ['','inactive','active'], :selected=>@metric.status.to_s )
38
+
39
+ .control-group
40
+ %label.control-label{:for => "title"} Sort order
41
+ .controls
42
+ = f.text_field :sort, :value => @metric.sort.nil? ? @metric.resource_type.metrics.count : @metric.sort, :class=>"span3"
43
+
44
+ .span6
45
+ .row
46
+ .control-group
47
+ %label.control-label{:for => "title"} Name
48
+ .controls
49
+ = f.text_field :name, :value => @metric.name, "data-type" => "#{ResourceType.find(@metric.resource_type).code}"
50
+
51
+ .control-group
52
+ %label.control-label{:for => "metric_description"} Description
53
+ .controls
54
+ = f.text_area :description, :class=>"input-block-level", :placeholder => "description", :value => @metric.description, :rows => 2
55
+ .row
56
+ .span6
57
+ .control-group
58
+ %label.control-label{:for => "title"} Show Detail View
59
+ .controls
60
+ = f.check_box :has_detail
61
+
62
+ .span6
63
+ .control-group
64
+ %label.control-label{:for => "title"} Value Type
65
+ .controls
66
+ = f.select(:data_type, ['','integer','average','currency'], :selected=>@metric.status.to_s )
67
+
68
+ .row-fluid
69
+ .span12
70
+
71
+
72
+
73
+ .control-group
74
+ %label.control-label{:for => "description"} Logic:
75
+ .controls
76
+ = f.text_area :logic, :class=>"my-code-area input-block-level", :placeholder => "Technical Explanation", :value => @metric.logic, :rows => 20
77
+ %br
78
+ .error-wrapper
79
+ %label.control-label{:for => "description"} Errors:
80
+ .controls
81
+ = f.text_area :logic_errors, :class=>"input-block-level errors", :placeholder => "Error Container", :value => "", :rows => 20
82
+ %br
83
+ .controls
84
+ %label.control-label{:for => "logic_staff"} Staff: (for purposes of metric evaluation)
85
+ = text_field_tag :logic_staff, @metric.resource_type.resources.last.code
86
+ %br
87
+ %button.btn.run_logic{"aria-hidden" => "true", "data-dismiss" => "modal"}
88
+ Run
89
+ %i.icon-play
90
+ .loaderImage{:style=>"display:none;"}
91
+ Loading...
92
+
93
+
94
+ %br
95
+ %br
96
+ .well{:style=>"position:relative;"}
97
+ %small{:style=>"padding:3px 6px; font-size:10px; background:#dfdfdf; position:absolute; top:0; right:0;"} Logic Output
98
+ .row-fluid
99
+ .span6
100
+ %strong Quantified Result:
101
+ %br
102
+ .quantified_result
103
+ .span6
104
+ %strong Detailed Result
105
+ %br
106
+ .detailed_results
107
+
108
+ %tbody
109
+
110
+
111
+ .control-group
112
+ .controls
113
+ = f.submit "Update Metric", :class => 'btn btn-primary'
114
+
115
+ - content_for :footer do
116
+ :javascript
117
+ $(document).ready(function() {
118
+ $(".error-wrapper").hide();
119
+ $("#metric_title").on("blur", function(){
120
+ $("#metric_name").val( $("#metric_name").data('type') + "_" + this.value.replace(/[^A-Z0-9]/ig, "_").toLowerCase());
121
+ });
122
+
123
+ var editor = ace.edit("metric_logic");
124
+ $('.my-code-area').val(editor.getValue());
125
+ });
126
+ $('#metric_logic').ace({ theme: 'twilight', lang: 'ruby' })
127
+
128
+ $('.run_logic').on('click', function(){
129
+ var editor_contents = $('.my-code-area').val();
130
+ $('.loaderImage').show();
131
+
132
+ $('.quantified_result').html('');
133
+ $('.detailed_results').html('');
134
+ $('.errors').html('');
135
+ $(".error-wrapper").hide()
136
+
137
+ $.ajax(
138
+ {
139
+ type: "POST",
140
+ url: "/admin/metrics/1/evaluate.js",
141
+ beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
142
+ contentType: "application/json; charset=utf-8",
143
+ data: JSON.stringify({logic: editor_contents , logic_staff: $("#logic_staff").val() }),
144
+ success: function(data){
145
+ $('.loaderImage').hide();
146
+ },
147
+ error: function (response) {
148
+ $('.loaderImage').hide();
149
+ $('.errors').html(response.responseText);
150
+ $('.error-wrapper').show();
151
+ }
152
+ }
153
+ );
154
+ return false;
155
+ });
@@ -0,0 +1,8 @@
1
+ <% if @has_error %>
2
+ <%= @result %>
3
+ <% else %>
4
+ $('.quantified_result').html('<%= @result %>');
5
+ $('.detailed_results').html('<%= @results %>');
6
+ <% end %>
7
+
8
+
@@ -0,0 +1,51 @@
1
+ .row-fluid
2
+ .span3
3
+ .well.sidebar-nav
4
+ %h3{:style=>"margin-top:0;"} Metric Types
5
+ .well
6
+ %ul.nav.nav-list
7
+ - @metric_categories.each do |c|
8
+ %li
9
+ %a{:href=>"#tab-#{c.id}", "data-toggle"=>"tab"}
10
+ = c.name
11
+
12
+ .span9
13
+ .well
14
+ .metric-content.tab-content{:style=>"border:0;"}
15
+ - @metric_categories.each_with_index do |c, i|
16
+ .tab-pane{:id=>"tab-#{c.id}", :class=> i == 0 ? "active" : ""}
17
+ %div.row
18
+ %h2.page-subtitle.pull-left= c.name
19
+ = link_to "<i class='icon-plus icon-white'></i> Create a new #{c.name} metric", new_admin_metric_url(:resource_type_id => c), :class=>"btn btn-primary pull-right"
20
+
21
+ - metrics = Metric.all(:conditions=>["resource_type_id=?", c.id], :order => 'category ASC, public_sort ASC')
22
+
23
+ - if metrics
24
+ - metrics.group_by{|x| x.category }.each do |category, _metrics|
25
+ %div#simpleList.list-group
26
+ %div.header{:draggable => false}
27
+ = category.present? ? category : 'No Category'
28
+
29
+ - _metrics.each do |metric|
30
+ %div.item.list-group-item{:class => cycle('odd', 'even'), :id => "metric-#{metric.id}"}
31
+ = link_to metric.title, edit_admin_metric_path(metric.id)
32
+
33
+ - if Result.count(:conditions=>["calculated_at = ? and metric_id = ?", Date.today.to_s, metric.id ]) == 0 && metric.status == 'active'
34
+ %p.label.warning Has not run today.
35
+ - if metric.status != 'active'
36
+ %p.label{:style=>"margin-left:5px;"} Not Active
37
+
38
+ .pull-right
39
+ .btn-group
40
+ %button.btn Action
41
+ %button.btn.dropdown-toggle{"data-toggle" => "dropdown"}
42
+ %span.caret
43
+ %ul.dropdown-menu
44
+ %li
45
+ = link_to "Edit".html_safe, edit_admin_metric_path(metric.id)
46
+ %li
47
+ = link_to "Calculate", "/admin/metrics/#{metric.id}/calculate"
48
+ %li
49
+ = link_to "Clone", "/admin/metrics/#{metric.id}/clone"
50
+ %li
51
+ = link_to "Delete", admin_metric_path(metric.id), :confirm => "Are you sure?", :method => :delete
@@ -0,0 +1,126 @@
1
+ .row-fluid
2
+ .span3
3
+ .well.sidebar-nav
4
+ = link_to "<i class='icon-arrow-left'></i> Back to metrics", admin_metrics_url, :class=>"btn"
5
+ .span9.well
6
+ .metric-content
7
+ %h3{:style=>"margin:0;"}= "New Metric"
8
+ %hr
9
+ - form_for ["admin/metrics", @metric], :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f|
10
+ = f.error_messages
11
+ = f.hidden_field :id, :value => @metric.id
12
+ = f.hidden_field :resource_type_id, :value => params[:resource_type_id]
13
+
14
+ .control-group
15
+ %label.control-label{:for => "title"} Title
16
+ .controls
17
+ = f.text_field :title, :placeholder => "title", :value => @metric.title
18
+
19
+ .control-group
20
+ %label.control-label{:for => "title"} Name
21
+ .controls
22
+ = f.text_field :name, :value => @metric.name, :disabled=>true, "data-type" => "#{ResourceType.find(params[:resource_type_id]).code}"
23
+
24
+ .control-group
25
+ %label.control-label{:for => "title"} Status
26
+ .controls
27
+ = f.select(:status, ['','inactive','active'], :selected=>@metric.status.to_s )
28
+
29
+ .control-group
30
+ %label.control-label{:for => "title"} Sort order (next position)
31
+ .controls
32
+ = f.text_field :sort, :value => Metric.count(:conditions=>["resource_type_id = ?", params[:resource_type_id]])+1
33
+
34
+ .control-group
35
+ %label.control-label{:for => "description"} Logic:
36
+ .controls
37
+ = f.text_area :logic, :class=>"my-code-area input-block-level", :placeholder => "Technical Explanation", :value => @metric.logic, :rows => 20
38
+
39
+ %br
40
+ .controls
41
+ %label.control-label{:for => "logic_staff"} Staff: (for purposes of metric evaluation)
42
+ = text_field_tag :logic_staff, Resource.first(:conditions=>["resource_type_id = ?", params[:resource_type_id]]).code
43
+
44
+ %br
45
+ %button.btn.run_logic{"aria-hidden" => "true", "data-dismiss" => "modal"}
46
+ Run
47
+ %i.icon-play
48
+ .loaderImage{:style=>"display:none;"}
49
+ Loading...
50
+
51
+
52
+ %br
53
+ %br
54
+ .well{:style=>"position:relative;"}
55
+ %small{:style=>"padding:3px 6px; font-size:10px; background:#dfdfdf; position:absolute; top:0; right:0;"} Logic Output
56
+ .row-fluid
57
+ .span6
58
+ %strong Quantified Result:
59
+ %br
60
+ .quantified_result
61
+
62
+ .span6
63
+ %strong Detailed Result
64
+ %br
65
+ .detailed_results
66
+
67
+ %tbody
68
+ - if @metric.sort
69
+ .control-group
70
+ %label.control-label{:for => "title"} Sort Order
71
+ .controls
72
+ = f.text_field :sort, :value => @metric.sort
73
+
74
+
75
+ .control-group
76
+ %label.control-label{:for => "metric_description"} Description
77
+ .controls
78
+ = f.text_area :description, :class=>"input-block-level", :placeholder => "description", :value => @metric.description, :rows => 4
79
+
80
+ .control-group
81
+ %label.control-label{:for => "description"} Technical Explanation
82
+ .controls
83
+ = f.text_area :description, :class=>"input-block-level", :placeholder => "Technical Explanation", :value => @metric.technical_explanation, :rows => 4
84
+
85
+ .control-group
86
+ .controls
87
+ = f.submit "Create Metric", :class => 'btn btn-primary'
88
+
89
+ - content_for :footer do
90
+ :javascript
91
+ $(document).ready(function() {
92
+
93
+ $("#metric_title").on("blur", function(){
94
+ $("#metric_name").val( $("#metric_name").data('type') + "_" + this.value.replace(/[^A-Z0-9]/ig, "_").toLowerCase());
95
+ });
96
+
97
+ var editor = ace.edit("metric_logic");
98
+ $('.my-code-area').val(editor.getValue());
99
+ });
100
+ $('#metric_logic').ace({ theme: 'twilight', lang: 'ruby' })
101
+
102
+ $('.run_logic').on('click', function(){
103
+ var editor_contents = $('.my-code-area').val();
104
+ $('.loaderImage').show();
105
+
106
+ $('.quantified_result').html('');
107
+ $('.detailed_results').html('');
108
+
109
+ $.ajax(
110
+ {
111
+ type: "POST",
112
+ url: "/admin/metrics/1/evaluate.js",
113
+ beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
114
+ contentType: "application/json; charset=utf-8",
115
+ data: JSON.stringify({logic: editor_contents , logic_staff: $("#logic_staff").val() }),
116
+ success: function(data){
117
+ $('.loaderImage').hide();
118
+
119
+ },
120
+ error: function (response) {
121
+ $('.loaderImage').hide();
122
+ }
123
+ }
124
+ );
125
+ return false;
126
+ });
@@ -0,0 +1,74 @@
1
+ <div class="container">
2
+ <h1 class="pagetitle"><%= @metric.title %></h1>
3
+
4
+ <table class="table table-striped table-bordered">
5
+ <tr>
6
+ <td>Description:</td>
7
+ <td><%= @metric.description %></td>
8
+ </tr>
9
+ <tr>
10
+ <td>Status:</td>
11
+ <td><%= @metric.status %></td>
12
+ </tr>
13
+ <tr>
14
+ <td>Explanation:</td>
15
+ <td><%= @metric.explanation %></td>
16
+ </tr>
17
+ <tr>
18
+ <td>Has Detail View:</td>
19
+ <td><%= @metric.has_detail %></td>
20
+ </tr>
21
+ <tr>
22
+ <td valign="top">Explanation:</td>
23
+ <td><%= @metric.explanation %></td>
24
+ </tr>
25
+ <tr>
26
+ <td valign="top">Technical Explanation:</td>
27
+ <td><%= @metric.technical_explanation %></td>
28
+ </tr>
29
+ </table>
30
+
31
+ <div class="metric-notes-container">
32
+ <h2>Notes:</h2>
33
+
34
+ <hr />
35
+ <div class="row">
36
+ <div class="note-entry-form well span4 pull-right" style="float:right;">
37
+ <h3>Create a Note</h3>
38
+ <hr />
39
+ <% form_for ["new_metric_notes", @metricnote], :url => { :controller =>'metric_notes' } do |f| %>
40
+
41
+ <%= f.hidden_field :user_id, :value => current_user.id %>
42
+ <%= f.hidden_field :metric_id, :value => @metric.id %>
43
+
44
+ <p><%= f.label :title %>
45
+ <%= f.text_field :title %></p>
46
+
47
+ <p><%= f.label :content %>
48
+ <%= f.text_field :content %></p>
49
+
50
+
51
+ <p><%= f.submit "Create" %></p>
52
+ <% end %>
53
+
54
+ </div>
55
+
56
+ <div class="metric-notes-list span7" style="float:left;">
57
+ <% if @metric.metric_notes.any? %>
58
+ <% @metric.metric_notes.reverse.each do |note| %>
59
+ <div class="well">
60
+ <span class="pull-right"><%= note.created_at.strftime("%m/%d/%Y at %I:%M%p") %></span>
61
+ <strong><%= note.title %></strong><br />
62
+ <%= note.content %>
63
+ </div>
64
+ <% end %>
65
+ <% else %>
66
+ <h2>No notes for this metric</h2>
67
+ <% end %>
68
+ </div>
69
+ </div>
70
+
71
+ </div>
72
+
73
+
74
+ </div>
data/config ADDED
@@ -0,0 +1,6 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = true
5
+ ignorecase = true
6
+ precomposeunicode = true
data/hooks/ctags ADDED
@@ -0,0 +1,10 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ PATH="/usr/local/bin:$PATH"
6
+ dir="`git rev-parse --git-dir`"
7
+ trap 'rm -f "$dir/$$.tags"' EXIT
8
+ git ls-files | \
9
+ "${CTAGS:-ctags}" --tag-relative -L - -f"$dir/$$.tags" --languages=-javascript,sql
10
+ mv "$dir/$$.tags" "$dir/tags"
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ LOCAL_HOOK=$HOME/.git_template.local/hooks/post-checkout
4
+ [[ -f $LOCAL_HOOK ]] && source $LOCAL_HOOK
5
+
6
+ .git/hooks/ctags >/dev/null 2>&1 &
data/hooks/post-commit ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ LOCAL_HOOK=$HOME/.git_template.local/hooks/post-commit
4
+ [[ -f $LOCAL_HOOK ]] && source $LOCAL_HOOK
5
+
6
+ .git/hooks/ctags >/dev/null 2>&1 &
data/hooks/post-merge ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ LOCAL_HOOK=$HOME/.git_template.local/hooks/post-merge
4
+ [[ -f $LOCAL_HOOK ]] && source $LOCAL_HOOK
5
+
6
+ .git/hooks/ctags >/dev/null 2>&1 &
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ case "$1" in
3
+ rebase) exec .git/hooks/post-merge ;;
4
+ esac
@@ -0,0 +1,3 @@
1
+ module MetricAdmin
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,23 @@
1
+ require "metric_admin/version"
2
+
3
+ module MetricAdmin
4
+ class << self
5
+ attr_accessor :logger
6
+ attr_accessor :configuration
7
+ end
8
+
9
+ def self.configure
10
+ self.configuration ||= Configuration.new
11
+ yield(configuration)
12
+ end
13
+
14
+ def self.logger
15
+ @logger ||= Logger.new($stdout).tap do |log|
16
+ log.progname = self.name
17
+ end
18
+ end
19
+
20
+ class Configuration
21
+
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'metric_admin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "metric_admin"
8
+ spec.version = MetricAdmin::VERSION
9
+ spec.authors = ["Analytics For Lawyers"]
10
+ spec.email = ["matt@analyticsforlawyers.com","brandon@analyticsforlawyers.com"]
11
+ spec.summary = %q{Gem that builds and edits metrics.}
12
+ spec.description = %q{Build and edit metrics.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.4.2"
23
+ end
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'metric_admin'
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metric_admin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Analytics For Lawyers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 10.4.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 10.4.2
41
+ description: Build and edit metrics.
42
+ email:
43
+ - matt@analyticsforlawyers.com
44
+ - brandon@analyticsforlawyers.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - HEAD
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - app/controllers/admin/metrics_controller.rb
56
+ - app/views/admin/metrics/edit.haml
57
+ - app/views/admin/metrics/evaluate.js.erb
58
+ - app/views/admin/metrics/index.haml
59
+ - app/views/admin/metrics/new.html.haml
60
+ - app/views/admin/metrics/show.html.erb
61
+ - config
62
+ - hooks/ctags
63
+ - hooks/post-checkout
64
+ - hooks/post-commit
65
+ - hooks/post-merge
66
+ - hooks/post-rewrite
67
+ - lib/metric_admin.rb
68
+ - lib/metric_admin/version.rb
69
+ - metric_admin.gemspec
70
+ - rails/init.rb
71
+ homepage: ''
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.4.6
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Gem that builds and edits metrics.
95
+ test_files: []