mno-enterprise-api 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -0
  3. data/Rakefile +12 -0
  4. data/app/assets/javascripts/mno_enterprise/angular/loading-page.app.js.coffee +156 -0
  5. data/app/assets/javascripts/mno_enterprise/application.js +13 -0
  6. data/app/controllers/devise/password_expired_controller.rb +55 -0
  7. data/app/controllers/mno_enterprise/auth/confirmations_controller.rb +5 -0
  8. data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +30 -0
  9. data/app/controllers/mno_enterprise/auth/passwords_controller.rb +5 -0
  10. data/app/controllers/mno_enterprise/auth/registrations_controller.rb +5 -0
  11. data/app/controllers/mno_enterprise/auth/sessions_controller.rb +7 -0
  12. data/app/controllers/mno_enterprise/auth/unlocks_controller.rb +5 -0
  13. data/app/controllers/mno_enterprise/deletion_requests_controller.rb +5 -0
  14. data/app/controllers/mno_enterprise/impersonate_controller.rb +48 -0
  15. data/app/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller.rb +16 -0
  16. data/app/controllers/mno_enterprise/jpi/v1/admin/base_resource_controller.rb +5 -0
  17. data/app/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller.rb +46 -0
  18. data/app/controllers/mno_enterprise/jpi/v1/admin/invoices_controller.rb +47 -0
  19. data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +27 -0
  20. data/app/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller.rb +14 -0
  21. data/app/controllers/mno_enterprise/jpi/v1/admin/users_controller.rb +63 -0
  22. data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +24 -0
  23. data/app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb +36 -0
  24. data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +32 -0
  25. data/app/controllers/mno_enterprise/jpi/v1/current_users_controller.rb +5 -0
  26. data/app/controllers/mno_enterprise/jpi/v1/deletion_requests_controller.rb +5 -0
  27. data/app/controllers/mno_enterprise/jpi/v1/impac/dashboards_controller.rb +5 -0
  28. data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +80 -0
  29. data/app/controllers/mno_enterprise/jpi/v1/impac/widgets_controller.rb +63 -0
  30. data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +25 -0
  31. data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +22 -0
  32. data/app/controllers/mno_enterprise/jpi/v1/organizations_controller.rb +5 -0
  33. data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +93 -0
  34. data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +88 -0
  35. data/app/controllers/mno_enterprise/org_invites_controller.rb +5 -0
  36. data/app/controllers/mno_enterprise/pages_controller.rb +5 -0
  37. data/app/controllers/mno_enterprise/provision_controller.rb +5 -0
  38. data/app/controllers/mno_enterprise/status_controller.rb +27 -0
  39. data/app/controllers/mno_enterprise/webhook/o_auth_controller.rb +5 -0
  40. data/app/mailers/mno_enterprise/system_notification_mailer.rb +5 -0
  41. data/app/models/mno_enterprise/health_check.rb +16 -0
  42. data/app/views/devise/password_expired/show.html.haml +32 -0
  43. data/app/views/mno_enterprise/auth/confirmations/default/_form.html.haml +49 -0
  44. data/app/views/mno_enterprise/auth/confirmations/default/_lounge.html.haml +34 -0
  45. data/app/views/mno_enterprise/auth/confirmations/default/_show.html.haml +10 -0
  46. data/app/views/mno_enterprise/auth/confirmations/lounge.html.haml +4 -0
  47. data/app/views/mno_enterprise/auth/confirmations/material/_form.html.haml +44 -0
  48. data/app/views/mno_enterprise/auth/confirmations/material/_lounge.html.haml +18 -0
  49. data/app/views/mno_enterprise/auth/confirmations/material/_show.html.haml +21 -0
  50. data/app/views/mno_enterprise/auth/confirmations/new.html.haml +31 -0
  51. data/app/views/mno_enterprise/auth/confirmations/show.html.haml +4 -0
  52. data/app/views/mno_enterprise/auth/mailer/confirmation_instructions.html.haml +4 -0
  53. data/app/views/mno_enterprise/auth/mailer/reset_password_instructions.html.haml +6 -0
  54. data/app/views/mno_enterprise/auth/mailer/unlock_instructions.html.haml +5 -0
  55. data/app/views/mno_enterprise/auth/passwords/edit.html.haml +53 -0
  56. data/app/views/mno_enterprise/auth/passwords/new.html.haml +34 -0
  57. data/app/views/mno_enterprise/auth/registrations/default/_form.html.haml +35 -0
  58. data/app/views/mno_enterprise/auth/registrations/default/_new.html.haml +11 -0
  59. data/app/views/mno_enterprise/auth/registrations/material/_form.html.haml +30 -0
  60. data/app/views/mno_enterprise/auth/registrations/material/_new.html.haml +10 -0
  61. data/app/views/mno_enterprise/auth/registrations/new.html.haml +4 -0
  62. data/app/views/mno_enterprise/auth/sessions/default/_form.html.haml +17 -0
  63. data/app/views/mno_enterprise/auth/sessions/default/_new.html.haml +11 -0
  64. data/app/views/mno_enterprise/auth/sessions/material/_form.html.haml +26 -0
  65. data/app/views/mno_enterprise/auth/sessions/material/_new.html.haml +11 -0
  66. data/app/views/mno_enterprise/auth/sessions/new.html.haml +4 -0
  67. data/app/views/mno_enterprise/auth/shared/_links.html.haml +24 -0
  68. data/app/views/mno_enterprise/auth/unlocks/new.html.haml +10 -0
  69. data/app/views/mno_enterprise/deletion_requests/show.html.haml +131 -0
  70. data/app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder +5 -0
  71. data/app/views/mno_enterprise/jpi/v1/admin/audit_events/index.json.jbuilder +4 -0
  72. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/_cloud_app.json.jbuilder +1 -0
  73. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/index.json.jbuilder +1 -0
  74. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/show.json.jbuilder +1 -0
  75. data/app/views/mno_enterprise/jpi/v1/admin/invoices/_invoice.json.jbuilder +2 -0
  76. data/app/views/mno_enterprise/jpi/v1/admin/invoices/index.json.jbuilder +1 -0
  77. data/app/views/mno_enterprise/jpi/v1/admin/invoices/show.json.jbuilder +2 -0
  78. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_credit_card.json.jbuilder +7 -0
  79. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_invoices.json.jbuilder +8 -0
  80. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_member.json.jbuilder +14 -0
  81. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_organization.json.jbuilder +1 -0
  82. data/app/views/mno_enterprise/jpi/v1/admin/organizations/in_arrears.json.jbuilder +8 -0
  83. data/app/views/mno_enterprise/jpi/v1/admin/organizations/index.json.jbuilder +7 -0
  84. data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +11 -0
  85. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/_tenant_invoice.json.jbuilder +5 -0
  86. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/index.json.jbuilder +1 -0
  87. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/show.json.jbuilder +1 -0
  88. data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -0
  89. data/app/views/mno_enterprise/jpi/v1/admin/users/index.json.jbuilder +2 -0
  90. data/app/views/mno_enterprise/jpi/v1/admin/users/show.json.jbuilder +9 -0
  91. data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +23 -0
  92. data/app/views/mno_enterprise/jpi/v1/app_instances/index.json.jbuilder +9 -0
  93. data/app/views/mno_enterprise/jpi/v1/app_instances/show.json.jbuilder +3 -0
  94. data/app/views/mno_enterprise/jpi/v1/billing/index.json.jbuilder +0 -0
  95. data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +37 -0
  96. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +9 -0
  97. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/index.json.jbuilder +1 -0
  98. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/show.json.jbuilder +1 -0
  99. data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -0
  100. data/app/views/mno_enterprise/jpi/v1/impac/kpis/show.json.jbuilder +1 -0
  101. data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +6 -0
  102. data/app/views/mno_enterprise/jpi/v1/impac/widgets/show.json.jbuilder +1 -0
  103. data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +14 -0
  104. data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +3 -0
  105. data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +3 -0
  106. data/app/views/mno_enterprise/jpi/v1/organizations/_arrears.json.jbuilder +11 -0
  107. data/app/views/mno_enterprise/jpi/v1/organizations/_billing.json.jbuilder +4 -0
  108. data/app/views/mno_enterprise/jpi/v1/organizations/_credit_card.json.jbuilder +7 -0
  109. data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +5 -0
  110. data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +8 -0
  111. data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +13 -0
  112. data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +13 -0
  113. data/app/views/mno_enterprise/jpi/v1/organizations/credit_card.json.jbuilder +1 -0
  114. data/app/views/mno_enterprise/jpi/v1/organizations/index.json.jbuilder +1 -0
  115. data/app/views/mno_enterprise/jpi/v1/organizations/members.json.jbuilder +3 -0
  116. data/app/views/mno_enterprise/jpi/v1/organizations/show.json.jbuilder +15 -0
  117. data/app/views/mno_enterprise/jpi/v1/organizations/show_reduced.json.jbuilder +3 -0
  118. data/app/views/mno_enterprise/jpi/v1/shopping_cart/organizations.json.jbuilder +5 -0
  119. data/app/views/mno_enterprise/jpi/v1/shopping_cart/show.json.jbuilder +59 -0
  120. data/app/views/mno_enterprise/jpi/v1/shopping_cart/show_item.json.jbuilder +34 -0
  121. data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +20 -0
  122. data/app/views/mno_enterprise/jpi/v1/teams/index.json.jbuilder +1 -0
  123. data/app/views/mno_enterprise/jpi/v1/teams/show.json.jbuilder +3 -0
  124. data/app/views/mno_enterprise/pages/app_access_unauthorized.html.haml +19 -0
  125. data/app/views/mno_enterprise/pages/app_logout.html.haml +18 -0
  126. data/app/views/mno_enterprise/pages/billing_details_required.html.haml +19 -0
  127. data/app/views/mno_enterprise/pages/loading.html.erb +69 -0
  128. data/app/views/mno_enterprise/provision/_provision_apps.html.haml +42 -0
  129. data/app/views/mno_enterprise/provision/_select_organization.html.haml +17 -0
  130. data/app/views/mno_enterprise/provision/new.html.haml +4 -0
  131. data/app/views/mno_enterprise/webhook/o_auth/authorize.html.haml +26 -0
  132. data/app/views/mno_enterprise/webhook/o_auth/providers/myob.html.haml +29 -0
  133. data/app/views/mno_enterprise/webhook/o_auth/providers/xero.html.haml +34 -0
  134. data/config/initializers/devise.rb +273 -0
  135. data/config/initializers/devise_extension.rb +9 -0
  136. data/config/initializers/devise_log.rb +12 -0
  137. data/config/initializers/health_check.rb +35 -0
  138. data/config/initializers/main_app_version.rb +6 -0
  139. data/config/routes.rb +152 -0
  140. data/lib/mno-enterprise-api.rb +1 -0
  141. data/lib/mno_enterprise/api.rb +14 -0
  142. data/lib/mno_enterprise/api/engine.rb +9 -0
  143. data/lib/mno_enterprise/concerns/controllers/deletion_requests_controller.rb +108 -0
  144. data/lib/mno_enterprise/concerns/controllers/jpi/v1/admin/base_resource_controller.rb +34 -0
  145. data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +58 -0
  146. data/lib/mno_enterprise/concerns/controllers/jpi/v1/deletion_requests_controller.rb +69 -0
  147. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +76 -0
  148. data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +180 -0
  149. data/lib/mno_enterprise/concerns/controllers/org_invites_controller.rb +44 -0
  150. data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +78 -0
  151. data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +71 -0
  152. data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +107 -0
  153. data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +158 -0
  154. data/lib/mno_enterprise/event_logger.rb +32 -0
  155. data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +68 -0
  156. data/spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb +141 -0
  157. data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +48 -0
  158. data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +51 -0
  159. data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +92 -0
  160. data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +159 -0
  161. data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +116 -0
  162. data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +92 -0
  163. data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +136 -0
  164. data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +76 -0
  165. data/spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb +94 -0
  166. data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +128 -0
  167. data/spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb +72 -0
  168. data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +80 -0
  169. data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +115 -0
  170. data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +516 -0
  171. data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +86 -0
  172. data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +29 -0
  173. data/spec/controllers/mno_enterprise/pages_controller_spec.rb +49 -0
  174. data/spec/controllers/mno_enterprise/provision_controller_spec.rb +94 -0
  175. data/spec/controllers/mno_enterprise/status_controller_spec.rb +34 -0
  176. data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +104 -0
  177. data/spec/lib/mno_enterprise/event_logger_spec.rb +28 -0
  178. data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +132 -0
  179. data/spec/rails_helper.rb +94 -0
  180. data/spec/requests/devise/authentication_spec.rb +43 -0
  181. data/spec/requests/devise/registration_spec.rb +64 -0
  182. data/spec/routing/devise/confirmation_routing_spec.rb +20 -0
  183. data/spec/routing/devise/passwords_routing_spec.rb +24 -0
  184. data/spec/routing/devise/registrations_routing_spec.rb +16 -0
  185. data/spec/routing/devise/sessions_routing_spec.rb +20 -0
  186. data/spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb +20 -0
  187. data/spec/routing/mno_enterprise/impersonate_controller_routing.spec.rb +15 -0
  188. data/spec/routing/mno_enterprise/jpi/v1/admin/audit_events_controller_routing_spec.rb +11 -0
  189. data/spec/routing/mno_enterprise/jpi/v1/admin/cloud_apps_controller_routing_spec.rb +24 -0
  190. data/spec/routing/mno_enterprise/jpi/v1/admin/invoices_controller_routing_spec.rb +37 -0
  191. data/spec/routing/mno_enterprise/jpi/v1/admin/organizations_controller_routing_spec.rb +20 -0
  192. data/spec/routing/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_routing_spec.rb +16 -0
  193. data/spec/routing/mno_enterprise/jpi/v1/admin/users_controller_routing_spec.rb +24 -0
  194. data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +12 -0
  195. data/spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb +15 -0
  196. data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +28 -0
  197. data/spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb +24 -0
  198. data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +22 -0
  199. data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +16 -0
  200. data/spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb +44 -0
  201. data/spec/routing/mno_enterprise/jpi/v1/teams_controller_routing_spec.rb +36 -0
  202. data/spec/routing/mno_enterprise/org_invites_controller_routing_spec.rb +12 -0
  203. data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +29 -0
  204. data/spec/routing/mno_enterprise/provision_controller_routing_spec.rb +15 -0
  205. data/spec/routing/mno_enterprise/status_controller_routing_spec.rb +19 -0
  206. data/spec/routing/mno_enterprise/webhook/o_auth_controller_routing_spec.rb +27 -0
  207. data/spec/spec_helper.rb +88 -0
  208. metadata +402 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ac990cf031d2475114a17d24207548face30f24c
