Permalink
Browse files

added environments

  • Loading branch information...
1 parent 3ce004b commit 2e700828f13932d722837c336d4dba9ffa12b1ca Yannick Simard committed Mar 16, 2012
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,3 @@
+// Place all the styles related to the Environments controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,56 @@
+body {
+ background-color: #fff;
+ color: #333;
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px; }
+
+p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px; }
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px; }
+
+a {
+ color: #000;
+ &:visited {
+ color: #666; }
+ &:hover {
+ color: #fff;
+ background-color: #000; } }
+
+div {
+ &.field, &.actions {
+ margin-bottom: 10px; } }
+
+#notice {
+ color: green; }
+
+.field_with_errors {
+ padding: 2px;
+ background-color: red;
+ display: table; }
+
+#error_explanation {
+ width: 450px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 0;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ margin-bottom: 0px;
+ background-color: #c00;
+ color: #fff; }
+ ul li {
+ font-size: 12px;
+ list-style: square; } }
@@ -1,5 +1,6 @@
class DashboardController < ApplicationController
def index
@jobs = Job.all
+ @environments = Environment.all
end
end
@@ -0,0 +1,83 @@
+class EnvironmentsController < ApplicationController
+ # GET /environments
+ # GET /environments.json
+ def index
+ @environments = Environment.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @environments }
+ end
+ end
+
+ # GET /environments/1
+ # GET /environments/1.json
+ def show
+ @environment = Environment.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @environment }
+ end
+ end
+
+ # GET /environments/new
+ # GET /environments/new.json
+ def new
+ @environment = Environment.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @environment }
+ end
+ end
+
+ # GET /environments/1/edit
+ def edit
+ @environment = Environment.find(params[:id])
+ end
+
+ # POST /environments
+ # POST /environments.json
+ def create
+ @environment = Environment.new(params[:environment])
+
+ respond_to do |format|
+ if @environment.save
+ format.html { redirect_to @environment, notice: 'Environment was successfully created.' }
+ format.json { render json: @environment, status: :created, location: @environment }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @environment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /environments/1
+ # PUT /environments/1.json
+ def update
+ @environment = Environment.find(params[:id])
+
+ respond_to do |format|
+ if @environment.update_attributes(params[:environment])
+ format.html { redirect_to @environment, notice: 'Environment was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @environment.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /environments/1
+ # DELETE /environments/1.json
+ def destroy
+ @environment = Environment.find(params[:id])
+ @environment.destroy
+
+ respond_to do |format|
+ format.html { redirect_to environments_url }
+ format.json { head :no_content }
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module EnvironmentsHelper
+end
@@ -0,0 +1,2 @@
+class Environment < ActiveRecord::Base
+end
@@ -1,6 +1,6 @@
<h1>Dashboard</h1>
-Jobs
+<h2>Jobs</h2>
<table>
<tr>
<td>Status</td>
@@ -14,4 +14,21 @@ Jobs
<%end%>
</table>
+<br>
+<br>
+<br>
+
+<h2>Environments</h2> <%= link_to "Environments", environments_path%>
+<table>
+ <tr>
+ <td>Name</td>
+ <td>Latest revision</td>
+ </tr>
+ <% @environments.each do |environment|%>
+ <tr>
+ <td><%= environment.name%></td>
+ <td><%= environment.revision%></td>
+ </tr>
+ <%end%>
+</table>
@@ -0,0 +1,25 @@
+<%= form_for(@environment) do |f| %>
+ <% if @environment.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@environment.errors.count, "error") %> prohibited this environment from being saved:</h2>
+
+ <ul>
+ <% @environment.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
+ <%= f.label :revision %><br />
+ <%= f.number_field :revision %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
@@ -0,0 +1,6 @@
+<h1>Editing environment</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @environment %> |
+<%= link_to 'Back', environments_path %>
@@ -0,0 +1,25 @@
+<h1>Listing environments</h1>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Revision</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @environments.each do |environment| %>
+ <tr>
+ <td><%= environment.name %></td>
+ <td><%= environment.revision %></td>
+ <td><%= link_to 'Show', environment %></td>
+ <td><%= link_to 'Edit', edit_environment_path(environment) %></td>
+ <td><%= link_to 'Destroy', environment, confirm: 'Are you sure?', method: :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Environment', new_environment_path %>
@@ -0,0 +1,5 @@
+<h1>New environment</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Back', environments_path %>
@@ -0,0 +1,15 @@
+<p id="notice"><%= notice %></p>
+
+<p>
+ <b>Name:</b>
+ <%= @environment.name %>
+</p>
+
+<p>
+ <b>Revision:</b>
+ <%= @environment.revision %>
+</p>
+
+
+<%= link_to 'Edit', edit_environment_path(@environment) %> |
+<%= link_to 'Back', environments_path %>
@@ -0,0 +1,10 @@
+class CreateEnvironments < ActiveRecord::Migration
+ def change
+ create_table :environments do |t|
+ t.string :name
+ t.integer :revision
+
+ t.timestamps
+ end
+ end
+end
View
@@ -11,7 +11,14 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120316175716) do
+ActiveRecord::Schema.define(:version => 20120316185604) do
+
+ create_table "environments", :force => true do |t|
+ t.string "name"
+ t.integer "revision"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
create_table "jobs", :force => true do |t|
t.string "name"
View
@@ -2,7 +2,7 @@ namespace :jenkins do
require 'json'
require 'net/http'
task :load => :environment do
- url = URI.parse APP_CONFIG['jenkins']['url']+"/api/json"
+ url = URI.parse APP_CONFIG['jenkins']['url']+APP_CONFIG['jenkins']['view']+"/api/json"
req = Net::HTTP::Get.new(url.path)
req.basic_auth APP_CONFIG['jenkins']['username'], APP_CONFIG['jenkins']['password']
res = Net::HTTP.start(url.host, url.port) {|http|

0 comments on commit 2e70082

Please sign in to comment.