module MnoEnterprise::Concerns::Controllers::PagesController

Public Instance Methods

app_access_unauthorized() click to toggle source

GET /app_access_unauthorized

# File lib/mno_enterprise/concerns/controllers/pages_controller.rb, line 45
def app_access_unauthorized
  @meta[:title] = "Unauthorized"
  @meta[:description] = "Application access not granted"
end
app_logout() click to toggle source

GET /app_logout

# File lib/mno_enterprise/concerns/controllers/pages_controller.rb, line 56
def app_logout
  @meta[:title] = "Logged out"
  @meta[:description] = "Logged out from application"
end
billing_details_required() click to toggle source
# File lib/mno_enterprise/concerns/controllers/pages_controller.rb, line 50
def billing_details_required
  @meta[:title] = "Billing Details Required"
  @meta[:description] = "Billing details have not been provided"
end
error() click to toggle source

Error page

# File lib/mno_enterprise/concerns/controllers/pages_controller.rb, line 78
def error
  handle_mnohub_error(params[:error_code])
end
launch() click to toggle source
Instance methods
GET /launch/:id
Redirect to Mno Enterprise app launcher
Launching an app (from dashboard) should redirect to this action
The true goal of this action is to hide maestrano in the link behind
any dashboard app picture

TODO: Access + existence checks could be added in the future. This is not
mandatory as Mno Enterprise will do it anyway
# File lib/mno_enterprise/concerns/controllers/pages_controller.rb, line 27
def launch
  app_instance = MnoEnterprise::AppInstance.find_by(uid: params[:id])
  MnoEnterprise::EventLogger.info('app_launch', current_user.id, 'App launched', app_instance)
  redirect_to MnoEnterprise.router.launch_url(params[:id], {wtk: MnoEnterprise.jwt(user_id: current_user.uid)}.reverse_merge(request.query_parameters))
end
loading() click to toggle source

GET /loading/:id Loading lounge - wait for an app to be online

# File lib/mno_enterprise/concerns/controllers/pages_controller.rb, line 35
def loading
  @app_instance = MnoEnterprise::AppInstance.where(uid: params[:id]).reload.first

  respond_to do |format|
    format.html { @app_instance_hash = app_instance_hash(@app_instance) }
    format.json { render json: app_instance_hash(@app_instance) }
  end
end
terms() click to toggle source
# File lib/mno_enterprise/concerns/controllers/pages_controller.rb, line 61
def terms
  @meta[:title] = 'Terms of Use'
  @meta[:description] = 'Terms of Use'

  ts = MnoEnterprise::App.order_by("updated_at.desc").first.try(:updated_at)
  @apps = if ts
    Rails.cache.fetch(['pages/terms/app-list', ts]) do
      # Temp solution as translated fields can not be filtered or sorted
      # MnoEnterprise::App.order_by("name.ac").reject{|i| i.terms_url.blank?}
      MnoEnterprise::App.all.reject{ |i| i.terms_url.blank? }.sort_by{ |a| a.name.downcase }
    end
  else
    []
  end
end

Private Instance Methods

app_instance_hash(app_instance) click to toggle source
# File lib/mno_enterprise/concerns/controllers/pages_controller.rb, line 83
def app_instance_hash(app_instance)
  return {} unless app_instance
  {
    id: app_instance.id,
    uid: app_instance.uid,
    name: app_instance.name,
    status: app_instance.status,
    durations: app_instance.durations,
    started_at: app_instance.started_at,
    stopped_at: app_instance.stopped_at,
    created_at: app_instance.created_at,
    server_time: Time.now.utc,
    is_online: app_instance.running?,
    errors: app_instance.errors ? app_instance.errors.full_messages : [],
    logo: app_instance.app.logo
  }
end