anoubis 1.0.7 → 1.0.11

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/anoubis/application_controller.rb +4 -0
  3. data/app/controllers/anoubis/data/actions.rb +947 -0
  4. data/app/controllers/anoubis/data/callbacks.rb +66 -0
  5. data/app/controllers/anoubis/data/convert.rb +422 -0
  6. data/app/controllers/anoubis/data/defaults.rb +215 -0
  7. data/app/controllers/anoubis/data/get.rb +529 -0
  8. data/app/controllers/anoubis/data/load.rb +87 -0
  9. data/app/controllers/anoubis/data/set.rb +47 -0
  10. data/app/controllers/anoubis/data/setup.rb +102 -0
  11. data/app/controllers/anoubis/data_controller.rb +17 -1
  12. data/app/controllers/anoubis/etc/field.rb +7 -0
  13. data/app/controllers/anoubis/output/basic.rb +1 -1
  14. data/app/controllers/anoubis/sso/server/login_controller.rb +5 -5
  15. data/app/controllers/anoubis/sso/server/user_controller.rb +2 -2
  16. data/app/models/anoubis/application_record.rb +60 -0
  17. data/config/locales/ru.yml +48 -47
  18. data/lib/anoubis/version.rb +1 -1
  19. metadata +11 -30
  20. data/app/controllers/anoubis/core/data/actions.rb +0 -962
  21. data/app/controllers/anoubis/core/data/callbacks.rb +0 -68
  22. data/app/controllers/anoubis/core/data/convert.rb +0 -407
  23. data/app/controllers/anoubis/core/data/defaults.rb +0 -217
  24. data/app/controllers/anoubis/core/data/get.rb +0 -531
  25. data/app/controllers/anoubis/core/data/load.rb +0 -89
  26. data/app/controllers/anoubis/core/data/set.rb +0 -49
  27. data/app/controllers/anoubis/core/data/setup.rb +0 -104
  28. data/app/controllers/anoubis/core/data_controller.rb +0 -28
  29. data/app/controllers/anoubis/sso/client/data/actions.rb +0 -5
  30. data/app/controllers/anoubis/sso/client/data/callbacks.rb +0 -5
  31. data/app/controllers/anoubis/sso/client/data/convert.rb +0 -5
  32. data/app/controllers/anoubis/sso/client/data/defaults.rb +0 -5
  33. data/app/controllers/anoubis/sso/client/data/get.rb +0 -5
  34. data/app/controllers/anoubis/sso/client/data/load.rb +0 -26
  35. data/app/controllers/anoubis/sso/client/data/set.rb +0 -5
  36. data/app/controllers/anoubis/sso/client/data/setup.rb +0 -5
  37. data/app/controllers/anoubis/sso/client/data_controller.rb +0 -21
  38. data/app/controllers/anoubis/tenant/data/actions.rb +0 -11
  39. data/app/controllers/anoubis/tenant/data/callbacks.rb +0 -11
  40. data/app/controllers/anoubis/tenant/data/convert.rb +0 -11
  41. data/app/controllers/anoubis/tenant/data/defaults.rb +0 -11
  42. data/app/controllers/anoubis/tenant/data/get.rb +0 -11
  43. data/app/controllers/anoubis/tenant/data/load.rb +0 -52
  44. data/app/controllers/anoubis/tenant/data/set.rb +0 -11
  45. data/app/controllers/anoubis/tenant/data/setup.rb +0 -11
  46. data/app/controllers/anoubis/tenant/data_controller.rb +0 -28
