thecore_ui_commons 3.3.4 → 3.3.6
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 +4 -4
- data/README.md +27 -1
- data/app/controllers/info_controller.rb +5 -3
- data/app/views/info/swagger.html.erb +55 -28
- data/app/views/layouts/swagger.html.erb +1 -5
- data/config/locales/en.ra_settings.yml +5 -3
- data/config/locales/it.yml +19 -19
- data/config/routes.rb +3 -2
- data/lib/thecore_ui_commons/version.rb +1 -1
- data/lib/thecore_ui_commons.rb +19 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d1091f859ef05f14096826e8d5cd82712958819de284543dfc26120e90c0dc4
|
|
4
|
+
data.tar.gz: aea72ad38d7f5ac1f53af37faef3fc7f3f5b8d7f0000f918bb568093950433f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a7096802f754f1f38d48adaf8491798e61f1cf725d850e53f5f7d40e209ecab3470371e04dc2d4bad5716fa5dcf27f1accfd0cab7c03693d30d54e8e244c9da
|
|
7
|
+
data.tar.gz: acc0f1101c996dab5ccce5673f0e415265fa3e49437c6f7cecba832d96909756e5927ecd2bc39bf3e7b62b00e7e42ed3966881625955974c989ee0b5b08b5b4d
|
data/README.md
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
# thecore_ui_commons
|
|
2
|
+
|
|
3
|
+
A Rails engine providing shared UI artifacts for [Thecore](https://github.com/gabrieletassoni/thecore/tree/release/3)-based host applications.
|
|
4
|
+
|
|
5
|
+
## What it provides
|
|
6
|
+
|
|
7
|
+
- **Layouts** — Devise session page, Swagger UI, mailer (HTML + text)
|
|
8
|
+
- **Partials** — Bootstrap flash alerts, Kaminari pagination, drag-drop file uploader, logos
|
|
9
|
+
- **ECharts helpers** — Ruby classes for building Apache ECharts config server-side (`Vector`, `MultipleVectors`, `Binary`, `BinarySeries`, `Speedometer`, `Map`)
|
|
10
|
+
- **Swagger versioning** — `/info/swagger/:version` with automatic version discovery from mounted routes
|
|
11
|
+
- **Assets** — shared CSS/JS manifests, Active Job monitor, Devise i18n injection
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Add to your host app's `Gemfile`:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'thecore_ui_commons', '~> 3.0'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The engine mounts automatically. No configuration required.
|
|
22
|
+
|
|
23
|
+
## Swagger UI
|
|
24
|
+
|
|
25
|
+
The Swagger UI is available at `/info/swagger` (redirects to `/info/swagger/v2`).
|
|
26
|
+
|
|
27
|
+
If your app mounts `model_driven_api`, the engine discovers all available API versions at startup by scanning `Rails.application.routes` for paths matching `api/vN/info/swagger`. A version nav banner appears automatically above the Swagger UI — no configuration needed.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
class InfoController < ApplicationController
|
|
2
|
-
# This is a model-less controller just to render che swagger page using a custom layout
|
|
3
2
|
layout 'swagger'
|
|
4
3
|
def swagger
|
|
4
|
+
@version = params[:version].to_s.gsub(/[^a-zA-Z0-9]/, '')
|
|
5
|
+
@versions = ThecoreUiCommons.swagger_api_versions
|
|
5
6
|
uri = URI(request.url)
|
|
6
|
-
@
|
|
7
|
+
@base_url = "#{uri.scheme}://#{uri.host}#{":#{uri.port}" if uri.port.present?}#{ENV.fetch("RAILS_RELATIVE_URL_ROOT", "")}"
|
|
8
|
+
@swagger_json_url = "#{@base_url}/api/#{@version}/info/swagger.json"
|
|
7
9
|
end
|
|
8
|
-
end
|
|
10
|
+
end
|
|
@@ -1,28 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</
|
|
1
|
+
<% if @versions.length > 1 %>
|
|
2
|
+
<% content_for :version_nav do %>
|
|
3
|
+
<style>
|
|
4
|
+
#version-nav {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 0.4rem;
|
|
8
|
+
padding: 0.55rem 1rem;
|
|
9
|
+
background: #f1f5f9;
|
|
10
|
+
border-bottom: 1px solid #e2e8f0;
|
|
11
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
12
|
+
font-size: 0.82rem;
|
|
13
|
+
color: #64748b;
|
|
14
|
+
}
|
|
15
|
+
#version-nav .vn-label { margin-right: 0.2rem; }
|
|
16
|
+
#version-nav a {
|
|
17
|
+
display: inline-block;
|
|
18
|
+
padding: 0.22rem 0.7rem;
|
|
19
|
+
border-radius: 999px;
|
|
20
|
+
text-decoration: none;
|
|
21
|
+
border: 1px solid #3b82f6;
|
|
22
|
+
color: #3b82f6;
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
transition: background 0.15s, color 0.15s;
|
|
25
|
+
}
|
|
26
|
+
#version-nav a:hover { background: #3b82f6; color: #fff; }
|
|
27
|
+
#version-nav a.current { background: #3b82f6; color: #fff; pointer-events: none; }
|
|
28
|
+
</style>
|
|
29
|
+
<div id="version-nav">
|
|
30
|
+
<span class="vn-label">API version:</span>
|
|
31
|
+
<% @versions.each do |v| %>
|
|
32
|
+
<% if v == @version %>
|
|
33
|
+
<a href="#" class="current"><%= v %></a>
|
|
34
|
+
<% else %>
|
|
35
|
+
<a href="<%= request.path.sub(/[^\/]+$/, v) %>"><%= v %></a>
|
|
36
|
+
<% end %>
|
|
37
|
+
<% end %>
|
|
38
|
+
</div>
|
|
39
|
+
<% end %>
|
|
40
|
+
<% end %>
|
|
41
|
+
|
|
42
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.19.5/swagger-ui-bundle.js"></script>
|
|
43
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.19.5/swagger-ui-standalone-preset.js"></script>
|
|
44
|
+
<script>
|
|
45
|
+
window.addEventListener('load', function () {
|
|
46
|
+
SwaggerUIBundle({
|
|
47
|
+
url: '<%= j @swagger_json_url %>',
|
|
48
|
+
dom_id: '#swagger-ui',
|
|
49
|
+
deepLinking: true,
|
|
50
|
+
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
|
|
51
|
+
plugins: [SwaggerUIBundle.plugins.DownloadUrl],
|
|
52
|
+
layout: 'StandaloneLayout'
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
<head>
|
|
3
3
|
<meta charset="UTF-8">
|
|
4
4
|
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.19.5/swagger-ui.css" >
|
|
5
|
-
<style>
|
|
6
|
-
.swagger-ui .topbar {
|
|
7
|
-
display: none;
|
|
8
|
-
}
|
|
9
|
-
</style>
|
|
10
5
|
</head>
|
|
11
6
|
|
|
12
7
|
<body>
|
|
8
|
+
<%= yield :version_nav %>
|
|
13
9
|
<div id="swagger-ui"></div>
|
|
14
10
|
<%=yield%>
|
|
15
11
|
</body>
|
data/config/locales/it.yml
CHANGED
|
@@ -4,45 +4,45 @@ it:
|
|
|
4
4
|
charts:
|
|
5
5
|
menu: Analisi
|
|
6
6
|
title: Grafici
|
|
7
|
-
breadcrumb: Grafici
|
|
7
|
+
breadcrumb: Grafici
|
|
8
8
|
links:
|
|
9
9
|
label: Collegamenti
|
|
10
10
|
settings:
|
|
11
11
|
label: Impostazioni
|
|
12
12
|
advanced: Avanzate
|
|
13
13
|
registries: Anagrafiche
|
|
14
|
-
operations: Operatività
|
|
14
|
+
operations: Operatività
|
|
15
15
|
tools:
|
|
16
16
|
label: "Strumenti"
|
|
17
|
-
advanced: Impostazioni
|
|
18
|
-
contact: "Aiutaci a Migliorare"
|
|
19
|
-
current_user: Utente corrente
|
|
20
|
-
dashboard: "Pagina Iniziale"
|
|
17
|
+
advanced: Impostazioni
|
|
18
|
+
contact: "Aiutaci a Migliorare"
|
|
19
|
+
current_user: Utente corrente
|
|
20
|
+
dashboard: "Pagina Iniziale"
|
|
21
21
|
devise:
|
|
22
22
|
omniauth:
|
|
23
23
|
labels:
|
|
24
|
-
entra_id:
|
|
24
|
+
entra_id:
|
|
25
25
|
html: Sign in con Microsoft <i class="fa fa-microsoft"></i>
|
|
26
|
-
google_oauth2:
|
|
26
|
+
google_oauth2:
|
|
27
27
|
html: Sign in con Google <i class="fa fa-google"></i>
|
|
28
28
|
sessions:
|
|
29
29
|
new:
|
|
30
30
|
login: Login
|
|
31
|
-
password: Password
|
|
32
|
-
dont_leve_or_drag_here: Upload in corso, si prega di non lasciare la pagina o trascinare qui altri file.
|
|
31
|
+
password: Password
|
|
32
|
+
dont_leve_or_drag_here: Upload in corso, si prega di non lasciare la pagina o trascinare qui altri file.
|
|
33
33
|
errors:
|
|
34
34
|
messages:
|
|
35
|
-
invalid: contiene caratteri
|
|
36
|
-
file_upload: Descrizione della procedura, prego aggiungere una traduzione per file_upload al
|
|
37
|
-
file_upload_subtitle: Descrizione aggiuntiva, prego aggiungere una traduzione per file_upload_subtitle al
|
|
38
|
-
hello: "Ciao Mondo"
|
|
35
|
+
invalid: contiene caratteri non validi
|
|
36
|
+
file_upload: Descrizione della procedura, prego aggiungere una traduzione per file_upload al file delle traduzioni.
|
|
37
|
+
file_upload_subtitle: Descrizione aggiuntiva, prego aggiungere una traduzione per file_upload_subtitle al file delle traduzioni.
|
|
38
|
+
hello: "Ciao Mondo"
|
|
39
39
|
import_success: Importazione completata con successo
|
|
40
40
|
loading: Caricamento
|
|
41
|
-
main_records: Anagrafiche
|
|
42
|
-
manage: "Gestione"
|
|
43
|
-
please_drag_and_drop_here: Trascinare qui i file da importare
|
|
41
|
+
main_records: Anagrafiche
|
|
42
|
+
manage: "Gestione"
|
|
43
|
+
please_drag_and_drop_here: Trascinare qui i file da importare
|
|
44
44
|
run_import: Forza l'importazione
|
|
45
|
-
sign_out: "
|
|
45
|
+
sign_out: "Esci"
|
|
46
46
|
tiered_times:
|
|
47
47
|
dd:
|
|
48
48
|
zero: "0 Giorni"
|
|
@@ -59,4 +59,4 @@ it:
|
|
|
59
59
|
ss:
|
|
60
60
|
zero: "0 Secondi"
|
|
61
61
|
one: "%{count} Secondo"
|
|
62
|
-
other: "%{count} Secondi"
|
|
62
|
+
other: "%{count} Secondi"
|
data/config/routes.rb
CHANGED
|
@@ -3,7 +3,7 @@ Rails.application.routes.draw do
|
|
|
3
3
|
controllers = {
|
|
4
4
|
sessions: "users/sessions"
|
|
5
5
|
}
|
|
6
|
-
controllers[:omniauth_callbacks] = 'users/omniauth_callbacks' if ThecoreAuthCommons.oauth_vars?
|
|
6
|
+
controllers[:omniauth_callbacks] = 'users/omniauth_callbacks' if ThecoreAuthCommons.respond_to?(:oauth_vars?) && ThecoreAuthCommons.oauth_vars?
|
|
7
7
|
devise_for :users, controllers: controllers
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -14,6 +14,7 @@ Rails.application.routes.draw do
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
scope ENV.fetch("RAILS_RELATIVE_URL_ROOT", "/") do
|
|
17
|
-
get '/info/swagger', to:
|
|
17
|
+
get '/info/swagger', to: redirect { |_params, req| "#{req.path}/v2" }
|
|
18
|
+
get '/info/swagger/:version', to: 'info#swagger'
|
|
18
19
|
end
|
|
19
20
|
end
|
data/lib/thecore_ui_commons.rb
CHANGED
|
@@ -16,6 +16,25 @@ require "omniauth/rails_csrf_protection"
|
|
|
16
16
|
require "thecore_ui_commons/engine"
|
|
17
17
|
|
|
18
18
|
module ThecoreUiCommons
|
|
19
|
+
@swagger_api_versions = nil
|
|
20
|
+
|
|
21
|
+
class << self
|
|
22
|
+
attr_writer :swagger_api_versions
|
|
23
|
+
|
|
24
|
+
def swagger_api_versions
|
|
25
|
+
@swagger_api_versions.nil? ? scan_swagger_routes(Rails.application.routes.routes) : @swagger_api_versions
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.scan_swagger_routes(routes)
|
|
30
|
+
routes
|
|
31
|
+
.map { |r| r.path.spec.to_s }
|
|
32
|
+
.grep(/\/api\/(v\d+)\/info\/swagger/)
|
|
33
|
+
.map { |p| p.match(/\/api\/(v\d+)\/info\/swagger/)[1] }
|
|
34
|
+
.uniq
|
|
35
|
+
.sort_by { |v| v[1..].to_i }
|
|
36
|
+
end
|
|
37
|
+
|
|
19
38
|
def self.save_files files
|
|
20
39
|
files.each do |pic|
|
|
21
40
|
upload_dir = Rails.root.join(Settings.ns(:importer).import_from_folder, 'uploads')
|