4
+ data.tar.gz: 99bc5e5acf3750aa28958a042859a055dc0f39cc
5
+ SHA512:
6
+ metadata.gz: a7540b2223e5a2f959f0b8470d98fb06deb5ce0e4e7e88480e87df45bb8785bd697afaef5dccb046b2125806bf251c71aa3386625ef0adaae41e982db2950e75
7
+ data.tar.gz: fa8668ea286b9761edac0fb6934dbd1ee8fbd440df0e4e50a72b40a60bce5191d356c9e2bc7c787f70e76289671e903e6ecd5b5d396c44c6d124522daef01bc6
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Copyright 2015 Maestrano Pty Ltd
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'mno_enterprise/testing_support/common_rake'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task default: :spec
7
+
8
+ desc "Generates a dummy app for testing"
9
+ task :test_app do
10
+ ENV['LIB_NAME'] = 'mno_enterprise/api'
11
+ Rake::Task['mno_enterprise:testing:create_dummy_app'].invoke
12
+ end
@@ -0,0 +1,156 @@
1
+ angular.module('loadingPageApp', []).controller('loadingController', [
2
+ '$scope', '$http', '$window', '$timeout'
3
+ ($scope, $http, $window, $timeout) ->
4
+
5
+ $scope.redirectionCounter = 5 #seconds
6
+ $scope.scheduler = null
7
+ $scope.redirectScheduler = null
8
+
9
+ #==========================
10
+ # Helpers
11
+ #==========================
12
+ $scope.currentStatus = () ->
13
+ if $scope.appInstance? && $scope.appInstance.id
14
+ if $scope.appInstance.errors && $scope.appInstance.errors.length > 0
15
+ 'errors'
16
+ else if $scope.appInstance.status in ['terminating', 'terminated']
17
+ 'terminated'
18
+ else if $scope.appInstance.status == 'running' && $scope.appInstance.is_online
19
+ 'online'
20
+ else if $scope.appInstance.status in ['provisioning', 'staged']
21
+ 'creating'
22
+ else if $scope.appInstance.status == 'updating' || ($scope.appInstance.status == 'running' && !$scope.appInstance.is_online)
23
+ 'updating'
24
+ else
25
+ # starting/stopping
26
+ # Note: If 'stopping' and no errors it means that a start has been
27
+ # successfully requested
28
+ 'loading'
29
+ else
30
+ 'not_found'
31
+
32
+ $scope.isProgressBarShown = () ->
33
+ $scope.currentStatus() == 'creating' || $scope.currentStatus() == 'loading'
34
+
35
+ $scope.redirectUrl = () ->
36
+ return '/mnoe/launch/#{appInstance.uid}'
37
+
38
+ # Return the action progression in percent unit
39
+ # Eg. $scope.progressBarPercent() -> 95%
40
+ $scope.progressBarPercent = () ->
41
+ # Get out of there if the bar is not shown
42
+ if !$scope.isProgressBarShown()
43
+ return 0
44
+
45
+ # Get the relevant status from an actionProgress
46
+ # point of view
47
+ realStatus = $scope.appInstance.status
48
+ realStatus = 'provisioning' if realStatus == 'staged'
49
+ realStatus = 'starting' if realStatus == 'restarting'
50
+
51
+ # Get the maxDuration (seconds) for the current action
52
+ # In case the app is stopping we consider that a start
53
+ # has been requested. Therefore we add the starting
54
+ # time on top of it
55
+ maxDuration = $scope.appInstance.durations[realStatus]
56
+ maxDuration += $scope.appInstance.durations['starting'] if realStatus == 'stopping'
57
+
58
+ # Get the referenceField based on
59
+ # the action being performed
60
+ referenceField = {
61
+ 'provisioning': 'created_at',
62
+ 'starting': 'started_at',
63
+ 'stopping': 'stopped_at',
64
+ }[realStatus]
65
+
66
+ # Get the action elapsed time in seconds
67
+ startTime = new Date($scope.appInstance[referenceField])
68
+ endTime = new Date($scope.appInstance.server_time)
69
+ elapsedTime = (endTime.getTime() - startTime.getTime()) / 1000
70
+
71
+ # Calculate the percentage
72
+ # Max value is 95% / Min value is 5%
73
+ # Cesar: test should prevent division by 0 and display of "Nan%"
74
+ if (maxDuration > 0)
75
+ percent = Math.round((elapsedTime / maxDuration)*100)
76
+ percent = Math.min(percent, 95)
77
+ percent = Math.max(percent, 5)
78
+ else
79
+ percent = 95
80
+
81
+ percent = "#{percent}%"
82
+ return percent
83
+
84
+ reloadAppInstance = (_appInstance)->
85
+ q = $http.get($window.location.pathname)
86
+ q.then(
87
+ (success) ->
88
+ angular.copy(success.data, _appInstance)
89
+ )
90
+ return q
91
+
92
+ $scope.startAutoRefresh = () ->
93
+ intervalMilliSec = 5 * 1000 # 15s
94
+ # Make sure we cancel any previous
95
+ # scheduler first
96
+ if $scope.scheduler?
97
+ $timeout.cancel($scope.scheduler)
98
+
99
+ # Configure the scheduler
100
+ $scope.scheduler = $timeout(->
101
+ reloadAppInstance($scope.appInstance)
102
+ $scope.startAutoRefresh()
103
+ ,intervalMilliSec)
104
+
105
+ $scope.stopAutoRefresh = () ->
106
+ if $scope.scheduler?
107
+ $timeout.cancel($scope.scheduler)
108
+
109
+ $scope.performRedirection = () ->
110
+ # Then reload the page
111
+ window.location = $scope.redirectUrl()
112
+
113
+ $scope.startRedirectCountdown = () ->
114
+ intervalMilliSec = 1 * 1000
115
+ # Make sure we cancel any previous
116
+ # scheduler first
117
+ if $scope.redirectScheduler?
118
+ $timeout.cancel($scope.redirectScheduler)
119
+
120
+ # Configure the scheduler
121
+ $scope.redirectScheduler = $timeout(->
122
+ $scope.redirectionCounter -= 1
123
+ $scope.startRedirectCountdown() if $scope.redirectionCounter > 0
124
+ $scope.performRedirection() if $scope.redirectionCounter == 0
125
+ ,intervalMilliSec)
126
+
127
+
128
+ $scope.stopRedirectCountdown = () ->
129
+ if $scope.redirectScheduler?
130
+ $timeout.cancel($scope.redirectScheduler)
131
+ $scope.redirectionCounter = 5
132
+
133
+ #==========================
134
+ # Init
135
+ #==========================
136
+ $scope.init = (data) ->
137
+ console.log(data)
138
+ $scope.appInstance = data
139
+
140
+ # Watch status
141
+ $scope.$watch(
142
+ (-> $scope.currentStatus())
143
+ ,(status)->
144
+ # Enable appInstance refresh?
145
+ if status == 'loading' || status == 'creating' || status == 'updating'
146
+ $scope.startAutoRefresh() unless $scope.scheduler
147
+ else
148
+ $scope.stopAutoRefresh() if $scope.scheduler
149
+
150
+ # Enable redirection counter?
151
+ if status == 'online'
152
+ $scope.startRedirectCountdown() unless $scope.redirectScheduler
153
+ else
154
+ $scope.stopRedirectCountdown() if $scope.redirectScheduler
155
+ )
156
+ ])
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree ./angular
@@ -0,0 +1,55 @@
1
+ class Devise::PasswordExpiredController < DeviseController
2
+ skip_before_filter :handle_password_change
3
+ before_filter :skip_password_change, only: [:show, :update]
4
+ prepend_before_filter :authenticate_scope!, :only => [:show, :update]
5
+
6
+ def show
7
+ if defined?(MnoEnterprise::Frontend)
8
+ respond_with(resource)
9
+ else
10
+ respond_with resource do |format|
11
+ format.html
12
+ format.json {render json: {error: 'Your password is expired. Please renew your password.'}, status: :forbidden}
13
+ end
14
+ end
15
+ end
16
+
17
+ def update
18
+ # resource.extend(Devise::Models::DatabaseAuthenticatablePatch)
19
+ if resource.update(resource_params.merge(current_password_required: true))
20
+ warden.session(scope)['password_expired'] = false
21
+ set_flash_message :notice, :updated
22
+ sign_in scope, resource, :bypass => true
23
+ redirect_to mnoe_home_path
24
+ else
25
+ clean_up_passwords(resource)
26
+ respond_with(resource, action: :show)
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def skip_password_change
33
+ return if !resource.nil? && resource.need_change_password?
34
+ redirect_to :root
35
+ end
36
+
37
+ def resource_params
38
+ permitted_params = [:current_password, :password, :password_confirmation]
39
+
40
+ if params.respond_to?(:permit)
41
+ params.require(resource_name).permit(*permitted_params)
42
+ else
43
+ params[scope].slice(*permitted_params)
44
+ end
45
+ end
46
+
47
+ def scope
48
+ resource_name.to_sym
49
+ end
50
+
51
+ def authenticate_scope!
52
+ send(:"authenticate_#{resource_name}!")
53
+ self.resource = send("current_#{resource_name}")
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class Auth::ConfirmationsController < Devise::ConfirmationsController
3
+ include MnoEnterprise::Concerns::Controllers::Auth::ConfirmationsController
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ module MnoEnterprise
2
+ class Auth::OmniauthCallbacksController < Devise::OmniauthCallbacksController
3
+ # You should configure your model like this:
4
+ # devise :omniauthable, omniauth_providers: [:twitter]
5
+
6
+ # You should also create an action method in this controller like this:
7
+ # def twitter
8
+ # end
9
+
10
+ # More info at:
11
+ # https://github.com/plataformatec/devise#omniauth
12
+
13
+ # GET|POST /resource/auth/twitter
14
+ # def passthru
15
+ # super
16
+ # end
17
+
18
+ # GET|POST /users/auth/twitter/callback
19
+ # def failure
20
+ # super
21
+ # end
22
+
23
+ # protected
24
+
25
+ # The path used when omniauth fails
26
+ # def after_omniauth_failure_path_for(scope)
27
+ # super(scope)
28
+ # end
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class Auth::PasswordsController < Devise::PasswordsController
3
+ include MnoEnterprise::Concerns::Controllers::Auth::PasswordsController
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class Auth::RegistrationsController < Devise::RegistrationsController
3
+ include MnoEnterprise::Concerns::Controllers::Auth::RegistrationsController
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module MnoEnterprise
2
+ class Auth::SessionsController < Devise::SessionsController
3
+ include MnoEnterprise::Concerns::Controllers::Auth::SessionsController
4
+
5
+
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class Auth::UnlocksController < Devise::UnlocksController
3
+ include MnoEnterprise::Concerns::Controllers::Auth::UnlocksController
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class DeletionRequestsController < ApplicationController
3
+ include MnoEnterprise::Concerns::Controllers::DeletionRequestsController
4
+ end
5
+ end
@@ -0,0 +1,48 @@
1
+ module MnoEnterprise
2
+ class ImpersonateController < ApplicationController
3
+ include MnoEnterprise::ImpersonateHelper
4
+
5
+ before_filter :authenticate_user!, except: ["destroy"]
6
+ before_filter :current_user_must_be_admin!, except: ["destroy"]
7
+
8
+ # Perform the user impersonate action
9
+ # GET /impersonate/user/123
10
+ def create
11
+ @user = MnoEnterprise::User.find(params[:user_id])
12
+ if @user.present?
13
+ impersonate(@user)
14
+ else
15
+ flash[:notice] = "User doesn't exist"
16
+ end
17
+ redirect_to mnoe_home_path
18
+ end
19
+
20
+ # Revert the user impersonation
21
+ # DELETE /impersonation/revert
22
+ def destroy
23
+ if current_impersonator
24
+ user = current_user
25
+ revert_impersonate
26
+ if user
27
+ flash[:notice] = "No longer impersonating #{user}"
28
+ else
29
+ flash[:notice] = "No longer impersonating a user"
30
+ end
31
+ else
32
+ flash[:notice] = "You weren't impersonating anyone"
33
+ end
34
+ redirect_to '/admin/'
35
+ end
36
+
37
+ private
38
+
39
+ def current_user_must_be_admin!
40
+ unless current_user.admin_role.present?
41
+ flash[:error] = "You don't have access to this section."
42
+ redirect_to :back
43
+ end
44
+ rescue ActionController::RedirectBackError
45
+ redirect_to '/'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,16 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::Admin::AuditEventsController < Jpi::V1::Admin::BaseResourceController
3
+
4
+ # GET /mnoe/jpi/v1/admin/audit_events
5
+ def index
6
+ @audit_events = MnoEnterprise::AuditEvent
7
+ @audit_events = @audit_events.limit(params[:limit]) if params[:limit]
8
+ @audit_events = @audit_events.skip(params[:offset]) if params[:offset]
9
+ @audit_events = @audit_events.order_by(params[:order_by]) if params[:order_by]
10
+ @audit_events = @audit_events.where(params[:where]) if params[:where]
11
+ @audit_events = @audit_events.all
12
+
13
+ response.headers['X-Total-Count'] = @audit_events.metadata[:pagination][:count]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::Admin::BaseResourceController < ApplicationController
3
+ include MnoEnterprise::Concerns::Controllers::Jpi::V1::Admin::BaseResourceController
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::Admin::CloudAppsController < Jpi::V1::Admin::BaseResourceController
3
+
4
+ # GET /mnoe/jpi/v1/admin/cloud_apps
5
+ def index
6
+ @cloud_apps = MnoEnterprise::App.cloud.all
7
+ end
8
+
9
+ # PUT /mnoe/jpi/v1/admin/cloud_apps/:id
10
+ def update
11
+ @cloud_app = MnoEnterprise::App.find params[:id]
12
+
13
+ if @cloud_app.update(cloud_app_params)
14
+ render :show, status: :ok
15
+ else
16
+ render json: @cloud_app.errors, status: :unprocessable_entity
17
+ end
18
+ end
19
+
20
+ # PUT /mnoe/jpi/v1/admin/cloud_apps/:id/regenerate_api_key
21
+ def regenerate_api_key
22
+ @cloud_app = MnoEnterprise::App.find params[:id]
23
+ @cloud_app.regenerate_api_key!
24
+ render :show
25
+ end
26
+
27
+ # PUT /mnoe/jpi/v1/admin/cloud_apps/:id/refresh_metadata
28
+ # params:
29
+ # - metadata_url: the metadata URL
30
+ def refresh_metadata
31
+ @cloud_app = MnoEnterprise::App.find params[:id]
32
+ result = @cloud_app.refresh_metadata! params[:metadata_url]
33
+ if result && result[:errors].blank?
34
+ render :show
35
+ else
36
+ render json: result, status: 400
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def cloud_app_params
43
+ params.require(:cloud_app).permit(:terms_url, :description, :tiny_description)
44
+ end
45
+ end
46
+ end