server list looks like something
This commit is contained in:
@@ -25,6 +25,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc
|
||||
gem 'active_scaffold'
|
||||
gem 'bootstrap', '~> 4.0.0.alpha3'
|
||||
gem 'ace-rails-ap'
|
||||
gem 'puma'
|
||||
|
||||
# Use ActiveModel has_secure_password
|
||||
# gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
@@ -86,6 +86,7 @@ GEM
|
||||
parser (2.3.0.6)
|
||||
ast (~> 2.2)
|
||||
powerpack (0.1.1)
|
||||
puma (2.16.0)
|
||||
rack (1.6.4)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
@@ -171,6 +172,7 @@ DEPENDENCIES
|
||||
coffee-rails (~> 4.1.0)
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
puma
|
||||
rails (= 4.2.5.1)
|
||||
rubocop
|
||||
sass-rails (~> 5.0)
|
||||
|
||||
BIN
web/app/assets/images/chub.png
Normal file
BIN
web/app/assets/images/chub.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
web/app/assets/images/ubuntu.png
Normal file
BIN
web/app/assets/images/ubuntu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
@@ -14,3 +14,5 @@
|
||||
//= require jquery_ujs
|
||||
//= require turbolinks
|
||||
//= require_tree .
|
||||
//= require active_scaffold
|
||||
//= require bootstrap-sprockets
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
@@ -10,6 +11,15 @@
|
||||
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
||||
* file per style scope.
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*= require active_scaffold
|
||||
*/
|
||||
@import "bootstrap";
|
||||
|
||||
#logo {
|
||||
margin: 20px;
|
||||
color: green;
|
||||
}
|
||||
|
||||
.server-thumbnail {
|
||||
margin: 15px;
|
||||
}
|
||||
4
web/app/controllers/operating_systems_controller.rb
Normal file
4
web/app/controllers/operating_systems_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class OperatingSystemsController < ApplicationController
|
||||
active_scaffold :operating_system do |conf|
|
||||
end
|
||||
end
|
||||
6
web/app/controllers/servers_controller.rb
Normal file
6
web/app/controllers/servers_controller.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class ServersController < ApplicationController
|
||||
active_scaffold :server do |conf|
|
||||
conf.columns = [:name, :operating_system]
|
||||
conf.columns[:operating_system].form_ui = :select
|
||||
end
|
||||
end
|
||||
2
web/app/helpers/operating_systems_helper.rb
Normal file
2
web/app/helpers/operating_systems_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module OperatingSystemsHelper
|
||||
end
|
||||
2
web/app/helpers/servers_helper.rb
Normal file
2
web/app/helpers/servers_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ServersHelper
|
||||
end
|
||||
3
web/app/models/operating_system.rb
Normal file
3
web/app/models/operating_system.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class OperatingSystem < ActiveRecord::Base
|
||||
has_many :servers
|
||||
end
|
||||
8
web/app/models/server.rb
Normal file
8
web/app/models/server.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Server < ActiveRecord::Base
|
||||
belongs_to :operating_system
|
||||
before_create :generate_hash
|
||||
|
||||
def generate_hash
|
||||
self.namehash = SecureRandom.hex
|
||||
end
|
||||
end
|
||||
@@ -7,8 +7,11 @@
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 id="logo">
|
||||
CHUB
|
||||
</h1>
|
||||
<div class="container-fluid">
|
||||
<%= yield %>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
23
web/app/views/servers/list.html.erb
Normal file
23
web/app/views/servers/list.html.erb
Normal file
@@ -0,0 +1,23 @@
|
||||
<div class="row">
|
||||
<div class="col-md-11">
|
||||
<h2>Servers</h2>
|
||||
</div>
|
||||
<div class="col-md-1 text-right">
|
||||
<%= link_to(new_server_path) do %>
|
||||
<button class="btn btn-default pull-right">Add Server</button>
|
||||
<% end %>
|
||||
</dev>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<% @page.items.each do |server| %>
|
||||
<div class="col-md-2 col-xs-6 text-md-center server-thumbnail">
|
||||
<div class="thumbnail">
|
||||
<%= image_tag('ubuntu.png', size: '128', class:"img-responsive" ) %>
|
||||
<div class="caption text-md-center" >
|
||||
<h3><%= server.name %></h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -9,3 +9,4 @@ Rails.application.config.assets.version = '1.0'
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
# Rails.application.config.assets.precompile += %w( search.js )
|
||||
Rails.application.config.assets.precompile += %w( active_scaffold/indicator.gif )
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
Rails.application.routes.draw do
|
||||
resources :operating_systems do as_routes end
|
||||
resources :servers do as_routes end
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
# You can have the root of your site routed with "root"
|
||||
# root 'welcome#index'
|
||||
root 'servers#index'
|
||||
|
||||
# Example of regular route:
|
||||
# get 'products/:id' => 'catalog#view'
|
||||
|
||||
12
web/db/migrate/20160220084417_create_servers.rb
Normal file
12
web/db/migrate/20160220084417_create_servers.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateServers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :servers do |t|
|
||||
t.string :name, null: false
|
||||
t.string :namehash, null: false
|
||||
t.integer :operating_system_id, null: false
|
||||
t.boolean :initialized, null: false, default: false
|
||||
t.string :hostname
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
class CreateOperatingSystems < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :operating_systems do |t|
|
||||
t.string :name, null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
30
web/db/schema.rb
Normal file
30
web/db/schema.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
# encoding: UTF-8
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20_160_220_091_225) do
|
||||
create_table 'operating_systems', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
end
|
||||
|
||||
create_table 'servers', force: :cascade do |t|
|
||||
t.string 'name', null: false
|
||||
t.string 'namehash', null: false
|
||||
t.integer 'operating_system_id', null: false
|
||||
t.boolean 'initialized', default: false, null: false
|
||||
t.string 'hostname'
|
||||
t.datetime 'created_at', null: false
|
||||
t.datetime 'updated_at', null: false
|
||||
end
|
||||
end
|
||||
49
web/test/controllers/operating_systems_controller_test.rb
Normal file
49
web/test/controllers/operating_systems_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class OperatingSystemsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@operating_system = operating_systems(:one)
|
||||
end
|
||||
|
||||
test 'should get index' do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:operating_systems)
|
||||
end
|
||||
|
||||
test 'should get new' do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'should create operating_system' do
|
||||
assert_difference('OperatingSystem.count') do
|
||||
post :create, operating_system: {}
|
||||
end
|
||||
|
||||
assert_redirected_to operating_system_path(assigns(:operating_system))
|
||||
end
|
||||
|
||||
test 'should show operating_system' do
|
||||
get :show, id: @operating_system
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'should get edit' do
|
||||
get :edit, id: @operating_system
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'should update operating_system' do
|
||||
patch :update, id: @operating_system, operating_system: {}
|
||||
assert_redirected_to operating_system_path(assigns(:operating_system))
|
||||
end
|
||||
|
||||
test 'should destroy operating_system' do
|
||||
assert_difference('OperatingSystem.count', -1) do
|
||||
delete :destroy, id: @operating_system
|
||||
end
|
||||
|
||||
assert_redirected_to operating_systems_path
|
||||
end
|
||||
end
|
||||
49
web/test/controllers/servers_controller_test.rb
Normal file
49
web/test/controllers/servers_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ServersControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@server = servers(:one)
|
||||
end
|
||||
|
||||
test 'should get index' do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:servers)
|
||||
end
|
||||
|
||||
test 'should get new' do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'should create server' do
|
||||
assert_difference('Server.count') do
|
||||
post :create, server: {}
|
||||
end
|
||||
|
||||
assert_redirected_to server_path(assigns(:server))
|
||||
end
|
||||
|
||||
test 'should show server' do
|
||||
get :show, id: @server
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'should get edit' do
|
||||
get :edit, id: @server
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'should update server' do
|
||||
patch :update, id: @server, server: {}
|
||||
assert_redirected_to server_path(assigns(:server))
|
||||
end
|
||||
|
||||
test 'should destroy server' do
|
||||
assert_difference('Server.count', -1) do
|
||||
delete :destroy, id: @server
|
||||
end
|
||||
|
||||
assert_redirected_to servers_path
|
||||
end
|
||||
end
|
||||
11
web/test/fixtures/operating_systems.yml
vendored
Normal file
11
web/test/fixtures/operating_systems.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
11
web/test/fixtures/servers.yml
vendored
Normal file
11
web/test/fixtures/servers.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
7
web/test/models/operating_system_test.rb
Normal file
7
web/test/models/operating_system_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class OperatingSystemTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
web/test/models/server_test.rb
Normal file
7
web/test/models/server_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ServerTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user