device_tracker 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +4 -0
  5. data/Gemfile +4 -0
  6. data/Rakefile +10 -0
  7. data/Readme.md +32 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/device_tracker.gemspec +63 -0
  11. data/exe/device_tracker +91 -0
  12. data/lib/device_tracker/app.rb +22 -0
  13. data/lib/device_tracker/config-schema.json +111 -0
  14. data/lib/device_tracker/config.ru +9 -0
  15. data/lib/device_tracker/controllers/application_controller.rb +226 -0
  16. data/lib/device_tracker/controllers/devices_controller.rb +315 -0
  17. data/lib/device_tracker/controllers/heartbeat_controller.rb +50 -0
  18. data/lib/device_tracker/controllers/os_controller.rb +38 -0
  19. data/lib/device_tracker/controllers/transactions_controller.rb +18 -0
  20. data/lib/device_tracker/controllers/users_controller.rb +131 -0
  21. data/lib/device_tracker/db/migrate/20150521071815_create_users.rb +14 -0
  22. data/lib/device_tracker/db/migrate/20150521082155_create_devices.rb +19 -0
  23. data/lib/device_tracker/db/migrate/20150521120335_create_operating_systems.rb +9 -0
  24. data/lib/device_tracker/db/migrate/20150527162242_create_transactions.rb +12 -0
  25. data/lib/device_tracker/db/migrate/20151027073050_create_heartbeat.rb +11 -0
  26. data/lib/device_tracker/db/migrate/20151028132946_add_user_verification.rb +8 -0
  27. data/lib/device_tracker/db/migrate/20151028141328_remove_is_active_from_users.rb +6 -0
  28. data/lib/device_tracker/db/migrate/20151029085629_add_password_reset_code_to_users.rb +8 -0
  29. data/lib/device_tracker/db/migrate/20151030130341_add_missing_column_to_devices.rb +8 -0
  30. data/lib/device_tracker/db/migrate/20151102141601_add_serial_number_to_devices.rb +8 -0
  31. data/lib/device_tracker/db/schema.rb +61 -0
  32. data/lib/device_tracker/db/seeds.rb +21 -0
  33. data/lib/device_tracker/dependencies.rb +16 -0
  34. data/lib/device_tracker/device_tracker.rb +18 -0
  35. data/lib/device_tracker/helpers/application_helper.rb +116 -0
  36. data/lib/device_tracker/helpers/user_helper.rb +24 -0
  37. data/lib/device_tracker/models/device.rb +42 -0
  38. data/lib/device_tracker/models/heartbeat.rb +7 -0
  39. data/lib/device_tracker/models/operating_system.rb +7 -0
  40. data/lib/device_tracker/models/transaction.rb +62 -0
  41. data/lib/device_tracker/models/user.rb +28 -0
  42. data/lib/device_tracker/public/css/bootstrap-sortable.css +100 -0
  43. data/lib/device_tracker/public/css/bootstrap.min.css +5 -0
  44. data/lib/device_tracker/public/css/custom.css +88 -0
  45. data/lib/device_tracker/public/favicon/android-chrome-144x144.png +0 -0
  46. data/lib/device_tracker/public/favicon/android-chrome-192x192.png +0 -0
  47. data/lib/device_tracker/public/favicon/android-chrome-36x36.png +0 -0
  48. data/lib/device_tracker/public/favicon/android-chrome-48x48.png +0 -0
  49. data/lib/device_tracker/public/favicon/android-chrome-72x72.png +0 -0
  50. data/lib/device_tracker/public/favicon/android-chrome-96x96.png +0 -0
  51. data/lib/device_tracker/public/favicon/apple-touch-icon-114x114.png +0 -0
  52. data/lib/device_tracker/public/favicon/apple-touch-icon-120x120.png +0 -0
  53. data/lib/device_tracker/public/favicon/apple-touch-icon-144x144.png +0 -0
  54. data/lib/device_tracker/public/favicon/apple-touch-icon-152x152.png +0 -0
  55. data/lib/device_tracker/public/favicon/apple-touch-icon-180x180.png +0 -0
  56. data/lib/device_tracker/public/favicon/apple-touch-icon-57x57.png +0 -0
  57. data/lib/device_tracker/public/favicon/apple-touch-icon-60x60.png +0 -0
  58. data/lib/device_tracker/public/favicon/apple-touch-icon-72x72.png +0 -0
  59. data/lib/device_tracker/public/favicon/apple-touch-icon-76x76.png +0 -0
  60. data/lib/device_tracker/public/favicon/apple-touch-icon-precomposed.png +0 -0
  61. data/lib/device_tracker/public/favicon/apple-touch-icon.png +0 -0
  62. data/lib/device_tracker/public/favicon/browserconfig.xml +12 -0
  63. data/lib/device_tracker/public/favicon/favicon-16x16.png +0 -0
  64. data/lib/device_tracker/public/favicon/favicon-32x32.png +0 -0
  65. data/lib/device_tracker/public/favicon/favicon-96x96.png +0 -0
  66. data/lib/device_tracker/public/favicon/favicon.ico +0 -0
  67. data/lib/device_tracker/public/favicon/manifest.json +41 -0
  68. data/lib/device_tracker/public/favicon/mstile-144x144.png +0 -0
  69. data/lib/device_tracker/public/favicon/mstile-150x150.png +0 -0
  70. data/lib/device_tracker/public/favicon/mstile-310x150.png +0 -0
  71. data/lib/device_tracker/public/favicon/mstile-310x310.png +0 -0
  72. data/lib/device_tracker/public/favicon/mstile-70x70.png +0 -0
  73. data/lib/device_tracker/public/favicon/safari-pinned-tab.svg +21 -0
  74. data/lib/device_tracker/public/favicon.png +0 -0
  75. data/lib/device_tracker/public/fonts/glyphicons-halflings-regular.eot +0 -0
  76. data/lib/device_tracker/public/fonts/glyphicons-halflings-regular.svg +288 -0
  77. data/lib/device_tracker/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  78. data/lib/device_tracker/public/fonts/glyphicons-halflings-regular.woff +0 -0
  79. data/lib/device_tracker/public/fonts/glyphicons-halflings-regular.woff2 +0 -0
  80. data/lib/device_tracker/public/js/bootstrap-sortable.js +211 -0
  81. data/lib/device_tracker/public/js/bootstrap.min.js +7 -0
  82. data/lib/device_tracker/public/js/jquery-2.1.4.min.js +4 -0
  83. data/lib/device_tracker/version.rb +4 -0
  84. data/lib/device_tracker/views/404.erb +25 -0
  85. data/lib/device_tracker/views/_alert.erb +5 -0
  86. data/lib/device_tracker/views/_device_form.erb +52 -0
  87. data/lib/device_tracker/views/_device_list.erb +47 -0
  88. data/lib/device_tracker/views/_footer.erb +3 -0
  89. data/lib/device_tracker/views/_header.erb +97 -0
  90. data/lib/device_tracker/views/_heartbeat_list.erb +25 -0
  91. data/lib/device_tracker/views/_user_form.erb +30 -0
  92. data/lib/device_tracker/views/devices/edit.erb +11 -0
  93. data/lib/device_tracker/views/devices/index.erb +12 -0
  94. data/lib/device_tracker/views/devices/new.erb +10 -0
  95. data/lib/device_tracker/views/devices/show.erb +283 -0
  96. data/lib/device_tracker/views/devices/users.erb +14 -0
  97. data/lib/device_tracker/views/emails/new_password.erb +17 -0
  98. data/lib/device_tracker/views/emails/password_reset.erb +18 -0
  99. data/lib/device_tracker/views/emails/registration.erb +16 -0
  100. data/lib/device_tracker/views/emails/reminder.erb +15 -0
  101. data/lib/device_tracker/views/emails/verification.erb +18 -0
  102. data/lib/device_tracker/views/forgot_password.erb +6 -0
  103. data/lib/device_tracker/views/index.erb +38 -0
  104. data/lib/device_tracker/views/layout.erb +8 -0
  105. data/lib/device_tracker/views/login.erb +14 -0
  106. data/lib/device_tracker/views/operating_system/operating_systems.json.jbuilder +9 -0
  107. data/lib/device_tracker/views/os/manage.erb +38 -0
  108. data/lib/device_tracker/views/transactions/_transactions_list.erb +18 -0
  109. data/lib/device_tracker/views/transactions/index.erb +3 -0
  110. data/lib/device_tracker/views/users/edit.erb +9 -0
  111. data/lib/device_tracker/views/users/manage.erb +31 -0
  112. data/lib/device_tracker/views/users/new.erb +7 -0
  113. metadata +505 -0
