Sha256: 1faaa18ebdc0b663b7d4c891a5cb01ceb486195f4d6004dc0ca5756309c38c44

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

class Settings<HTTPController
  layout :main

  def index(req)
    getTargetApp(req)
  end
  
  def _editApp(req)
    getTargetApp(req)
    case @targetApp
    when HTTPApp
      @instances=@targetApp.instances
      viewInstead :_http_app
    else
      viewInstead :_web_server
    end
  end

  def add(req)
    getTargetApp(req)
    case @targetApp
      when HTTPApp
        instName=params["NewInstanceName"]
        @targetApp.createInstance(instName) if instName
    end

    redirect_to(url(:action=>:index,:appId=>@targetApp.object_id))
  end

  def del(req)
    getTargetApp(req)
    case @targetApp
      when HTTPApp
        @targetApp.deleteInstance(params["instanceName"])
      when LocalWebServerApp
        @targetApp.deleteMount(params["mount"])
    end
    redirect_to(url(:action=>:index,:appId=>@targetApp.object_id))
  end


  def addMount(req)
    getTargetApp(req)
    httpApp=@app.cluster.getAppByName(params["httpApp"])
    instance=httpApp.getInstanceByName(params["httpAppInstance"])
    @targetApp.mount(params["mountPath"],instance)
    redirect_to(url(:action=>:index,:appId=>@targetApp.object_id))
  end

private
  def getTargetApp(req)
    @apps=@app.cluster.getLocalApplications
    id=req.path[0]
    id||=params["appId"]
    apps=@apps.select{|capp|capp.object_id.to_s==id}
    app=apps[0]

    if app
      @appSettings=app.settings
      @targetApp=app
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appswarm-0.0.1 apps/admin/controllers/settings.rb