@@ -0,0 +1,102 @@
1
+ module Anoubis
2
+ ##
3
+ # Module consists all procedures and functons of {DataController}
4
+ module Data
5
+ ##
6
+ # Module setups system parameters for {DataController}
7
+ module Setup
8
+ ##
9
+ # Setups frame data information. It loads menu data, sets titles and tabs of the frame.
10
+ def setup_frame
11
+ self.load_menu_data
12
+ if self.etc.menu
13
+ self.get_parent_data
14
+ if self.etc.data.parent
15
+ self.output.title = self.etc.menu.page_title.sub '%{title}', self.etc.data.parent.sys_title.to_s
16
+ else
17
+ self.output.title = self.etc.menu.page_title
18
+ end
19
+ self.output.short = self.etc.menu.short_title
20
+ self.output.mode = self.etc.menu.mode
21
+ self.output.access = self.etc.menu.access
22
+ end
23
+ tabs = self.tabs
24
+ tabs.each do |key, item|
25
+ item = self.get_tab key, item
26
+ self.output.addTab(item)
27
+ end
28
+ end
29
+
30
+ ##
31
+ # Setups order for current tab. Parameters is set into {Anoubis::Etc::TabItem#sort self.etc.tab.sort} and
32
+ # {Anoubis::Etc::TabItem#order self.etc.tab.order} attributes.
33
+ def setup_order
34
+ sort = nil
35
+ first = nil
36
+ self.etc.data.fields.each do |key, field|
37
+ if field.order
38
+ first = key if !first
39
+ first = key if field.order.default
40
+ if params.key? :sort
41
+ sort = key if params[:sort] == key.to_s
42
+ end
43
+ end
44
+ end
45
+ sort = first if !sort
46
+ if sort
47
+ self.etc.tab.sort = sort.to_s
48
+ self.etc.tab.order = self.etc.data.fields[sort].order.order
49
+ if params.key? :order
50
+ self.etc.tab.order = :desc if params[:order] == 'desc'
51
+ self.etc.tab.order = :asc if params[:order] == 'asc'
52
+ end
53
+ end
54
+ end
55
+
56
+ ##
57
+ # @!group Block of fields setup functions
58
+
59
+ ##
60
+ # Setups defined fields and places it into attribute {Anoubis::Etc::Data#fields self.etc.data.fields}
61
+ def setup_fields
62
+ if !self.etc.data.fields
63
+ self.etc.data.fields = {}
64
+
65
+ fields = self.fields
66
+
67
+ fields.each_key do |key|
68
+ if fields[key].key? :edit
69
+ if self.menu_access fields[key][:edit], false
70
+ fields[key][:editable] = fields[key][:edit]
71
+ end
72
+ end
73
+ self.etc.data.fields[key] = Anoubis::Etc::Field.new(key, self.get_model, fields[key].merge(action: self.etc.action))
74
+ end
75
+ self.setup_order if %w[index export].include? self.etc.action
76
+ end
77
+ end
78
+
79
+ ##
80
+ # Setups additional parameters for table field with type 'datetime'
81
+ # Resulting data placed in {Etc::Data#fields self.etc.data.fields} (Hash)
82
+ # @param key [Symbol] key of table field.
83
+ def setup_fields_datetime (key)
84
+ self.etc.data.fields[key][:format] = 'full' if !self.etc.data.fields[key].has_key? :format
85
+ self.etc.data.fields[key][:format] = 'full' if !['full', 'month', 'date', 'datetime'].include? self.etc.data.fields[key][:format]
86
+ end
87
+
88
+
89
+
90
+ ##
91
+ # Setups additional parameters for table field with type 'float'
92
+ # Resulting data placed in {Etc::Data#fields self.etc.data.fields} (Hash)
93
+ # @param key [Symbol] key of table field.
94
+ def setup_fields_float (key)
95
+ self.etc.data.fields[key][:precision] = 2 if !self.etc.data.fields[key][:precision]
96
+ self.etc.data.fields[key][:point] = ',' if !self.etc.data.fields[key][:point]
97
+ self.etc.data.fields[key][:separator] = '' if !self.etc.data.fields[key][:separator]
98
+ end
99
+ # @!endgroup
100
+ end
101
+ end
102
+ end
@@ -1,5 +1,21 @@
1
+ require_dependency "anoubis/data/actions"
2
+ require_dependency "anoubis/data/load"
3
+ require_dependency "anoubis/data/get"
4
+ require_dependency "anoubis/data/set"
5
+ require_dependency "anoubis/data/setup"
6
+ require_dependency "anoubis/data/defaults"
7
+ require_dependency "anoubis/data/convert"
8
+ require_dependency "anoubis/data/callbacks"
9
+
1
10
  ##
2
11
  # Main data controller class
3
12
  class Anoubis::DataController < Anoubis::ApplicationController
4
-
13
+ include Anoubis::Data::Actions
14
+ include Anoubis::Data::Load
15
+ include Anoubis::Data::Get
16
+ include Anoubis::Data::Set
17
+ include Anoubis::Data::Setup
18
+ include Anoubis::Data::Defaults
19
+ include Anoubis::Data::Convert
20
+ include Anoubis::Data::Callbacks
5
21
  end
@@ -152,6 +152,13 @@ module Anoubis
152
152
 
153
153
  end
154
154
 
155
+ ##
156
+ # Initialize additional parameters for {Anoubis::Etc::Field#type 'hash' field type} for controller actions.
157
+ # @param options [Hash] field's initial options
158
+ def initialize_hash (options)
159
+
160
+ end
161
+
155
162
  ##
