Commit 9448385f authored by nazarf's avatar nazarf

set and check miner status

parent e6391590
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="ruby">
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>
\ No newline at end of file
This diff is collapsed.
source 'https://rubygems.org'
gem 'rails', '4.2.8'
gem 'mysql2'
gem 'mysql2', '~> 0.4.3'
gem 'uglifier', '>= 1.3.0'
gem 'sass-rails', '~> 5.0'
gem 'coffee-rails', '~> 4.1.0'
......
......@@ -35,53 +35,48 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
acts_as_list (0.9.4)
activerecord (>= 3.0)
airbrussh (1.1.2)
acts_as_list (1.1.0)
activerecord (>= 4.2)
airbrussh (1.4.1)
sshkit (>= 1.6.1, != 1.7.0)
arel (6.0.4)
autoprefixer-rails (6.7.7.1)
execjs
bcrypt (3.1.11-x64-mingw32)
bcrypt (3.1.11-x86-mingw32)
binding_of_caller (0.7.2)
autoprefixer-rails (10.4.13.0)
execjs (~> 2)
bcrypt (3.1.18)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
bootstrap-will_paginate (0.0.11)
bootstrap-will_paginate (1.0.0)
will_paginate
bootstrap3-datetimepicker-rails (4.15.35)
momentjs-rails (>= 2.8.1)
builder (3.2.3)
builder (3.2.4)
capistrano (3.7.2)
airbrussh (>= 1.0.0)
capistrano-harrow
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (1.2.0)
capistrano-bundler (2.1.0)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-faster-assets (1.0.2)
capistrano-faster-assets (1.1.0)
capistrano (>= 3.1)
capistrano-harrow (0.5.3)
capistrano-rails (1.2.3)
capistrano-rails (1.6.2)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-bundler (>= 1.1, < 3)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
carrierwave (1.0.0)
carrierwave (1.3.3)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
ckeditor (4.2.4)
cocaine
ssrf_filter (~> 1.0, < 1.1.0)
ckeditor (5.1.1)
orm_adapter (~> 0.5.0)
climate_control (0.2.0)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
......@@ -90,39 +85,45 @@ GEM
execjs
coffee-script-source (1.12.2)
commonjs (0.2.7)
concurrent-ruby (1.0.5)
debug_inspector (0.0.2)
devise (4.2.1)
concurrent-ruby (1.2.2)
crass (1.0.6)
debug_inspector (1.1.0)
devise (4.9.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-i18n (1.1.2)
devise-i18n (1.11.0)
devise (>= 4.9.0)
digest (3.1.1)
erubis (2.7.0)
execjs (2.7.0)
font-awesome-rails (4.7.0.1)
railties (>= 3.2, < 5.1)
globalid (0.3.7)
activesupport (>= 4.1.0)
haml (4.0.7)
execjs (2.8.1)
ffi (1.15.5)
font-awesome-rails (4.7.0.8)
railties (>= 3.2, < 8.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
haml (5.2.2)
temple (>= 0.8.0)
tilt
haml-rails (0.9.0)
haml-rails (1.0.0)
actionpack (>= 4.0.1)
activesupport (>= 4.0.1)
haml (>= 4.0.6, < 5.0)
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
html2haml (2.1.0)
html2haml (2.3.0)
erubis (~> 2.7.0)
haml (~> 4.0)
haml (>= 4.0)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
i18n (0.8.1)
jbuilder (2.6.3)
activesupport (>= 3.0.0, < 5.2)
multi_json (~> 1.2)
jquery-rails (4.3.1)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
io-wait (0.3.0)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jquery-rails (4.5.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
......@@ -131,36 +132,51 @@ GEM
json (1.8.6)
less (2.6.0)
commonjs (~> 0.2.7)
less-rails (2.8.0)
actionpack (>= 4.0)
less-rails (4.0.0)
actionpack (>= 4)
less (~> 2.6.0)
sprockets (> 2, < 4)
tilt
loofah (2.0.3)
sprockets (>= 2)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
mime-types (3.1)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.6.1)
mini_portile2 (2.1.0)
minitest (5.10.1)
momentjs-rails (2.17.1)
mime-types-data (3.2023.0218.1)
mini_magick (4.12.0)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
minitest (5.15.0)
momentjs-rails (2.29.4.1)
railties (>= 3.1)
multi_json (1.12.1)
mysql2 (0.4.5-x64-mingw32)
mysql2 (0.4.5-x86-mingw32)
mysql2 (0.4.10)
nested_form (0.3.2)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.1.0)
nokogiri (1.7.1-x64-mingw32)
mini_portile2 (~> 2.1.0)
nokogiri (1.7.1-x86-mingw32)
mini_portile2 (~> 2.1.0)
net-imap (0.2.2)
digest
net-protocol
strscan
net-pop (0.1.2)
net-protocol
net-protocol (0.1.2)
io-wait
timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-smtp (0.3.0)
digest
net-protocol
timeout
net-ssh (6.1.0)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
orm_adapter (0.5.0)
rack (1.6.5)
racc (1.6.2)
rack (1.6.13)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.8)
......@@ -174,27 +190,35 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.8)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
rails-deprecated_sanitizer (1.0.4)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (4.2.8)
actionpack (= 4.2.8)
activesupport (= 4.2.8)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (4.3.0)
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
ruby_parser (3.8.4)
sexp_processor (~> 4.1)
sass (3.4.23)
sass-rails (5.0.6)
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
ruby_parser (3.19.2)
sexp_processor (~> 4.16)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
......@@ -203,36 +227,38 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
sexp_processor (4.8.0)
simple_form (3.4.0)
actionpack (> 4, < 5.1)
activemodel (> 4, < 5.1)
sprockets (3.7.1)
sexp_processor (4.16.1)
simple_form (4.0.0)
actionpack (> 4)
activemodel (> 4)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.12.0)
sshkit (1.21.4)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.19.4)
ssrf_filter (1.0.8)
strscan (3.0.6)
temple (0.10.0)
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.7)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tilt (2.1.0)
timeout (0.3.2)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
twitter-bootstrap-rails (3.2.2)
actionpack (>= 3.1)
execjs (>= 2.2.2, >= 2.2)
less-rails (>= 2.5.0)
railties (>= 3.1)
tzinfo (1.2.2)
tzinfo (1.2.11)
thread_safe (~> 0.1)
tzinfo-data (1.2017.1)
tzinfo (>= 1.0.0)
uglifier (3.1.9)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
warden (1.2.7)
rack (>= 1.0)
......@@ -241,11 +267,10 @@ GEM
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
will_paginate (3.1.5)
will_paginate (3.3.1)
PLATFORMS
x64-mingw32
x86-mingw32
ruby
DEPENDENCIES
acts_as_list
......@@ -269,7 +294,7 @@ DEPENDENCIES
jquery-ui-rails
mini_magick
momentjs-rails (>= 2.9.0)
mysql2
mysql2 (~> 0.4.3)
nested_form
rails (= 4.2.8)
sass-rails (~> 5.0)
......@@ -283,4 +308,4 @@ DEPENDENCIES
will_paginate
BUNDLED WITH
1.14.3
1.17.3
......@@ -9,4 +9,10 @@ class FrontController < ApplicationController
@page = Page.find_by(url_id: params[:id]) || Page.find(params[:id])
end
def update_miner_activity
miner = Miner.find_by(name: params[:name])
miner.update(status: 'work')
render json: {status: 'ok'}
end
end
class MinersController < AdminController
before_action :set_miner, only: [:show, :edit, :update, :destroy]
before_action :check_administrator
# GET /miners
# GET /miners.json
def index
@miners = Miner.all
end
# GET /miners/1
# GET /miners/1.json
def show
end
# GET /miners/new
def new
@miner = Miner.new
end
# GET /miners/1/edit
def edit
end
# POST /miners
# POST /miners.json
def create
@miner = Miner.new(miner_params)
respond_to do |format|
if @miner.save
format.html { redirect_to @miner, notice: 'Miner was successfully created.' }
format.json { render :show, status: :created, location: @miner }
else
format.html { render :new }
format.json { render json: @miner.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /miners/1
# PATCH/PUT /miners/1.json
def update
respond_to do |format|
if @miner.update(miner_params)
format.html { redirect_to @miner, notice: 'Miner was successfully updated.' }
format.json { render :show, status: :ok, location: @miner }
else
format.html { render :edit }
format.json { render json: @miner.errors, status: :unprocessable_entity }
end
end
end
# DELETE /miners/1
# DELETE /miners/1.json
def destroy
@miner.destroy
respond_to do |format|
format.html { redirect_to miners_url, notice: 'Miner was successfully destroyed.' }
format.json { head :no_content }
end
end
def miners_activity
@data = Miner.all.map do |miner|
{
name: miner.name,
status: miner.status,
hash_rate: miner.hash_rate,
last_activity: miner.last_activity,
ip_address: miner.ip_address,
port: miner.port,
wallet_address: miner.wallet_address,
password: miner.password,
algorithm: miner.algorithm,
ip_address_2: miner.ip_address_2,
port_2: miner.port_2,
wallet_address_2: miner.wallet_address_2,
password_2: miner.password_2,
algorithm_2: miner.algorithm_2
}
end
render json: @data
end
private
# Use callbacks to share common setup or constraints between actions.
def set_miner
@miner = Miner.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def miner_params
params.require(:miner).permit(:name, :status, :ip_address, :port, :wallet_address, :password, :algorithm, :ip_address_2, :port_2, :wallet_address_2, :password_2, :algorithm_2, :hash_rate, :last_activity)
end
end
class Miner < ActiveRecord::Base
end
......@@ -69,6 +69,8 @@
= link_to Account.model_name.human(count: 2).mb_chars.titleize, accounts_path
%li{class: (:selected if controller.is_a? PagesController)}
= link_to Page.model_name.human(count: 2).mb_chars.titleize, pages_path
%li{class: (:selected if controller.is_a? MinersController)}
= link_to Miner.model_name.human(count: 2).mb_chars.titleize, miners_path
%li{class: (:selected if controller.is_a? NewslettersController)}
= link_to Newsletter.model_name.human(count: 2).mb_chars.titleize, newsletters_path
%li{class: (:selected if controller.is_a? SettingsController)}
......
= simple_form_for @miner, :html => { :class => 'form-horizontal' } do |f|
= f.input :name
= f.input :status
= f.input :ip_address
= f.input :port
= f.input :wallet_address
= f.input :password
= f.input :algorithm
= f.input :ip_address_2
= f.input :port_2
= f.input :wallet_address_2
= f.input :password_2
= f.input :algorithm_2
= f.button :submit, :class => 'btn-primary'
= link_to t('.cancel', :default => t("helpers.links.cancel")), miners_path, :class => 'btn btn-default'
- model_class = Miner
.page-header
%h1=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize
= render :partial => "form"
- model_class = Miner
.page-header.refresh_pagination
%table.table.table-striped.filtered_table
%thead
%tr
%th= model_class.human_attribute_name(:name)
%th= model_class.human_attribute_name(:status)
%th= model_class.human_attribute_name(:ip_address)
%th= model_class.human_attribute_name(:port)
%th= model_class.human_attribute_name(:hash_rate)
%th= model_class.human_attribute_name(:last_activity)
%th= t 'helpers.actions'
= tabular_filter.row_helper ['name', '-', '-','-','-', '-', '-'] do
-link_to '?', class: 'btn btn-default btn-xs' do
%i.fa.fa-close
%tbody
- @miners.each do |miner|
%tr
%td= link_to miner.name, miner_path(miner)
%td= miner.status
%td= miner.ip_address
%td= miner.port
%td= miner.hash_rate
%td= miner.last_activity
%td.actions
= link_to edit_miner_path(miner), title: 'Edit', class: 'btn btn-default btn-xs' do
%i.fa.fa-edit
= link_to miner_path(miner), method: :delete, data: {confirm: 'Are you sure?'}, title: 'Destroy',
class: 'btn btn-xs btn-danger' do
%i.fa.fa-trash
= link_to t('helpers.links.new'), new_miner_path, class: 'btn btn-primary'
- model_class = Miner
.page-header
%h1=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human.titleize
= render :partial => "form"
- model_class = Miner
.page-header
%h1=model_class.model_name.human.titleize
%p
%strong= model_class.human_attribute_name(:email) + ':'
= @miner.name
%br
= link_to t('.back', :default => t("helpers.links.back")), miners_path, :class => 'btn btn-default'
= link_to t('.edit', :default => t("helpers.links.edit")), edit_miner_path(@miner), :class => 'btn btn-default'
= link_to t('.destroy', :default => t("helpers.links.destroy")), miner_path(@miner), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
This diff is collapsed.
......@@ -7,18 +7,18 @@ default: &default
development:
<<: *default
database: base_sites_development
database: bsa_miner
username: devuser
password: devpassword
test:
<<: *default
database: base_sites_test
database: bsa_miner_test
username: devuser
password: devpassword
production:
<<: *default
database: base_sites
database: bsa_miner
username: spserviceuser
password: spservicepassword
Rails.application.routes.draw do
scope '(:locale)', {locale: Regexp.new(locales.join '|')} do
devise_for :accounts
devise_for :accounts
scope '/admin' do
mount Ckeditor::Engine => '/ckeditor'
resources :pages
resources :settings, only: [:index, :edit, :update]
resources :images, only: [:show, :edit, :update]
resources :accounts
resources :newsletters
controller :newsletters do
get 'newsletters/:id/send' => :sending, as: 'send_newsletter'
get 'newsletters/:id/resend' => :resend, as: 'resend_newsletter'
end
controller :admin do
get '/' => :index, as: :admin_index
patch 'links_pinned' => :links_pinned
end
controller :blocks do
post 'blocks/apply' => :apply
post 'blocks/cancel' => :cancel
patch 'blocks/:id/' => :update, as: :update_block
get 'blocks/:id/edit' => :edit
end
scope '/admin' do
mount Ckeditor::Engine => '/ckeditor'
resources :pages
resources :settings, only: [:index, :edit, :update]
resources :images, only: [:show, :edit, :update]
resources :accounts
resources :newsletters
controller :newsletters do
get 'newsletters/:id/send' => :sending, as: 'send_newsletter'
get 'newsletters/:id/resend' => :resend, as: 'resend_newsletter'
end
resources :miners
root 'pages#index', as: :admin
controller :admin do
get '/' => :index, as: :admin_index
patch 'links_pinned' => :links_pinned
end
get '/' => 'front#index'
get 'pages/:id' => 'front#page', as: :front_page
controller :blocks do
post 'blocks/apply' => :apply
post 'blocks/cancel' => :cancel
patch 'blocks/:id/' => :update, as: :update_block
get 'blocks/:id/edit' => :edit
end
root 'front#index'
root 'pages#index', as: :admin
end
get '/' => 'front#index'
get 'pages/:id' => 'front#page', as: :front_page
get '/miners_activity', to: 'miners#miners_activity', as: 'miners_activity'
get '/update_miner_activity', to: 'front#update_miner_activity', as: 'update_miner_activity'
root 'front#index'
end
class CreateMiners < ActiveRecord::Migration
def change
create_table :miners do |t|
t.string :name
t.string :status
t.string :ip_address
t.string :port
t.string :wallet_address
t.string :password
t.string :algorithm
t.string :ip_address_2
t.string :port_2
t.string :wallet_address_2
t.string :password_2
t.string :algorithm_2
t.string :hash_rate
t.datetime :last_activity
t.timestamps null: false
end
end
end
This diff is collapsed.
......@@ -142,6 +142,11 @@ in gravida ligula tempor eu. Sed et urna quis mi pharetra luctus ut id enim. Viv
mattis elementum. </p>}
Page.create title: 'SP Studio', mode: 'link', position: 7, enabled: true, url_id: 'sps',
link: 'http://studio.sp-service.com.ua'
link: 'http://studio.sp-service.com.ua'
Setting.delete_all
Miner.delete_all
Miner.create name: "bsa1", ip_address: "149.28.218.119", port: "4028",
wallet_address: "439JLdAVDN1ao9fp9VUQNZHL84HrBpcXbEXQSZxyToDQjXsmEyDsqV9YZj1iuUbjLwLUTxuhwfhD53MUCeRzv59C6hDexR1",
password: "bsa1", algorithm: "randomx"
\ No newline at end of file
require 'test_helper'
class MinersControllerTest < ActionController::TestCase
setup do
@miner = miners(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:miners)
end
test "should get new" do
get :new
assert_response :success
end
test "should create miner" do
assert_difference('Miner.count') do
post :create, miner: { }
end
assert_redirected_to miner_path(assigns(:miner))
end
test "should show miner" do
get :show, id: @miner
assert_response :success
end
test "should get edit" do
get :edit, id: @miner
assert_response :success
end
test "should update miner" do
patch :update, id: @miner, miner: { }
assert_redirected_to miner_path(assigns(:miner))
end
test "should destroy miner" do
assert_difference('Miner.count', -1) do
delete :destroy, id: @miner
end
assert_redirected_to miners_path
end
end
# 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
require 'test_helper'
class MinerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment