Module: Configure::Views

Defined in:
lib/mongrel_config/win32_app.rb

Instance Method Summary collapse

Instance Method Details

#_running_procsObject



237
238
239
240
241
# File 'lib/mongrel_config/win32_app.rb', line 237

def _running_procs
  running = []
  W32Support.list.each {|s| running << s.service_name if s.current_state =~ /running/}
  running
end

#infoObject



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/mongrel_config/win32_app.rb', line 175

def info
  div :id=>"viewport" do
    @services.each do |s|
    
      h2 { "#{s.service_name} service information" }
      table do
        tr { th {"Attribute"}; th {"Value"} }
        
        s.each_pair do |memb,obj|
          name = memb.to_s.tr("_"," ").capitalize
          tr { 
            td { b { "#{name}: " } }
            td { obj.inspect }
          }
        end
      end
    end
  end
end

#install_formObject



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/mongrel_config/win32_app.rb', line 206

def install_form
  div do
    h2 { "Install New Mongrel Service" }
    p { "Items with an * are mandatory.  Leave an item blank to not specify it." }
    form :action=>"/install", :method=>"POST" do
      b { "* Service Name: "}; input :name => "service_name"; br
      b { "* Root: "}; input :name => "root"; br
      b { "* Environment: "}; input :name => "environment", :value => "development"; br
      b { "*Address: "}; input :name => "address", :value => "0.0.0.0"; br
      b { "*Port: "}; input :name => "port", :value => "4000", :size => 6; br
      b { "Display Name: "}; input :name => "display_name"; br
      b { "MIME Map File: "};  input :name => "mime"; br
      b { "Number Processor Threads: "}; input :name => "num_procs", :size => 3; br
      b { "Request Timeout: "}; input :name => "timeout", :size => 3; br
      b { "Assigned CPU: " }; input :name => "cpu", :size => 2; br

      p { input :type=>"submit", :value => "INSTALL" }
    end
  end
end

#install_resultObject



228
229
230
231
232
233
234
235
# File 'lib/mongrel_config/win32_app.rb', line 228

def install_result
  div :id=>"viewport" do
    h2 { "Install Results"}
    pre do
      self << @result
    end
  end
end

#layoutObject



130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/mongrel_config/win32_app.rb', line 130

def layout
  links = [ 
    ["/config", "Status"], 
    ["/config/install", "Install"], 
    ["/config/logs", "Logs"]
    ]
  body_content = yield
  currently_running = _running_procs

  open(GemPlugin::Manager.instance.resource("mongrel_config", "/index_win32.html")) do |f|
    template = ERB.new(f.read)
    self << template.result(binding)
  end
end

#listObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/mongrel_config/win32_app.rb', line 146

def list
  div :id=>"viewport" do
    table do
      tr { th { "Service"}; th { "Status"}; th { "Control" }; th { "Delete" } }
      @services.each do |s|
        status = W32Support.status(s.service_name)
        tr { 
          td { a(s.service_name, :href => "/info/#{s.service_name}") }
          td { status.capitalize }
          td { 
            if status =~ /stopped/
              a("start",:href => "/start/#{s.service_name}")
            elsif status =~ /running/
              a("stop",:href => "/stop/#{s.service_name}") 
            else
              b { "in progress" }
            end
          }
          td {
            a("delete!",:href => "/delete/#{s.service_name}", 
              :onclick=>"return confirm('Delete #{s.service_name}?') == '1'")
          }
        }
      end
    end
  end
end

#service_logsObject



195
196
197
198
199
200
201
202
203
204
# File 'lib/mongrel_config/win32_app.rb', line 195

def service_logs
  h2 { "Latest Service Activity Logs" }
  a("[clear logs]", :href => "/clear_logs")

  div :id=>"viewport" do
    pre :style=>"font-size: 10pt;" do
      self << $service_logs
    end
  end
end