156
163
  # Initialize additional parameters for {Anoubis::Etc::Field#type 'number' field type} for controller actions.
157
164
  # @param options [Hash] field's initial options
@@ -30,7 +30,7 @@ module Anoubis
30
30
  self.result = 0
31
31
  self.tab = ''
32
32
  self.messages = {
33
- '0': I18n.t('success'),
33
+ '0': I18n.t('anoubis.success'),
34
34
  '-1': I18n.t('errors.access_not_allowed'),
35
35
  '-2': I18n.t('errors.incorrect_parameters')
36
36
  }
@@ -23,7 +23,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
23
23
 
24
24
  result = {
25
25
  result: 0,
26
- message: I18n.t('core.success')
26
+ message: I18n.t('anoubis.success')
27
27
  }
28
28
  code = 200
29
29
 
@@ -107,7 +107,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
107
107
  def create
108
108
  result = {
109
109
  result: 0,
110
- message: I18n.t('core.success')
110
+ message: I18n.t('anoubis.success')
111
111
  }
112
112
  code = 200
113
113
 
@@ -155,7 +155,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
155
155
  def update
156
156
  result = {
157
157
  result: 0,
158
- message: I18n.t('core.success')
158
+ message: I18n.t('anoubis.success')
159
159
  }
160
160
 
161
161
  if self.system
@@ -213,7 +213,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
213
213
  def destroy
214
214
  result = {
215
215
  result: 0,
216
- message: I18n.t('core.success')
216
+ message: I18n.t('anoubis.success')
217
217
  }
218
218
 
219
219
  begin
@@ -263,7 +263,7 @@ class Anoubis::Sso::Server::LoginController < Anoubis::Sso::Server::ApplicationC
263
263
  def show
264
264
  result = {
265
265
  result: 0,
266
- message: I18n.t('core.success')
266
+ message: I18n.t('anoubis.success')
267
267
  }
268
268
 
269
269
  if self.system
@@ -6,7 +6,7 @@ class Anoubis::Sso::Server::UserController < Anoubis::Sso::Server::ApplicationCo
6
6
  def show
7
7
  result = {
8
8
  result: 0,
9
- message: I18n.t('anubis.core.success')
9
+ message: I18n.t('anoubis.success')
10
10
  }
11
11
  code = 200
12
12
 
@@ -25,7 +25,7 @@ class Anoubis::Sso::Server::UserController < Anoubis::Sso::Server::ApplicationCo
25
25
  def update
26
26
  result = {
27
27
  result: 0,
28
- message: I18n.t('anubis.core.success')
28
+ message: I18n.t('anoubis.success')
29
29
  }
30
30
  code = 200
31
31
 
@@ -2,9 +2,29 @@
2
2
  class Anoubis::ApplicationRecord < ActiveRecord::Base
3
3
  self.abstract_class = true
4
4
 
5
+ after_initialize :initialize_anubis_application_record
6
+
5
7
  ## Redis database variable
6
8
  attr_accessor :redis
7
9
 
10
+ # @!attribute [rw] need_refresh
11
+ # @return [Boolean] defines when table representation data should be updated even after simple update
12
+ attr_accessor :need_refresh
13
+
14
+ ##
15
+ # Fires after ApplicationRecord initialized for define default values
16
+ def initialize_anubis_application_record
17
+ self.need_refresh = false
18
+
19
+ after_initialize_anubis_application_record
20
+ end
21
+
22
+ ##
23
+ # Fires after initialize default variables
24
+ def after_initialize_anubis_application_record
25
+
26
+ end
27
+
8
28
  ##
9
29
  # Returns {https://github.com/redis/redis-rb Redis database} class
10
30
  # @return [Class] {https://github.com/redis/redis-rb Redis} class reference
@@ -123,4 +143,44 @@ class Anoubis::ApplicationRecord < ActiveRecord::Base
123
143
  end
124
144
  result
125
145
  end
