thecore_ui_commons 2.1.8 → 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/thecore_ui_commons/thecore.js +1 -3
- data/config/initializers/charts_helper.rb +45 -0
- data/config/initializers/thecore_ui_commons_application_config.rb +3 -0
- data/{lib/helpers → config/initializers}/thecore_ui_commons_helper.rb +3 -1
- data/config/locales/en.yml +38 -27
- data/db/migrate/20200515070620_add_username_to_user.rb +39 -0
- data/lib/concerns/thecore_ui_commons_user.rb +2 -1
- data/lib/thecore_ui_commons.rb +6 -1
- data/lib/thecore_ui_commons/engine.rb +0 -5
- data/lib/thecore_ui_commons/version.rb +1 -1
- metadata +35 -7
- data/db/migrate/20190920115550_create_action_text_tables.action_text.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea33b6b025d99acfffd0c7409f2d43afdd08c943b1cde57a91b2ed2be2c39d6e
|
4
|
+
data.tar.gz: 74316d7395c7a3837b7c65588302c749dc1a09dddd1a56bdc17eb2fa2bc1206d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ecba4a7144e2797ad4fe9804f0de16206eb624e875317649fc10ade3f4c7880c4927760df332516fef7a05fdbcacb8ff6f209c18f291aae5f19c798e68c661d
|
7
|
+
data.tar.gz: 7ca7ca4aaafdafa5ec1abbf2f5baecf929b66319246c9cbc6d982410cebf030d7548c9161e60d742f20b3b3cdfc22adb615332fcd8f69ca8774fbd9d30cff8dc
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'date'
|
2
|
+
module Helpers
|
3
|
+
module ChartsHelper
|
4
|
+
def candlestick_data
|
5
|
+
@acc = rand(6570..6650)
|
6
|
+
60.times.map {|i| [Date.today - 60 + i, ohlc] }.to_h
|
7
|
+
end
|
8
|
+
|
9
|
+
def ohlc
|
10
|
+
open = @acc + rand(-20..20)
|
11
|
+
high = open + rand(0..100)
|
12
|
+
low = open - rand(0..100)
|
13
|
+
@acc = close = open + rand(-((high-low)/3)..((high-low)/2))
|
14
|
+
[open, high, low, close]
|
15
|
+
end
|
16
|
+
|
17
|
+
### HIGH PRIORITY CHARTS
|
18
|
+
def charts_high_pie_demo
|
19
|
+
pie_chart([{name: "Series A", data: 25},{name: "Series B", data: 100},{name: "Series C", data: 200},{name: "Series D", data: 125}], legend: "left")
|
20
|
+
end
|
21
|
+
|
22
|
+
def charts_high_candlestick_demo
|
23
|
+
candlestick_options = {plot_options: {candlestick: {colors: {upward: '#3C90EB',downward: '#DF7D46'}}}}
|
24
|
+
candlestick_chart(candlestick_data, candlestick_options)
|
25
|
+
end
|
26
|
+
|
27
|
+
### MEDIUM PRIORITY CHARTS
|
28
|
+
def charts_medium_radar_demo
|
29
|
+
radar_series = [{name: "What it should be",data: { "Code review"=>10, "Issues"=>5, "Pull request"=>25, "Commits"=>60 }},{name: "What it really is",data: { "Code review"=>1, "Issues"=>3, "Pull request"=>7, "Commits"=>89 }}]
|
30
|
+
radar_chart(radar_series,{title: "GitHub Radar", markers: {size: 4}, theme: 'palette4'})
|
31
|
+
end
|
32
|
+
|
33
|
+
def charts_medium_bubble_demo
|
34
|
+
bubble_series = (1..4).map do |n|{name: "Bubble#{n}",data: 20.times.map{[rand(750),rand(10..60),rand(70)]}}end
|
35
|
+
bubble_chart(bubble_series, data_labels: false, theme: 'palette6')
|
36
|
+
end
|
37
|
+
|
38
|
+
def charts_medium_range_demo
|
39
|
+
range_bar_series = [{name: "Series A",data: {'A' => [1, 5],'B' => [4, 6],'C' => [5, 8],'D' => [3, 11]}}, {name: "Series B",data: {'A' => [2, 6],'B' => [1, 3],'C' => [7, 8],'D' => [5, 9]}}]
|
40
|
+
range_bar_chart(range_bar_series, theme: 'palette3')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
ActiveSupport.on_load(:action_view) { include Helpers::ChartsHelper }
|
@@ -18,6 +18,9 @@ Rails.application.configure do
|
|
18
18
|
config.assets.precompile += %w( thecore_ui_commons/thecore.css )
|
19
19
|
# Very important, needed for trix (i.e.)
|
20
20
|
config.assets.paths << root.join('node_modules')
|
21
|
+
# To store D3 Data
|
22
|
+
# https://medium.com/@hguotblog/use-d3-js-for-data-visualisation-with-rails-69b4f030e366
|
23
|
+
config.assets.paths << root.join('data')
|
21
24
|
# Putting also a reference on the assets foldes in the paths, so to have the
|
22
25
|
# stylesheet and javascript hack work proprly in layout
|
23
26
|
# config.assets.paths <<
|
data/config/locales/en.yml
CHANGED
@@ -1,33 +1,44 @@
|
|
1
|
-
# Files in the config/locales directory are used for internationalization
|
2
|
-
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
-
# than English, add the necessary files in this directory.
|
4
|
-
#
|
5
|
-
# To use the locales, use `I18n.t`:
|
6
|
-
#
|
7
|
-
# I18n.t 'hello'
|
8
|
-
#
|
9
|
-
# In views, this is aliased to just `t`:
|
10
|
-
#
|
11
|
-
# <%= t('hello') %>
|
12
|
-
#
|
13
|
-
# To use a different locale, set it with `I18n.locale`:
|
14
|
-
#
|
15
|
-
# I18n.locale = :es
|
16
|
-
#
|
17
|
-
# This would use the information in config/locales/es.yml.
|
18
|
-
#
|
19
|
-
# To learn more, please read the Rails Internationalization guide
|
20
|
-
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
-
|
22
1
|
en:
|
23
|
-
current_user: Current
|
24
|
-
hello:
|
25
|
-
dashboard:
|
26
|
-
contact:
|
27
|
-
manage:
|
28
|
-
sign_out:
|
2
|
+
current_user: Current User
|
3
|
+
hello: Hello World
|
4
|
+
dashboard: Dashboard
|
5
|
+
contact: Help us
|
6
|
+
manage: Manage
|
7
|
+
sign_out: Sign Out
|
8
|
+
advanced: Advanced
|
9
|
+
main_records: Registries
|
10
|
+
errors:
|
11
|
+
messages:
|
12
|
+
invalid: Invalid characters
|
13
|
+
tiered_times:
|
14
|
+
dd:
|
15
|
+
zero: "0 Days"
|
16
|
+
one: "%{count} Day"
|
17
|
+
other: "%{count} Days"
|
18
|
+
hh:
|
19
|
+
zero: "0 Hours"
|
20
|
+
one: "%{count} Hour"
|
21
|
+
other: "%{count} Hours"
|
22
|
+
mm:
|
23
|
+
zero: "0 Minutes"
|
24
|
+
one: "%{count} Minute"
|
25
|
+
other: "%{count} Minutes"
|
26
|
+
ss:
|
27
|
+
zero: "0 Seconds"
|
28
|
+
one: "%{count} Second"
|
29
|
+
other: "%{count} Seconds"
|
29
30
|
admin:
|
30
31
|
links:
|
31
32
|
label: Links
|
33
|
+
tools:
|
34
|
+
label: Tools
|
32
35
|
settings:
|
36
|
+
label: Settings
|
33
37
|
advanced: Advanced
|
38
|
+
registries: Registries
|
39
|
+
operations: Operations
|
40
|
+
actions:
|
41
|
+
charts:
|
42
|
+
menu: Analisys
|
43
|
+
title: Charts
|
44
|
+
breadcrumb: Charts
|
@@ -1,4 +1,43 @@
|
|
1
1
|
class AddUsernameToUser < ActiveRecord::Migration[6.0]
|
2
|
+
class User < ApplicationRecord
|
3
|
+
# Include default devise modules. Others available are:
|
4
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
5
|
+
devise :database_authenticatable, :trackable, :validatable
|
6
|
+
# TODO: If it works, these must be added to another gem one which deal
|
7
|
+
# more with sessions
|
8
|
+
# devise :database_authenticatable
|
9
|
+
# devise :rememberable
|
10
|
+
# devise :trackable
|
11
|
+
# devise :validatable
|
12
|
+
# devise :timeoutable, timeout_in: 30.minutes
|
13
|
+
# REFERENCES
|
14
|
+
has_many :role_users, dependent: :destroy, inverse_of: :user
|
15
|
+
has_many :roles, through: :role_users, inverse_of: :users
|
16
|
+
# VALIDATIONS
|
17
|
+
validates :email, uniqueness: { case_sensitive: false }, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }
|
18
|
+
validates :password, presence: true, on: :create
|
19
|
+
validates :password_confirmation, presence: true, on: :create
|
20
|
+
validate :check_password_and_confirmation_equal
|
21
|
+
validates_each :admin do |record, attr, value|
|
22
|
+
# Don't want admin == false if the current user is the only admin
|
23
|
+
record.errors.add(attr, I18n.t("validation.errors.cannot_unadmin_last_admin")) if record.admin_changed? && record.admin_was == true && User.where(admin: true).count == 1
|
24
|
+
end
|
25
|
+
|
26
|
+
def display_name
|
27
|
+
email
|
28
|
+
end
|
29
|
+
|
30
|
+
def has_role? role
|
31
|
+
roles.include? role
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def check_password_and_confirmation_equal
|
37
|
+
errors.add(:password, I18n.t("validation.errors.password_and_confirm_must_be_the_same")) unless password == password_confirmation
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
2
41
|
def change
|
3
42
|
add_column :users, :username, :string
|
4
43
|
add_index :users, :username
|
@@ -5,6 +5,8 @@ module ThecoreUiCommonsUser
|
|
5
5
|
|
6
6
|
included do
|
7
7
|
devise :database_authenticatable, :trackable, :validatable, :rememberable, :timeoutable, timeout_in: 30.minutes, authentication_keys: [:login]
|
8
|
+
validates :username, uniqueness: { case_sensitive: false }, presence: true, length: { in: 4..15 }
|
9
|
+
validates_format_of :username, with: /\A[a-zA-Z0-9]*\z/, on: :create, message: "can only contain letters and digits"
|
8
10
|
|
9
11
|
attr_writer :login
|
10
12
|
|
@@ -13,7 +15,6 @@ module ThecoreUiCommonsUser
|
|
13
15
|
end
|
14
16
|
# Use login
|
15
17
|
def self.find_first_by_auth_conditions(warden_conditions)
|
16
|
-
puts "################################ VIENE USATO? #####################################################"
|
17
18
|
conditions = warden_conditions.dup
|
18
19
|
if login = conditions.delete(:login)
|
19
20
|
where(conditions.to_h).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
|
data/lib/thecore_ui_commons.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'thecore_background_jobs' # This brings backend commons also.
|
2
2
|
# Rails
|
3
3
|
require 'serviceworker-rails'
|
4
|
+
require "groupdate"
|
5
|
+
require "apexcharts"
|
4
6
|
|
5
7
|
require 'concerns/thecore_ui_commons_user'
|
6
8
|
|
9
|
+
# require 'helpers/thecore_ui_commons_helper'
|
10
|
+
# require 'helpers/charts_helper'
|
11
|
+
|
7
12
|
require "thecore_ui_commons/engine"
|
8
13
|
|
9
14
|
module ThecoreUiCommons
|
@@ -1,10 +1,5 @@
|
|
1
|
-
require 'helpers/thecore_ui_commons_helper'
|
2
1
|
module ThecoreUiCommons
|
3
2
|
class Engine < ::Rails::Engine
|
4
|
-
initializer "thecore_ui_commons.view_helpers" do
|
5
|
-
ActiveSupport.on_load(:action_view) { include Helpers::ThecoreUiCommonsHelper }
|
6
|
-
end
|
7
|
-
|
8
3
|
initializer 'thecore_ui_commons.add_to_migrations' do |app|
|
9
4
|
unless app.root.to_s.match root.to_s
|
10
5
|
# APPEND TO MAIN APP MIGRATIONS FROM THIS GEM
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thecore_ui_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: thecore_background_jobs
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: serviceworker-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: groupdate
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: apexcharts
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.1'
|
41
69
|
description: Engine to serve configurations and rails module useful for all the UIs.
|
42
70
|
email:
|
43
71
|
- gabriele.tassoni@gmail.com
|
@@ -97,7 +125,9 @@ files:
|
|
97
125
|
- app/views/layouts/mailer.html.erb
|
98
126
|
- app/views/layouts/mailer.text.erb
|
99
127
|
- app/views/layouts/thecore.html.erb
|
128
|
+
- config/initializers/charts_helper.rb
|
100
129
|
- config/initializers/thecore_ui_commons_application_config.rb
|
130
|
+
- config/initializers/thecore_ui_commons_helper.rb
|
101
131
|
- config/locales/en.ra_settings.yml
|
102
132
|
- config/locales/en.simple_form.yml
|
103
133
|
- config/locales/en.yml
|
@@ -105,11 +135,9 @@ files:
|
|
105
135
|
- config/locales/it.simple_form.yml
|
106
136
|
- config/locales/it.yml
|
107
137
|
- config/routes.rb
|
108
|
-
- db/migrate/20190920115550_create_action_text_tables.action_text.rb
|
109
138
|
- db/migrate/20200515070620_add_username_to_user.rb
|
110
139
|
- db/migrate/20200515132932_add_rememberable_to_user.rb
|
111
140
|
- lib/concerns/thecore_ui_commons_user.rb
|
112
|
-
- lib/helpers/thecore_ui_commons_helper.rb
|
113
141
|
- lib/tasks/thecore_ui_commons_tasks.rake
|
114
142
|
- lib/thecore_ui_commons.rb
|
115
143
|
- lib/thecore_ui_commons/engine.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# This migration comes from action_text (originally 20180528164100)
|
2
|
-
class CreateActionTextTables < ActiveRecord::Migration[6.0]
|
3
|
-
def change
|
4
|
-
create_table :action_text_rich_texts do |t|
|
5
|
-
t.string :name, null: false
|
6
|
-
t.text :body, size: :long
|
7
|
-
t.references :record, null: false, polymorphic: true, index: false
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
|
11
|
-
t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|