-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.rb
More file actions
72 lines (67 loc) · 1.67 KB
/
admin.rb
File metadata and controls
72 lines (67 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'json'
get '/admin' do
incidents = get_all_feedback
puts "incidents: #{incidents.count}"
erb :"admin/index", :layout => :admin_layout, :locals => { :incidents => incidents }
end
get '/admin/location/:location' do
erb :"admin/location", :layout => :admin_layout
end
get '/admin/incident/:incident' do
incidents = get_all_feedback
incidents.each do |o|
if o[:id].to_s == params[:incident].to_s
params[:incidentReported] = o
end
end
erb :"admin/incident", :layout => :admin_layout
end
get '/admin/api/incidents_by_location' do
{
:name => 'Total incidents by location',
:value => 58,
:children => [
{
:name => 'Ward 10',
:value => 13,
:url => '/admin/location/ward_10'
},
{
:name => 'Reception',
:value => 23,
:url => '/admin/location/reception'
},
{
:name => 'Ward 6S',
:value => 18,
:url => '/admin/location/ward_6s'
},
{
:name => 'Ward 21',
:value => 4,
:url => '/admin/location/ward_21'
},
]
}.to_json
end
get '/admin/api/incidents_by_location/:location' do
{
:name => 'Ward 21',
:value => 23,
:children => [
{ :name => 'Facilities', :value => 9 },
{ :name => 'Miscommunication', :value => 6 },
{ :name => 'Drug Error', :value => 3 }
]
}.to_json
end
get '/admin/api/incidents_over_time' do
[
{ :date => '01-01-2013', :value => 10 },
{ :date => '01-02-2013', :value => 11 },
{ :date => '01-03-2013', :value => 14 },
{ :date => '01-04-2013', :value => 8 },
{ :date => '01-05-2013', :value => 23 },
{ :date => '01-06-2013', :value => 5 }
].to_json
end