146
+
147
+ ##
148
+ # Returns system title of table element
149
+ # @return [String] System title
150
+ def sys_title
151
+ id.to_s
152
+ end
153
+
154
+ ##
155
+ # Returns the ability to create new data. By default all items may be deleted. For another result
156
+ # procedure should be overridden.
157
+ # @param args [Hash] transferred parameters
158
+ # @option args [String] :controller Called controller identifier
159
+ # @option args [String] :tab Called controller tab element
160
+ # @return [Boolean] true if new data may be created.
161
+ def can_new(args = {})
162
+ true
163
+ end
164
+
165
+ ##
166
+ # Returns the ability to edit the data. By default all items may be edited. For another result
167
+ # procedure should be overridden.
168
+ # @param args [Hash] transferred parameters
169
+ # @option args [String] :controller Called controller identifier
170
+ # @option args [String] :tab Called controller tab element
171
+ # @return [Boolean] true if data may be edited
172
+ def can_edit(args = {})
173
+ true
174
+ end
175
+
176
+ ##
177
+ # Returns the ability to delete a data. By default all items may be deleted. For another result
178
+ # procedure should be overridden.
179
+ # @param args [Hash] transferred parameters
180
+ # @option args [String] :controller Called controller identifier
181
+ # @option args [String] :tab Called controller tab element
182
+ # @return [Boolean] true if data may be deleted
183
+ def can_delete(args = {})
184
+ true
185
+ end
126
186
  end
@@ -39,6 +39,8 @@ ru:
39
39
  all: "Все"
40
40
  success: "Успешное завершение"
41
41
  error: "Ошибка"
42
+ default_tab: "Основная"
43
+ default_tab_hint: "Это основная вкладка"
42
44
  errors:
43
45
  incorrect_login: "Некорректный логин или пароль"
44
46
  session_expired: "Сессия завершена"
@@ -50,6 +52,51 @@ ru:
50
52
  title: "Дашборд"
51
53
  page_title: "Дашборд"
52
54
  short_title: "Дашборд"
55
+ form:
56
+ titles:
57
+ edit: "Редактирование элемента: %{title}"
58
+ show: "Просмотр элемента: %{title}"
59
+ new: "Добавление нового элемента"
60
+ months:
61
+ main:
62
+ - "Январь"
63
+ - "Февраль"
64
+ - "Март"
65
+ - "Апрель"
66
+ - "Май"
67
+ - "Июнь"
68
+ - "Июль"
69
+ - "Август"
70
+ - "Сентябрь"
71
+ - "Октябрь"
72
+ - "Ноябрь"
73
+ - "Декабрь"
74
+ second:
75
+ - "Января"
76
+ - "Февраля"
77
+ - "Марта"
78
+ - "Апреля"
79
+ - "Мая"
80
+ - "Июня"
81
+ - "Июля"
82
+ - "Августа"
83
+ - "Сентября"
84
+ - "Октября"
85
+ - "Ноября"
86
+ - "Декабря"
87
+ short:
88
+ - "янв"
89
+ - "фев"
90
+ - "мар"
91
+ - "апр"
92
+ - "май"
93
+ - "июн"
94
+ - "июл"
95
+ - "авг"
96
+ - "сен"
97
+ - "окт"
98
+ - "ноя"
99
+ - "дек"
53
100
 
54
101
 
55
102
 
@@ -66,48 +113,7 @@ ru:
66
113
  incorrect_parameters: Некорректные параметры
67
114
  error_changing_data: Ошибка изменения данных
68
115
 
69
- default_tab: Основная
70
- default_tab_hint: Это основная вкладка
71
- months:
72
- main:
73
- - Январь
74
- - Февраль
75
- - Март
76
- - Апрель
77
- - Май
78
- - Июнь
79
- - Июль
80
- - Август
81
- - Сентябрь
82
- - Октябрь
83
- - Ноябрь
84
- - Декабрь
85
- second:
86
- - Января
87
- - Февраля
88
- - Марта
89
- - Апреля
90
- - Мая
91
- - Июня
92
- - Июля
93
- - Августа
94
- - Сентября
95
- - Октября
96
- - Ноября
97
- - Декабря
98
- short:
99
- - янв
100
- - фев
101
- - мар
102
- - апр
103
- - май
104
- - июн
105
- - июл
106
- - авг
107
- - сен
108
- - окт
109
- - ноя
110
- - дек
116
+
111
117
  install2:
112
118
  groups:
113
119
  admin: Администраторы
@@ -122,11 +128,6 @@ ru:
122
128
  buttons:
123
129
  edit: "Редактировать: %{title}"
124
130
  delete: "Удалить: %{title}"
125
- form:
126
- titles:
127
- edit: "Редактирование элемента: %{title}"
128
- show: "Просмотр элемента: %{title}"
129
- new: "Добавление нового элемента"
130
131
 
131
132
  tenants:
132
133
  errors:
@@ -1,5 +1,5 @@
1
1
  module Anoubis
2
2
  ##
3
3
  # Anoubis current version