@@ -0,0 +1,52 @@
1
+ <div class="form-group">
2
+ <label for="unid">Unique Identification Number</label>
3
+ <input type="text" class="form-control" id="unid" name="device[unid]" placeholder="BBCFM0XXX" value="<%= value_for(:unid, @device) %>">
4
+ </div>
5
+
6
+ <div class="form-group">
7
+ <label for="manufacturer">Manufacturer</label>
8
+ <input type="text" class="form-control" id="manufacturer" name="device[manufacturer]" placeholder="Apple" value="<%= value_for(:manufacturer, @device) %>">
9
+ </div>
10
+
11
+ <div class="form-group">
12
+ <label for="device">Name</label>
13
+ <input type="text" class="form-control" id="device" name="device[device]" placeholder="iPhone 6s" value="<%= value_for(:device, @device) %>">
14
+ </div>
15
+
16
+ <div class="form-group">
17
+ <label for="description">Description</label>
18
+ <textarea class="form-control" name="device[description]" id="description" rows="3" placeholder="The phone is orange and has scratches down the side."><%= value_for(:description, @device) %></textarea>
19
+ </div>
20
+
21
+ <div class="form-group">
22
+ <label for="imei">IMEI</label>
23
+ <input type="text" class="form-control" id="imei" name="device[imei]" placeholder="351XXXXXXXXXXXX" value="<%= value_for(:imei, @device) %>">
24
+ </div>
25
+
26
+ <div class="form-group">
27
+ <label for="serial">Serial Number</label>
28
+ <input type="text" class="form-control" id="serial" name="device[serial_number]" placeholder="F2LLXXXXXXXX" value="<%= value_for(:serial_number, @device) %>">
29
+ </div>
30
+
31
+ <div class="form-group">
32
+ <label for="operating_system">Operating System</label>
33
+ <select class="form-control" name="device[operating_system_id]" class="form-control">
34
+ <option disabled hidden selected>-- Operating System --</option>
35
+ <% @operating_systems.each do |os| %>
36
+ <option value="<%= os.id %>" <%= "selected" if @device.operating_system_id == os.id %>> <%= os.name %> </option>
37
+ <% end %>
38
+ </select>
39
+ </div>
40
+
41
+ <div class="checkbox">
42
+ <label>
43
+ <input type="checkbox" name="device[sim_card]" value="true" <%= @device.sim_card ? "checked" : "" %>>
44
+ Sim card
45
+ </label>
46
+ </div>
47
+ <div class="checkbox">
48
+ <label>
49
+ <input type="checkbox" name="device[debug_device]" value="true" <%= @device.debug_device ? "checked" : "" %>>
50
+ Debug device
51
+ </label>
52
+ </div>
@@ -0,0 +1,47 @@
1
+ <table class="table table-hover sortable">
2
+ <thead>
3
+ <tr>
4
+ <th>Devcie ID</th>
5
+ <th>Name</th>
6
+ <th>Operating System</th>
7
+ <th width="30%">Information</th>
8
+ <th>Transaction Count</th>
9
+ <th width="10%">Action</th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% @devices.each do |device| %>
14
+ <tr class="<%= device.missing ? "danger" : "" %>">
15
+ <td><a href="/devices/<%= device.id %>"><%= device.unid %></a></td>
16
+ <td><%= device.full_name %></td>
17
+ <td>
18
+ <%= device.operating_system.nil? ? "N/A" : device.operating_system.name %>
19
+ </td>
20
+ <td>
21
+ <% if !device.user.nil? %>
22
+ Checked out by <b><a href="mailto:<%= device.user.email %>"><%= device.user.name %></a></b><br>
23
+ on <%= device.checked_out_since_formatted %><br>
24
+ <% else %>
25
+ <% end %>
26
+ </td>
27
+ <td>
28
+ <%= device.transactions.count %>
29
+ </td>
30
+ <td>
31
+ <% if !session[:user].nil? and device.user_id != session[:user][:id] %>
32
+ <form action="<%= "/devices/#{device.unid.downcase}/checkout" %>" method="post">
33
+ <input type="hidden" name="_method" value="put">
34
+ <button class="btn btn-success btn-xs btn-full-width" type="submit">Checkout Device</button>
35
+ </form>
36
+ <% else %>
37
+ <form action="<%= "/devices/#{device.unid.downcase}/return" %>" method="post">
38
+ <input type="hidden" name="_method" value="put">
39
+ <button class="btn btn-danger btn-xs btn-full-width" type="submit">Return Device</button>
40
+ </form>
41
+ <% end %>
42
+ </td>
43
+ </tr>
44
+ <% end %>
45
+ </tbody>
46
+ </table>
47
+ </div>
@@ -0,0 +1,3 @@
1
+ </div> <!-- Container -->
2
+ </body>
3
+ </html>
@@ -0,0 +1,97 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+
8
+ <link rel="apple-touch-icon" sizes="57x57" href="/favicon/apple-touch-icon-57x57.png">
9
+ <link rel="apple-touch-icon" sizes="60x60" href="/favicon/apple-touch-icon-60x60.png">
10
+ <link rel="apple-touch-icon" sizes="72x72" href="/favicon/apple-touch-icon-72x72.png">
11
+ <link rel="apple-touch-icon" sizes="76x76" href="/favicon/apple-touch-icon-76x76.png">
12
+ <link rel="apple-touch-icon" sizes="114x114" href="/favicon/apple-touch-icon-114x114.png">
13
+ <link rel="apple-touch-icon" sizes="120x120" href="/favicon/apple-touch-icon-120x120.png">
14
+ <link rel="apple-touch-icon" sizes="144x144" href="/favicon/apple-touch-icon-144x144.png">
15
+ <link rel="apple-touch-icon" sizes="152x152" href="/favicon/apple-touch-icon-152x152.png">
16
+ <link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon-180x180.png">
17
+ <link rel="icon" type="image/png" href="/favicon/favicon-32x32.png" sizes="32x32">
18
+ <link rel="icon" type="image/png" href="/favicon/android-chrome-192x192.png" sizes="192x192">
19
+ <link rel="icon" type="image/png" href="/favicon/favicon-96x96.png" sizes="96x96">
20
+ <link rel="icon" type="image/png" href="/favicon/favicon-16x16.png" sizes="16x16">
21
+ <link rel="manifest" href="/favicon/manifest.json">
22
+ <link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#5bbad5">
23
+ <link rel="shortcut icon" href="/favicon/favicon.ico" type="image/x-icon">
24
+ <meta name="msapplication-TileColor" content="#da532c">
25
+ <meta name="msapplication-TileImage" content="/favicon/mstile-144x144.png">
26
+ <meta name="msapplication-config" content="/favicon/browserconfig.xml">
27
+ <meta name="theme-color" content="#ffffff">
28
+
29
+ <title><%= @title || "Home" %> | BBC Device Tracker </title>
30
+
31
+ <link rel="stylesheet" href="https://bootswatch.com/flatly/bootstrap.min.css">
32
+ <link rel="stylesheet" href="/css/custom.css">
33
+ <link rel="stylesheet" href="/css/bootstrap-sortable.css">
34
+
35
+ <script src="/js/jquery-2.1.4.min.js"></script>
36
+ <script src="/js/bootstrap.min.js"></script>
37
+ <script src="/js/bootstrap-sortable.js"></script>
38
+ </head>
39
+ <body>
40
+
41
+ <div class="container">
42
+
43
+ <nav class="navbar navbar-default navbar-fixed-top">
44
+ <div class="container">
45
+ <div class="navbar-header">
46
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
47
+ <span class="sr-only">Toggle navigation</span>
48
+ <span class="icon-bar"></span>
49
+ <span class="icon-bar"></span>
50
+ <span class="icon-bar"></span>
51
+ </button>
52
+ <a class="navbar-brand" href="/">
53
+ Device Tracker
54
+ </a>
55
+ </div>
56
+ <div id="navbar" class="collapse navbar-collapse">
57
+ <ul class="nav navbar-nav navbar-right">
58
+ <li><a href="/">Home</a></li>
59
+ <% unless session[:user].nil? %>
60
+ <li class="dropdown">
61
+ <a href="#" class="dropdown-toggle"
62
+ data-toggle="dropdown" role="button"
63
+ aria-haspopup="true" aria-expanded="false">Devices <span class="caret"></span></a>
64
+ <ul class="dropdown-menu">
65
+ <% if admin? %>
66
+ <li><a href="/devices/new">Create device</a></li>
67
+ <% end %>
68
+ <li><a href="/devices">All devices</a></li>
69
+ <li><a href="/devices/checked-out">Checked out devices</a></li>
70
+ <li><a href="/devices/users/<%= session[:user][:id] %>">My devices</a></li>
71
+ </ul>
72
+ </li>
73
+ <% end %>
74
+ <% if session[:user].nil? %>
75
+ <li><a href="/login">Login</a></li>
76
+ <li><a href="/users/new">Register</a></li>
77
+ <% else %>
78
+ <li><a href="/transactions">Transactions</a></li>
79
+ <li class="dropdown">
80
+ <a href="#" class="dropdown-toggle"
81
+ data-toggle="dropdown" role="button"
82
+ aria-haspopup="true" aria-expanded="false"><%= session[:user][:name] %> <span class="caret"></span></a>
83
+ <ul class="dropdown-menu">
84
+ <% if admin? %>
85
+ <li><a href="/users/manage">Manage users</a></li>
86
+ <li><a href="/os/manage">Manage OS</a></li>
87
+ <li><a href="/users/new">Create account</a></li>
88
+ <% end %>
89
+ <li><a href="/users/<%= session[:user][:id] %>/edit">Edit account</a></li>
90
+ <li><a href="/logout">Logout</a></li>
91
+ </ul>
92
+ </li>
93
+ <% end %>
94
+ </ul>
95
+ </div><!--/.nav-collapse -->
96
+ </div>
97
+ </nav>
@@ -0,0 +1,25 @@
1
+ <table class="table table-bordered table-hover table-condensed">
2
+ <thead>
3
+ <tr>
4
+ <th>Devcie ID</th>
5
+ <th>Latitude</th>
6
+ <th>Longitude</th>
7
+ <th>Received</th>
8
+ <th>Action</th>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% @heartbeats.each do |heartbeat| %>
13
+ <tr>
14
+ <td> <a href="/heartbeats/<%= heartbeat.device.unid %>"><%= heartbeat.device.unid %></a> </td>
15
+ <td> <%= heartbeat.latitude %> </td>
16
+ <td> <%= heartbeat.longitude %> </td>
17
+ <td> <%= heartbeat.created_at.strftime("%A, %d %B %Y at %I:%M%p") %> </td>
18
+ <td width="10%">
19
+ <a class="btn btn-info btn-xs"
20
+ href="https://www.google.com/maps/preview/@<%= heartbeat.latitude %>,<%= heartbeat.longitude %>,16z" role="button">Google Maps</a>
21
+ </td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
@@ -0,0 +1,30 @@
1
+ <div class="form-group">
2
+ <label for="name">Name</label>
3
+ <input type="text" class="form-control" id="name" name="user[name]" placeholder="John Doe" value="<%= value_for(:name, @user) %>">
4
+ </div>
5
+ <div class="form-group">
6
+ <label for="username">Username</label>
7
+ <input type="text" class="form-control" id="username" name="user[username]" placeholder="john.doe" value="<%= value_for(:username, @user) %>">
8
+ </div>
9
+ <div class="form-group">
10
+ <label for="email">Email address</label>
11
+ <input type="email" class="form-control" id="email" name="user[email]" placeholder="john.doe@example.com" value="<%= value_for(:email, @user) %>">
12
+ </div>
13
+ <div class="form-group">
14
+ <label for="password">Password</label>
15
+ <input type="password" class="form-control" id="password" name="user[password]" placeholder="Password">
16
+ </div>
17
+ <div class="form-group">
18
+ <label for="password_confirmation">Password confirmation</label>
19
+ <input type="password" class="form-control" id="password_confirmation" name="user[password_confirmation]" placeholder="Password confirmation">
20
+ </div>
21
+ <% if @is_admin %>
22
+ <div class="form-group">
23
+ <input type="checkbox" id="is_admin" name="user[is_admin]" <%= @user.is_admin == true ? "checked='checked'" : "" %>>
24
+ <label for="is_admin">Administrator</label>
25
+ </div>
26
+ <div class="form-group">
27
+ <input type="checkbox" id="is_verified" name="user[is_verified]" <%= @user.is_verified == true ? "checked='checked'" : "" %>>
28
+ <label for="is_verified">Verified</label>
29
+ </div>
30
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <h2>Editing: <%= @device.full_name %></h2>
2
+ <hr>
3
+
4
+ <form action="/devices/<%= @device.id %>" method="post">
5
+ <input type="hidden" name="_method" value="put">
6
+
7
+ <%= partial :device_form %>
8
+
9
+ <button type="submit" class="btn btn-success pull-right">Update Device</button>
10
+
11
+ </form>
@@ -0,0 +1,12 @@
1
+ <h2><%= @title %></h2>
2
+
3
+ <% if @show_search %>
4
+ <form class="form-inline pull-right search" action="<%= "/devices" %>" method="get">
5
+ <div class="form-group">
6
+ <input type="text" class="form-control" id="device_name" name="device_name" placeholder="Samsung Galaxy S6">
7
+ </div>
8
+ <button type="submit" class="btn btn-info btn-sm">Search</button>
9
+ </form>
10
+ <% end %>
11
+
12
+ <%= partial :device_list %>
@@ -0,0 +1,10 @@
1
+ <h2>Create new Device</h2>
2
+ <hr>
3
+
4
+ <form action="/devices/create" method="post">
5
+
6
+ <%= partial :device_form %>
7
+
8
+ <button type="submit" class="btn btn-success pull-right">Add Device</button>
9
+
10
+ </form>
@@ -0,0 +1,283 @@
1
+ <% if @device.passed_use_by_date? %>
2
+ <div class="alert alert-warning alert" role="alert">
3
+ This device has been checked out since <%= @device.checked_out_since_formatted %> (<%= @device.days_checked_out %> days). If you need it, please contact <a class="alert-link" href="mailto:<%=@device.user.email%>"><%= @device.user.name %>.</a>
4
+ </div>
5
+ <% end %>
6
+
7
+ <h2><%= @device.full_name %></h2>
8
+ <span class="label label-<%= @device.available ? "success" : "warning" %>">
9
+ <%= @device.available? ? "Available" : "Unavailable" %></span>
10
+
11
+ <hr>
12
+ <div class="row">
13
+ <div class="col-md-7">
14
+
15
+ <div class="panel panel-default">
16
+ <!-- Default panel contents -->
17
+ <div class="panel-heading">
18
+ Basic Information
19
+ <% if admin? %>
20
+ <a class="pull-right" href="/devices/<%= @device.id %>/edit">Edit</a>
21
+ <% end %>
22
+ </div>
23
+ <div class="panel-body">
24
+ <p><%= @device.description %></p>
25
+ </div>
26
+
27
+ <!-- List group -->
28
+ <ul class="list-group">
29
+ <li class="list-group-item">
30
+ <b>Name:
31
+ </b>
32
+ <%= @device.device %>
33
+ </li>
34
+ <li class="list-group-item">
35
+ <b>Manufacturer:
36
+ </b>
37
+ <%= @device.manufacturer %>
38
+ </li>
39
+ <% unless @device.imei.nil? %>
40
+ <li class="list-group-item">
41
+ <b>IMEI: </b> <%= @device.imei %>
42
+ </li>
43
+ <% end %>
44
+ <% unless @device.serial_number.nil? %>
45
+ <li class="list-group-item">
46
+ <b>Serial Number: </b><%= @device.serial_number %>
47
+ </li>
48
+ <% end %>
49
+ <li class="list-group-item">
50
+ <b>Sim card:
51
+ </b>
52
+ <%= @device.sim_card? ? "Yes" : "No" %>
53
+ </li>
54
+ <li class="list-group-item">
55
+ <b>Debug device:
56
+ </b>
57
+ <%= @device.debug_device? ? "Yes" : "No" %>
58
+ </li>
59
+ <% if admin? %>
60
+ <li class="list-group-item">
61
+ <% if @device.missing? %>
62
+ <form method="post" action="/devices/<%= @device.id %>/found" class="right-margin" style="display: inline-block;">
63
+ <input type="hidden" value="put" name="_method">
64
+ <button type="submit" class="btn btn-success btn-xs">Device Found</a>
65
+ </form>
66
+ <% else %>
67
+ <form method="post" action="/devices/<%= @device.id %>/missing" class="right-margin" style="display: inline-block;">
68
+ <input type="hidden" value="put" name="_method">
69
+ <button type="submit" class="btn btn-warning btn-xs">Report Missing</a>
70
+ </form>
71
+ <% end %>
72
+ <form method="post" action="/devices/<%= @device.id %>" style="display: inline-block;">
73
+ <input type="hidden" value="delete" name="_method">
74
+ <button type="submit" class="btn btn-danger button-destructive btn-xs">Delete Device</button>
75
+ </form>
76
+
77
+ <% if @device.passed_use_by_date? %>
78
+ <a href="#" class="btn btn-xs btn-info pull-right" data-toggle="modal" data-target="#sendReminder">Send Reminder</a>
79
+ <% end %>
80
+ </li>
81
+ <% end %>
82
+ </ul>
83
+ </div>
84
+
85
+ <div class="panel panel-default">
86
+ <!-- Default panel contents -->
87
+ <div class="panel-heading">Operating System</div>
88
+ <!-- List group -->
89
+ <ul class="list-group">
90
+ <li class="list-group-item">
91
+ <% if @device.operating_system.nil? %>
92
+ No operating system has been added, please <a href="/devices/<%= @device.id%>/edit">add one</a>.
93
+ <% else %>
94
+ <b>OS:</b> <%= @device.operating_system.name %>
95
+ <% end %>
96
+ </li>
97
+ <% if !@device.operating_system.nil? and !@device.operating_system.api_level.nil? %>
98
+ <li class="list-group-item">
99
+ <b>API Level:
100
+ </b>
101
+ <%= @device.operating_system.api_level %>
102
+ </li>
103
+ <% end %>
104
+ </ul>
105
+ </div>
106
+
107
+ <% unless @device.available %>
108
+ <div class="panel panel-default">
109
+ <!-- Default panel contents -->
110
+ <div class="panel-heading">Current User</div>
111
+ <!-- List group -->
112
+ <ul class="list-group">
113
+ <li class="list-group-item">
114
+ <b>Name:
115
+ </b>
116
+ <%= @device.user.name %>
117
+ </li>
118
+ <li class="list-group-item">
119
+ <b>Email:
120
+ </b>
121
+ <a href="mailto:<%= @device.user.email %>"><%= @device.user.email %></a>
122
+ </li>
123
+ </ul>
124
+ </div>
125
+ <% end %>
126
+
127
+ <% if admin? %>
128
+ <div class="panel panel-default">
129
+ <!-- Default panel contents -->
130
+ <div class="panel-heading">Assign Device</div>
131
+ <!-- List group -->
132
+ <ul class="list-group">
133
+ <li class="list-group-item">
134
+ <form action="/devices/<%= @device.id %>/assign" id="assign-form" method="post">
135
+ <input name="_method" type="hidden" value="put">
136
+ <select class="form-control" name="user_id">
137
+ <option disabled hidden selected>-- Assign --</option>
138
+ <% @users.each do |user| %>
139
+ <% next if user == @device.user %>
140
+ <option value="<%= user.id %>"><%= user.email %></option>
141
+ <% end %>
142
+ </select>
143
+
144
+ </form>
145
+ <form action="/devices/<%= @device.unid %>/return" id="return-form" method="post">
146
+ <input name="_method" type="hidden" value="put">
147
+ </form>
148
+ <div class="top-margin">
149
+ <button class="btn btn-info btn-xs" form="assign-form" type="submit">Assign</button>
150
+ <% unless @device.available %>
151
+ <button class="btn btn-warning btn-xs" form="return-form" type="submit">Return</button>
152
+ <% end %>
153
+ </div>
154
+ </li>
155
+ </ul>
156
+ </div>
157
+ <% end %>
158
+
159
+ </div>
160
+ <div class="col-md-5">
161
+
162
+ <% if @device.missing? %>
163
+ <div class="panel panel-danger">
164
+ <div class="panel-heading">
165
+ <h3 class="panel-title">Device Missing Alert</h3>
166
+ </div>
167
+ <div class="panel-body">
168
+ <p>This device has been reported missing and must be found.
169
+ See details below for last known transaction information.</p>
170
+ </div>
171
+ <ul class="list-group">
172
+ <li class="list-group-item">
173
+ <% if @last_checkout_transaction.nil? %>
174
+ This device has never been checked out
175
+ <% else %>
176
+ <b>Description: </b> <%= @last_checkout_transaction.description %>
177
+ <% end %>
178
+ </li>
179
+ </ul>
180
+ </div>
181
+ <% end %>
182
+
183
+ <% if @device.heartbeats.last %>
184
+ <div id="map"></div>
185
+ <div class="top-margin">
186
+ <small>
187
+ <b>Last heartbeat: </b>
188
+ <%= @device.heartbeats.first.created_at.strftime("%A, %d %B %Y at %I:%M%p")%>
189
+ </small>
190
+ </div>
191
+
192
+ <hr>
193
+
194
+ <% end %>
195
+
196
+ <h4>Transactions</h4>
197
+
198
+ <% if @transactions.empty? %>
199
+ <p>No transactions have yet been made</p>
200
+ <% else %>
201
+ <h5 class="pull-right"><strong>Count: </strong><span class="label label-info"><%= @transactions.count %></span></h5>
202
+ <table class="table table-condensed table-hover">
203
+ <thead>
204
+ <tr>
205
+ <th>Description</th>
206
+ <th>Time</th>
207
+ </tr>
208
+ </thead>
209
+ <tbody>
210
+ <% @transactions.each do |transaction| %>
211
+ <tr>
212
+ <td><small><%= transaction.description %></small></td>
213
+ <td><small><%= transaction.created_at %></small></td>
214
+ </tr>
215
+ <% end %>
216
+ </tbody>
217
+ </table>
218
+ <% end %>
219
+
220
+
221
+ </div>
222
+ </div>
223
+
224
+ <% if @device.heartbeats.last %>
225
+
226
+ <script type="text/javascript">
227
+ var myLatLng = {lat: <%= @device.heartbeats.last.latitude %>, lng: <%= @device.heartbeats.last.longitude %> };
228
+
229
+ var map;
230
+ function initMap() {
231
+ map = new google.maps.Map(document.getElementById('map'), {
232
+ center: myLatLng,
233
+ scrollwheel: false,
234
+ zoom: 16
235
+ });
236
+
237
+ // Create a marker and set its position.
238
+ var marker = new google.maps.Marker({
239
+ map: map,
240
+ position: myLatLng,
241
+ title: 'Device Location'
242
+ });
243
+ }
244
+ </script>
245
+
246
+ <script async defer
247
+ src="https://maps.googleapis.com/maps/api/js?key=<%= settings.google_maps_api_key %>&amp;callback=initMap">
248
+ </script>
249
+
250
+ <% end %>
251
+
252
+ <% if @device.passed_use_by_date? %>
253
+ <div class="modal fade" id="sendReminder" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
254
+ <div class="modal-dialog" role="document">
255
+ <div class="modal-content">
256
+ <div class="modal-header">
257
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
258
+ <h4 class="modal-title" id="myModalLabel">Send Reminder to <%= @device.user.name %>?</h4>
259
+ </div>
260
+ <div class="modal-body">
261
+ <p>
262
+ Would you like to send a reminder to <b><%= @device.user.name %></b> to return this device?
263
+ This person has had this device checked out since <b><%= @device.checked_out_since_formatted %></b>.
264
+ </p>
265
+ </div>
266
+ <div class="modal-footer">
267
+ <button type="button" class="btn btn-default btn-xs" data-dismiss="modal">Close</button>
268
+ <form action="/devices/<%= @device.id %>/send_reminder" method="post" style="display: inline-block;">
269
+ <button type="submit" class="btn btn-primary btn-xs">Send Reminder</button>
270
+ </form>
271
+ </div>
272
+ </div>
273
+ </div>
274
+ </div>
275
+ <% end %>
276
+
277
+ <script type="text/javascript">
278
+ $(document).ready(function() {
279
+ $('.button-destructive').on('click', function() {
280
+ return confirm('Are you sure you want to carry out this action?');
281
+ });
282
+ });
283
+ </script>
@@ -0,0 +1,14 @@
1
+ <h2>My Devices</h2>
2
+ <p>
3
+ Here is a list of devices you currently have checked out. Please ensure you keep this lis <b>up-to-date</b> by
4
+ returning devices that you have finished with. Also, remember to
5
+ <b class="text-danger">turn off the devices after you've finished with them.</b>
6
+ </p>
7
+
8
+ <% if @devices.size < 1 %>
9
+ <p>
10
+ You don't yet have any devices checked out. Head <a href="/devices">over to here</a> to get started.
11
+ </p>
12
+ <% else %>
13
+ <%= partial :device_list %>
14
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <h1>Device Tracker - New Password</h1>
2
+
3
+ <p>
4
+ Hello, <%= @user.name %><br><br>
5
+ Just a quick FYI on your new password...
6
+
7
+ <br>
8
+ <br>
9
+ <p><b>Password: </b><%= @new_password %></p>
10
+
11
+ <p>Please change your password a.s.a.p!</p>
12
+
13
+ <br>
14
+ <br>
15
+ Thanks,<br>
16
+ Device Tracker Team
17
+ </p>
@@ -0,0 +1,18 @@
1
+ <h1>Device Tracker - Password Reset</h1>
2
+
3
+ <p>
4
+ Hello, <%= @user.name %><br><br>
5
+ You have requested to reset your password? If you have just click on the link below
6
+ and you will have a new password sent to your email address.
7
+
8
+ <br>
9
+ <br>
10
+ <a href="<%= @reset_url %>">
11
+ Reset Password
12
+ </a>
13
+
14
+ <br>
15
+ <br>
16
+ Thanks,<br>
17
+ Device Tracker Team
18
+ </p>
@@ -0,0 +1,16 @@
1
+ <h1>Device Tracker - Account Verification</h1>
2
+
3
+ <p>
4
+ <%= @user.name %> has created an account that is pending verification.
5
+
6
+ <br>
7
+ <br>
8
+ <a href="<%= @verification_link %>">
9
+ Click here to verify the account
10
+ </a>
11
+
12
+ <br>
13
+ <br>
14
+ Thanks,<br>
15
+ Device Tracker Team
16
+ </p>