lesli_dashboard 1.1.2 → 1.1.4
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/Rakefile +6 -1
- data/app/assets/stylesheets/lesli_dashboard/application.css +190 -0
- data/app/controllers/lesli_dashboard/components_controller.rb +71 -49
- data/app/controllers/lesli_dashboard/dashboards_controller.rb +88 -3
- data/app/controllers/lesli_dashboard/shared/dashboards_controller.rb +11 -11
- data/app/helpers/lesli_dashboard/components_helper.rb +2 -2
- data/app/models/lesli_dashboard/account.rb +11 -7
- data/app/models/lesli_dashboard/component.rb +15 -2
- data/app/models/lesli_dashboard/dashboard.rb +5 -1
- data/app/models/lesli_dashboard/shared/dashboard.rb +6 -50
- data/app/operators/lesli_dashboard/dashboard_registration_operator.rb +32 -0
- data/app/presenters/lesli_dashboard/dashboard_presenter.rb +31 -0
- data/app/services/lesli_dashboard/component_service.rb +123 -0
- data/app/services/lesli_dashboard/dashboard_service.rb +124 -30
- data/app/views/lesli_dashboard/components/_component.html.erb +48 -2
- data/app/views/lesli_dashboard/components/_form.html.erb +13 -16
- data/app/views/lesli_dashboard/components/_list.html.erb +9 -0
- data/app/views/lesli_dashboard/components/index.html.erb +7 -16
- data/app/views/lesli_dashboard/dashboards/_actions.html.erb +19 -0
- data/app/views/lesli_dashboard/dashboards/_component-calendar.html.erb +1 -1
- data/app/views/lesli_dashboard/dashboards/_form.html.erb +29 -0
- data/app/views/lesli_dashboard/dashboards/edit.html.erb +8 -32
- data/app/views/lesli_dashboard/dashboards/index.html.erb +21 -32
- data/app/views/lesli_dashboard/dashboards/new.html.erb +4 -32
- data/app/views/lesli_dashboard/dashboards/shared/_header.html.erb +13 -2
- data/app/views/lesli_dashboard/dashboards/shared/_navigation.html.erb +20 -0
- data/app/views/lesli_dashboard/dashboards/shared/show.html.erb +24 -31
- data/app/views/lesli_dashboard/dashboards/show.html.erb +7 -2
- data/config/locales/translations.en.yml +55 -3
- data/config/locales/translations.es.yml +59 -3
- data/config/locales/translations.fr.yml +55 -3
- data/config/locales/translations.it.yml +55 -3
- data/config/locales/translations.pt.yml +55 -3
- data/config/routes.rb +6 -0
- data/db/migrate/0306050110_create_lesli_dashboard_dashboards.rb +8 -4
- data/db/migrate/20260118063343_create_lesli_dashboard_components.rb +5 -4
- data/lib/lesli_dashboard/engine.rb +1 -5
- data/lib/lesli_dashboard/version.rb +2 -2
- data/lib/lesli_dashboard/widget_catalog.rb +43 -0
- data/lib/lesli_dashboard.rb +1 -0
- data/lib/tasks/lesli_dashboard_tasks.rake +11 -11
- data/readme.md +17 -10
- metadata +14 -11
- data/app/assets/config/lesli_dashboard_manifest.js +0 -38
- data/app/assets/stylesheets/lesli_dashboard/application.tailwind.css +0 -33
- data/app/controllers/lesli_dashboard/dashboard/components_controller.rb +0 -60
- data/app/models/lesli_dashboard/dashboard/component.rb +0 -50
- data/app/views/lesli_dashboard/components/edit.html.erb +0 -12
- data/app/views/lesli_dashboard/components/new.html.erb +0 -11
- data/app/views/lesli_dashboard/components/show.html.erb +0 -10
- data/app/views/lesli_dashboard/dashboards/shared/edit.html.erb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a7249ab6b9d099f3bb760861a6127072d59b7adc30ab00ba04c8091cc605108
|
|
4
|
+
data.tar.gz: 79118f3971712e08b1ceeed57fa008ee48bd1608fe1bc62701c38c59e171b24b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40153f4f035f6cfcef77d3317b3caa6102fd0a6e0473462fd0bff9be0c143f4844e802f77f2f5784a9fa2f3df34319318098881371c7b9bf8da06be8861e1331
|
|
7
|
+
data.tar.gz: cc2d24b9cd81d1bdc5c8db6d1fd9c476b36ab2455f3c9dcd11bc7a9b3ee7c5f2ec72f7299ff4fa9cd15648da8a0ce678d50e02beb0fb07a94cc89c95cdc16a03
|
data/Rakefile
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
require "bundler/setup"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
|
4
|
+
|
|
5
|
+
load "rails/tasks/engine.rake"
|
|
4
6
|
|
|
5
7
|
require "bundler/gem_tasks"
|
|
8
|
+
|
|
9
|
+
desc "Run engine tests through the dummy Rails application"
|
|
10
|
+
task test: "app:test"
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
2
|
+
/*!
|
|
3
|
+
|
|
4
|
+
Lesli
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2026, Lesli Technologies, S. A.
|
|
7
|
+
|
|
8
|
+
This program is free software: you can redistribute it and/or modify
|
|
9
|
+
it under the terms of the GNU General Public License as published by
|
|
10
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
(at your option) any later version.
|
|
12
|
+
|
|
13
|
+
This program is distributed in the hope that it will be useful,
|
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
You should have received a copy of the GNU General Public License
|
|
19
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
20
|
+
|
|
21
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
|
22
|
+
|
|
23
|
+
Made with ♥ by LesliTech
|
|
24
|
+
Building a better future, one line of code at a time.
|
|
25
|
+
|
|
26
|
+
@contact hello@lesli.tech
|
|
27
|
+
@website https://www.lesli.tech
|
|
28
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
29
|
+
|
|
30
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
31
|
+
// ·
|
|
32
|
+
*/
|
|
33
|
+
@layer properties;
|
|
34
|
+
@layer theme, utilities;
|
|
35
|
+
@layer theme {
|
|
36
|
+
:root, :host {
|
|
37
|
+
--color-slate-50: oklch(98.4% 0.003 247.858);
|
|
38
|
+
--color-slate-300: oklch(86.9% 0.022 252.894);
|
|
39
|
+
--spacing: 0.25rem;
|
|
40
|
+
--radius-2xl: 1rem;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
@layer utilities {
|
|
44
|
+
.col-span-12 {
|
|
45
|
+
grid-column: span 12 / span 12;
|
|
46
|
+
}
|
|
47
|
+
.mt-6 {
|
|
48
|
+
margin-top: calc(var(--spacing) * 6);
|
|
49
|
+
}
|
|
50
|
+
.mb-6 {
|
|
51
|
+
margin-bottom: calc(var(--spacing) * 6);
|
|
52
|
+
}
|
|
53
|
+
.flex {
|
|
54
|
+
display: flex;
|
|
55
|
+
}
|
|
56
|
+
.grid {
|
|
57
|
+
display: grid;
|
|
58
|
+
}
|
|
59
|
+
.h-full {
|
|
60
|
+
height: 100%;
|
|
61
|
+
}
|
|
62
|
+
.w-full {
|
|
63
|
+
width: 100%;
|
|
64
|
+
}
|
|
65
|
+
.min-w-0 {
|
|
66
|
+
min-width: 0px;
|
|
67
|
+
}
|
|
68
|
+
.grid-cols-12 {
|
|
69
|
+
grid-template-columns: repeat(12, minmax(0, 1fr));
|
|
70
|
+
}
|
|
71
|
+
.flex-wrap {
|
|
72
|
+
flex-wrap: wrap;
|
|
73
|
+
}
|
|
74
|
+
.items-center {
|
|
75
|
+
align-items: center;
|
|
76
|
+
}
|
|
77
|
+
.items-stretch {
|
|
78
|
+
align-items: stretch;
|
|
79
|
+
}
|
|
80
|
+
.justify-center {
|
|
81
|
+
justify-content: center;
|
|
82
|
+
}
|
|
83
|
+
.gap-3 {
|
|
84
|
+
gap: calc(var(--spacing) * 3);
|
|
85
|
+
}
|
|
86
|
+
.gap-4 {
|
|
87
|
+
gap: calc(var(--spacing) * 4);
|
|
88
|
+
}
|
|
89
|
+
.rounded-2xl {
|
|
90
|
+
border-radius: var(--radius-2xl);
|
|
91
|
+
}
|
|
92
|
+
.border {
|
|
93
|
+
border-style: var(--tw-border-style);
|
|
94
|
+
border-width: 1px;
|
|
95
|
+
}
|
|
96
|
+
.border-dashed {
|
|
97
|
+
--tw-border-style: dashed;
|
|
98
|
+
border-style: dashed;
|
|
99
|
+
}
|
|
100
|
+
.border-slate-300 {
|
|
101
|
+
border-color: var(--color-slate-300);
|
|
102
|
+
}
|
|
103
|
+
.bg-slate-50\/70 {
|
|
104
|
+
background-color: color-mix(in srgb, oklch(98.4% 0.003 247.858) 70%, transparent);
|
|
105
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
106
|
+
background-color: color-mix(in oklab, var(--color-slate-50) 70%, transparent);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
.px-6 {
|
|
110
|
+
padding-inline: calc(var(--spacing) * 6);
|
|
111
|
+
}
|
|
112
|
+
.py-12 {
|
|
113
|
+
padding-block: calc(var(--spacing) * 12);
|
|
114
|
+
}
|
|
115
|
+
@media (width >= 40rem) {
|
|
116
|
+
.sm\:gap-5 {
|
|
117
|
+
gap: calc(var(--spacing) * 5);
|
|
118
|
+
}
|
|
119
|
+
.sm\:py-16 {
|
|
120
|
+
padding-block: calc(var(--spacing) * 16);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
@media (width >= 48rem) {
|
|
124
|
+
.md\:col-span-6 {
|
|
125
|
+
grid-column: span 6 / span 6;
|
|
126
|
+
}
|
|
127
|
+
.md\:col-span-12 {
|
|
128
|
+
grid-column: span 12 / span 12;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
@media (width >= 64rem) {
|
|
132
|
+
.lg\:col-span-1 {
|
|
133
|
+
grid-column: span 1 / span 1;
|
|
134
|
+
}
|
|
135
|
+
.lg\:col-span-2 {
|
|
136
|
+
grid-column: span 2 / span 2;
|
|
137
|
+
}
|
|
138
|
+
.lg\:col-span-3 {
|
|
139
|
+
grid-column: span 3 / span 3;
|
|
140
|
+
}
|
|
141
|
+
.lg\:col-span-4 {
|
|
142
|
+
grid-column: span 4 / span 4;
|
|
143
|
+
}
|
|
144
|
+
.lg\:col-span-5 {
|
|
145
|
+
grid-column: span 5 / span 5;
|
|
146
|
+
}
|
|
147
|
+
.lg\:col-span-6 {
|
|
148
|
+
grid-column: span 6 / span 6;
|
|
149
|
+
}
|
|
150
|
+
.lg\:col-span-7 {
|
|
151
|
+
grid-column: span 7 / span 7;
|
|
152
|
+
}
|
|
153
|
+
.lg\:col-span-8 {
|
|
154
|
+
grid-column: span 8 / span 8;
|
|
155
|
+
}
|
|
156
|
+
.lg\:col-span-9 {
|
|
157
|
+
grid-column: span 9 / span 9;
|
|
158
|
+
}
|
|
159
|
+
.lg\:col-span-10 {
|
|
160
|
+
grid-column: span 10 / span 10;
|
|
161
|
+
}
|
|
162
|
+
.lg\:col-span-11 {
|
|
163
|
+
grid-column: span 11 / span 11;
|
|
164
|
+
}
|
|
165
|
+
.lg\:col-span-12 {
|
|
166
|
+
grid-column: span 12 / span 12;
|
|
167
|
+
}
|
|
168
|
+
.lg\:gap-6 {
|
|
169
|
+
gap: calc(var(--spacing) * 6);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
.\[\&_\.box\]\:h-full .box {
|
|
173
|
+
height: 100%;
|
|
174
|
+
}
|
|
175
|
+
.\[\&\>\*\]\:h-full > * {
|
|
176
|
+
height: 100%;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
@property --tw-border-style {
|
|
180
|
+
syntax: "*";
|
|
181
|
+
inherits: false;
|
|
182
|
+
initial-value: solid;
|
|
183
|
+
}
|
|
184
|
+
@layer properties {
|
|
185
|
+
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
186
|
+
*, ::before, ::after, ::backdrop {
|
|
187
|
+
--tw-border-style: solid;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -1,60 +1,82 @@
|
|
|
1
1
|
module LesliDashboard
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
class ComponentsController < ApplicationController
|
|
3
|
+
before_action :load_dashboard
|
|
4
|
+
before_action :load_component, only: [:update, :destroy, :move]
|
|
5
|
+
rescue_from ActiveRecord::RecordNotFound do
|
|
6
|
+
respond_with_not_found
|
|
7
|
+
end
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
def index
|
|
10
|
+
prepare_editor
|
|
11
|
+
respond_with_lesli(json: @components)
|
|
12
|
+
end
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
def create
|
|
15
|
+
@service.create(params.require(:component).permit(:component).to_h.symbolize_keys)
|
|
16
|
+
respond_to_mutation(:created)
|
|
17
|
+
end
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
def update
|
|
20
|
+
widget = @service.widgets.find { |definition| definition.identifier == @service.result.component }
|
|
21
|
+
keys = widget ? widget.settings.keys : []
|
|
22
|
+
attributes = params.require(:component).permit(:size, config: keys).to_h.symbolize_keys
|
|
23
|
+
@service.update(attributes)
|
|
24
|
+
respond_to_mutation(:updated)
|
|
25
|
+
end
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
def move
|
|
28
|
+
@service.move(params.require(:direction))
|
|
29
|
+
respond_to_mutation(:moved)
|
|
30
|
+
end
|
|
22
31
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
def destroy
|
|
33
|
+
@service.destroy
|
|
34
|
+
respond_to_mutation(:removed)
|
|
35
|
+
end
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
redirect_to @component, notice: "Component was successfully created."
|
|
29
|
-
else
|
|
30
|
-
render :new, status: :unprocessable_content
|
|
31
|
-
end
|
|
32
|
-
end
|
|
37
|
+
private
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
else
|
|
39
|
-
render :edit, status: :unprocessable_content
|
|
40
|
-
end
|
|
41
|
-
end
|
|
39
|
+
def load_dashboard
|
|
40
|
+
@service = ComponentService.new(current_user, dashboard_id: params[:dashboard_id])
|
|
41
|
+
@dashboard = @service.dashboard
|
|
42
|
+
end
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
redirect_to components_path, notice: "Component was successfully destroyed.", status: :see_other
|
|
47
|
-
end
|
|
44
|
+
def load_component
|
|
45
|
+
@service.find(params[:id])
|
|
46
|
+
end
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
def prepare_editor
|
|
49
|
+
@widgets = @service.widgets.index_by(&:identifier)
|
|
50
|
+
@components = @dashboard.components.order(:position, :id).to_a
|
|
51
|
+
@new_component = @dashboard.components.build
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def respond_to_mutation(message)
|
|
55
|
+
component = @service.result
|
|
56
|
+
prepare_editor
|
|
57
|
+
if @service.successful?
|
|
58
|
+
streams = if action_name == "update"
|
|
59
|
+
[turbo_stream.replace("dashboard-component-#{component.id}", partial: "lesli_dashboard/components/component", locals: { component: component })]
|
|
60
|
+
else
|
|
61
|
+
[turbo_stream.replace("dashboard-components-list", partial: "lesli_dashboard/components/list")]
|
|
62
|
+
end
|
|
63
|
+
streams << turbo_stream.replace("dashboard-component-form", partial: "lesli_dashboard/components/form") if action_name == "create"
|
|
64
|
+
streams << stream_notification_success(t("lesli_dashboard.components.#{message}"))
|
|
65
|
+
respond_with_lesli(
|
|
66
|
+
turbo: streams, json: { component: component, components: @components },
|
|
67
|
+
redirect: managed_dashboard_components_path(@dashboard), status: action_name == "create" ? :created : :ok
|
|
68
|
+
)
|
|
69
|
+
else
|
|
70
|
+
@new_component = component if action_name == "create"
|
|
71
|
+
@components.map! { |record| record.id == component.id ? component : record }
|
|
72
|
+
target = action_name == "create" ? "dashboard-component-form" : "dashboard-component-#{component.id}"
|
|
73
|
+
partial = action_name == "create" ? "form" : "component"
|
|
74
|
+
respond_with_lesli(
|
|
75
|
+
html: :index, status: :unprocessable_content,
|
|
76
|
+
json: { errors: component.errors.to_hash },
|
|
77
|
+
turbo: turbo_stream.replace(target, partial: "lesli_dashboard/components/#{partial}", locals: { component: component })
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
60
82
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Lesli
|
|
4
4
|
|
|
5
|
-
Copyright (c)
|
|
5
|
+
Copyright (c) 2026, Lesli Technologies, S. A.
|
|
6
6
|
|
|
7
7
|
This program is free software: you can redistribute it and/or modify
|
|
8
8
|
it under the terms of the GNU General Public License as published by
|
|
@@ -19,7 +19,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
19
19
|
|
|
20
20
|
Lesli · Ruby on Rails SaaS Development Framework.
|
|
21
21
|
|
|
22
|
-
Made with ♥ by
|
|
22
|
+
Made with ♥ by LesliTech
|
|
23
23
|
Building a better future, one line of code at a time.
|
|
24
24
|
|
|
25
25
|
@contact hello@lesli.tech
|
|
@@ -29,8 +29,93 @@ Building a better future, one line of code at a time.
|
|
|
29
29
|
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
30
30
|
// ·
|
|
31
31
|
=end
|
|
32
|
-
|
|
33
32
|
module LesliDashboard
|
|
34
33
|
class DashboardsController < Lesli::Shared::DashboardsController
|
|
34
|
+
helper_method :dashboard_action_allowed?
|
|
35
|
+
|
|
36
|
+
before_action :load_dashboard, only: [:edit, :update, :destroy]
|
|
37
|
+
|
|
38
|
+
def index
|
|
39
|
+
@dashboards = DashboardService.new(current_user).index.result
|
|
40
|
+
respond_with_lesli(json: @dashboards)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def show
|
|
44
|
+
return super unless params[:id]
|
|
45
|
+
|
|
46
|
+
@service = DashboardService.new(current_user).find(params[:id])
|
|
47
|
+
return respond_with_not_found unless @service.found?
|
|
48
|
+
|
|
49
|
+
@dashboard = @service.result
|
|
50
|
+
@dashboard_engine = @dashboard.engine
|
|
51
|
+
@dashboards = DashboardService.new(current_user).index(engine: @dashboard.engine).result
|
|
52
|
+
@components = @dashboard.components.order(:position, :id)
|
|
53
|
+
@dashboard_presenter = DashboardPresenter.new(@dashboard)
|
|
54
|
+
respond_with_lesli(json: @dashboard)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def new
|
|
58
|
+
engine = params[:engine] if WidgetCatalog.engines.include?(params[:engine])
|
|
59
|
+
@dashboard = Dashboard.new(engine: engine)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def edit
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def create
|
|
66
|
+
@service = DashboardService.new(current_user).create(dashboard_params)
|
|
67
|
+
@dashboard = @service.result
|
|
68
|
+
return render_form(:new) unless @service.successful?
|
|
69
|
+
|
|
70
|
+
success(t("lesli_dashboard.dashboards.created"))
|
|
71
|
+
respond_with_lesli(json: @dashboard, status: :created, redirect: managed_dashboard_path(@dashboard))
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def update
|
|
75
|
+
@service.update(dashboard_params)
|
|
76
|
+
@dashboard = @service.result
|
|
77
|
+
return render_form(:edit) unless @service.successful?
|
|
78
|
+
|
|
79
|
+
success(t("lesli_dashboard.dashboards.updated"))
|
|
80
|
+
respond_with_lesli(json: @dashboard, redirect: managed_dashboard_path(@dashboard))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def destroy
|
|
84
|
+
@service.destroy
|
|
85
|
+
success(t("lesli_dashboard.dashboards.deleted"))
|
|
86
|
+
respond_with_lesli(json: { id: @dashboard.id }, redirect: managed_dashboards_path)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
private
|
|
90
|
+
|
|
91
|
+
def dashboard_action_allowed?(action)
|
|
92
|
+
!defined?(LesliShield) || current_user.has_privileges_for?("lesli_dashboard/dashboards", action)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def load_dashboard
|
|
96
|
+
@service = DashboardService.new(current_user)
|
|
97
|
+
# Preserve the existing singular edit URL for the engine's default.
|
|
98
|
+
@service = if params[:id]
|
|
99
|
+
@service.find(params[:id])
|
|
100
|
+
else
|
|
101
|
+
@service.show(engine: "LesliDashboard", id: params[:dashboard_id])
|
|
102
|
+
end
|
|
103
|
+
return respond_with_not_found unless @service.found?
|
|
104
|
+
|
|
105
|
+
@dashboard = @service.result
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def dashboard_params
|
|
109
|
+
params.require(:dashboard).permit(:name, :engine, :default).to_h.symbolize_keys
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def render_form(template)
|
|
113
|
+
respond_with_lesli(
|
|
114
|
+
html: template,
|
|
115
|
+
json: { errors: @dashboard.errors.to_hash },
|
|
116
|
+
turbo: turbo_stream.replace("dashboard-form", partial: "lesli_dashboard/dashboards/form"),
|
|
117
|
+
status: :unprocessable_content
|
|
118
|
+
)
|
|
119
|
+
end
|
|
35
120
|
end
|
|
36
121
|
end
|
|
@@ -33,18 +33,18 @@ Building a better future, one line of code at a time.
|
|
|
33
33
|
module LesliDashboard
|
|
34
34
|
module Shared
|
|
35
35
|
class DashboardsController < ApplicationController
|
|
36
|
-
#before_action :set_dashboard, only: [:show, :update, :destroy, :options]
|
|
37
|
-
|
|
38
|
-
def edit
|
|
39
|
-
# renders the edit view for dashboard
|
|
40
|
-
end
|
|
41
|
-
|
|
42
36
|
def show
|
|
43
|
-
|
|
44
|
-
@
|
|
45
|
-
@
|
|
46
|
-
@
|
|
47
|
-
|
|
37
|
+
engine = self.class.module_parent.name
|
|
38
|
+
@dashboard_engine = engine
|
|
39
|
+
@dashboard_entry_path = request.path
|
|
40
|
+
@dashboards = DashboardService.new(current_user).index(engine: engine).result
|
|
41
|
+
@dashboard = DashboardService.new(current_user).show(
|
|
42
|
+
engine: engine,
|
|
43
|
+
id: params[:dashboard_id]
|
|
44
|
+
).result
|
|
45
|
+
|
|
46
|
+
@components = @dashboard ? @dashboard.components.order(:position, :id) : []
|
|
47
|
+
@dashboard_presenter = DashboardPresenter.new(@dashboard)
|
|
48
48
|
render(template:"lesli/shared/dashboards/show")
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Lesli
|
|
4
4
|
|
|
5
|
-
Copyright (c)
|
|
5
|
+
Copyright (c) 2026, Lesli Technologies, S. A.
|
|
6
6
|
|
|
7
7
|
This program is free software: you can redistribute it and/or modify
|
|
8
8
|
it under the terms of the GNU General Public License as published by
|
|
@@ -19,11 +19,11 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
19
19
|
|
|
20
20
|
Lesli · Ruby on Rails SaaS Development Framework.
|
|
21
21
|
|
|
22
|
-
Made with ♥ by
|
|
22
|
+
Made with ♥ by LesliTech
|
|
23
23
|
Building a better future, one line of code at a time.
|
|
24
24
|
|
|
25
25
|
@contact hello@lesli.tech
|
|
26
|
-
@website https://www.lesli.
|
|
26
|
+
@website https://www.lesli.tech
|
|
27
27
|
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
28
28
|
|
|
29
29
|
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
@@ -32,11 +32,15 @@ Building a better future, one line of code at a time.
|
|
|
32
32
|
|
|
33
33
|
module LesliDashboard
|
|
34
34
|
class Account < ApplicationRecord
|
|
35
|
-
|
|
35
|
+
self.table_name = "lesli_dashboard_accounts"
|
|
36
|
+
belongs_to :account, class_name: "Lesli::Account", inverse_of: :dashboard
|
|
37
|
+
validates :account_id, uniqueness: true
|
|
36
38
|
|
|
37
|
-
has_many :dashboards
|
|
38
|
-
has_many :users,
|
|
39
|
+
has_many :dashboards, inverse_of: :account
|
|
40
|
+
has_many :users, through: :account
|
|
39
41
|
|
|
42
|
+
# Core account creation provisions this workspace. Initialize dashboards
|
|
43
|
+
# in the same transaction so SaaS signups need no maintenance task.
|
|
40
44
|
after_create :initialize_account
|
|
41
45
|
|
|
42
46
|
def initialize_account
|
|
@@ -44,7 +48,7 @@ module LesliDashboard
|
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def initialize_dashboards(account)
|
|
47
|
-
|
|
51
|
+
DashboardRegistrationOperator.new(account).operate
|
|
48
52
|
end
|
|
49
53
|
end
|
|
50
54
|
end
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
module LesliDashboard
|
|
2
2
|
class Component < ApplicationRecord
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
self.table_name = "lesli_dashboard_components"
|
|
4
|
+
|
|
5
|
+
belongs_to :dashboard, inverse_of: :components
|
|
6
|
+
validates :component, presence: true
|
|
7
|
+
validates :size, numericality: { only_integer: true, in: 1..12 }
|
|
8
|
+
validates :position, numericality: { only_integer: true, greater_than: 0 }
|
|
9
|
+
validate :config_is_an_object
|
|
10
|
+
|
|
11
|
+
COMPONENTS_GENERAL = %i[count chart_bar chart_line date weather calendar].freeze
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def config_is_an_object
|
|
16
|
+
errors.add(:config, :invalid) unless config.is_a?(Hash)
|
|
17
|
+
end
|
|
5
18
|
end
|
|
6
19
|
end
|
|
@@ -32,11 +32,15 @@ Building a better future, one line of code at a time.
|
|
|
32
32
|
|
|
33
33
|
module LesliDashboard
|
|
34
34
|
class Dashboard < Lesli::Shared::Dashboard
|
|
35
|
+
self.table_name = "lesli_dashboard_dashboards"
|
|
35
36
|
COMPONENTS = [
|
|
36
37
|
:count,
|
|
37
38
|
:chart_bar,
|
|
38
39
|
:chart_line,
|
|
39
|
-
:
|
|
40
|
+
{ calendar: {
|
|
41
|
+
config: { week_starts_on: "sunday" },
|
|
42
|
+
settings: { week_starts_on: { type: :select, choices: %w[sunday monday] } }
|
|
43
|
+
} },
|
|
40
44
|
:date,
|
|
41
45
|
:weather]
|
|
42
46
|
end
|
|
@@ -4,58 +4,14 @@ module LesliDashboard
|
|
|
4
4
|
self.table_name = "lesli_dashboard_dashboards"
|
|
5
5
|
self.abstract_class = true
|
|
6
6
|
|
|
7
|
-
belongs_to :
|
|
8
|
-
|
|
9
|
-
has_many :components, class_name: 'LesliDashboard::Component'
|
|
7
|
+
belongs_to :account, class_name: "LesliDashboard::Account", inverse_of: :dashboards
|
|
8
|
+
has_many :components, class_name: "LesliDashboard::Component", inverse_of: :dashboard
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
normalizes :name, with: ->(name) { name.strip }
|
|
11
|
+
validates :name, :engine, presence: true
|
|
12
|
+
attr_readonly :account_id, :engine
|
|
13
13
|
|
|
14
|
-
COMPONENTS = []
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
# @return [void]
|
|
19
|
-
# @descriptions This is an after_updated and after_create method that validates that at any moment in time, there is only
|
|
20
|
-
# one default dashboard in the engine. If there is another default dashboard, it's *default* field is set to false
|
|
21
|
-
# before committing the changes
|
|
22
|
-
# @example
|
|
23
|
-
# CloudFocus::Dasbhoard.where(default: false).first.update!(default: true)
|
|
24
|
-
# # This will automatically trigger this function and remove the *default* field from the old default dashboard
|
|
25
|
-
def verify_default_dashboard
|
|
26
|
-
if default
|
|
27
|
-
dashboards = self.class.where.not(id: id).where(account: account)
|
|
28
|
-
self.class.where.not(id: id).where(account: account).update_all(default: false)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
unless self.class.where(account: account).find_by(default: true)
|
|
32
|
-
errors.add(:base, I18n.t("core.dashboards.messages_danger_default_dashboard_must_exist"))
|
|
33
|
-
raise ActiveRecord::Rollback
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Build the Rails models and engine information for
|
|
38
|
-
# the current engine implementing the shared dashboards
|
|
39
|
-
# Example: For the LesliAudit engine
|
|
40
|
-
# {
|
|
41
|
-
# :module_name => "audit",
|
|
42
|
-
# :module_name_full => "LesliAudit",
|
|
43
|
-
# :module_model => "LesliAudit::Dashboard",
|
|
44
|
-
# :module_model_component => "LesliAudit::Dashboard::Component"
|
|
45
|
-
# }
|
|
46
|
-
def self.dynamic_info
|
|
47
|
-
|
|
48
|
-
module_info = self.name.split("::")
|
|
49
|
-
|
|
50
|
-
module_name = module_info[0].sub("Lesli", "").downcase
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
module_name: module_name,
|
|
54
|
-
module_name_full: module_info[0],
|
|
55
|
-
module_model: "#{ module_info[0] }::Dashboard".constantize,
|
|
56
|
-
module_model_component: "#{ module_info[0] }::Dashboard::Component".constantize
|
|
57
|
-
}
|
|
58
|
-
end
|
|
14
|
+
COMPONENTS = [].freeze
|
|
59
15
|
end
|
|
60
16
|
end
|
|
61
17
|
end
|