4
- VERSION = '1.0.7'
4
+ VERSION = '1.0.11'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anoubis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Ryabov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-21 00:00:00.000000000 Z
11
+ date: 2022-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -149,18 +149,17 @@ files:
149
149
  - Rakefile
150
150
  - app/controllers/anoubis/application_controller.rb
151
151
  - app/controllers/anoubis/core/application_controller.rb
152
- - app/controllers/anoubis/core/data/actions.rb
153
- - app/controllers/anoubis/core/data/callbacks.rb
154
- - app/controllers/anoubis/core/data/convert.rb
155
- - app/controllers/anoubis/core/data/defaults.rb
156
- - app/controllers/anoubis/core/data/get.rb
157
- - app/controllers/anoubis/core/data/load.rb
158
- - app/controllers/anoubis/core/data/set.rb
159
- - app/controllers/anoubis/core/data/setup.rb
160
- - app/controllers/anoubis/core/data_controller.rb
161
152
  - app/controllers/anoubis/core/index/actions.rb
162
153
  - app/controllers/anoubis/core/index/callbacks.rb
163
154
  - app/controllers/anoubis/core/index_controller.rb
155
+ - app/controllers/anoubis/data/actions.rb
156
+ - app/controllers/anoubis/data/callbacks.rb
157
+ - app/controllers/anoubis/data/convert.rb
158
+ - app/controllers/anoubis/data/defaults.rb
159
+ - app/controllers/anoubis/data/get.rb
160
+ - app/controllers/anoubis/data/load.rb
161
+ - app/controllers/anoubis/data/set.rb
162
+ - app/controllers/anoubis/data/setup.rb
164
163
  - app/controllers/anoubis/data_controller.rb
165
164
  - app/controllers/anoubis/etc.rb
166
165
  - app/controllers/anoubis/etc/base.rb
@@ -183,15 +182,6 @@ files:
183
182
  - app/controllers/anoubis/output/menu.rb
184
183
  - app/controllers/anoubis/output/update.rb
185
184
  - app/controllers/anoubis/sso/client/application_controller.rb
186
- - app/controllers/anoubis/sso/client/data/actions.rb
187
- - app/controllers/anoubis/sso/client/data/callbacks.rb
188
- - app/controllers/anoubis/sso/client/data/convert.rb
189
- - app/controllers/anoubis/sso/client/data/defaults.rb
190
- - app/controllers/anoubis/sso/client/data/get.rb
191
- - app/controllers/anoubis/sso/client/data/load.rb
192
- - app/controllers/anoubis/sso/client/data/set.rb
193
- - app/controllers/anoubis/sso/client/data/setup.rb
194
- - app/controllers/anoubis/sso/client/data_controller.rb
195
185
  - app/controllers/anoubis/sso/client/index/actions.rb
196
186
  - app/controllers/anoubis/sso/client/index/callbacks.rb
197
187
  - app/controllers/anoubis/sso/client/index_controller.rb
@@ -199,15 +189,6 @@ files:
199
189
  - app/controllers/anoubis/sso/server/login_controller.rb
200
190
  - app/controllers/anoubis/sso/server/user_controller.rb
201
191
  - app/controllers/anoubis/tenant/application_controller.rb
202
- - app/controllers/anoubis/tenant/data/actions.rb
203
- - app/controllers/anoubis/tenant/data/callbacks.rb
204
- - app/controllers/anoubis/tenant/data/convert.rb
205
- - app/controllers/anoubis/tenant/data/defaults.rb
206
- - app/controllers/anoubis/tenant/data/get.rb
207
- - app/controllers/anoubis/tenant/data/load.rb
208
- - app/controllers/anoubis/tenant/data/set.rb
209
- - app/controllers/anoubis/tenant/data/setup.rb
210
- - app/controllers/anoubis/tenant/data_controller.rb
211
192
  - app/controllers/anoubis/tenant/index/actions.rb
212
193
  - app/controllers/anoubis/tenant/index/callbacks.rb
213
194
  - app/controllers/anoubis/tenant/index_controller.rb
@@ -340,7 +321,7 @@ metadata:
340
321
  homepage_uri: https://github.com/RA-Company/
341
322
  source_code_uri: https://github.com/RA-Company/anoubis
342
323
  changelog_uri: https://github.com/RA-Company/anoubis/blob/main/CHANGELOG.md
343
- documentation_uri: https://www.rubydoc.info/gems/anoubis/1.0.7
324
+ documentation_uri: https://www.rubydoc.info/gems/anoubis/1.0.11
344
325
  post_install_message:
345
326
  rdoc_options: []
346
327
  require_paths: