mno-enterprise-api 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module MnoEnterprise::Concerns::Controllers::Jpi::V1::DeletionRequestsController
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
#==================================================================
|
|
5
|
+
# Included methods
|
|
6
|
+
#==================================================================
|
|
7
|
+
# 'included do' causes the included code to be evaluated in the
|
|
8
|
+
# context where it is included rather than being executed in the module's context
|
|
9
|
+
included do
|
|
10
|
+
respond_to :json
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
#==================================================================
|
|
14
|
+
# Class methods
|
|
15
|
+
#==================================================================
|
|
16
|
+
module ClassMethods
|
|
17
|
+
# def some_class_method
|
|
18
|
+
# 'some text'
|
|
19
|
+
# end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#==================================================================
|
|
23
|
+
# Instance methods
|
|
24
|
+
#==================================================================
|
|
25
|
+
# POST /deletion_request.json
|
|
26
|
+
def create
|
|
27
|
+
@deletion_request = MnoEnterprise::DeletionRequest.new(user_id: current_user.id)
|
|
28
|
+
|
|
29
|
+
if @deletion_request.save
|
|
30
|
+
# TODO: deliver_later => need to use user#id and deletion_request#id
|
|
31
|
+
MnoEnterprise::SystemNotificationMailer.deletion_request_instructions(current_user, @deletion_request).deliver_now
|
|
32
|
+
render json: @deletion_request, status: :created
|
|
33
|
+
else
|
|
34
|
+
render json: @deletion_request.errors, status: :unprocessable_entity
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# PUT /deletion_request/1/resend.json
|
|
39
|
+
def resend
|
|
40
|
+
@deletion_request = current_user.deletion_request
|
|
41
|
+
|
|
42
|
+
# Check that the user has a deletion_request in progress
|
|
43
|
+
# and that the token provided (params[:id]) matches the
|
|
44
|
+
# deletion_request token
|
|
45
|
+
if @deletion_request.present? && @deletion_request.token == params[:id]
|
|
46
|
+
MnoEnterprise::SystemNotificationMailer.deletion_request_instructions(current_user, @deletion_request).deliver_now
|
|
47
|
+
render json: @deletion_request
|
|
48
|
+
else
|
|
49
|
+
head :bad_request
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# DELETE /deletion_request/1.json
|
|
54
|
+
def destroy
|
|
55
|
+
@deletion_request = current_user.deletion_request
|
|
56
|
+
|
|
57
|
+
# Check that the user has a deletion_request in progress
|
|
58
|
+
# and that the token provided (params[:id]) matches the
|
|
59
|
+
# deletion_request token
|
|
60
|
+
if @deletion_request.present? && @deletion_request.token == params[:id]
|
|
61
|
+
# Work around
|
|
62
|
+
MnoEnterprise::DeletionRequest.find(@deletion_request.id).destroy
|
|
63
|
+
|
|
64
|
+
head :no_content
|
|
65
|
+
else
|
|
66
|
+
head :bad_request
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module MnoEnterprise::Concerns::Controllers::Jpi::V1::Impac::DashboardsController
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
#==================================================================
|
|
5
|
+
# Included methods
|
|
6
|
+
#==================================================================
|
|
7
|
+
# 'included do' causes the included code to be evaluated in the
|
|
8
|
+
# context where it is included rather than being executed in the module's context
|
|
9
|
+
included do
|
|
10
|
+
respond_to :json
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
#==================================================================
|
|
14
|
+
# Instance methods
|
|
15
|
+
#==================================================================
|
|
16
|
+
# GET /mnoe/jpi/v1/impac/dashboards
|
|
17
|
+
def index
|
|
18
|
+
dashboards
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /mnoe/jpi/v1/impac/dashboards/1
|
|
22
|
+
def show
|
|
23
|
+
dashboard
|
|
24
|
+
render json: { errors: "Dashboard id #{params[:id]} doesn't exist" }, status: :not_found unless @dashboard
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# POST /mnoe/jpi/v1/impac/dashboards
|
|
28
|
+
# -> POST /api/mnoe/v1/users/282/dashboards
|
|
29
|
+
def create
|
|
30
|
+
if @dashboard = dashboards.create(dashboard_create_params)
|
|
31
|
+
# authorize! :create, @dashboard
|
|
32
|
+
MnoEnterprise::EventLogger.info('dashboard_create', current_user.id, 'Dashboard Creation', nil, @dashboard)
|
|
33
|
+
render 'show'
|
|
34
|
+
else
|
|
35
|
+
render json: @dashboard.errors, status: :bad_request
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# PUT /mnoe/jpi/v1/impac/dashboards/1
|
|
40
|
+
def update
|
|
41
|
+
if dashboard.update(dashboard_update_params)
|
|
42
|
+
# dashboard.assign_attributes(attrs)
|
|
43
|
+
# authorize! :update, dashboard
|
|
44
|
+
render 'show'
|
|
45
|
+
else
|
|
46
|
+
render json: @dashboard.errors, status: :bad_request
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# DELETE /mnoe/jpi/v1/impac/dashboards/1
|
|
51
|
+
def destroy
|
|
52
|
+
# authorize! :destroy, @dashboard
|
|
53
|
+
if dashboard.destroy
|
|
54
|
+
MnoEnterprise::EventLogger.info('dashboard_delete', current_user.id, 'Dashboard Deletion', nil, dashboard)
|
|
55
|
+
head status: :ok
|
|
56
|
+
else
|
|
57
|
+
render json: 'Unable to destroy dashboard', status: :bad_request
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
protected
|
|
62
|
+
|
|
63
|
+
def dashboard
|
|
64
|
+
@dashboard ||= current_user.dashboards.to_a.find { |d| d.id.to_s == params[:id].to_s }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def dashboards
|
|
68
|
+
@dashboards ||= current_user.dashboards
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def dashboard_params
|
|
72
|
+
params.require(:dashboard).permit(:name, :currency, {widgets_order: []}, {organization_ids: []})
|
|
73
|
+
end
|
|
74
|
+
alias :dashboard_update_params :dashboard_params
|
|
75
|
+
alias :dashboard_create_params :dashboard_params
|
|
76
|
+
end
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
module MnoEnterprise::Concerns::Controllers::Jpi::V1::OrganizationsController
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
#==================================================================
|
|
5
|
+
# Included methods
|
|
6
|
+
#==================================================================
|
|
7
|
+
# 'included do' causes the included code to be evaluated in the
|
|
8
|
+
# context where it is included rather than being executed in the module's context
|
|
9
|
+
included do
|
|
10
|
+
respond_to :json
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
#==================================================================
|
|
14
|
+
# Instance methods
|
|
15
|
+
#==================================================================
|
|
16
|
+
# GET /mnoe/jpi/v1/organizations
|
|
17
|
+
def index
|
|
18
|
+
@organizations ||= current_user.organizations
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /mnoe/jpi/v1/organizations/1
|
|
22
|
+
def show
|
|
23
|
+
organization # load organization
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# PUT /mnoe/jpi/v1/organizations/:id
|
|
27
|
+
def update
|
|
28
|
+
# Update and Authorize
|
|
29
|
+
organization.assign_attributes(organization_update_params)
|
|
30
|
+
authorize! :update, organization
|
|
31
|
+
|
|
32
|
+
# Save
|
|
33
|
+
if organization.save
|
|
34
|
+
render 'show_reduced'
|
|
35
|
+
else
|
|
36
|
+
render json: organization.errors, status: :bad_request
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# DELETE /mnoe/jpi/v1/organizations/1
|
|
41
|
+
def destroy
|
|
42
|
+
if organization
|
|
43
|
+
authorize! :destroy, organization
|
|
44
|
+
organization.destroy
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
head :no_content
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# POST /mnoe/jpi/v1/organizations
|
|
51
|
+
def create
|
|
52
|
+
# Create new organization
|
|
53
|
+
@organization = MnoEnterprise::Organization.create(organization_update_params)
|
|
54
|
+
|
|
55
|
+
# Add the current user as Super Admin
|
|
56
|
+
@organization.add_user(current_user,'Super Admin')
|
|
57
|
+
|
|
58
|
+
# Bust cache
|
|
59
|
+
current_user.refresh_user_cache
|
|
60
|
+
|
|
61
|
+
render 'show'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# PUT /mnoe/jpi/v1/organizations/:id/charge
|
|
65
|
+
# def charge
|
|
66
|
+
# authorize! :manage_billing, organization
|
|
67
|
+
# payment = organization.charge
|
|
68
|
+
# s = ''
|
|
69
|
+
# if payment
|
|
70
|
+
# if payment.success?
|
|
71
|
+
# s = 'success'
|
|
72
|
+
# else
|
|
73
|
+
# s = 'fail'
|
|
74
|
+
# end
|
|
75
|
+
# else
|
|
76
|
+
# s = 'error'
|
|
77
|
+
# end
|
|
78
|
+
#
|
|
79
|
+
# render json: { status: s, data: payment }
|
|
80
|
+
# end
|
|
81
|
+
|
|
82
|
+
# PUT /mnoe/jpi/v1/organizations/:id/update_billing
|
|
83
|
+
def update_billing
|
|
84
|
+
whitelist = ['title','first_name','last_name','number','month','year','country','verification_value','billing_address','billing_city','billing_postcode', 'billing_country']
|
|
85
|
+
attributes = params[:credit_card].select { |k,v| whitelist.include?(k.to_s) }
|
|
86
|
+
authorize! :manage_billing, organization
|
|
87
|
+
|
|
88
|
+
# Upsert
|
|
89
|
+
if @credit_card = organization.credit_card
|
|
90
|
+
@credit_card.assign_attributes(attributes.merge(organization_id: @credit_card.organization_id))
|
|
91
|
+
@credit_card.save
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
if @credit_card.errors.empty?
|
|
95
|
+
render 'credit_card'
|
|
96
|
+
else
|
|
97
|
+
render json: @credit_card.errors, status: :bad_request
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# TODO: specs
|
|
102
|
+
# PUT /mnoe/jpi/v1/organizations/:id/invite_members
|
|
103
|
+
def invite_members
|
|
104
|
+
# Filter
|
|
105
|
+
whitelist = ['email','role','team_id']
|
|
106
|
+
attributes = []
|
|
107
|
+
params[:invites].each do |invite|
|
|
108
|
+
attributes << invite.select { |k,v| whitelist.include?(k.to_s) }
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Authorize and create
|
|
112
|
+
authorize! :invite_member, organization
|
|
113
|
+
attributes.each do |invite|
|
|
114
|
+
@org_invite = organization.org_invites.create(
|
|
115
|
+
user_email: invite['email'],
|
|
116
|
+
user_role: invite['role'],
|
|
117
|
+
team_id: invite['team_id'],
|
|
118
|
+
referrer_id: current_user.id
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
MnoEnterprise::SystemNotificationMailer.organization_invite(@org_invite).deliver_now
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Reload users
|
|
125
|
+
organization.users.reload
|
|
126
|
+
|
|
127
|
+
render 'members'
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# TODO: specs
|
|
131
|
+
# PUT /mnoe/jpi/v1/organizations/:id/update_member
|
|
132
|
+
def update_member
|
|
133
|
+
attributes = params[:member]
|
|
134
|
+
@member = organization.users.where(email: attributes[:email]).first
|
|
135
|
+
@member ||= organization.org_invites.active.where(user_email: attributes[:email]).first
|
|
136
|
+
|
|
137
|
+
# Authorize and update
|
|
138
|
+
authorize! :invite_member, organization
|
|
139
|
+
if @member.is_a?(MnoEnterprise::User)
|
|
140
|
+
organization.users.update(id: @member.id, role: attributes[:role])
|
|
141
|
+
elsif @member.is_a?(MnoEnterprise::OrgInvite)
|
|
142
|
+
@member.user_role = attributes[:role]
|
|
143
|
+
@member.save
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
render 'members'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# TODO: specs
|
|
150
|
+
# PUT /mnoe/jpi/v1/organizations/:id/remove_member
|
|
151
|
+
def remove_member
|
|
152
|
+
attributes = params[:member]
|
|
153
|
+
@member = organization.users.where(email: attributes[:email]).first
|
|
154
|
+
@member ||= organization.org_invites.active.where(user_email: attributes[:email]).first
|
|
155
|
+
|
|
156
|
+
# Authorize and update
|
|
157
|
+
authorize! :invite_member, organization
|
|
158
|
+
if @member.is_a?(MnoEnterprise::User)
|
|
159
|
+
organization.remove_user(@member)
|
|
160
|
+
elsif @member.is_a?(MnoEnterprise::OrgInvite)
|
|
161
|
+
@member.cancel!
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
render 'members'
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
protected
|
|
168
|
+
def organization
|
|
169
|
+
@organization ||= current_user.organizations.to_a.find{ |o| o.id.to_s == params[:id].to_s }
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def organization_permitted_update_params
|
|
173
|
+
[:name, :soa_enabled, :industry, :size]
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def organization_update_params
|
|
177
|
+
params.fetch(:organization, {}).permit(*organization_permitted_update_params)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module MnoEnterprise::Concerns::Controllers::OrgInvitesController
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
#==================================================================
|
|
5
|
+
# Included methods
|
|
6
|
+
#==================================================================
|
|
7
|
+
# 'included do' causes the included code to be evaluated in the
|
|
8
|
+
# context where it is included rather than being executed in the module's context
|
|
9
|
+
included do
|
|
10
|
+
before_filter :authenticate_user!
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
#==================================================================
|
|
14
|
+
# Class methods
|
|
15
|
+
#==================================================================
|
|
16
|
+
module ClassMethods
|
|
17
|
+
# def some_class_method
|
|
18
|
+
# 'some text'
|
|
19
|
+
# end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#==================================================================
|
|
23
|
+
# Instance methods
|
|
24
|
+
#==================================================================
|
|
25
|
+
# GET /org_invites/1?token=HJuiofjpa45A73255a74F534FDfds
|
|
26
|
+
# TODO: improve integration with new frontends
|
|
27
|
+
def show
|
|
28
|
+
@current_user = current_user
|
|
29
|
+
@org_invite = MnoEnterprise::OrgInvite.active.where(id: params[:id], token: params[:token]).first
|
|
30
|
+
redirect_path = mnoe_home_path
|
|
31
|
+
|
|
32
|
+
if @org_invite && !@org_invite.expired? && @org_invite.accept!(current_user)
|
|
33
|
+
redirect_path += "#/?dhbRefId=#{ @org_invite.organization.id}"
|
|
34
|
+
message = { notice: "You are now part of #{@org_invite.organization.name}" }
|
|
35
|
+
yield(:success, @org_invite) if block_given?
|
|
36
|
+
elsif @org_invite && @org_invite.expired?
|
|
37
|
+
message = { alert: "It looks like this invite has expired. Please ask your company administrator to resend the invite." }
|
|
38
|
+
else
|
|
39
|
+
message = { alert: "Unfortunately, this invite does not seem to be valid." }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
redirect_to redirect_path, message
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
module MnoEnterprise::Concerns::Controllers::PagesController
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
#==================================================================
|
|
5
|
+
# Included methods
|
|
6
|
+
#==================================================================
|
|
7
|
+
# 'included do' causes the included code to be evaluated in the
|
|
8
|
+
# context where it is included rather than being executed in the module's context
|
|
9
|
+
included do
|
|
10
|
+
before_filter :authenticate_user!, only: [:launch]
|
|
11
|
+
before_filter :redirect_to_lounge_if_unconfirmed, only: [:launch]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
#==================================================================
|
|
15
|
+
# Instance methods
|
|
16
|
+
#==================================================================
|
|
17
|
+
# GET /launch/:id
|
|
18
|
+
# Redirect to Mno Enterprise app launcher
|
|
19
|
+
# Launching an app (from dashboard) should redirect to this action
|
|
20
|
+
# The true goal of this action is to hide maestrano in the link behind
|
|
21
|
+
# any dashboard app picture
|
|
22
|
+
#
|
|
23
|
+
# TODO: Access + existence checks could be added in the future. This is not
|
|
24
|
+
# mandatory as Mno Enterprise will do it anyway
|
|
25
|
+
def launch
|
|
26
|
+
app = MnoEnterprise::AppInstance.find_by(uid: params[:id])
|
|
27
|
+
MnoEnterprise::EventLogger.info('app_launch', current_user.id, "App launched", app.name, app)
|
|
28
|
+
redirect_to MnoEnterprise.router.launch_url(params[:id], wtk: MnoEnterprise.jwt(user_id: current_user.uid))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# GET /loading/:id
|
|
32
|
+
# Loading lounge - wait for an app to be online
|
|
33
|
+
def loading
|
|
34
|
+
@app_instance = MnoEnterprise::AppInstance.where(uid: params[:id]).reload.first
|
|
35
|
+
|
|
36
|
+
respond_to do |format|
|
|
37
|
+
format.html { @app_instance_hash = app_instance_hash(@app_instance) }
|
|
38
|
+
format.json { render json: app_instance_hash(@app_instance) }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# GET /app_access_unauthorized
|
|
43
|
+
def app_access_unauthorized
|
|
44
|
+
@meta[:title] = "Unauthorized"
|
|
45
|
+
@meta[:description] = "Application access not granted"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def billing_details_required
|
|
49
|
+
@meta[:title] = "Billing Details Required"
|
|
50
|
+
@meta[:description] = "Billing details have not been provided"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# GET /app_logout
|
|
54
|
+
def app_logout
|
|
55
|
+
@meta[:title] = "Logged out"
|
|
56
|
+
@meta[:description] = "Logged out from application"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
def app_instance_hash(app_instance)
|
|
61
|
+
return {} unless app_instance
|
|
62
|
+
{
|
|
63
|
+
id: app_instance.id,
|
|
64
|
+
uid: app_instance.uid,
|
|
65
|
+
name: app_instance.name,
|
|
66
|
+
status: app_instance.status,
|
|
67
|
+
durations: app_instance.durations,
|
|
68
|
+
started_at: app_instance.started_at,
|
|
69
|
+
stopped_at: app_instance.stopped_at,
|
|
70
|
+
created_at: app_instance.created_at,
|
|
71
|
+
server_time: Time.now.utc,
|
|
72
|
+
is_online: app_instance.online?,
|
|
73
|
+
errors: app_instance.errors ? app_instance.errors.full_messages : [],
|
|
74
|
+
logo: app_instance.app.logo
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|