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,15 @@
1
+ <h1>Device Tracker - Reminder</h1>
2
+
3
+ <p>
4
+ Hello, <%= @device.user.name %><br><br>
5
+ It seems that you checked out the <a href="<%= @device_url %>"><%= @device.full_name %></a> on the <b><%= @device.checked_out_since_formatted %></b>.
6
+ Just to let you know that people will start to wonder where this device has gone!
7
+ <br>
8
+ <br>
9
+ So let someone know that you intend on keeping the device, or return it please.
10
+
11
+ <br>
12
+ <br>
13
+ Thanks,<br>
14
+ Device Tracker Team
15
+ </p>
@@ -0,0 +1,18 @@
1
+ <h1>Device Tracker - New Account</h1>
2
+
3
+ <p>
4
+ Hello, <%= @user.name %><br><br>
5
+
6
+ Your account has now been verified.
7
+
8
+ <br>
9
+ <br>
10
+ <a href="<%= @get_started_link %>">
11
+ Click here to get started
12
+ </a>
13
+
14
+ <br>
15
+ <br>
16
+ Thanks,<br>
17
+ Device Tracker Team
18
+ </p>
@@ -0,0 +1,6 @@
1
+ <form class="form-signin" method="post" action="/forgot-password">
2
+ <h2 class="form-signin-heading">What's your email?</h2>
3
+ <label for="email" class="sr-only">Email address</label>
4
+ <input type="email" class="form-control" id="email" name="email" placeholder="Email" autofocus="" required="">
5
+ <button class="btn btn-lg btn-primary btn-sm pull-right" type="submit">Request Password</button>
6
+ </form>
@@ -0,0 +1,38 @@
1
+ <div class="jumbotron">
2
+ <div class="container">
3
+ <h1>Device Tracker</h1>
4
+ <p>Welcome to the BBC Sport device <b>Device Tracker</b>. The aim of this application is to monitor
5
+ the use of devices across BBC Sport and stop them going walkies!</p>
6
+ <p><a class="btn btn-primary btn-lg" href="/devices" role="button">Checkout a Device</a></p>
7
+ </div>
8
+ </div>
9
+
10
+ <table class="table table-hover">
11
+ <thead>
12
+ <tr>
13
+ <th>Device</th>
14
+ <th>Withdrawn by</th>
15
+ <th>Since</th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ <% @devices.each do |device| %>
20
+ <tr class="clickable-row <%= device.passed_use_by_date? ? "danger" : "" %>" data-url="/devices/<%= device.id %>">
21
+ <td><%= device.full_name %></td>
22
+ <td><%= device.user.name %></td>
23
+ <td><%= device.checked_out_since_formatted %></td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+
29
+ <script type="text/javascript">
30
+ $(document).ready(function() {
31
+ $('.clickable-row').on('click', function() {
32
+ var $this = $(this),
33
+ url = $this.data('url');
34
+
35
+ window.location.href = url;
36
+ });
37
+ });
38
+ </script>
@@ -0,0 +1,8 @@
1
+ <%= partial :header %>
2
+
3
+ <div class="main">
4
+ <%= partial :alert %>
5
+ <%= yield %>
6
+ </div>
7
+
8
+ <%= partial :footer %>
@@ -0,0 +1,14 @@
1
+ <form class="form-signin" method="post" action="/login">
2
+ <h2 class="form-signin-heading">Please sign in</h2>
3
+ <label for="email" class="sr-only">Email address</label>
4
+ <input type="email" class="form-control" id="email" name="user[email]" value="<%= flash[:email] %>" placeholder="Email" autofocus="" required="">
5
+ <label for="password" class="sr-only">Password</label>
6
+ <input type="password" class="form-control" id="password" name="user[password]" placeholder="Password" required="">
7
+
8
+ <div class="form-group">
9
+ <a href="/forgot-password">Forgot password?</a> |
10
+ <a href="/users/new">Register an account</a>
11
+ </div>
12
+
13
+ <button class="btn btn-lg btn-primary btn-sm pull-right" type="submit">Sign in</button>
14
+ </form>
@@ -0,0 +1,9 @@
1
+ json.set! :operatingSystems do
2
+ json.array! operating_systems do |os|
3
+ json.operatingSystem do
4
+ json.id os.id
5
+ json.name os.name
6
+ json.apiLevel os.api_level if os.api_level
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ <h1>Operating Systems</h1>
2
+ <div>
3
+ <div>
4
+ <form action="/os/create" method="post">
5
+ <div class="form-group">
6
+ <label for="name">Name</label>
7
+ <input type="text" name="os[name]" id="name" class="form-control" placeholder="iOS 9.1">
8
+ </div>
9
+ <div class="form-group">
10
+ <label for="api-level">API Level</label>
11
+ <input type="text" name="os[api_level]" id="api-level" class="form-control" placeholder="22">
12
+ </div>
13
+
14
+ <button type="submit" class="btn btn-success">Add</button>
15
+ </form>
16
+ </div>
17
+ <table class="table table-hover table-condensed top-margin-large">
18
+ <thead>
19
+ <tr>
20
+ <th>Name</th>
21
+ <th></th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <% @os.each do |os| %>
26
+ <tr>
27
+ <td><%= os.name %></td>
28
+ <td width="10%">
29
+ <form method="post" action="/os/<%= os.id %>/delete">
30
+ <input type="hidden" name="_method" value="delete">
31
+ <button class="btn btn-danger btn-xs btn-full-width" type="submit">Delete</button>
32
+ </form>
33
+ </td>
34
+ </tr>
35
+ <% end %>
36
+ </tbody>
37
+ </table>
38
+ </div>
@@ -0,0 +1,18 @@
1
+ <table class="table table-hover">
2
+ <thead>
3
+ <tr>
4
+ <th>Type</th>
5
+ <th>Description</th>
6
+ <th>Time of Transaction</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ <% @transactions.each do |transaction| %>
11
+ <tr>
12
+ <td> <%= transaction.transaction_type %> </td>
13
+ <td> <%= transaction.description %> </td>
14
+ <td> <%= transaction.created_at %> </td>
15
+ </tr>
16
+ <% end %>
17
+ </tbody>
18
+ </table>
@@ -0,0 +1,3 @@
1
+ <h3>Showing 100 of the Latest Transactions</h3><br>
2
+
3
+ <%= partial :"transactions/transactions_list" %>
@@ -0,0 +1,9 @@
1
+ <h2>Editing: <%= @user.name %></h2>
2
+ <p>Once you have finished editing your account, just hit save and your profile will be updated immediately.</p>
3
+ <br>
4
+
5
+ <form method="post" action="/users/<%= @user.id %>" class="form-horizontal">
6
+ <input type="hidden" name="_method" value="put" />
7
+ <%= partial :user_form %>
8
+ <button type="submit" class="btn btn-success pull-right">Save</button>
9
+ </form>
@@ -0,0 +1,31 @@
1
+ <table class="table table-hover sortable">
2
+ <thead>
3
+ <tr>
4
+ <th>Username</th>
5
+ <th>Name</th>
6
+ <th>Information</th>
7
+ <th></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% @users.each do |user| %>
12
+ <tr class="<%= user.is_verified? ? "" : "active" %>">
13
+ <td width="20%"><%= user.username %></td>
14
+ <td width="20%"><%= user.name %></td>
15
+ <td width="50%">
16
+ <b>Email: </b><a href="mailto:<%= user.email %>"><%= user.email %></a><br>
17
+ <b>Administrator: </b><%= user.is_admin? == true ? "Yes" : "No"%><br>
18
+ <b>Device count: </b><%= user.devices.size %><br>
19
+ <b>Account Verified: </b><%= user.is_verified? == true ? "Yes" : "No" %><br>
20
+ </td>
21
+ <td width="10%">
22
+ <a href="/users/<%= user.id %>/edit" class="btn btn-warning btn-full-width btn-xs padding-bottom">Edit</a>
23
+ <form method="post" action="/users/<%= user.id %>/delete">
24
+ <input type="hidden" name="_method" value="delete">
25
+ <button class="btn btn-danger btn-xs btn-full-width" type="submit">Delete</button>
26
+ </form>
27
+ </td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
@@ -0,0 +1,7 @@
1
+ <h2>Register an Account</h2>
2
+ <br>
3
+
4
+ <form method="post" action="/users/create">
5
+ <%= partial :user_form %>
6
+ <button type="submit" class="btn btn-primary pull-right">Register</button>
7
+ </form>