thecore_ui_commons 2.1.7 → 2.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4143e4e7f04c0e8f7c20087478451c3d21a23159f9a46c7d1538a9116fdca4a
4
- data.tar.gz: d87ab5529a8abc0289a51fb72cd0989e3ef13678e24acfcd4d9b1a46fec08474
3
+ metadata.gz: d9f7aac2f4ddbb633d8dcb66dcddcbad97048fc61465a795485e54b1ea046dcc
4
+ data.tar.gz: f1bcb8e2baaa71d7c51eb480d5f7ce830612691d486f4077918ffa98867b8044
5
5
  SHA512:
6
- metadata.gz: c3a89897b04d5c57d7c441b8e374e5995f9e9cc97ec361d0d87f3328f2900905d6d2e746e3bcee42bbca815d8702ba70104ed353d14189382059f3bd982d2afe
7
- data.tar.gz: ecd1c9c5c3040ec9c30b26174ecd8b1dd9ba6a6b95bfac301f837ef548b1ccd409a78e318c60cac3e2fb24be63570c7e276ea6235cd053597ca53ff60b894b3d
6
+ metadata.gz: 0001dd702d33688143879408db4cdc08c0009405b9f1c23bbed90d02c33abc210f3c5f6f4e1ccaf57eb27b927efbee4cd5f6818c5224772825579c89ce97ce4e
7
+ data.tar.gz: b529965589247146cf64fd6fa4075fa8bc2fc5ea63b5f6376cfc3ac5617c6ff80d3f9c18a56aa6c80dac6bc33d716cd8d21c70e31bb29554ccd6af12e10c325f
@@ -5,5 +5,4 @@
5
5
  //= require bootstrap
6
6
  //= require ie
7
7
  //= require timer
8
- //= require trix
9
- //= require_tree .
8
+ //= require apexcharts
@@ -3,7 +3,7 @@
3
3
  // the trix-editor content (whether displayed or under editing). Feel free to incorporate this
4
4
  // inclusion directly in any other asset bundle and remove this file.
5
5
  //
6
- //= require trix
6
+ //= require trix/dist/trix
7
7
 
8
8
  // We need to override trix.css’s image gallery styles to accommodate the
9
9
  // <action-text-attachment> element we wrap around attachments. Otherwise,
@@ -16,3 +16,7 @@
16
16
  *= require_self
17
17
  */
18
18
  @import 'actiontext.scss';
19
+
20
+ #new_user div {
21
+ margin-bottom: .5em;
22
+ }
@@ -1,13 +1,11 @@
1
1
  <div class="col-md-4 col-md-offset-4">
2
2
  <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
3
3
  <div class="field">
4
- <%= f.label :login %><br />
5
- <%= f.text_field :login, autofocus: true, :class => "form-control" %>
4
+ <%= f.text_field :login, autofocus: true, :class => "form-control", placeholder: t("devise.sessions.new.login") %>
6
5
  </div>
7
6
 
8
7
  <div class="field">
9
- <%= f.label :password %><br />
10
- <%= f.password_field :password, autocomplete: "off", :class => "form-control" %>
8
+ <%= f.password_field :password, autocomplete: "off", :class => "form-control", placeholder: t("devise.sessions.new.password") %>
11
9
  </div>
12
10
 
13
11
  <% if devise_mapping.rememberable? -%>
@@ -20,7 +18,7 @@
20
18
  <% end -%>
21
19
 
22
20
  <div class="actions">
23
- <%= f.submit t("devise.sessions.new.sign_in"), :class => "btn btn-warning" %>
21
+ <%= f.submit t("devise.sessions.new.sign_in"), :class => "btn" %>
24
22
 
25
23
  <%= render "devise/shared/links" %>
26
24
  </div>
@@ -10,13 +10,10 @@
10
10
  <%= tag("link", rel: "manifest", href: asset_path("manifest.json", skip_pipeline: true)) %>
11
11
  <meta name="turbolinks-cache-control" content="no-cache">
12
12
 
13
- <%-Rails.application.config.assets.paths.each do |p| %>
14
13
  <%# Getting all the assets needed by thecore from all the gems %>
