mno-enterprise-api 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -0
- data/Rakefile +12 -0
- data/app/assets/javascripts/mno_enterprise/angular/loading-page.app.js.coffee +156 -0
- data/app/assets/javascripts/mno_enterprise/application.js +13 -0
- data/app/controllers/devise/password_expired_controller.rb +55 -0
- data/app/controllers/mno_enterprise/auth/confirmations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +30 -0
- data/app/controllers/mno_enterprise/auth/passwords_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/registrations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/sessions_controller.rb +7 -0
- data/app/controllers/mno_enterprise/auth/unlocks_controller.rb +5 -0
- data/app/controllers/mno_enterprise/deletion_requests_controller.rb +5 -0
- data/app/controllers/mno_enterprise/impersonate_controller.rb +48 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller.rb +16 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/base_resource_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller.rb +46 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/invoices_controller.rb +47 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +27 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller.rb +14 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/users_controller.rb +63 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +24 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb +36 -0
- data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +32 -0
- data/app/controllers/mno_enterprise/jpi/v1/current_users_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/deletion_requests_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/dashboards_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +80 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/widgets_controller.rb +63 -0
- data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +25 -0
- data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +22 -0
- data/app/controllers/mno_enterprise/jpi/v1/organizations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +93 -0
- data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +88 -0
- data/app/controllers/mno_enterprise/org_invites_controller.rb +5 -0
- data/app/controllers/mno_enterprise/pages_controller.rb +5 -0
- data/app/controllers/mno_enterprise/provision_controller.rb +5 -0
- data/app/controllers/mno_enterprise/status_controller.rb +27 -0
- data/app/controllers/mno_enterprise/webhook/o_auth_controller.rb +5 -0
- data/app/mailers/mno_enterprise/system_notification_mailer.rb +5 -0
- data/app/models/mno_enterprise/health_check.rb +16 -0
- data/app/views/devise/password_expired/show.html.haml +32 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_form.html.haml +49 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_lounge.html.haml +34 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_show.html.haml +10 -0
- data/app/views/mno_enterprise/auth/confirmations/lounge.html.haml +4 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_form.html.haml +44 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_lounge.html.haml +18 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_show.html.haml +21 -0
- data/app/views/mno_enterprise/auth/confirmations/new.html.haml +31 -0
- data/app/views/mno_enterprise/auth/confirmations/show.html.haml +4 -0
- data/app/views/mno_enterprise/auth/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/mno_enterprise/auth/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/mno_enterprise/auth/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/mno_enterprise/auth/passwords/edit.html.haml +53 -0
- data/app/views/mno_enterprise/auth/passwords/new.html.haml +34 -0
- data/app/views/mno_enterprise/auth/registrations/default/_form.html.haml +35 -0
- data/app/views/mno_enterprise/auth/registrations/default/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/registrations/material/_form.html.haml +30 -0
- data/app/views/mno_enterprise/auth/registrations/material/_new.html.haml +10 -0
- data/app/views/mno_enterprise/auth/registrations/new.html.haml +4 -0
- data/app/views/mno_enterprise/auth/sessions/default/_form.html.haml +17 -0
- data/app/views/mno_enterprise/auth/sessions/default/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/sessions/material/_form.html.haml +26 -0
- data/app/views/mno_enterprise/auth/sessions/material/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/sessions/new.html.haml +4 -0
- data/app/views/mno_enterprise/auth/shared/_links.html.haml +24 -0
- data/app/views/mno_enterprise/auth/unlocks/new.html.haml +10 -0
- data/app/views/mno_enterprise/deletion_requests/show.html.haml +131 -0
- data/app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/admin/audit_events/index.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/_cloud_app.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/_invoice.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/show.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_credit_card.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_invoices.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_member.json.jbuilder +14 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_organization.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/in_arrears.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/index.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +11 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/_tenant_invoice.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/index.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/show.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +23 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/index.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/billing/index.json.jbuilder +0 -0
- data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +37 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +6 -0
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +14 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_arrears.json.jbuilder +11 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_billing.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_credit_card.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/credit_card.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/members.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/show.json.jbuilder +15 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/show_reduced.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/organizations.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/show.json.jbuilder +59 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/show_item.json.jbuilder +34 -0
- data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +20 -0
- data/app/views/mno_enterprise/jpi/v1/teams/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/teams/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/pages/app_access_unauthorized.html.haml +19 -0
- data/app/views/mno_enterprise/pages/app_logout.html.haml +18 -0
- data/app/views/mno_enterprise/pages/billing_details_required.html.haml +19 -0
- data/app/views/mno_enterprise/pages/loading.html.erb +69 -0
- data/app/views/mno_enterprise/provision/_provision_apps.html.haml +42 -0
- data/app/views/mno_enterprise/provision/_select_organization.html.haml +17 -0
- data/app/views/mno_enterprise/provision/new.html.haml +4 -0
- data/app/views/mno_enterprise/webhook/o_auth/authorize.html.haml +26 -0
- data/app/views/mno_enterprise/webhook/o_auth/providers/myob.html.haml +29 -0
- data/app/views/mno_enterprise/webhook/o_auth/providers/xero.html.haml +34 -0
- data/config/initializers/devise.rb +273 -0
- data/config/initializers/devise_extension.rb +9 -0
- data/config/initializers/devise_log.rb +12 -0
- data/config/initializers/health_check.rb +35 -0
- data/config/initializers/main_app_version.rb +6 -0
- data/config/routes.rb +152 -0
- data/lib/mno-enterprise-api.rb +1 -0
- data/lib/mno_enterprise/api.rb +14 -0
- data/lib/mno_enterprise/api/engine.rb +9 -0
- data/lib/mno_enterprise/concerns/controllers/deletion_requests_controller.rb +108 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/admin/base_resource_controller.rb +34 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +58 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/deletion_requests_controller.rb +69 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +76 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +180 -0
- data/lib/mno_enterprise/concerns/controllers/org_invites_controller.rb +44 -0
- data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +78 -0
- data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +71 -0
- data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +107 -0
- data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +158 -0
- data/lib/mno_enterprise/event_logger.rb +32 -0
- data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +68 -0
- data/spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb +141 -0
- data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +48 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +51 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +92 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +159 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +116 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +92 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +136 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +76 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb +94 -0
- data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +128 -0
- data/spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb +72 -0
- data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +80 -0
- data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +115 -0
- data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +516 -0
- data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +86 -0
- data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +29 -0
- data/spec/controllers/mno_enterprise/pages_controller_spec.rb +49 -0
- data/spec/controllers/mno_enterprise/provision_controller_spec.rb +94 -0
- data/spec/controllers/mno_enterprise/status_controller_spec.rb +34 -0
- data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +104 -0
- data/spec/lib/mno_enterprise/event_logger_spec.rb +28 -0
- data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +132 -0
- data/spec/rails_helper.rb +94 -0
- data/spec/requests/devise/authentication_spec.rb +43 -0
- data/spec/requests/devise/registration_spec.rb +64 -0
- data/spec/routing/devise/confirmation_routing_spec.rb +20 -0
- data/spec/routing/devise/passwords_routing_spec.rb +24 -0
- data/spec/routing/devise/registrations_routing_spec.rb +16 -0
- data/spec/routing/devise/sessions_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/impersonate_controller_routing.spec.rb +15 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/audit_events_controller_routing_spec.rb +11 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/cloud_apps_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/invoices_controller_routing_spec.rb +37 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/organizations_controller_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_routing_spec.rb +16 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/users_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +12 -0
- data/spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb +15 -0
- data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +28 -0
- data/spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +22 -0
- data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +16 -0
- data/spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb +44 -0
- data/spec/routing/mno_enterprise/jpi/v1/teams_controller_routing_spec.rb +36 -0
- data/spec/routing/mno_enterprise/org_invites_controller_routing_spec.rb +12 -0
- data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +29 -0
- data/spec/routing/mno_enterprise/provision_controller_routing_spec.rb +15 -0
- data/spec/routing/mno_enterprise/status_controller_routing_spec.rb +19 -0
- data/spec/routing/mno_enterprise/webhook/o_auth_controller_routing_spec.rb +27 -0
- data/spec/spec_helper.rb +88 -0
- 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,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,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,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
|