thecore_ui_commons 2.1.6 → 2.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d71a88aedf5e29fd308b9fc96059e6ba86920276f15e4598cf022227aadaaa10
4
- data.tar.gz: 4beab2991ffdb24463709959e9fc63a600cb978e61dd4fa4b2a79c8bc7007a75
3
+ metadata.gz: 35e973462c71403a22fa0a4c9b0f0e6ae829d033b6fccf41dc9598a29d416ada
4
+ data.tar.gz: 0071ef14d44a19a2de1186117a8c40734aed3985b7c7af301d6e6b1288e228db
5
5
  SHA512:
6
- metadata.gz: 281cbf4a31a5b0cb7482d8c31da18c26737548a72fb5625a65c73ab51c8cdedcfaf4367e6b1557b6329dee01c62daab2d9ea45513c160d89b381e46028d7b9de
7
- data.tar.gz: 055dc5d18c7ef103bdc07f56d9035d2b7db7df31af825accf913b748dea77b868bd862e8e372852cbd470f6761fe3c8827e86cdd8e6dd7ce70478e01e0f244a5
6
+ metadata.gz: 1bb36d792e8bfdef00a42a874d451701ad788bad55d4f9a3ebcd5293a6be0e3540d5758d8875394916c4c22a8f5dbd30f672c5dcf6eabe7ac09f145699942cc1
7
+ data.tar.gz: f3fb4c6db173f572d4745fd54fd27e85b44b93c524cebdf100d83c71305141fcd27e5dc471f463a6a0d02e8e3d70cec9f211ca3122180e311ef412d1fc7fc306
@@ -1,2 +0,0 @@
1
- require("trix")
2
- require("@rails/actiontext")
@@ -0,0 +1,8 @@
1
+ //= require jquery
2
+ //= require jquery-ui
3
+ //= require jquery-ui/widgets/dialog
4
+ //= require jquery_ujs
5
+ //= require bootstrap
6
+ //= require ie
7
+ //= require timer
8
+ //= require apexcharts
@@ -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 :email %><br />
5
- <%= f.text_field :email, autofocus: true, :class => "form-control" %>
4
+ <%= f.text_field :login, autofocus: true, :class => "form-control", placeholder: t(: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(: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>
@@ -9,9 +9,12 @@
9
9
 
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
- <%= stylesheet_link_tag 'thecore', media: 'all', 'data-turbolinks-track' => true %>
13
- <%= javascript_include_tag 'thecore', 'data-turbolinks-track' => true %>
14
12
 
13
+ <%# Getting all the assets needed by thecore from all the gems %>
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") %>
17
+
15
18
  <%= favicon_link_tag 'apple-touch-icon.png', rel: 'apple-touch-icon', sizes: "180x180" %>
16
19
  <%= favicon_link_tag 'favicon-32x32.png', rel: 'icon', sizes: "32x32" %>
17
20
  <%= favicon_link_tag 'favicon-16x16.png', rel: 'icon', sizes: "16x16" %>
@@ -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 }
@@ -1,5 +1,4 @@
1
1
  Rails.application.configure do
2
- config.assets.precompile += %w( thecore_ui_commons/index.js thecore_ui_commons/index.css )
3
2
  config.assets.precompile += %w( favicon.ico )
4
3
  config.assets.precompile += %w( apple-touch-icon.png )
5
4
  config.assets.precompile += %w( favicon-32x32.png )
@@ -15,22 +14,34 @@ Rails.application.configure do
15
14
  config.assets.precompile += %w( ie.js )
16
15
  config.assets.precompile += %w( manifest.json )
17
16
  config.assets.precompile += %w( browserconfig.xml )
18
-
17
+ config.assets.precompile += %w( thecore_ui_commons/thecore.js )
18
+ config.assets.precompile += %w( thecore_ui_commons/thecore.css )
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")
19
30
  # config.action_controller.asset_host = if ENV['RAILS_URL'].blank? || ENV['RAILS_RELATIVE_URL_ROOT'].blank?
20
31
  # "http://localhost:3000"
21
32
  # else
22
33
  # "#{ENV['RAILS_URL']}#{ENV['RAILS_RELATIVE_URL_ROOT']}"
23
34
  # end
24
-
35
+
25
36
  config.filter_parameters += [:password]
26
-
37
+
27
38
  config.active_record.raise_in_transactional_callbacks = true
28
-
39
+
29
40
  config.serviceworker.routes.draw do
30
41
  match "/manifest.json"
31
42
  end
32
-
43
+
33
44
  config.after_initialize do
34
45
  User.send(:include, ThecoreUiCommonsUser)
35
- end
46
+ end
36
47
  end
@@ -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,44 @@
1
+ en:
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"
30
+ admin:
31
+ links:
32
+ label: Links
33
+ tools:
34
+ label: Tools
35
+ settings:
36
+ label: Settings
37
+ advanced: Advanced
38
+ registries: Registries
39
+ operations: Operations
40
+ actions:
41
+ charts:
42
+ menu: Analisys
43
+ title: Charts
44
+ breadcrumb: Charts
@@ -0,0 +1,4 @@
1
+ it:
2
+ activerecord:
3
+ models:
4
+ rails_admin_settings/setting: Configurations
@@ -0,0 +1,44 @@
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
+ errors:
11
+ messages:
12
+ invalid: contiene caratteri invalidi
13
+ tiered_times:
14
+ dd:
15
+ zero: "0 Giorni"
16
+ one: "%{count} Giorno"
17
+ other: "%{count} Giorni"
18
+ hh:
19
+ zero: "0 Ore"
20
+ one: "%{count} Ora"
21
+ other: "%{count} Ore"
22
+ mm:
23
+ zero: "0 Minuti"
24
+ one: "%{count} Minuto"
25
+ other: "%{count} Minuti"
26
+ ss:
27
+ zero: "0 Secondi"
28
+ one: "%{count} Secondo"
29
+ other: "%{count} Secondi"
30
+ admin:
31
+ links:
32
+ label: Collegamenti
33
+ tools:
34
+ label: "Strumenti"
35
+ settings:
36
+ label: Impostazioni
37
+ advanced: Avanzate
38
+ registries: Anagrafiche
39
+ operations: Operatività
40
+ actions:
41
+ charts:
42
+ menu: Analisi
43
+ title: Grafici
44
+ breadcrumb: Grafici
@@ -1,9 +1,51 @@
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
44
 
45
+ puts "Computing username for existing emails"
46
+ User.reset_column_information
6
47
  User.all.each do |u|
48
+ puts "User: #{u.email} into #{u.email.split("@").first}"
7
49
  u.username = u.email.split("@").first
8
50
  u.save!
9
51
  end
@@ -4,7 +4,26 @@ module ThecoreUiCommonsUser
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- devise :rememberable
8
- devise :timeoutable, timeout_in: 30.minutes
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"
10
+
11
+ attr_writer :login
12
+
13
+ def login
14
+ @login || self.username || self.email
15
+ end
16
+ # Use login
17
+ def self.find_first_by_auth_conditions(warden_conditions)
18
+ conditions = warden_conditions.dup
19
+ if login = conditions.delete(:login)
20
+ where(conditions.to_h).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
21
+ elsif conditions.has_key?(:username) || conditions.has_key?(:email)
22
+ # Case insensitive login
23
+ conditions[:email].downcase! if conditions[:email]
24
+ conditions[:username].downcase! if conditions[:username]
25
+ where(conditions.to_h).first
26
+ end
27
+ end
9
28
  end
10
29
  end
@@ -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.6'
2
+ VERSION = '2.1.11'
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.6
4
+ version: 2.1.11
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-15 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
@@ -49,12 +77,6 @@ files:
49
77
  - README.md
50
78
  - Rakefile
51
79
  - app/assets/config/thecore_ui_commons_manifest.js
52
- - app/assets/config/trix/LICENSE
53
- - app/assets/config/trix/README.md
54
- - app/assets/config/trix/dist/trix-core.js
55
- - app/assets/config/trix/dist/trix.css
56
- - app/assets/config/trix/dist/trix.js
57
- - app/assets/config/trix/package.json
58
80
  - app/assets/images/android-chrome-192x192.png
59
81
  - app/assets/images/android-chrome-512x512.png
60
82
  - app/assets/images/apple-touch-icon.png
@@ -69,10 +91,10 @@ files:
69
91
  - app/assets/javascripts/ie.js
70
92
  - app/assets/javascripts/manifest.json
71
93
  - app/assets/javascripts/pages.coffee
72
- - app/assets/javascripts/thecore.js
94
+ - app/assets/javascripts/thecore_ui_commons/thecore.js
73
95
  - app/assets/javascripts/timer.js
74
- - app/assets/stylesheets/actiontext.scss
75
- - app/assets/stylesheets/thecore.scss
96
+ - app/assets/stylesheets/thecore_ui_commons/actiontext.scss
97
+ - app/assets/stylesheets/thecore_ui_commons/thecore.scss
76
98
  - app/controllers/application_controller.rb
77
99
  - app/views/active_storage/blobs/_blob.html.erb
78
100
  - app/views/contact_mailer/contact_message.html.erb
@@ -103,12 +125,16 @@ files:
103
125
  - app/views/layouts/mailer.html.erb
104
126
  - app/views/layouts/mailer.text.erb
105
127
  - app/views/layouts/thecore.html.erb
106
- - app/views/shared/_flash.html.erb
128
+ - config/initializers/charts_helper.rb
107
129
  - config/initializers/thecore_ui_commons_application_config.rb
130
+ - config/initializers/thecore_ui_commons_helper.rb
131
+ - config/locales/en.ra_settings.yml
108
132
  - config/locales/en.simple_form.yml
133
+ - config/locales/en.yml
134
+ - config/locales/it.ra_settings.yml
109
135
  - config/locales/it.simple_form.yml
136
+ - config/locales/it.yml
110
137
  - config/routes.rb
111
- - db/migrate/20190920115550_create_action_text_tables.action_text.rb
112
138
  - db/migrate/20200515070620_add_username_to_user.rb
113
139
  - db/migrate/20200515132932_add_rememberable_to_user.rb
114
140
  - lib/concerns/thecore_ui_commons_user.rb