diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index a9a6fd9..e96083d 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -56,4 +56,6 @@ // Right Click Event -//= require contextmenu \ No newline at end of file +//= require contextmenu + +//= require js/validator/validator.js \ No newline at end of file diff --git a/app/controllers/node_controller.rb b/app/controllers/node_controller.rb index fde0bb2..18ed4e3 100644 --- a/app/controllers/node_controller.rb +++ b/app/controllers/node_controller.rb @@ -1,7 +1,8 @@ class NodeController < ApplicationController def index @hosts = Array.new - + @nodes = Node.all.order("id asc") + if get_hosts.blank? flash[:danger] = "Check Server" else @@ -12,4 +13,21 @@ class NodeController < ApplicationController def get_hosts return ['2', 'aaa', 'bbb', 'ccc'] end + + def node_add + new_node = Node.new + new_node.host_name = params[:host_name] + new_node.host_ip = params[:host_ip] + new_node.host_port = params[:host_port] + new_node.user_name = params[:user_name] + new_node.user_password = params[:user_password] + new_node.save + redirect_to '/node/index' + end + + def node_delete + one_node = Node.find(params[:node_id]) + one_node.destroy + redirect_to '/node/index' + end end diff --git a/app/models/node.rb b/app/models/node.rb new file mode 100644 index 0000000..3713f57 --- /dev/null +++ b/app/models/node.rb @@ -0,0 +1,2 @@ +class Node < ActiveRecord::Base +end diff --git a/app/views/node/index.html.erb b/app/views/node/index.html.erb index edcd1bb..970aa18 100644 --- a/app/views/node/index.html.erb +++ b/app/views/node/index.html.erb @@ -8,12 +8,88 @@
+
+
+
+
+

Add Node

+ +
+
+
+
+ Node Info + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+
+
+
+
-
+
-

Hover rows Try hovering over the rows

+

Node List Try hovering over the rows

+ \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2ba1ed1..05aeea8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,8 @@ Rails.application.routes.draw do #Node get 'node/index' => 'node#index' + post 'node/add' => "node#node_add" + get 'node/delete/:node_id' => "node#node_delete" diff --git a/db/migrate/20160920111650_create_nodes.rb b/db/migrate/20160920111650_create_nodes.rb new file mode 100644 index 0000000..d8f37a0 --- /dev/null +++ b/db/migrate/20160920111650_create_nodes.rb @@ -0,0 +1,14 @@ +class CreateNodes < ActiveRecord::Migration + def change + create_table :nodes do |t| + + t.string :host_name + t.string :host_ip + t.integer :host_port + t.string :user_name + t.string :user_password + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index aba0ad7..7ea0653 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,17 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160819061449) do +ActiveRecord::Schema.define(version: 20160920111650) do + + create_table "nodes", force: :cascade do |t| + t.string "host_name" + t.string "host_ip" + t.integer "host_port" + t.string "user_name" + t.string "user_password" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end create_table "users", force: :cascade do |t| t.string "email", default: "", null: false diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/nodes.yml @@ -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 diff --git a/test/models/node_test.rb b/test/models/node_test.rb new file mode 100644 index 0000000..ccc3765 --- /dev/null +++ b/test/models/node_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class NodeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end