15
- <%= stylesheet_link_tag("#{p.to_s.split("/").last}/thecore", media: 'all', 'data-turbolinks-track' => true) if File.exists?("#{p}/thecore.scss") %>
16
- <%= javascript_include_tag("#{Dir["#{p}/**/thecore.js"].first.split("/")[-2]}/thecore", 'data-turbolinks-track' => true) if Dir["#{p}/**/thecore.js"].any? %>
17
- <%-end%>
18
- <%= stylesheet_link_tag('application', media: 'all', 'data-turbolinks-track' => true) if ::Rails.application.assets.find_asset("application.css")%>
19
- <%= javascript_include_tag('application', 'data-turbolinks-track' => true) if ::Rails.application.assets.find_asset("application.js") %>
14
+ <%= get_asset_tags_for("thecore")%>
15
+ <%= stylesheet_link_tag('application', media: 'all', 'data-turbolinks-track' => true) if (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset("application.css")%>
16
+ <%= javascript_include_tag('application', 'data-turbolinks-track' => true) if (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset("application.js") %>
20
17
 
21
18
  <%= favicon_link_tag 'apple-touch-icon.png', rel: 'apple-touch-icon', sizes: "180x180" %>
22
19
  <%= favicon_link_tag 'favicon-32x32.png', rel: 'icon', sizes: "32x32" %>
@@ -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 }
@@ -16,7 +16,17 @@ Rails.application.configure do
16
16
  config.assets.precompile += %w( browserconfig.xml )
17
17
  config.assets.precompile += %w( thecore_ui_commons/thecore.js )
18
18
  config.assets.precompile += %w( thecore_ui_commons/thecore.css )
19
- config.assets.paths << Rails.root.join('node_modules')
19
+ # Very important, needed for trix (i.e.)
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')
24
+ # Putting also a reference on the assets foldes in the paths, so to have the
25
+ # stylesheet and javascript hack work proprly in layout
26
+ # config.assets.paths <<
27
+ # root.join("app", "assets", "stylesheets", "thecore_ui_commons")
28
+ # config.assets.paths <<
29
+ # root.join("app", "assets", "javascripts", "thecore_ui_commons")
20
30
  # config.action_controller.asset_host = if ENV['RAILS_URL'].blank? || ENV['RAILS_RELATIVE_URL_ROOT'].blank?
21
31
  # "http://localhost:3000"
22
32
  # else
@@ -0,0 +1,22 @@
1
+ module Helpers
2
+ module ThecoreUiCommonsHelper
3
+ def get_asset_tags_for(basename)
4
+ out = []
5
+ # Needs to reverse since Paths are traversed in the order they occur in the search path. By default, this means the files in app/assets take precedence, and will mask corresponding paths in lib and vendor.
6
+ Rails.application.config.assets.paths.reverse.each do |basedir|
7
+ base = "#{basedir}/**/#{basename}"
8
+ base_s = Dir["#{base}.scss"]
9
+ base_j = Dir["#{base}.js"]
10
+ out << stylesheet_link_tag("#{get_folder base_s}/#{basename}", media: 'all', 'data-turbolinks-track' => true) if base_s.any?
11
+ out << javascript_include_tag("#{get_folder base_j}/#{basename}", 'data-turbolinks-track' => true) if base_j.any?
12
+ end
13
+ out.join("\n ").html_safe
14
+ end
15
+
16
+ def get_folder(base)
17
+ base.first.split("/")[-2]
18
+ end
19
+ end
20
+ end
21
+
22
+ ActiveSupport.on_load(:action_view) { include Helpers::ThecoreUiCommonsHelper }
@@ -0,0 +1,4 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ rails_admin_settings/setting: Configurations
@@ -0,0 +1,49 @@
1
+ en:
2
+ current_user: Current User
3
+ devise:
4
+ sessions:
5
+ new:
6
+ login: Login
7
+ password: Password
8
+ hello: Hello World
9
+ dashboard: Dashboard
10
+ contact: Help us
11
+ manage: Manage
12
+ sign_out: Sign Out
13
+ advanced: Advanced
14
+ main_records: Registries
15
+ errors:
16
+ messages:
17
+ invalid: Invalid characters
18
+ tiered_times:
19
+ dd:
20
+ zero: "0 Days"
21
+ one: "%{count} Day"
22
+ other: "%{count} Days"
23
+ hh:
24
+ zero: "0 Hours"
25
+ one: "%{count} Hour"
26
+ other: "%{count} Hours"
27
+ mm:
28
+ zero: "0 Minutes"
29
+ one: "%{count} Minute"
30
+ other: "%{count} Minutes"
31
+ ss:
32
+ zero: "0 Seconds"
33
+ one: "%{count} Second"
34
+ other: "%{count} Seconds"
35
+ admin:
36
+ links:
37
+ label: Links
38
+ tools:
39
+ label: Tools
40
+ settings:
41
+ label: Settings
42
+ advanced: Advanced
43
+ registries: Registries
44
+ operations: Operations
45
+ actions:
46
+ charts:
47
+ menu: Analisys
48
+ title: Charts
49
+ breadcrumb: Charts
@@ -0,0 +1,4 @@
1
+ it:
2
+ activerecord:
3
+ models:
4
+ rails_admin_settings/setting: Configurations
@@ -0,0 +1,49 @@
1
+ it:
2
+ current_user: Utente corrente
3
+ hello: "Ciao Mondo"
4
+ dashboard: "Pannello di controllo"
5
+ contact: "Aiutaci a Migliorare"
6
+ manage: "Gestione"
7
+ sign_out: "Uscita"
8
+ advanced: Impostazioni
9
+ main_records: Anagrafiche
10
+ devise:
11
+ sessions:
12
+ new:
13
+ login: Login
14
+ password: Password
15
+ errors:
16
+ messages:
17
+ invalid: contiene caratteri invalidi
18
+ tiered_times:
19
+ dd:
20
+ zero: "0 Giorni"
21
+ one: "%{count} Giorno"
22
+ other: "%{count} Giorni"
23
+ hh:
24
+ zero: "0 Ore"
25
+ one: "%{count} Ora"
26
+ other: "%{count} Ore"
27
+ mm:
28
+ zero: "0 Minuti"
29
+ one: "%{count} Minuto"
30
+ other: "%{count} Minuti"
31
+ ss:
32
+ zero: "0 Secondi"
33
+ one: "%{count} Secondo"
34
+ other: "%{count} Secondi"
35
+ admin:
36
+ links:
37
+ label: Collegamenti
38
+ tools:
39
+ label: "Strumenti"
40
+ settings:
41
+ label: Impostazioni
42
+ advanced: Avanzate
43
+ registries: Anagrafiche
44
+ operations: Operatività
45
+ actions:
46
+ charts:
47
+ menu: Analisi
48
+ title: Grafici
49
+ breadcrumb: Grafici
@@ -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
@@ -1,9 +1,14 @@
1
- require 'thecore_backend_commons'
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,3 +1,3 @@
1
1
  module ThecoreUiCommons
2
- VERSION = '2.1.7'
2
+ VERSION = '2.1.12'
3
3
  end
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.7
4
+ version: 2.1.12
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-17 00:00:00.000000000 Z
11
+ date: 2020-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: thecore_backend_commons
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.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.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
@@ -65,11 +93,8 @@ files:
65
93
  - app/assets/javascripts/pages.coffee
66
94
  - app/assets/javascripts/thecore_ui_commons/thecore.js
67
95
  - app/assets/javascripts/timer.js
68
- - app/assets/javascripts/trix-core.js
69
- - app/assets/javascripts/trix.js
70
96
  - app/assets/stylesheets/thecore_ui_commons/actiontext.scss
71
97
  - app/assets/stylesheets/thecore_ui_commons/thecore.scss
72
- - app/assets/stylesheets/trix.css
73
98
  - app/controllers/application_controller.rb
74
99
  - app/views/active_storage/blobs/_blob.html.erb
75
100
  - app/views/contact_mailer/contact_message.html.erb
@@ -100,11 +125,16 @@ files:
100
125
  - app/views/layouts/mailer.html.erb
101
126
  - app/views/layouts/mailer.text.erb
102
127
  - app/views/layouts/thecore.html.erb
128
+ - config/initializers/charts_helper.rb
103
129
  - config/initializers/thecore_ui_commons_application_config.rb
130
+ - config/initializers/thecore_ui_commons_helper.rb
131
+ - config/locales/en.ra_settings.yml
104
132
  - config/locales/en.simple_form.yml
133
+ - config/locales/en.yml
134
+ - config/locales/it.ra_settings.yml
105
135
  - config/locales/it.simple_form.yml
136
+ - config/locales/it.yml
106
137
  - config/routes.rb
107
- - db/migrate/20190920115550_create_action_text_tables.action_text.rb
108
138
  - db/migrate/20200515070620_add_username_to_user.rb
109
139
  - db/migrate/20200515132932_add_rememberable_to_user.rb
110
140
  - lib/concerns/thecore_ui_commons_user.rb